private void ApproveButton_Click(object sender, EventArgs e) { DialogResult result; if (IsSaleItemChanged) { result = MessageBox.Show(Resources.SaleApproveUnsavedItemsText.FormatWith(saleID), Resources.SaleApproveConfirmationCaption, MessageBoxButtons.YesNoCancel); switch (result) { case DialogResult.Yes: SaveSaleItemButton_Click(sender, e); break; case DialogResult.Cancel: return; } } else { result = MessageBox.Show(Resources.SaleApproveConfirmationText.FormatWith(saleID), Resources.SaleApproveConfirmationCaption, MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } } using (var repository = new SaleRepository()) { repository.ApproveSale(saleID); repository.CalculateComponentStockQuantity(saleID); repository.Commit(); } ViewSaleDetailTab(saleID, true); }