Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void ActivateCommandsAndControlsContractChanger()
- {
- ActivateCheckBoxesEvents();
- UpdateEvent = true;
- //=-=-=-=-=--=-=-=-=-=-=-=-=-=
- InitializeModifiableContractComboBox();
- modifiableContractControl_SelectedValueChanged(null, EventArgs.Empty);
- UpdateEvent = false;
- if (ActivatedEventArgs.ActivateFlags.HasFlag(ActivateFlags.NewFromTemplate))
- {
- }
- CardControl.Saved += CardControl_Saved;
- CardControl.Saving += CardControl_Saving;
- }
- public override void CardControl_Saving(object sender, System.ComponentModel.CancelEventArgs e)
- {
- if (IsContractSelected.HasValue && IsContractSelected.Value)
- {
- var cd = Customizable.FindPropertyItem<CheckEdit>("ChangesContractDuration");
- var pp = Customizable.FindPropertyItem<CheckEdit>("ChangesProlongationTerms");
- var pt = Customizable.FindPropertyItem<CheckEdit>("ChangesPaymentTerms");
- if (cd == null || pp == null || pt == null)
- {
- Messages.TraceMessage("Checkbox missing");
- e.Cancel = true;
- }
- if (!(cd.Checked)&&!(pp.Checked)&&!(pt.Checked))
- {
- UiService.ShowMessage("No settings are selected to change contract!");
- e.Cancel = true;
- };
- if (cd.Checked)
- {
- var contractDuration = Customizable.FindPropertyItem<ComboBoxEdit>("ContractDuration_New");
- var selectedItem = (BaseUniversalItemDescription)contractDuration.SelectedItem;
- if (selectedItem != null)
- {
- if (selectedItem.Item.Name.Contains("FixTerm", StringComparison.OrdinalIgnoreCase) ||
- selectedItem.Item.Name.Contains("TillFullExecution",
- StringComparison.OrdinalIgnoreCase))
- {
- var expirationDate_Reg = LayoutHelper.FindCustomPropertyItem("ExpirationDate_Reg");
- if (expirationDate_Reg.Control.Text != null || expirationDate_Reg.Control.Text != DateTime.MinValue.ToString() || expirationDate_Reg.Control.Text != DateTime.MaxValue.ToString())
- {
- UiService.ShowMessage("Expiration date must be choosen correctly for selected Contract duration.");
- e.Cancel = true;
- };
- };
- if (selectedItem.Item.Name.Contains("Other", StringComparison.OrdinalIgnoreCase))
- {
- var ExpirationDateValue_Reg = LayoutHelper.FindCustomPropertyItem("ExpirationDateValue_Reg");
- if (string.IsNullOrEmpty(ExpirationDateValue_Reg.Control.Text))
- {
- UiService.ShowMessage("Expiration comment must be filled for selected Contract duration.");
- e.Cancel = true;
- };
- };
- }
- else
- {
- UiService.ShowMessage("Contract duration is not set! Or turn off checkbox Appendix changes contract duration.");
- e.Cancel = true;
- };
- };
- }
- else
- {
- UiService.ShowMessage("Document to be changed is not set!");
- e.Cancel = true;
- };
- if (!e.Cancel) base.CardControl_Saving(sender, e);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement