Beispiel #1
0
        private void button21_Click(object sender, EventArgs e)
        {
            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("Did you get the due amount", "?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (r == DialogResult.Yes)
                {
                    db.sql.Close();
                    db.sql.Open();


                    SqlCommand cmd  = new SqlCommand("insert into opd_due_collection(reg_no,due_paid,discount2,date,date2,user_name,password)values('" + label84.Text + "','" + richTextBox22.Text + "','" + label57.Text + "','" + date + "','" + dd + "','" + user_name + "','" + password + "')", db.sql);
                    SqlCommand cmd2 = new SqlCommand("update user_cash_collection_OPD set due_paid='" + richTextBox22.Text + "' where reg_no='" + label84.Text + "'", db.sql);
                    int        a    = cmd.ExecuteNonQuery();
                    cmd2.ExecuteNonQuery();
                    if (a > 0)
                    {
                        MessageBox.Show("Due collected Sucessfully");
                        Opd_Due_Collection_Print due = new Opd_Due_Collection_Print(label84.Text, richTextBox22.Text, user_name);
                        due.Show();
                        show_due_list();
                    }

                    db.sql.Close();
                }
            }
            catch
            {
            }
        }
Beispiel #2
0
        private void button21_Click(object sender, EventArgs e)
        {
            try
            {
                double old         = 0;
                double payment     = Convert.ToDouble(richTextBox22.Text);
                double new_payment = 0;
                if (label84.Text == "")
                {
                    MessageBox.Show("Select an ID");
                }
                else
                {
                    try
                    {
                        db.sql.Close();
                        db.sql.Open();
                        SqlCommand    cmm = new SqlCommand("select due_paid from user_cash_collection_OPD where reg_no='" + label84.Text + "' and type='OPD Bill'", db.sql);
                        SqlDataReader red = cmm.ExecuteReader();
                        while (red.Read())
                        {
                            old = Convert.ToDouble(red[0]);
                        }
                        new_payment = old + payment;
                        db.sql.Close();
                        db.sql.Open();
                        SqlCommand cmd3 = new SqlCommand("delete from opd_due_collection where reg_no='" + label84.Text + "'", db.sql);
                        cmd3.ExecuteNonQuery();
                        db.sql.Close();
                    }
                    catch
                    {
                    }
                    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("Did you get the due amount", "?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (r == DialogResult.Yes)
                    {
                        db.sql.Close();
                        db.sql.Open();


                        SqlCommand cmd  = new SqlCommand("insert into opd_due_collection(reg_no,due_paid,discount2,date,date2,user_name,password)values('" + label84.Text + "','" + richTextBox22.Text + "','" + label57.Text + "','" + date + "','" + dd + "','" + user_name + "','" + password + "')", db.sql);
                        SqlCommand cmd2 = new SqlCommand("update user_cash_collection_OPD set due_paid='" + new_payment + "' where reg_no='" + label84.Text + "'", db.sql);
                        int        a    = cmd.ExecuteNonQuery();
                        cmd2.ExecuteNonQuery();
                        if (a > 0)
                        {
                            MessageBox.Show("Due collected Sucessfully");
                            Opd_Due_Collection_Print due = new Opd_Due_Collection_Print(label84.Text, richTextBox22.Text, user_name);
                            due.Show();
                            show_due_list();
                        }

                        db.sql.Close();
                    }
                }
            }
            catch
            {
            }
        }