예제 #1
0
        private void newInventoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form NewProduct = new ManageProducts();

            NewProduct.MdiParent = this;
            NewProduct.Show();
        }
예제 #2
0
        private void button6_Click(object sender, EventArgs e)
        {
            Form ManageProducts = new ManageProducts();

            ManageProducts.MdiParent = ParentForm;
            ManageProducts.Show();
        }
예제 #3
0
        public static void AddNewProduct(int Barcode, string Name)
        {
            try
            {
                ConnectDatabase();
                using (con)
                {
                    using (SQLiteCommand cmd = new SQLiteCommand(con))
                    {
                        SQLiteTransaction transaction = null;
                        transaction = con.BeginTransaction();

                        cmd.CommandText = @"INSERT INTO products (product_barcode, product_name) 
                                            VALUES (@Barcode, @Name)";
                        cmd.Prepare();
                        cmd.Parameters.AddWithValue("Barcode", Barcode);
                        cmd.Parameters.AddWithValue("Name", Name);
                        cmd.ExecuteNonQuery();
                        transaction.Commit();
                    }
                }
                ManageProducts.labelChange("Added!", Barcode + " \n  " + Name);
            }
            catch (SQLiteException SQLiteThrow)
            {
                string stringCutted = SQLiteThrow.Message.Split(' ').Last();
                if (SQLiteThrow.ErrorCode == 19)
                {
                    if (Equals(stringCutted, "products.product_name"))
                    {
                        MessageBox.Show("This product name already exist!");
                    }
                    else if (Equals(stringCutted, "products.product_barcode"))
                    {
                        MessageBox.Show("This product barcode already exist!");
                    }
                    else
                    {
                        MessageBox.Show("AddNewProduct Message19: " + SQLiteThrow.Message + "\n");
                    }
                }
                else
                {
                    MessageBox.Show("AddNewProduct Message: " + SQLiteThrow.Message + "\n");
                }
            }
        }