private void back_button_Click(object sender, EventArgs e) { Reports_Page g = new Reports_Page(); g.Show(); this.Hide(); }
private void Reports_Link_Click(object sender, EventArgs e) { Reports_Page g = new Reports_Page(); g.Show(); this.Hide(); }
private void stock_in_button_Click(object sender, EventArgs e) { if (stock_in_view.Rows.Count == 0) { MessageBox.Show("Please input item/s to be stocked in", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { Conn.Open(); string query2 = "insert into stock_in(stock_in_id, " + "stock_in_date, delivery_date) VALUES " + "('" + Convert.ToInt32(stock_in_id.Text) + "','" + "" + stock_date.Value.ToString(format) + "','" + "" + del_date.Value.ToString(format) + "')"; main.CUD_Statement(query2); foreach (DataGridViewRow row in stock_in_view.Rows) { if (row.IsNewRow) { continue; } int countrow2 = stock_in_view.Rows.Count; for (int a = 0; a < countrow2; a++) { string ex = "select inventory_quantity from inventory where item_id_inventory_fk =" + stock_in_view.Rows[a].Cells[8].Value; DataTable dt = new DataTable(); dt = main.SELECT_Statement(ex); if (dt.Rows.Count == 0) { MySqlCommand cmd2 = new MySqlCommand("insert into inventory (item_id_inventory_fk, inventory_quantity) values (@item_id, @invq)", Conn); cmd2.Parameters.AddWithValue("@invq", stock_in_view.Rows[a].Cells[3].Value); cmd2.Parameters.AddWithValue("@item_id", stock_in_view.Rows[a].Cells[8].Value); cmd2.ExecuteNonQuery(); } else { 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_in_view.Rows[a].Cells[3].Value); cmd2.Parameters.AddWithValue("@item_id", stock_in_view.Rows[a].Cells[8].Value); cmd2.ExecuteNonQuery(); } } } foreach (DataGridViewRow row in item_view.Rows) { if (row.IsNewRow) { continue; } int countrow2 = item_view.Rows.Count; for (int a = 0; a < countrow2; a++) { if (Convert.ToInt32(item_view.Rows[a].Cells[6].Value) == 0) { MySqlCommand cmd2 = new MySqlCommand("update purchase_order_details set purch_itemqty=0, purch_dstatus='Complete' where purch_itemid=@item_id and purch_purchid=@pid", Conn); cmd2.Parameters.AddWithValue("@invq", item_view.Rows[a].Cells[6].Value); cmd2.Parameters.AddWithValue("@item_id", item_view.Rows[a].Cells[7].Value); cmd2.Parameters.AddWithValue("@pid", item_view.Rows[a].Cells[0].Value); cmd2.ExecuteNonQuery(); } else { MySqlCommand cmd2 = new MySqlCommand("update purchase_order_details set purch_itemqty=@invq, purch_dstatus='Incomplete' where purch_itemid=@item_id and purch_purchid=@pid", Conn); cmd2.Parameters.AddWithValue("@invq", item_view.Rows[a].Cells[6].Value); cmd2.Parameters.AddWithValue("@item_id", item_view.Rows[a].Cells[7].Value); cmd2.Parameters.AddWithValue("@pid", item_view.Rows[a].Cells[0].Value); cmd2.ExecuteNonQuery(); } } } foreach (DataGridViewRow row in stock_in_view.Rows) { if (row.IsNewRow) { continue; } int countrow = stock_in_view.Rows.Count; for (int i = 0; i < countrow; i++) { MySqlCommand cmd = new MySqlCommand("INSERT INTO stock_in_details(item_id_stock_in_fk,stock_in_quantity, stock_in_id_fk) VALUES (@iditem,@stckqty,'" + stock_in_id.Text + "')", Conn); cmd.Parameters.AddWithValue("@iditem", stock_in_view.Rows[i].Cells[8].Value); cmd.Parameters.AddWithValue("@stckqty", stock_in_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 in Successful!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); disp_data(); Reports_Page g = new Reports_Page(); g.Show(); this.Hide(); } }