Exemplo n.º 1
0
        public override void CreerPersonnes(clsPersonne personne)
        {
            clsCommunAccesDonnees commun    = new clsCommunAccesDonnees();
            SqlConnection         connexion = new SqlConnection();


            connexion = commun.OuvirConnexion();
            if (connexion == null)
            {
                throw new Exception();
            }

            SqlCommand command = new SqlCommand("tblPersonneAjouter", connexion)
            {
                CommandType = CommandType.StoredProcedure
            };

            command.Parameters.Add(new SqlParameter("@nom", personne.sNom));
            command.Parameters.Add(new SqlParameter("@prenom", personne.sPrenom));
            command.Parameters.Add(new SqlParameter("@adresses", personne.sAdresse));
            command.Parameters.Add(new SqlParameter("@naissance", personne.dDateNaissance));
            command.Parameters.Add(new SqlParameter("@niveau", (int)clsPersonne.enuNiveau.iCLIENT));
            command.Parameters.Add(new SqlParameter("@sexe", personne.eSexe == clsPersonne.enuSexe.iHOMME? "M": "F"));

            command.ExecuteNonQuery();

            commun.FermerConnexion();
        }
Exemplo n.º 2
0
        /// <summary>
        /// retrieve client details based on id
        /// assign value to textbox
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAnnuler_Click(object sender, EventArgs e)
        {
            try
            {
                if (personne == null || personne.iID <= 0)
                {
                    throw new Exception(clsCommun.ErreurApplicationGeneric);
                }

                if (personne.eNiveau == clsPersonne.enuNiveau.iCLIENT)
                {
                    personneTransaction = personne;
                }

                if (personneTransaction.iID > 0)
                {
                    RecupererPersonneParNiveau();

                    if (panier == null || panier.objPersonnes == null || panier.objPersonnes.iID <= 0)
                    {
                        throw new Exception(clsCommun.ErreurRecupererPersonne);
                    }
                }

                AttribuerValeur(panier);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                frmAuthentification authentification = new frmAuthentification();
                authentification.Show();
                this.Hide();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// over ride adbstract method to create a new client
        /// validate  client info
        /// instanciate data layer abstract class
        /// call method to save client data in data layer
        /// </summary>
        /// <param name="personne"></param>
        public override void CreerPersonne(clsPersonne personne)
        {
            if (!EstValabe(personne))
            {
                throw new Exception(clsCommun.ErreurValidationClients);
            }

            accesDonnees = new clsSuperviseurAccesDonnees();
            accesDonnees.CreerPersonnes(personne);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Button event to validate ans exit application
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnValider_Click(object sender, EventArgs e)
        {
            try
            {
                ///declaration of local variables
                string              utilisatueur = txtUtilisateur.Text.Trim();
                string              motDePasse   = txtMotDePasse.Text.Trim();
                clsPersonne         authentifier = new clsPersonne();
                clsGestionPersonnes gestion;

                if (string.IsNullOrWhiteSpace(utilisatueur) || (string.IsNullOrWhiteSpace(utilisatueur) && string.IsNullOrWhiteSpace(motDePasse)))
                {
                    throw new Exception(clsCommun.ErreurUtilisateur);
                }

                //get authentication based on credentials by data layer
                gestion      = new clsGestionSuperviseur();
                authentifier = gestion.AuthentifierPersonne(utilisatueur, motDePasse);

                if (authentifier == null)
                {
                    throw new Exception(clsCommun.ErreurEntree);
                }

                //navigation based on role
                switch (authentifier.eNiveau)
                {
                case clsPersonne.enuNiveau.iCLIENT:
                    SupprimerEntree();
                    Routage(authentifier);
                    break;

                case clsPersonne.enuNiveau.iCHEF_RAYON:
                    SupprimerEntree();
                    Routage(authentifier);
                    break;

                case clsPersonne.enuNiveau.iSUPERVISEUR:
                    SupprimerEntree();
                    Routage(authentifier);
                    break;

                default:
                    throw new Exception(clsCommun.ErreurUtilisateurInvalide);
                }
            }
            catch (Exception ex)
            {
                SupprimerEntree();
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// retrieve list of clients by business layer
        /// return datatable as data type
        /// </summary>
        /// <param name="personne"></param>
        /// <returns></returns>
        private DataTable RecupereListeClients(clsPersonne personne)
        {
            DataTable resultat = new DataTable();

            switch (personne.eNiveau)
            {
            case clsPersonne.enuNiveau.iSUPERVISEUR:
                gestion  = new clsGestionSuperviseur();
                resultat = gestion.RecupererListePersonnes(personne.iID);
                break;

            case clsPersonne.enuNiveau.iCHEF_RAYON:
                gestion  = new clsGestionChefRayon();
                resultat = gestion.RecupererListePersonnes(personne.iID);
                break;
            }

            return(resultat);
        }
Exemplo n.º 6
0
        private void Routage(clsPersonne personne)
        {
            frmGestionDesPersonnes gestionDesPersonnes = new frmGestionDesPersonnes();
            frmInfoClients         infoClients         = new frmInfoClients();

            /// make control visible based on user role
            /// this allow developer to used only one form for both chef de rayon and supervisor
            switch (personne.eNiveau)
            {
            case clsPersonne.enuNiveau.iCLIENT:
                infoClients.Text     = clsCommun.TitreModeclient;
                infoClients.personne = personne;
                infoClients.btnPrecedent.Hide();
                infoClients.btnSuivant.Hide();
                infoClients.personneTransaction = personne;
                infoClients.Show();
                this.Hide();
                break;

            case clsPersonne.enuNiveau.iCHEF_RAYON:
                gestionDesPersonnes.Text = clsCommun.TitreModeChefRayon;
                gestionDesPersonnes.lblInformation.Text = clsCommun.InformationModeChefRayon;
                gestionDesPersonnes.personne            = personne;
                gestionDesPersonnes.btnAjouter.Hide();
                gestionDesPersonnes.btnSupprimer.Hide();
                gestionDesPersonnes.btnVisualiser.Text = "Modifier";
                gestionDesPersonnes.Show();
                this.Hide();
                break;

            default:
                gestionDesPersonnes.Text = clsCommun.TitreModeSuperviseur;
                gestionDesPersonnes.lblInformation.Text = clsCommun.InformationModeSuperviseur;
                gestionDesPersonnes.personne            = personne;
                gestionDesPersonnes.Show();
                this.Hide();
                break;
            }
        }
Exemplo n.º 7
0
        private bool EstValabe(clsPersonne personne)
        {
            bool resultat = true;
            var  date     = DateTime.Now;

            if (personne.iID > 0)
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(personne.sNom))
            {
                return(false);
            }
            if (string.IsNullOrWhiteSpace(personne.sAdresse))
            {
                return(false);
            }
            switch (personne.eSexe)
            {
            case clsPersonne.enuSexe.iHOMME:
            case clsPersonne.enuSexe.iFEMME:
                break;

            default:
                return(false);
            }

            if (personne.dDateNaissance == null)
            {
                return(false);
            }

            if (personne.dDateNaissance.Date.AddYears(18) > DateTime.Today.Date)
            {
                return(false);
            }

            return(resultat);
        }
Exemplo n.º 8
0
        /// <summary>
        /// call method in business layer to retrieve list of clients
        /// retrieve list of clients based on authenticator role
        /// </summary>
        /// <param name="personne"></param>
        /// <returns></returns>
        private List <int> RecupererListPersonParId(clsPersonne personne)
        {
            List <int>          resultat = new List <int>();
            clsGestionPersonnes gestion;
            DataTable           tableDeDonnees = new DataTable();

            switch (personne.eNiveau)
            {
            case clsPersonne.enuNiveau.iCLIENT:
                break;

            case clsPersonne.enuNiveau.iCHEF_RAYON:
                gestion        = new clsGestionChefRayon();
                tableDeDonnees = gestion.RecupererListePersonnes(personne.iID);
                break;

            case clsPersonne.enuNiveau.iSUPERVISEUR:
                gestion        = new clsGestionSuperviseur();
                tableDeDonnees = gestion.RecupererListePersonnes(personne.iID);
                break;

            default:
                break;
            }

            if (tableDeDonnees == null || tableDeDonnees.Rows.Count <= 0)
            {
                return(resultat);
            }

            foreach (DataRow item in tableDeDonnees.Rows)
            {
                resultat.Add(Convert.ToInt32(item[0]));
            }

            return(resultat);
        }
Exemplo n.º 9
0
        /// <summary>
        /// validate id and password
        /// call mathod from data layer
        /// if valid retrieve user info
        /// </summary>
        /// <param name="utilisatueur"></param>
        /// <param name="motDePasse"></param>
        /// <returns></returns>
        public clsPersonne AuthentifierPersonne(string utilisatueur, string motDePasse)
        {
            clsPersonne resultat = new clsPersonne();

            try
            {
                if (!Valider(utilisatueur, motDePasse))
                {
                    throw new Exception();
                }

                DataTable tableDeDonnees = new DataTable();

                gestion        = new clsSuperviseurAccesDonnees();
                tableDeDonnees = gestion.AuthentifierPersonne(utilisatueur, motDePasse);

                if (tableDeDonnees == null)
                {
                    throw new Exception();
                }

                resultat.iID            = Convert.ToInt32(tableDeDonnees.Rows[0][0]);
                resultat.eNiveau        = RecupereNiveauUtilisateur(Convert.ToInt32(tableDeDonnees.Rows[0][1]));
                resultat.sNom           = tableDeDonnees.Rows[0][2].ToString();
                resultat.sPrenom        = tableDeDonnees.Rows[0][3].ToString();
                resultat.dDateNaissance = Convert.ToDateTime(tableDeDonnees.Rows[0][4]);
                resultat.eSexe          = RecupereSexe(tableDeDonnees.Rows[0][5].ToString());
                resultat.sAdresse       = tableDeDonnees.Rows[0][7].ToString();

                return(resultat);
            }
            catch (Exception)
            {
                return(resultat = null);
            }
        }
Exemplo n.º 10
0
 public override void CreerPersonne(clsPersonne personne)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 11
0
 /// <summary>
 /// update client
 /// </summary>
 /// <param name="personne"></param>
 public void ModifierPersonnes(clsPersonne personne)
 {
     gestion = new clsSuperviseurAccesDonnees();
     gestion.MAJPersonne(personne);
 }
Exemplo n.º 12
0
 /// <summary>
 /// declare abstract classes
 /// mathod to:
 ///     create client
 ///     retrieve list of vlients
 ///     delete client
 /// </summary>
 /// <param name="personne"></param>
 public abstract void CreerPersonne(clsPersonne personne);