private void button1_Click(object sender, EventArgs e) { if (label2.Text == "") { MessageBox.Show("Select an Id first..."); } else { try { double unpaid_paid = Convert.ToDouble(richTextBox2.Text); double total_paid = unpaid_paid + paid; double x = 0; double discount = total - total_paid;; string date = DateTime.Now.ToShortDateString(); DateTime d = DateTime.ParseExact(date, "M/d/yyyy", CultureInfo.InvariantCulture); string dd = d.ToString("dd/MM/yyyy"); string dd2 = d.ToString("yyyy/MM/dd"); if (Date == dd) { paid2 = total_paid; due2 = 0; } DialogResult r = MessageBox.Show("Did You Get The Unpaid Amount Confirm Please", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.Yes) { try { db.sql.Close(); db.sql.Open(); SqlCommand cmd = new SqlCommand("update paid_and_due set paid='" + paid2 + "',due='" + due2 + "', less='" + discount + "',paid_date='" + dd + "' where invoice_no='" + id + "'", db.sql); SqlCommand cmd4 = new SqlCommand("update due_collection set due_paid='" + unpaid_paid + "',discount2='" + label7.Text + "',paid_date='" + dd + "',date2='" + dd2 + "' where reg_no='" + id + "'", db.sql); int a = cmd.ExecuteNonQuery(); cmd4.ExecuteNonQuery(); db.sql.Close(); show(); if (a > 0) { MessageBox.Show("Paid Successfully...."); diagnostic_bill dbb = new diagnostic_bill(label2.Text); dbb.Show(); } } catch { } } else { } } catch { } } }
private void button2_Click(object sender, EventArgs e) { try { diagnostic_bill db = new diagnostic_bill(label2.Text); db.Show(); } catch { } }
private void button3_Click(object sender, EventArgs e) { if (richTextBox5.Text == "") { MessageBox.Show("You Have to pay Some Amount"); } else { // try { string date = dateTimePicker1.Text; DateTime d = DateTime.ParseExact(date, "dd/MM/yyyy", CultureInfo.InvariantCulture); string dd = d.ToString("yyyy/MM/dd"); DialogResult r = MessageBox.Show("Do You Want to save this data....??", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (r == DialogResult.Yes) { int c = 0; string paid_date = "0"; int match = Convert.ToInt32(label9.Text); double total = Convert.ToDouble(label13.Text); double paid = Convert.ToDouble(richTextBox5.Text); double due = Convert.ToDouble(label15.Text); double discount = Convert.ToDouble(richTextBox9.Text); double discount_total = Convert.ToDouble(label22.Text); if (due == 0) { paid_date = date; } db.sql.Close(); db.sql.Open(); SqlCommand cmd1 = new SqlCommand("select * from paid_and_due where invoice_no='" + match + "'", db.sql); SqlDataReader read = cmd1.ExecuteReader(); while (read.Read()) { c++; } if (c > 0) { db.sql.Close(); db.sql.Open(); SqlCommand cmd2 = new SqlCommand("update paid_and_due set total='" + total + "', paid='" + paid + "',due='" + due + "',discount='" + discount + "',discount_total='" + discount_total + "',paid_date='" + paid_date + "' where invoice_no='" + match + "'", db.sql); SqlCommand cmd4 = new SqlCommand("update due_collection set due='" + due + "' where reg_no='" + match + "'", db.sql); SqlCommand cmde = new SqlCommand("update referance set name='" + comboBox1.Text + "',patient_name='" + richTextBox1.Text + "',date='" + date + "',bill='" + label13.Text + "',date2='" + dd + "',after_discount='" + label22.Text + "' where patient_id='" + label9.Text + "'", db.sql); SqlCommand cmdd = new SqlCommand("update diagnostic_person set referdoctor='" + comboBox1.Text + "' where id='" + label9.Text + "'", db.sql); cmd2.ExecuteNonQuery(); int x = cmde.ExecuteNonQuery(); cmd4.ExecuteNonQuery(); cmdd.ExecuteNonQuery(); button5.Enabled = true; diagnostic_bill dbb = new diagnostic_bill(label9.Text); show_daily_status(); dbb.Show(); } else { db.sql.Close(); db.sql.Open(); SqlCommand cmd = new SqlCommand("insert into paid_and_due(invoice_no,total,paid,due,discount,discount_total,paid_date,date2)values('" + match + "','" + total + "','" + paid + "','" + due + "','" + discount + "','" + discount_total + "','" + paid_date + "','" + dd + "')", db.sql); SqlCommand cmdd = new SqlCommand("insert into due_collection(reg_no,name,due,test_date)values('" + match + "','" + richTextBox1.Text + "','" + due + "','" + date + "')", db.sql); SqlCommand cmddd = new SqlCommand("insert into referance(name,patient_id,patient_name,date,bill,date2,after_discount) values('" + comboBox1.Text + "','" + label9.Text + "','" + richTextBox1.Text + "','" + date + "','" + label13.Text + "','" + dd + "','" + label22.Text + "')", db.sql); cmd.ExecuteNonQuery(); cmdd.ExecuteNonQuery(); cmddd.ExecuteNonQuery(); db.sql.Close(); button5.Enabled = true; button4.Enabled = false; diagnostic_bill dbb = new diagnostic_bill(label9.Text); show_daily_status(); dbb.Show(); } } } /* catch * { * MessageBox.Show("Give a valid Paing Amount","",MessageBoxButtons.OK,MessageBoxIcon.Error); * }*/ } }