private void BtnConfirm_Click(object sender, EventArgs e) { try { lblMsg2.Text = string.Empty; if (Convert.ToDecimal(dgvStudentInfo.Rows[0].Cells["BalanceDue"].Value) <= 0) { lblMsg2.Text = "This student has not any balance due"; //MessageBox.Show("This student has not any balance due"); } else if (txtPayment.Text == string.Empty) { lblMsg2.Text = "Enter a valid amount"; } else if (Convert.ToDecimal(txtPayment.Text) > Convert.ToDecimal(dgvStudentInfo.Rows[0].Cells["BalanceDue"].Value)) { lblMsg2.Text = "The payment cannot be greater than the student's current balancedue"; //MessageBox.Show("The payment cannot be greater than the student's current balancedue"); } else if (txtPayment.Text == string.Empty) { lblMsg2.Text = "Please enter the amount to pay"; //MessageBox.Show("Please enter the amount to pay"); } else { StudentBL studentBL = new StudentBL(); PaymentBL paymentBL = new PaymentBL(); string type = string.Empty; if (rdoCredit.Checked == true) { type = "Credit"; } else { type = "Debit"; } if (studentBL.MakePayment(dgvStudents.CurrentRow.Cells["ID"].Value.ToString(), Convert.ToDecimal(txtPayment.Text)) && paymentBL.AddPayment(Convert.ToInt32(dgvStudents.CurrentRow.Cells["ID"].Value), Convert.ToDecimal(txtPayment.Text), type)) { MessageBox.Show("Payment was successful"); txtSearch.Clear(); txtPayment.Clear(); rdoDebit.Checked = true; dgvStudents.DataSource = null; dgvStudentInfo.DataSource = null; } else { MessageBox.Show("Payment failed"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().ToString()); } }
public IHttpActionResult Post([FromBody] Payment p) { try { PaymentBL.AddPayment(p); return(Ok()); } catch { throw; } }
public HttpResponseMessage AddExpenditure(Expenditure expenditure) { try { ExpenditureBL.Add(expenditure); if (expenditure.type == (int)ExpenditureType.Irregular) { PaymentBL.AddPayment(expenditure); } return(Request.CreateResponse(HttpStatusCode.OK, true)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.ExpectationFailed, ex)); } }
public HttpResponseMessage AddPayment(Payment payment) { PaymentBL.AddPayment(payment); return(Request.CreateResponse(HttpStatusCode.OK, true)); }