Exemplo n.º 1
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         String          constring   = "server=localhost;user id=root;password=root;persistsecurityinfo=True;database=medical";
         MySqlConnection conDataBase = new MySqlConnection(constring);
         conDataBase.Open();
         string          sql         = "select * from avl_stock where p_name='" + textBox1.Text + "'";
         MySqlCommand    cmdDataBase = new MySqlCommand(sql, conDataBase);
         MySqlDataReader rdr;
         rdr = cmdDataBase.ExecuteReader();
         rdr.Read();
         int          old  = int.Parse(rdr["p_price"].ToString());
         int          ne   = int.Parse(textBox2.Text);
         MySqlCommand cmd2 = new MySqlCommand("update avl_stock set p_price=" + ne + " where p_name='" + textBox1.Text + "'", conDataBase);
         rdr.Close();
         cmd2.ExecuteNonQuery();
         conDataBase.Close();
         available v = new available();
         v.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Exemplo n.º 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                String          constring   = "server=localhost;user id=root;password=root;persistsecurityinfo=True;database=medical";
                MySqlConnection conDataBase = new MySqlConnection(constring);
                conDataBase.Open();
                string          sql         = "select * from avl_stock where p_name='" + textBox1.Text + "'";
                MySqlCommand    cmdDataBase = new MySqlCommand(sql, conDataBase);
                MySqlDataReader rdr;
                rdr = cmdDataBase.ExecuteReader();
                rdr.Read();
                int check = int.Parse(rdr["p_quantity"].ToString());
                if (check > (int.Parse(textBox2.Text)))
                {
                    int total = 0;
                    int price = int.Parse(rdr["p_price"].ToString());

                    int new_q = 0;
                    new_q = int.Parse(rdr["p_quantity"].ToString()) - int.Parse(textBox2.Text);
                    rdr.Close();
                    MySqlCommand cmd3 = new MySqlCommand("update avl_stock set p_quantity=" + new_q + " where p_name='" + textBox1.Text + "' ", conDataBase);
                    cmd3.ExecuteNonQuery();


                    total = (int.Parse(textBox2.Text)) * price;
                    MySqlCommand cmd2 = new MySqlCommand("insert into  bill (p_name,p_quantity,p_total) values ('" + textBox1.Text + "'," + textBox2.Text + "," + total + ")", conDataBase);
                    cmd2.ExecuteNonQuery();

                    load();
                    conDataBase.Close();
                }
                else
                {
                    MessageBox.Show("item is not available");
                    available a = new available();
                    a.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            textBox1.Text = "";
            textBox2.Text = "";
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            available a = new available();

            a.Show();
        }