Advertisement
Guest User

ContractChanger Saving ver2

a guest
May 30th, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.90 KB | None | 0 0
  1.      private void ActivateCommandsAndControlsContractChanger()
  2.         {
  3.             ActivateCheckBoxesEvents();
  4.             UpdateEvent = true;
  5.             //=-=-=-=-=--=-=-=-=-=-=-=-=-=
  6.             InitializeModifiableContractComboBox();
  7.             modifiableContractControl_SelectedValueChanged(null, EventArgs.Empty);
  8.  
  9.             UpdateEvent = false;
  10.             if (ActivatedEventArgs.ActivateFlags.HasFlag(ActivateFlags.NewFromTemplate))
  11.             {
  12.  
  13.             }
  14.             CardControl.Saved += CardControl_Saved;
  15.             CardControl.Saving += CardControl_Saving;
  16.         }
  17.  
  18.         public override void CardControl_Saving(object sender, System.ComponentModel.CancelEventArgs e)
  19.         {
  20.             if (IsContractSelected.HasValue && IsContractSelected.Value)
  21.             {
  22.                 var cd = Customizable.FindPropertyItem<CheckEdit>("ChangesContractDuration");
  23.                 var pp = Customizable.FindPropertyItem<CheckEdit>("ChangesProlongationTerms");
  24.                 var pt = Customizable.FindPropertyItem<CheckEdit>("ChangesPaymentTerms");
  25.                 if (cd == null || pp == null || pt == null)
  26.                 {
  27.                     Messages.TraceMessage("Checkbox missing");
  28.                     e.Cancel = true;
  29.                 }
  30.  
  31.                 if (!(cd.Checked)&&!(pp.Checked)&&!(pt.Checked))
  32.                 {
  33.                      UiService.ShowMessage("No settings are selected to change contract!");
  34.                      e.Cancel = true;
  35.                 };
  36.  
  37.                 if (cd.Checked)
  38.                 {
  39.                     var contractDuration = Customizable.FindPropertyItem<ComboBoxEdit>("ContractDuration_New");
  40.                     var selectedItem = (BaseUniversalItemDescription)contractDuration.SelectedItem;
  41.  
  42.                     if (selectedItem != null)
  43.                     {
  44.                         if (selectedItem.Item.Name.Contains("FixTerm", StringComparison.OrdinalIgnoreCase) ||
  45.                                 selectedItem.Item.Name.Contains("TillFullExecution",
  46.                                 StringComparison.OrdinalIgnoreCase))
  47.                             {
  48.                                 var expirationDate_Reg = LayoutHelper.FindCustomPropertyItem("ExpirationDate_Reg");
  49.                                 if (expirationDate_Reg.Control.Text != null || expirationDate_Reg.Control.Text != DateTime.MinValue.ToString() || expirationDate_Reg.Control.Text != DateTime.MaxValue.ToString())
  50.                                 {
  51.                                     UiService.ShowMessage("Expiration date must be choosen correctly for selected Contract duration.");
  52.                                     e.Cancel = true;
  53.                                 };
  54.                             };
  55.                         if (selectedItem.Item.Name.Contains("Other", StringComparison.OrdinalIgnoreCase))
  56.                             {
  57.                                 var ExpirationDateValue_Reg = LayoutHelper.FindCustomPropertyItem("ExpirationDateValue_Reg");
  58.                                 if (string.IsNullOrEmpty(ExpirationDateValue_Reg.Control.Text))
  59.                                 {
  60.                                     UiService.ShowMessage("Expiration comment must be filled for selected Contract duration.");
  61.                                     e.Cancel = true;
  62.                                 };
  63.                             };
  64.                     }
  65.                     else
  66.                     {
  67.                         UiService.ShowMessage("Contract duration is not set! Or turn off checkbox Appendix changes contract duration.");
  68.                         e.Cancel = true;
  69.                     };
  70.                 };
  71.  
  72.             }
  73.             else
  74.             {
  75.                   UiService.ShowMessage("Document to be changed is not set!");
  76.                   e.Cancel = true;
  77.             };
  78.  
  79.             if (!e.Cancel) base.CardControl_Saving(sender, e);
  80.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement