private void btnDelete_Clicked(object sender, EventArgs e) { Button btn = (Button)sender; Payment payment = btn.Data ["Payment"] as Payment; if (payment == null) { return; } using (MessageOkCancel dialog = new MessageOkCancel( Translator.GetString("Delete Payment"), "Icons.TradePoint32.png", Translator.GetString("Do you want to delete the selected payment?"), "Icons.Delete32.png")) { if (dialog.Run() != ResponseType.Ok) { return; } } payments.Remove(payment); RefreshGrid(); parentWindow.Resize(10, 10); txtReceived.GrabFocus(); OnPaymentDeleted(EventArgs.Empty); }
public void btnDelete_Clicked(object sender, EventArgs e) { T group = gPanel.GetSelectedGroup(); DeletePermission permission = GetDeletePermission(group); switch (permission) { case DeletePermission.InUse: MessageError.ShowDialog( Translator.GetString("This group cannot be deleted, because it is not empty. Please, delete or move to another group the containing items in order to delete this group!"), "Icons.Group16.png"); return; case DeletePermission.Reserved: case DeletePermission.No: MessageError.ShowDialog( string.Format(Translator.GetString("Cannot delete group \"{0}\"!"), group.Name), "Icons.Group16.png"); return; } using (MessageOkCancel dialog = new MessageOkCancel( Translator.GetString("Delete group"), "Icons.Group16.png", string.Format(Translator.GetString("Do you want to delete group with name \"{0}\"?"), group.Name), "Icons.Delete32.png")) { if (dialog.Run() != ResponseType.Ok) { return; } } DeleteGroup(group); ReloadGroups(); if (group.Parent != null) { gPanel.SelectGroupId(group.Parent.Id); } else { gPanel.SelectGroupId(-1); } OnGroupDeleted(); }
public override void OnOperationSave(bool askForConfirmation) { bool printReceipt = false; if (!OperationValidate()) { return; } if (!OperationDetailsValidate(true)) { return; } if (askForConfirmation) { MessageOkCancel dialogSave; if (editMode) { dialogSave = new MessageOkCancel( Translator.GetString("Edit waste"), string.Empty, Translator.GetString("Do you want to save the changes?"), "Icons.Question32.png"); } else { dialogSave = new MessageOkCancel( Translator.GetString("Saving waste"), string.Empty, Translator.GetString("Do you want to save the operation?"), "Icons.Question32.png"); } if (dialogSave.Run() != ResponseType.Ok) { operation.AddNewDetail(); EditGridField(operation.Details.Count - 1, colItem.Index); return; } } if (BusinessDomain.AppConfiguration.IsPrintingAvailable()) { if (BusinessDomain.AppConfiguration.AskBeforeDocumentPrint == AskDialogState.NotSaved) { using (MessageYesNoRemember dialogPrint = new MessageYesNoRemember( Translator.GetString("Print document"), string.Empty, Translator.GetString("Do you want to print a document?"), "Icons.Question32.png")) { ResponseType resp = dialogPrint.Run(); if (resp == ResponseType.Yes) { printReceipt = true; } if (dialogPrint.RememberChoice) { BusinessDomain.AppConfiguration.AskBeforeDocumentPrint = resp == ResponseType.Yes ? AskDialogState.Yes : AskDialogState.No; } } } else if (BusinessDomain.AppConfiguration.AskBeforeDocumentPrint == AskDialogState.Yes) { printReceipt = true; } } try { PrepareOpertionForSaving(); CommitOperation(); } catch (InsufficientItemAvailabilityException ex) { MessageError.ShowDialog(string.Format(Translator.GetString("The waste cannot be saved due to insufficient quantity of item \"{0}\"."), ex.ItemName), ErrorSeverity.Warning, ex); EditGridField(ex.ItemName); return; } catch (Exception ex) { MessageError.ShowDialog( Translator.GetString("An error occurred while saving the waste operation!"), ErrorSeverity.Error, ex); return; } if (printReceipt && WaitForPendingOperationCompletion()) { try { WasteProtocol protocol = new WasteProtocol(operation); FormHelper.PrintPreviewObject(protocol); } catch (Exception ex) { MessageError.ShowDialog( Translator.GetString("An error occurred while generating the protocol!"), ErrorSeverity.Error, ex); } } OnOperationSaved(); if (editMode) { OnPageClose(); } else { ReInitializeForm(null); } }