private void addbutton_Click(object sender, EventArgs e) { if (customerNamefield.Text == "Customer Name" || customerNamefield.Text == "") { app.notifyTo(statusLabel, "Please enter the customer name!", "warning"); } else if (transactionAmountfield.Text == "Transaction Amount" || transactionAmountfield.Text == "") { app.notifyTo(statusLabel, "Please enter the transaction amount", "warning"); } else if (paymentmodeField.Text == "Payment Mode" || paymentmodeField.Text == "") { app.notifyTo(statusLabel, "Please select the payment mode", "warning"); } else { if (customerNamefield.Text != "" && transactionAmountfield.Text != "" && paymentmodeField.Text != "" && customerNamefield.Text != "Customer Name" && transactionAmountfield.Text != "Transaction Amount" && paymentmodeField.Text != "Payment Mode") { int transactionAmount = 0; if (app.isAllDigits(transactionAmountfield.Text)) { transactionAmount = int.Parse(transactionAmountfield.Text); Payment payment = new Payment() { customer_name = customerNamefield.Text, transaction_amount = transactionAmount, payment_mode = paymentmodeField.Text, description = paymentDescriptionField.Text, transaction_type = "Payment", }; if (transactionAmount > 0) { addbutton.Enabled = false; int response = addService.addPayment(payment); addbutton.Enabled = true; if (response > 0) { User user = app.getSession(); Customer customer = getService.getCustomerByName(customerNamefield.Text); Payment pay = getService.getLastPayment(user.id, customer.id); Report report = new Report(customer.id, pay.id, "#payment"); report.ShowDialog(); customerNamefield.Text = "Customer Name"; transactionAmountfield.Text = "Transaction Amount"; paymentmodeField.Text = "Payment Mode"; paymentDescriptionField.Text = "Description"; refreshCutsomerBalance(customerNamefield.Text); } else { if (response == -404) { app.notifyTo(statusLabel, "The customer " + customerNamefield.Text + " is not found", "warning"); } else if (response == -202) { app.showWarning("The customer " + payment.customer_name + " is not Owing!"); } else { app.notifyTo(statusLabel, "Transaction failed, please try latter ", "warning"); } } } else { app.notifyTo(statusLabel, "Oops! the Transaction amount can not be Zero ", "warning"); } } else { app.notifyTo(statusLabel, "Invalid transaction amount, please type only numbers!", "error"); } } } }