private void ApproveButton_Click(object sender, EventArgs e) { DialogResult result; if (IsInventoryItemChanged) { result = MessageBox.Show(Resources.InventoryApproveUnsavedItemsText.FormatWith(inventoryID), Resources.InventoryApproveConfirmationCaption, MessageBoxButtons.YesNoCancel); switch (result) { case DialogResult.Yes: SaveInventoryItemButton_Click(sender, e); break; case DialogResult.Cancel: return; } } else { result = MessageBox.Show(Resources.InventoryApproveConfirmationText.FormatWith(inventoryID), Resources.InventoryApproveConfirmationCaption, MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } } using (var repository = new InventoryRepository()) { repository.ApproveInventory(inventoryID); repository.CalculateComponentStockQuantity(inventoryID); repository.Commit(); } ViewInventoryDetailTab(inventoryID, true); }