private void btnOk_Click(object sender, EventArgs e) { using (ReceiptBLL receiptBLL = new ReceiptBLL()) { if (remainingAmount >= 0) { receipt.GivenAmount = Convert.ToDecimal(txtGivenAmount.Text); this.retrunReference = receiptBLL.AddReceiptDetails(receipt); var returnValue = Convert.ToInt32(this.retrunReference); if (returnValue > 0) { MessageBox.Show("Receipt printed succesful"); this.retrunValue = returnValue; receiptForm.Enabled = true; this.DialogResult = DialogResult.OK; this.Close(); } else { this.retrunValue = 0; MessageBox.Show("Receipt print faild"); } } else { this.retrunValue = 0; MessageBox.Show("Customer Given amount should be greater than receipt amount"); } } }