private void button1_Click(object sender, EventArgs e)
        {
            int    catId       = int.Parse(catID.Text);
            int    productId   = int.Parse(ID.Text);
            string productName = this.nom_du_produit.Text.Trim();
            double prix        = double.Parse(this.prix.Text);
            string description = this.description.Text.Trim();

            string query = "insert into produit values(" + productId + ",'" + productName + "'," + prix + " ," + catId + " ,'" + description + "')";

            Cnx.InsertData(sqliteCon, query);
            Cnx.populateTable(sqliteCon, "select * from produit", this.dataGridView1);

            SQLiteDataReader maxId = Cnx.getData(sqliteCon, "select MAX(id) from produit");

            if (maxId.Read())
            {
                int newId = maxId.GetInt32(0) + 1;
                this.ID.Text = newId.ToString();
            }


            this.ID.Text             = "";
            this.nom_du_produit.Text = "";
            this.prix.Text           = "";
            this.description.Text    = "";

            MessageBox.Show("Product Successfully Added");
        }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            int    categorieId  = int.Parse(this.categorieID.Text.Trim());
            String categorieNom = this.categorie.Text.Trim();


            try
            {
                if (categorieNom == "")
                {
                    MessageBox.Show("Please Type a New Category Name to be added.");
                    Cnx.populateTable(sqliteCon, "select * from categories", this.dataGridView1);
                }
                else
                {
                    String query = "update categories set id=" + categorieId + ", nom_cat='" + categorieNom + "' where id=" + categorieId + ";";
                    Cnx.InsertData(sqliteCon, query);
                    Cnx.populateTable(sqliteCon, "select * from categories", this.dataGridView1);
                    setNeWCatId();
                    this.categorie.Text = "";
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            String username = this.username.Text.Trim();
            String query    = "Delete from accounts where username='******';";

            Cnx.InsertData(sqliteCon, query);

            getAccounts();
        }
        private void button2_Click(object sender, EventArgs e)
        {
            String username = this.username.Text.Trim();
            String password = this.password.Text.Trim();
            String nom      = this.nom.Text.Trim();
            String prenom   = this.prenom.Text.Trim();
            String jobID    = this.comboBox1.SelectedItem.ToString();

            String query = "update accounts set username = '******', password='******',nom='" + nom + "',prenom='" + prenom + "',job_id='" + jobID + "' where username='******';";

            Cnx.InsertData(sqliteCon, query);

            getAccounts();
        }
        private void button3_Click(object sender, EventArgs e)
        {
            int    productId = int.Parse(ID.Text);
            String query     = "Delete from produit where id=" + productId + ";";

            Cnx.InsertData(sqliteCon, query);
            Cnx.populateTable(sqliteCon, "select * from produit", this.dataGridView1);

            this.ID.Text             = "";
            this.nom_du_produit.Text = "";
            this.prix.Text           = "";
            this.description.Text    = "";

            MessageBox.Show("Product Successfully Deleted");
        }
Beispiel #6
0
        private void button3_Click(object sender, EventArgs e)
        {
            int categorieId = int.Parse(this.categorieID.Text.Trim());



            try
            {
                String query = "Delete from categories where id=" + categorieId + ";";
                Cnx.InsertData(sqliteCon, query);
                Cnx.populateTable(sqliteCon, "select * from categories", this.dataGridView1);
                setNeWCatId();
                this.categorie.Text = "";
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            String username = this.username.Text.Trim();
            String password = this.password.Text.Trim();
            String nom      = this.nom.Text.Trim();
            String prenom   = this.prenom.Text.Trim();
            String jobID    = this.comboBox1.SelectedItem.ToString();

            System.Diagnostics.Debug.WriteLine(jobID);
            try
            {
                String query = "insert into accounts values('" + username + "','" + password + "','" + nom + "','" + prenom + "','" + jobID + "');";

                Cnx.InsertData(sqliteCon, query);

                getAccounts();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex);
            }
        }