private void ApproveButton_Click(object sender, EventArgs e) { DialogResult result; if (IsSupplyItemChanged) { result = MessageBox.Show(Resources.SupplyApproveUnsavedItemsText.FormatWith(supplyID), Resources.SupplyApproveConfirmationCaption, MessageBoxButtons.YesNoCancel); switch (result) { case DialogResult.Yes: SaveSupplyItemButton_Click(sender, e); break; case DialogResult.Cancel: return; } } else { result = MessageBox.Show(Resources.SupplyApproveConfirmationText.FormatWith(supplyID), Resources.SupplyApproveConfirmationCaption, MessageBoxButtons.YesNo); if (result == DialogResult.No) { return; } } using (var repository = new SupplyRepository()) { repository.ApproveSupply(supplyID); repository.CalculateComponentStockQuantity(supplyID); repository.Commit(); } ViewSupplyDetailTab(supplyID, true); }