Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int   n, QTY;
            float price = 0;

            if (textBox3.Text != "" && textBox2.Text != "")
            {
                int.TryParse(textBox3.Text, out QTY);
                price  = Units_Cost * QTY;
                profit = profit * QTY;
                if (Check == false)
                {
                    newValue();
                }
                if (Stock == false)
                {
                    f_profit += profit;
                    total    += price;
                    n         = dataGridView1.Rows.Add();
                    dataGridView1.Rows[n].Cells[0].Value = textBox2.Text;
                    dataGridView1.Rows[n].Cells[1].Value = label6.Text;
                    dataGridView1.Rows[n].Cells[2].Value = textBox3.Text;
                    dataGridView1.Rows[n].Cells[3].Value = price.ToString();
                    string          con  = "server=localhost;user id=root;database=weerodara";
                    MySqlConnection conn = new MySqlConnection(con);
                    conn.Open();
                    string       add1    = "INSERT INTO `Order_SET`( `Bill_No`, `Item_Number`, `QTY`, `Price`, `Date`, `Wholesale or Retail`, `Profits`) VALUES ('" + Bill_ID.ToString() + "','" + item_no.ToString() + "','" + textBox3.Text + "','" + price.ToString() + "','" + Bill_No1.ToString() + "', 'Wholesale', " + profit + ")";
                    MySqlCommand camadd1 = new MySqlCommand(add1, conn);
                    camadd1.ExecuteNonQuery();
                    string       add    = "UPDATE `stock_details` SET `Number_Of_Units`='" + New_QTY.ToString() + "' WHERE `Item_number`='" + item_no.ToString() + "'";
                    MySqlCommand camadd = new MySqlCommand(add, conn);
                    camadd.ExecuteNonQuery();
                    MessageBox.Show("Stock Table Updated & Orders Table rowa insert", "System Ditails");
                    formClear();
                    label13.Visible = true;
                    label13.Text    = total.ToString();

                    conn.Close();
                }
            }
        }