TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ahmet Taha
NA
381
20.4k
error in displaying in school billing system c#
Apr 19 2021 2:58 PM
private void txt_sID_KeyUp(object sender, KeyEventArgs e)
{
txt_name.Text = "";
txtYear.Text = "";
txtSchYear.Text = "";
txt_total.Text = "0.00";
txt_bal.Text = "0.00";
tbl.Items.Clear();
cn = ClassDB.ConnectDB();
cmd = new SqlCommand("SELECT * FROM tblStudentRegistration WHERE lrn='" + txt_sID.Text + "' AND status ='" + "ACTIVE" + "'", cn);
dr = cmd.ExecuteReader();
if (dr.Read())
{
txt_name.Text = dr.GetString(1);
txtYear.Text = dr.GetString(19);
txtSchYear.Text = dr.GetString(22);
try
{
cn = ClassDB.ConnectDB();
cmd = new SqlCommand("SELECT * FROM tblstudpayment WHERE lrn='" + txt_sID.Text + "' ", cn);
dr = cmd.ExecuteReader();
int ctr = 0;
while (dr.Read())
{
ctr++;
}
if (ctr > 0)
{
txt_total.Text = Convert.ToString(dr.GetValue(7))
tbl.Items.Clear();
cn = ClassDB.ConnectDB();
cmd = new SqlCommand("SELECT * FROM tblschoolfee WHERE gradelevel LIKE '" + txtYear.Text + "%' ", cn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
ListViewItem item = new ListViewItem(Convert.ToString(dr.GetValue(0)));
item.SubItems.Add(dr.GetString(2));
item.SubItems.Add(Convert.ToString(dr.GetValue(3)));
tbl.Items.Add(item);
}
}
else
{
cn = ClassDB.ConnectDB();
cmd = new SqlCommand("SELECT * FROM tblschoolfee WHERE gradelevel ='" + txtYear.Text + "' ", cn);
dr = cmd.ExecuteReader();
while (dr.Read())
{
ListViewItem item = new ListViewItem(Convert.ToString(dr.GetValue(0)));
item.SubItems.Add(dr.GetString(2));
item.SubItems.Add(Convert.ToString(dr.GetValue(3)));
tbl.Items.Add(item);
}
decimal gtotal = 0;
foreach (ListViewItem lstItem in tbl.Items)
{
gtotal += decimal.Parse(lstItem.SubItems[2].Text);
}
txt_total.Text = Convert.ToString(gtotal.ToString("###,###,##0.#0"));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
Reply
Answers (
4
)
bot web chat exposing the key
Csharp bot user interface