private void BL_DueAmttxt_TextChanged(object sender, EventArgs e) { con_str.Open(); cmd = new SqlCommand("select isnull(count(BL_BalAmt),0) from Bill where BL_Lno='" + BL_LnoCombo.Text + "'", con_str); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { int count = int.Parse(dr[0].ToString()); //float count = dr.GetValue(0); if (count == 0) { try { float interest = float.Parse(BL_Inttxt.Text); float DAmt = float.Parse(BL_DueAmttxt.Text); float TotAmt = interest + DAmt; BL_TotAmttxt.Text = TotAmt.ToString(); float SAmt = float.Parse(BL_LAmttxt.Text); float BalAmt = SAmt - DAmt; BL_BalAmttxt.Text = BalAmt.ToString(); } catch (Exception ex) { } } else { cmd = new SqlCommand("select top 1 BL_BalAmt-'" + BL_DueAmttxt.Text + "' from Bill where BL_Lno='" + BL_LnoCombo.Text + "' order by BL_Date Desc", con_str); dr = cmd.ExecuteReader(); while (dr.Read()) { try { { BL_BalAmttxt.Text = dr.GetValue(0).ToString(); float interest = float.Parse(BL_Inttxt.Text); float DAmt = float.Parse(BL_DueAmttxt.Text); float TotAmt = interest + DAmt; BL_TotAmttxt.Text = TotAmt.ToString(); } } catch (Exception ex) { } } dr.Close(); } } dr.Close(); con_str.Close(); }
con_str.Open();
TextChanged
if
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)