예제 #1
0
        private void Subtract_Click(object sender, EventArgs e)
        {
            string query = "select stock_in from product where product_id='" + id.Text + "';";

            conn.Open();
            MySqlCommand     com = new MySqlCommand(query, conn);
            MySqlDataAdapter adp = new MySqlDataAdapter(com);

            conn.Close();
            DataTable dt = new DataTable();

            adp.Fill(dt);
            int input = Int32.Parse(quan.Text);
            int s_in  = Int32.Parse(dt.Rows[0][0].ToString());
            int dif   = (s_in - input);

            if (String.IsNullOrEmpty(quan.Text))
            {
                MessageBox.Show("Please fill up the field.", "Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else if (s_in < 0)
            {
                MessageBox.Show("Insufficient items.", "Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            else
            {
                DialogResult dialogResult = MessageBox.Show("Stock items?", "Confirm", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes)
                {
                    if (dif < 0)
                    {
                        MessageBox.Show("Insufficient stocked in items.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                    else
                    {
                        string query1 = "UPDATE product SET stock_in='" + dif + "' where product_id= '" + id.Text + "';";
                        MessageBox.Show("Stocked out '" + input + "' items!", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        if (s_in <= 30)
                        {
                            MessageBox.Show("Item needs to be purchased", "Test", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                        b = true;
                        executeQuery(query1);
                        this.Close();
                        inventory i = new inventory();
                        i.loadAll2();
                        this.DialogResult = DialogResult.Yes;
                    }
                }
            }
        }
예제 #2
0
파일: In.cs 프로젝트: rjsreroma/SAD
        private void In_FormClosing(object sender, FormClosingEventArgs e)
        {
            inventory i = new inventory();

            i.loadAll2();
        }