示例#1
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form InInventoryForm = new InInventory();

            InInventoryForm.MdiParent = ParentForm;
            InInventoryForm.Show();
        }
示例#2
0
        public static void InInventoryUpdate(int Barcode, int Number, string[] Location)
        {
            try
            {
                ConnectDatabase();
                using (con)
                {
                    using (SQLiteCommand cmd = new SQLiteCommand(con))
                    {
                        SQLiteTransaction transaction = null;
                        transaction = con.BeginTransaction();

                        cmd.CommandText = @"
                            UPDATE stock SET stock_number = stock_number + @Number WHERE 
                                stock_id IN (SELECT stock_id FROM stock WHERE 
                                product_id IN (SELECT product_id FROM products WHERE product_barcode = @Barcode)
                                AND
                                location_id IN (SELECT location_id FROM locations WHERE 
                                    location_a = @Location1 AND location_b = @Location2 AND location_c = @Location3));

                            INSERT INTO history (product_id, history_status, location_id, stock_number) 
                            VALUES 
                                ((SELECT product_id FROM products WHERE product_barcode = @Barcode), 
                                '1', 
                                (SELECT location_id FROM locations WHERE 
                                    location_a = @Location1 AND location_b = @Location2 AND location_c = @Location3),
                                @Number)
                        ";
                        cmd.Prepare();
                        cmd.Parameters.AddWithValue("Barcode", Barcode);
                        cmd.Parameters.AddWithValue("Location1", Location[0]);
                        cmd.Parameters.AddWithValue("Location2", Location[1]);
                        cmd.Parameters.AddWithValue("Location3", Location[2]);
                        cmd.Parameters.AddWithValue("Number", Number);
                        cmd.ExecuteNonQuery();
                        transaction.Commit();
                    }
                }
                InInventory.labelChange("Added on!", Barcode + " \n  " + Number + " \n  " + Location[0] + Location[1] + Location[2]);
            }
            catch (SQLiteException SQLiteThrow)
            {
                MessageBox.Show("InInventoryUpdate Message: " + SQLiteThrow.Message);
            }
        }