private void btnsubmit_Click(object sender, EventArgs e)
        {
            string username = txtusername.Text;
            string email    = txtemail.Text;
            string password = SHA.petitsha(txtpass.Text);

            User.RoleType role = User.RoleType.EMPLOYE;
            if (cbrole.Text == "Employe")
            {
                role = User.RoleType.EMPLOYE;
            }
            else if (cbrole.Text == "Admin")
            {
                role = User.RoleType.ADMIN;
            }

            string sql = $"insert into admin (username,email ,pass, Role) Values ('{username}', '{email}','{password}', {User.roleTypeToInt(role)})";


            if (DataBaseUtil.executeNonQuery(sql) > 0)
            {
                this.DialogResult = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("User " + username + " exists already");
            }
        }
示例#2
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            labelVerif.Visible = false;
            string           Libelle     = txtLibelle.Text;
            string           MotsCles    = txtMots.Text;
            string           Description = txtdesc.Text;
            decimal          Quantite    = nudQuantite.Value;
            float            Prix        = float.Parse(txtPrix.Text);
            NumberFormatInfo nfi         = new NumberFormatInfo();

            nfi.NumberDecimalSeparator = ".";
            string strprix     = Prix.ToString(nfi);
            int    idcategorie = (cbCategorie.SelectedItem as Categorie).Id;
            int    idimage     = (cbImage.SelectedItem as Image).Id;
            string sql         = $"insert into produit (nom_produit, p_motscles, description, qteProduit, prix, id_categorie, id_image) Values ('{Libelle}', '{MotsCles}', '{Description}', {Quantite}, {strprix}, {idcategorie}, {idimage}) ";

            if (DataBaseUtil.executeNonQuery(sql) > 0)
            {
                labelVerif.ForeColor = Color.Green;
                labelVerif.Visible   = true;
                labelVerif.Text      = " Les informations ont bien été enregistrées ";
                this.DialogResult    = DialogResult.OK;
            }
            else
            {
                MessageBox.Show("Echec d'ajout du produit");
            }
        }
示例#3
0
        private void AjouterJournalConnexion(int id_admin, DateTime t, bool etat)
        {
            string dt  = t.ToString("yyyy-MM-dd HH:mm:ss");
            string sql = $"INSERT INTO journal (dateconnect, etat, PersonID) VALUES ('{dt}', {etat}, {id_admin})";

            if (DataBaseUtil.executeNonQuery(sql) == -1)
            {
                MessageBox.Show("Erreur lors de l'insertion dans le journal");
            }
        }
示例#4
0
        private void btndeleteAdmin_Click(object sender, EventArgs e)
        {
            List <User> selected = new List <User>();

            foreach (DataGridViewRow row in DGVAdmin.SelectedRows)
            {
                selected.Add(lesadmins[row.Index]);
                //DGVParticipant.Rows.RemoveAt(row.Index);
            }
            foreach (User s in selected)
            {
                string sql = "DELETE FROM admin WHERE id = " + s.Id;
                DataBaseUtil.executeNonQuery(sql);
            }
            load_admin();
        }
示例#5
0
        private void btnDeleteSalon_Click(object sender, EventArgs e)
        {
            List <Produit> selected = new List <Produit>();

            foreach (DataGridViewRow row in DGVProduit.SelectedRows)
            {
                selected.Add(lesproduits[row.Index]);
                //DGVParticipant.Rows.RemoveAt(row.Index);
            }
            foreach (Produit s in selected)
            {
                string sql = "DELETE FROM produit WHERE id_produit = " + s.Id;
                DataBaseUtil.executeNonQuery(sql);
            }
            load_produit();
        }
示例#6
0
        private void btnDeleteParticipant_Click(object sender, EventArgs e)
        {
            List <Client> selected = new List <Client>();

            foreach (DataGridViewRow row in DGVClient.SelectedRows)
            {
                selected.Add(lesclients[row.Index]);
                //DGVParticipant.Rows.RemoveAt(row.Index);
            }
            foreach (Client p in selected)
            {
                string sql = "DELETE FROM users WHERE id = '" + p.Id + "'";
                DataBaseUtil.executeNonQuery(sql);
            }
            load_client();
        }
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            labelVerif.Visible = false;



            string nom         = txtusername.Text;
            string tel         = txttel.Text;
            string departement = txtadresse.Text;
            string email       = txtemail.Text;
            string sql         = $"insert into users (username, tel, adresse, email) Values ('{nom}', '{tel}', '{departement}', '{email}') ";

            if (DataBaseUtil.executeNonQuery(sql) > 0)
            {
                labelVerif.ForeColor = Color.Green;
                labelVerif.Visible   = true;
                labelVerif.Text      = " Les informations ont bien été enregistrées ";
            }
            else
            {
                MessageBox.Show("Echec de l'ajout d'un client");
            }
        }
示例#8
0
        private void DGVParticipant_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (0 <= e.RowIndex && e.RowIndex < lesclients.Count)
            {
                Client client         = lesclients[e.RowIndex];
                string modifiedColumn = null;
                if (e.ColumnIndex == 1)
                {
                    modifiedColumn = "username";
                    client.Pseudo  = DGVClient.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                }
                else if (e.ColumnIndex == 2)
                {
                    modifiedColumn = "tel";
                    client.Tel     = DGVClient.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                }
                else if (e.ColumnIndex == 3)
                {
                    modifiedColumn = "adresse";
                    client.Adresse = DGVClient.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                }
                else if (e.ColumnIndex == 4)
                {
                    modifiedColumn = "email";
                    client.Email   = DGVClient.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                }
                if (modifiedColumn != null)
                {
                    string sql = $"UPDATE users SET {modifiedColumn} = '{DGVClient.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()}' WHERE id = {client.Id} ";

                    if (DataBaseUtil.executeNonQuery(sql) == -1)
                    {
                        MessageBox.Show("Failed to Update User");
                    }
                }
            }
        }
示例#9
0
        private void DGVSalon_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (0 <= e.RowIndex && e.RowIndex < lesproduits.Count)
            {
                float   prix           = -1;
                Produit produit        = lesproduits[e.RowIndex];
                string  strvalue       = null;
                int     intvalue       = 0;
                string  modifiedColumn = null;
                if (e.ColumnIndex == 1)
                {
                    modifiedColumn = "titre_produit";
                    strvalue       = DGVProduit.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                }
                else if (e.ColumnIndex == 2)
                {
                    modifiedColumn = "description_courte";
                    strvalue       = DGVProduit.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                }
                else if (e.ColumnIndex == 3)
                {
                    modifiedColumn = "description_longue";
                    strvalue       = DGVProduit.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                }
                else if (e.ColumnIndex == 4)
                {
                    modifiedColumn = "qteProduit";
                    intvalue       = int.Parse(DGVProduit.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
                }
                else if (e.ColumnIndex == 5)
                {
                    modifiedColumn = "prix";
                    prix           = float.Parse(DGVProduit.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString());
                }
                else if (e.ColumnIndex == 6)
                {
                    modifiedColumn = "id_categorie";
                    string tmp = DGVProduit.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString();
                    intvalue = Categorie.stringToId(tmp);
                    if (intvalue == 0)
                    {
                        MessageBox.Show("Catégorie introuvable");
                        return;
                    }
                }

                if (modifiedColumn != null)
                {
                    string sql = null;
                    if (strvalue != null)
                    {
                        sql = $"UPDATE produit SET {modifiedColumn} = '{strvalue}' WHERE id_produit = {produit.Id} ";
                    }
                    else if (prix >= 0)
                    {
                        NumberFormatInfo nfi = new NumberFormatInfo();
                        nfi.NumberDecimalSeparator = ".";
                        string strprix = prix.ToString(nfi);
                        sql = $"UPDATE produit SET {modifiedColumn} = {strprix} WHERE id_produit = {produit.Id} ";
                    }
                    else
                    {
                        sql = $"UPDATE produit SET {modifiedColumn} = {intvalue} WHERE id_produit = {produit.Id} ";
                    }
                    if (DataBaseUtil.executeNonQuery(sql) == -1)
                    {
                        MessageBox.Show("Failed to Update User");
                    }
                }
            }
        }
示例#10
0
        public static bool lockUnlockUser(string username, bool locked)
        {
            string sql = $"UPDATE admin SET locked = {locked} WHERE admin.username = '******' AND admin.Role <> 1 ";

            return(DataBaseUtil.executeNonQuery(sql) > 0);
        }