예제 #1
0
        public void InsertionUpdateDeleteServiteur(ClsMembre pt, int choix)
        {
            try
            {
                InitialiserConnexion();

                if (!conn.State.ToString().ToLower().Equals("open")) conn.Open();
                cmd = conn.CreateCommand();
                switch (choix)
                {
                    case 1:
                        cmd.CommandText = "insert into Serviteur values (@code,@nom,@sexe,@adresse,@etatcivil,@phone,@photo,@mail,@cellule,@ministere,@dateadd,null) ";
                        SetParametre(cmd, "@code", DbType.String, 50, pt.Code_Servi.ToUpper());
                        SetParametre(cmd, "@nom", DbType.String, 50, pt.Nom.ToUpper());
                        SetParametre(cmd, "@sexe", DbType.String, 50, pt.Sexe.ToUpper());
                        SetParametre(cmd, "@Adresse", DbType.String, 50, pt.Adresse.ToUpper());
                        SetParametre(cmd, "@etatcivil", DbType.String, 50, pt.EtaCivil.ToUpper());
                        SetParametre(cmd, "@phone", DbType.String, 50, pt.Phone.ToUpper());
                        if (pt.Photo != null)
                            SetParametre(cmd, "@photo", DbType.Binary, Int32.MaxValue, pt.Photo);
                        else
                            SetParametre(cmd, "@photo", DbType.Binary, Int32.MaxValue, DBNull.Value);
                        SetParametre(cmd, "@mail", DbType.String, 50, pt.Mail.ToUpper());
                        SetParametre(cmd, "@cellule", DbType.String, 50, pt.Cellule.ToUpper());
                        SetParametre(cmd, "@ministere", DbType.String, 50, pt.Ministere.ToUpper());
                        SetParametre(cmd, "@dateadd", DbType.String, 50, pt.Date.ToUpper());
                        cmd.ExecuteNonQuery();
                        fx.Messages(1);
                        break;
                    case 2:
                        cmd.CommandText = "update Serviteur set nom_complet=@nom,sexe=@sexe,adresse=@adresse,etat_civil=@etatcivil,phone=@phone,photo=@photo,email=@mail,CODE_CELLULE=@cellule,code_ministere=@ministere,date_modif=@date_modif where code=@code";
                        SetParametre(cmd, "@code", DbType.String, 50, pt.Code_Servi.ToUpper());
                        SetParametre(cmd, "@nom", DbType.String, 50, pt.Nom.ToUpper());
                        SetParametre(cmd, "@sexe", DbType.String, 50, pt.Sexe.ToUpper());
                        SetParametre(cmd, "@Adresse", DbType.String, 50, pt.Adresse.ToUpper());
                        SetParametre(cmd, "@etatcivil", DbType.String, 50, pt.EtaCivil.ToUpper());
                        SetParametre(cmd, "@phone", DbType.String, 50, pt.Phone.ToUpper());
                        if (pt.Photo != null)
                            SetParametre(cmd, "@photo", DbType.Binary, Int32.MaxValue, pt.Photo);
                        else
                            SetParametre(cmd, "@photo", DbType.Binary, Int32.MaxValue, DBNull.Value);
                        SetParametre(cmd, "@mail", DbType.String, 50, pt.Mail.ToUpper());
                        SetParametre(cmd, "@cellule", DbType.String, 50, pt.Cellule.ToUpper());
                        SetParametre(cmd, "@ministere", DbType.String, 50, pt.Ministere.ToUpper());
                        SetParametre(cmd, "@date_modif", DbType.String, 50, pt.Date.ToUpper());
                        cmd.ExecuteNonQuery();
                        fx.Messages(1);
                        break;
                    case 3:
                        cmd.CommandText = "delete from Membre where Id_Memb=@id";
                        MessageBox.Show("Suppression reçu!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        break;
                }

                cmd.Dispose();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                conn.Close();
            }
        }
예제 #2
0
        public void InsertionUpdateDeleteAgent(ClsMembre pt, int choix)
        {
            try
            {
                InitialiserConnexion();

                if (!conn.State.ToString().ToLower().Equals("open"))
                {
                    conn.Open();
                }
                cmd = conn.CreateCommand();
                switch (choix)
                {
                case 1:
                    cmd.CommandText = "insert into Agent values (@code,@nom,@mail,@phone,@photo,@barcode,@sexe,@dateAdd,null,@Code_Fonction) ";
                    SetParametre(cmd, "@code", DbType.String, 50, pt.Code_Agent.ToUpper());
                    SetParametre(cmd, "@nom", DbType.String, 50, pt.Nom.ToUpper());
                    SetParametre(cmd, "@mail", DbType.String, 50, pt.Mail.ToUpper());
                    SetParametre(cmd, "@phone", DbType.String, 50, pt.Phone.ToUpper());
                    if (pt.Photo != null)
                    {
                        SetParametre(cmd, "@photo", DbType.Binary, Int32.MaxValue, pt.Photo);
                    }
                    else
                    {
                        SetParametre(cmd, "@photo", DbType.Binary, Int32.MaxValue, DBNull.Value);
                    }
                    SetParametre(cmd, "@barcode", DbType.Int32, 50, pt.Barcode);
                    SetParametre(cmd, "@sexe", DbType.String, 50, pt.Sexe.ToUpper());
                    SetParametre(cmd, "@dateAdd", DbType.String, 50, pt.Date);
                    SetParametre(cmd, "@Code_Fonction", DbType.String, 50, pt.Code_fonction);
                    cmd.ExecuteNonQuery();
                    fx.Messages(1);
                    break;

                case 2:
                    cmd.CommandText = "update Agent set nom_complet=@nom,phone=@phone,photo=@photo,email=@mail,sexe=@sexe,date_modif=@date_modif,Code_Fonction=@Code_Fonction where code=@code";
                    SetParametre(cmd, "@code", DbType.String, 50, pt.Code_Agent.ToUpper());
                    SetParametre(cmd, "@nom", DbType.String, 50, pt.Nom.ToUpper());
                    SetParametre(cmd, "@mail", DbType.String, 50, pt.Mail.ToUpper());
                    SetParametre(cmd, "@phone", DbType.String, 50, pt.Phone.ToUpper());
                    if (pt.Photo != null)
                    {
                        SetParametre(cmd, "@photo", DbType.Binary, Int32.MaxValue, pt.Photo);
                    }
                    else
                    {
                        SetParametre(cmd, "@photo", DbType.Binary, Int32.MaxValue, DBNull.Value);
                    }
                    SetParametre(cmd, "@barcode", DbType.Int32, 50, pt.Barcode);
                    SetParametre(cmd, "@sexe", DbType.String, 50, pt.Sexe.ToUpper());
                    SetParametre(cmd, "@date_modif", DbType.String, 50, pt.Date.ToUpper());
                    SetParametre(cmd, "@Code_Fonction", DbType.String, 50, pt.Code_fonction);
                    cmd.ExecuteNonQuery();
                    fx.Messages(1);
                    break;

                case 3:
                    cmd.CommandText = "delete from Membre where Id_Memb=@id";
                    MessageBox.Show("Suppression reçu!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cmd.ExecuteNonQuery();
                    fx.Messages(1);
                    break;
                }
                cmd.Dispose();
                conn.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                cmd.Dispose();
                conn.Close();
            }
        }