Esempio n. 1
0
        private void button4_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");
                int      c    = 0;
                db.sql.Close();
                db.sql.Open();
                SqlCommand    cmd1 = new SqlCommand("select * from medicine_selling_history where inv_id='" + richTextBox7.Text + "'", db.sql);
                SqlDataReader read = cmd1.ExecuteReader();
                while (read.Read())
                {
                    c++;
                }
                if (c > 0)
                {
                    db.sql.Close();
                    db.sql.Open();
                    SqlCommand cmd2  = new SqlCommand("update medicine_selling_history set discount='" + richTextBox9.Text + "', total='" + label23.Text + "',paid='" + richTextBox6.Text + "',due='" + label24.Text + "' where inv_id='" + richTextBox7.Text + "'", db.sql);
                    SqlCommand cmddd = new SqlCommand("update user_cash_collection_pharmacy set paid='" + richTextBox6.Text + "' where reg_no='" + richTextBox7.Text + "'", db.sql);
                    cmd2.ExecuteNonQuery();
                    cmddd.ExecuteNonQuery();
                    pharmacy_bill pb = new pharmacy_bill(richTextBox7.Text);
                    pb.Show();
                    db.sql.Close();
                }
                else
                {
                    db.sql.Close();
                    db.sql.Open();

                    SqlCommand cmd    = new SqlCommand("insert into medicine_selling_history (inv_id,reg_id,name,age,gender,contact,discount,total,paid,due,date,date2,card_id)values('" + richTextBox7.Text + "','" + richTextBox3.Text + "','" + richTextBox4.Text + "','" + richTextBox5.Text + "','" + comboBox2.Text + "','" + richTextBox2.Text + "','" + richTextBox9.Text + "','" + label23.Text + "','" + richTextBox6.Text + "','" + label24.Text + "','" + dateTimePicker1.Text + "','" + dd + "','" + richTextBox27.Text + "')", db.sql);
                    SqlCommand cmdddd = new SqlCommand("insert into user_cash_collection_pharmacy(user_name,password,reg_no,name,paid,date,date2) values('" + user_name + "','" + password + "','" + richTextBox7.Text + "','" + richTextBox4.Text + "','" + richTextBox6.Text + "','" + date + "','" + dd + "')", db.sql);
                    cmdddd.ExecuteNonQuery();
                    int a = cmd.ExecuteNonQuery();
                    if (a > 0)
                    {
                        MessageBox.Show("Selling Successfull");
                        pharmacy_bill pb = new pharmacy_bill(richTextBox7.Text);
                        pb.Show();
                        //clear_field();
                    }
                    db.sql.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            pharmacy_bill pb = new pharmacy_bill(richTextBox7.Text);

            pb.Show();
        }