private static bool ShowMessageHasInvoiceChangeUser <TOper> (TOper oper, long invNum, string icon, out bool allowView) where TOper : Operation { allowView = false; string message; if (oper.OperationType == OperationType.Consignment) { message = Translator.GetString("Consignment No.{0} cannot be edited because the issued invoice No.{1} is attached to a sale on it. Please, void the invoice before editing this consignment."); } else if (oper.OperationType != OperationType.Purchase) { message = Translator.GetString("Document No.{0} cannot be edited because the issued invoice No.{1} is attached to it. Please, void the invoice before editing this document."); } else { message = Translator.GetString("Document No.{0} cannot be edited because the received invoice No.{1} is attached to it. Please, void the invoice before editing this document."); } message += "\n\n" + Translator.GetString("Do you want to change the operator in this document instead?"); using (Message msg = new Message(Translator.GetString("Warning!"), icon, string.Format(message, Operation.GetFormattedOperationNumber(oper.Id), Operation.GetFormattedOperationNumber(invNum)), "Icons.Question32.png")) { msg.Buttons = MessageButtons.YesNo; if (msg.Run() != ResponseType.Yes) { allowView = true; return(false); } } User [] users; using (ChooseEditUser dialog = new ChooseEditUser(true, oper.UserId)) { if (dialog.Run() != ResponseType.Ok) { return(false); } users = dialog.SelectedItems; } if (users.Length == 0) { return(false); } Operation.ChangeUser(oper.OperationType, oper.Id, users [0].Id); return(true); }
public static ResponseType ChooseDataFieldValue(DbField field, ref object value) { DataType fieldType = ReportProvider.GetDataFieldType(field); ChooseEdit dlgChooseEdit = null; ChooseDate dlgChooseDate = null; switch (field.StrongField) { case DataField.PartnerName: dlgChooseEdit = new ChooseEditPartner(true, string.Empty); break; case DataField.PartnersGroupsName: dlgChooseEdit = new ChooseEditPartnersGroup(); break; case DataField.ItemName: dlgChooseEdit = new ChooseEditItem(true); break; case DataField.ItemsGroupName: dlgChooseEdit = new ChooseEditItemsGroup(); break; case DataField.LocationName: case DataField.SourceLocationName: case DataField.TargetLocationName: dlgChooseEdit = new ChooseEditLocation(true, string.Empty); break; case DataField.LocationsGroupsName: dlgChooseEdit = new ChooseEditLocationsGroup(); break; case DataField.UserName: case DataField.OperationsUserName: case DataField.OperationsOperatorName: dlgChooseEdit = new ChooseEditUser(true, string.Empty); break; case DataField.UsersGroupsName: case DataField.OperationsUsersGroupsName: case DataField.OperationsOperatorsGroupsName: dlgChooseEdit = new ChooseEditUsersGroup(); break; default: if (fieldType == DataType.Date || fieldType == DataType.DateTime) { DateTime selectedDate = BusinessDomain.GetDateValue((string)value); dlgChooseDate = new ChooseDate { Selection = selectedDate == DateTime.MinValue ? BusinessDomain.Today : selectedDate }; } break; } value = null; ResponseType ret = ResponseType.Cancel; if (dlgChooseEdit != null) { using (dlgChooseEdit) { ret = dlgChooseEdit.Run(); string [] selection = dlgChooseEdit.SelectedItemsText; if (ret == ResponseType.Ok && selection.Length > 0) { value = selection [0]; } } } else if (dlgChooseDate != null) { using (dlgChooseDate) { ret = dlgChooseDate.Run(); value = BusinessDomain.GetFormattedDate(dlgChooseDate.Selection); } } return(ret); }