From 7733b166115cc808070c355aeb34e21d215debb0 Mon Sep 17 00:00:00 2001 From: tanshu Date: Thu, 12 Jan 2017 12:45:21 +0530 Subject: [PATCH] Fix: To prevent accidental double printing, the print bill and print kot buttons are greyed out once clicked till the end of the function --- .../Sales/SalesForm.cs | 46 +++++++++++-------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs index 698100f..64dc419 100644 --- a/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs +++ b/Tanshu.Accounts.PointOfSale/Sales/SalesForm.cs @@ -405,6 +405,7 @@ namespace Tanshu.Accounts.PointOfSale.Sales } private void btnPrintBill_Click(object sender, EventArgs e) { + btnPrintBill.Enabled = false; bool isPrinted = false, isVoid = false; if (_controller._voucher.VoucherID != Guid.Empty) using (var bi = new VoucherBI()) @@ -414,35 +415,42 @@ namespace Tanshu.Accounts.PointOfSale.Sales isVoid = dbVoucher.Void; } - if (!_controller.CanSaveBill(isPrinted, isVoid)) - return; - var amount = _controller._bill.NetAmount; - _controller.SetDiscount(); - ShowInfo(); - var printed = _controller.SaveAndPrintBill(isPrinted, amount); - if (!printed) - return; - if (_controller._editVoucherID.HasValue) - this.Close(); - else + if (_controller.CanSaveBill(isPrinted, isVoid)) { + var amount = _controller._bill.NetAmount; + _controller.SetDiscount(); ShowInfo(); - FormState = SaleFormState.Waiting; + var printed = _controller.SaveAndPrintBill(isPrinted, amount); + if (printed) + { + if (_controller._editVoucherID.HasValue) + this.Close(); + else + { + ShowInfo(); + FormState = SaleFormState.Waiting; + } + } } + btnPrintBill.Enabled = true; + } private void btnPrintKot_Click(object sender, EventArgs e) { + btnPrintKot.Enabled = false; var printed = _controller.SaveAndPrintKot(); - if (!printed) - return; - if (_controller._editVoucherID.HasValue) - this.Close(); - else + if (printed) { - ShowInfo(); - FormState = SaleFormState.Waiting; + if (_controller._editVoucherID.HasValue) + this.Close(); + else + { + ShowInfo(); + FormState = SaleFormState.Waiting; + } } + btnPrintKot.Enabled = true; } private void btnQuantity_Click(object sender, EventArgs e)