示例#1
0
        private void Inventory_Link_Click(object sender, EventArgs e)
        {
            Inventory_List g = new Inventory_List();

            g.Show();
            this.Hide();
        }
示例#2
0
        private void stock_out_button_Click(object sender, EventArgs e)
        {
            if (stock_out_view.Rows.Count == 0)
            {
                MessageBox.Show("Please input item/s to be stocked out", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                Conn.Open();
                string query2 = "insert into stock_out(stock_out_id, " + "stock_out_date) VALUES " +
                                "('" + Convert.ToInt32(stock_out_id.Text) + "','" +
                                "" + stock_out_date.Value.ToString(format) + "')";
                main.CUD_Statement(query2);
                Conn.Close();

                foreach (DataGridViewRow row in stock_out_view.Rows)
                {
                    int countrow2 = stock_out_view.Rows.Count;
                    for (int a = 0; a < countrow2; a++)
                    {
                        string    ex = "select inventory_quantity from inventory where item_id_inventory_fk =" + stock_out_view.Rows[a].Cells[8].Value;
                        DataTable dt = new DataTable();
                        dt = main.SELECT_Statement(ex);

                        if (dt.Rows.Count == 0)
                        {
                        }
                        else
                        {
                            Conn.Open();
                            MySqlCommand cmd2 = new MySqlCommand("update inventory set inventory_quantity=(inventory_quantity - @invq) where item_id_inventory_fk=@item_id", Conn);
                            cmd2.Parameters.AddWithValue("@invq", stock_out_view.Rows[a].Cells[3].Value);
                            cmd2.Parameters.AddWithValue("@item_id", stock_out_view.Rows[a].Cells[8].Value);
                            cmd2.ExecuteNonQuery();
                            Conn.Close();
                        }
                        foreach (DataGridViewRow row1 in stock_out_view.Rows)
                        {
                            int countrow = stock_out_view.Rows.Count;
                            for (int i = 0; i < countrow - 1; i++)
                            {
                                Conn.Open();

                                MySqlCommand cmd = new MySqlCommand("INSERT INTO stock_out_details(item_id_stock_out_fk,stock_out_quantity, stock_out_id_fk) VALUES (@iditem,@stckqty,'" + stock_out_id.Text + "')", Conn);
                                cmd.Parameters.AddWithValue("@iditem", stock_out_view.Rows[i].Cells[8].Value);
                                cmd.Parameters.AddWithValue("@stckqty", stock_out_view.Rows[i].Cells[3].Value);
                                cmd.ExecuteNonQuery();

                                Conn.Close();
                            }
                        }

                        // messagebox for yes and no if sure about transaction
                        // show list of all items bought
                        MessageBox.Show("Stock out Successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        disp_data();
                        Inventory_List g = new Inventory_List();
                        g.Show();
                        this.Hide();
                    }
                }
            }
        }