Hi guys,
I am trying to update my table Installment and table Accountabilities after having a transaction. But when I am trying to save the transaction that I did, only Payment Staus did not update and still remain. What I need to do is that if the user pays incomplete, the payment status should still be 'Not Fully Paid' otherwise if the user pay exact amount, the payment status should be 'Fully paid'. But whenever I tried to pay exactly, the payment status does not change.
here is my code:
private void button2_Click(object sender, EventArgs e)
{
latefees.Text = "0";
double late = Convert.ToDouble(latefees.Text);
double txtbal = Convert.ToDouble(txt_bal.Text);
double art = Convert.ToDouble(textBox1.Text);
int rb = 0;
if(art >= txtbal)
{
decimal tot = Convert.ToDecimal(art) - (Convert.ToDecimal(txtbal)+ Convert.ToDecimal(late));
textBox2.Text = tot.ToString("N2");
textBox3.Text = Convert.ToString(Math.Round(Convert.ToDecimal(rb)));
}
else if (txtbal > art)
{
decimal tot = (Convert.ToDecimal(txtbal) + Convert.ToDecimal(late)) - Convert.ToDecimal(art);
textBox2.Text = Convert.ToString(Math.Round(Convert.ToDecimal(rb)));
textBox3.Text = tot.ToString("N2");
}
if(txt_bal.Text == "0" || txt_bal.Text == "0.00")
{
txt_pstatus.Text = "Fully Paid";
}
}
private void button4_Click(object sender, EventArgs e)
{
MySqlConnection = new SqlConnection(conn.GetServers());
MySqlConnection.Open();
string chk = "UPDATE tblInstallment SET Balance=@rbal,PaymentStatus=@psts,LateFees=@lfe WHERE InstallID = @ins";
SqlCommand gc = new SqlCommand(chk, MySqlConnection);
gc.Parameters.AddWithValue("@ins", label13.Text);
gc.Parameters.AddWithValue("@rbal",textBox3.Text );
gc.Parameters.AddWithValue("@psts", txt_pstatus.Text);
gc.Parameters.AddWithValue("@lfe", latefees.Text);
SqlDataReader rd = gc.ExecuteReader();
rd.Close();
string hue = "UPDATE tblAccountabilities SET Balance=@bala,PaymentStatus=@tats WHERE StudentNumber = @studnum";
SqlCommand gc1 = new SqlCommand(hue, MySqlConnection);
gc1.Parameters.AddWithValue("@studnum",stud_id.Text);
gc1.Parameters.AddWithValue("@bala", textBox3.Text);
gc1.Parameters.AddWithValue("@tats", txt_pstatus.Text);
SqlDataReader eu = gc1.ExecuteReader();
eu.Close();
MessageBox.Show("Payment Information has been Updated.");
}