Esempio n. 1
0
        public UtilisateurDB GetUser(string login, string password)
        {
            try
            {
                DataAccesDataContext dbContext = new DataAccesDataContext();
                UtilisateurDB        ls        = new UtilisateurDB();
                var pm = (from c in dbContext.Utilisateur


                          where c.login == login && c.Mdp == password && c.Etat == "A"

                          select new UtilisateurDB
                {
                    code_utilisateur = c.code_utilisateur,
                    code_profil = c.code_profil,
                    Mdp = c.Mdp,
                    Nom_utilisateur = c.Nom_utilisateur,
                    Etat = c.Etat.ToString(),
                    login = c.login
                });

                return(pm.ToList().FirstOrDefault());
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                return(null);
            }
        }
Esempio n. 2
0
        public UtilisateurDB GetUser(int code_utilisateur)
        {
            try
            {
                DataAccesDataContext dbContext = new DataAccesDataContext();
                UtilisateurDB        ls        = new UtilisateurDB();
                var pm = (from c in dbContext.Utilisateur
                          join d in dbContext.profil on c.code_profil equals d.code_profil
                          where c.code_utilisateur == code_utilisateur
                          select new UtilisateurDB
                {
                    code_utilisateur = c.code_utilisateur,
                    Nom_utilisateur = c.Nom_utilisateur,
                    login = c.login,
                    Mdp = c.Mdp,
                    Etat = c.Etat.ToString(),
                    code_profil = c.code_profil,
                    code_partenaire = c.code_partenaire
                });

                return(pm.ToList().FirstOrDefault());
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                return(null);
            }
        }
Esempio n. 3
0
        public List <adresseDB> GetAdresse(UtilisateurDB user)
        {
            try
            {
                DataAccesDataContext dbContext = new DataAccesDataContext();
                adresseDB            ls        = new adresseDB();
                var pm = (from c in dbContext.adresse
                          join a in dbContext.partenaire on c.code_adresse equals a.code_adresse
                          join o in dbContext.Utilisateur on a.code_partenaire equals o.code_partenaire
                          where o.code_utilisateur == user.code_utilisateur

                          select new adresseDB
                {
                    code_adresse = c.code_adresse,
                    code_postal = c.code_postal == null ? "" : c.code_postal,
                    email = c.email == null ? "" : c.email,
                    fax = c.fax == null ? "" : c.fax,
                    gouvernerat = c.gouvernerat == null ?"" : c.code_postal,
                    rue = c.rue == null ? "" : c.rue,
                    tel = c.tel == null ? "" : c.tel,
                    ville = c.ville == null ? "" : c.ville
                }).OrderBy(w => w.code_adresse);

                return(pm.ToList());
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                return(null);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["code_utilisateur"] == null)
            {
                Response.Redirect("login.aspx");
            }
            if (!IsPostBack)
            {
                if (Session["code_utilisateur"] != null)
                {
                    AstreeDonnees a    = new AstreeDonnees();
                    UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                    adresseDB     adr  = a.GetAdresse(user).FirstOrDefault();
                    //img=ConvertbyteToImage(user.Image);
                    Txttel.Text = adr.tel;

                    Txtgouvernerat.Text = adr.gouvernerat;
                    TxtVille.Text       = adr.ville;
                    TxTUserProfil.Text  = user.description_profil;
                }
                else
                {
                    Response.Redirect("login.aspx");
                }
            }
            importerF.Attributes.Add("onclick", "document.getElementById('" + FileUpload1.ClientID + "').click();return false;");
        }
Esempio n. 5
0
        public List <UtilisateurDB> GetUser()
        {
            try
            {
                DataAccesDataContext dbContext = new DataAccesDataContext();
                UtilisateurDB        ls        = new UtilisateurDB();
                var pm = (from c in dbContext.Utilisateur
                          join d in dbContext.profil on c.code_profil equals d.code_profil

                          select new UtilisateurDB
                {
                    code_utilisateur = c.code_utilisateur,
                    Nom_utilisateur = c.Nom_utilisateur,
                    login = c.login,
                    Mdp = c.Mdp,
                    Etat = c.Etat.ToString(),
                    code_profil = c.code_profil,
                    description_profil = d.description_profil
                });

                return(pm.ToList());
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                return(null);
            }
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["code_utilisateur"] == null)
            {
                Response.Redirect("login.aspx");
            }


            if (!IsPostBack)
            {
                // bind chart type names to ddl

                ddlChartType.DataSource = Enum.GetNames(typeof(SeriesChartType));
                ddlChartType.DataBind();

                foreach (ListItem ite in ddlChartType.Items)
                {
                    if (ite.Text == "Column")
                    {
                        ite.Selected = true;
                    }
                }

                AstreeDonnees         a      = new AstreeDonnees();
                UtilisateurDB         user   = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                List <statistiquesDB> lsStat = a.GetStatistiques().Where(w => w.Agence == user.code_partenaire.ToString()).ToList();
                Session["lstStat"]         = lsStat;
                gv_statistiques.DataSource = lsStat;
                gv_statistiques.DataBind();
                //DataBind();
                getAnnee();
                getBranche();
                getCharte();
            }
        }
Esempio n. 7
0
        protected void gv_User_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                lblMessage.Text = gv_User.Rows[gv_User.SelectedIndex].Cells[1].Text;
                AstreeDonnees ad  = new AstreeDonnees();
                string        ret = ad.maj_user(gv_User.Rows[gv_User.SelectedIndex].Cells[1].Text);
                Label         x   = (Label)Master.FindControl("lblNotifCompteDesactive") as Label;
                Label         y   = (Label)Master.FindControl("nbNotification") as Label;

                List <UtilisateurDB> lsNotification = ad.GetUser().Where(w => w.Etat.Trim() == "N").ToList();

                x.Text = lsNotification.Count().ToString();
                y.Text = lsNotification.Count().ToString();
                if (ret == "Active")
                {
                    lblMessage.Text = "Traitement fait avec succès!!";
                    this.BindGrid();
                    //gv_User.SelectedIndex = -1;
                    UtilisateurDB     S       = ad.GetUser().Where(w => w.login == gv_User.Rows[gv_User.SelectedIndex].Cells[1].Text).FirstOrDefault();
                    partenaireDB      part2   = ad.GetPartenair().Where(w => w.code_partenaire == S.code_partenaire).FirstOrDefault();
                    adresseDB         adr     = ad.GetAdresse().Where(w => w.code_adresse == part2.code_adresse).FirstOrDefault();
                    string            chaine  = "Le compte de votre utilisateur =" + S.Nom_utilisateur + "  est activé";
                    MailMessage       o       = new MailMessage("*****@*****.**", adr.email, "Activation du compte", chaine);
                    NetworkCredential netCred = new NetworkCredential("*****@*****.**", "HA_ouma147896321");
                    SmtpClient        smtpobj = new SmtpClient("smtp.gmail.com", 25);
                    smtpobj.EnableSsl   = true;
                    smtpobj.Credentials = netCred;
                    smtpobj.Send(o);
                }
                else if (ret == "Desactive")
                {
                    lblMessage.Text = "Traitement fait avec succès!!";
                    this.BindGrid();
                    // gv_User.SelectedIndex = -1;
                    UtilisateurDB     S       = ad.GetUser().Where(w => w.login == gv_User.Rows[gv_User.SelectedIndex].Cells[1].Text).FirstOrDefault();
                    partenaireDB      part2   = ad.GetPartenair().Where(w => w.code_partenaire == S.code_partenaire).FirstOrDefault();
                    adresseDB         adr     = ad.GetAdresse().Where(w => w.code_adresse == part2.code_adresse).FirstOrDefault();
                    string            chaine  = "Le compte de votre utilisateur =" + S.Nom_utilisateur + "  est désaactivé";
                    MailMessage       o       = new MailMessage("*****@*****.**", adr.email, "Désactivation du compte", chaine);
                    NetworkCredential netCred = new NetworkCredential("*****@*****.**", "HA_ouma147896321");
                    SmtpClient        smtpobj = new SmtpClient("smtp.gmail.com", 25);
                    smtpobj.EnableSsl   = true;
                    smtpobj.Credentials = netCred;
                    smtpobj.Send(o);
                }
                else
                {
                    lblMessage.Text = ret;
                }
            }
            catch (Exception ex)
            {
                //Response.Redirect("PageErreur.aspx");
            }
        }
Esempio n. 8
0
        private void BindGrid()
        {
            AstreeDonnees a    = new AstreeDonnees();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));

            List <serviceDB> ls = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Derogation") && (w.libelleType.Trim() == "Remise") && (w.codeUtilisateur == user.code_utilisateur)).OrderBy(w => w.etat).ThenByDescending(w => w.code_service).ToList();

            foreach (serviceDB x in ls)
            {
                if (x.libelleBranche.Trim() == "Choisir")
                {
                    x.libelleBranche = "";
                }
                if (x.libelleSousbranche.Trim() == "Choisir")
                {
                    x.libelleSousbranche = "";
                }
            }
            Session["lstremise"]     = ls;
            gv_Derogation.DataSource = ls;
            gv_Derogation.DataBind();

            List <serviceDB> lss = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Derogation") && (w.libelleType.Trim() == "Prorogation") && (w.codeUtilisateur == user.code_utilisateur)).OrderBy(w => w.etat).ThenByDescending(w => w.code_service).ToList();

            foreach (serviceDB x in lss)
            {
                if (x.libelleBranche.Trim() == "Choisir")
                {
                    x.libelleBranche = "";
                }
                if (x.libelleSousbranche.Trim() == "Choisir")
                {
                    x.libelleSousbranche = "";
                }
            }
            Session["lstproro"]      = lss;
            gvProrogation.DataSource = lss;
            gvProrogation.DataBind();

            List <serviceDB> lsss = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Derogation") && (w.libelleType.Trim() == "Souscription") && (w.codeUtilisateur == user.code_utilisateur)).OrderBy(w => w.etat).ThenByDescending(w => w.code_service).ToList();

            foreach (serviceDB x in lsss)
            {
                if (x.libelleBranche.Trim() == "Choisir")
                {
                    x.libelleBranche = "";
                }
                if (x.libelleSousbranche.Trim() == "Choisir")
                {
                    x.libelleSousbranche = "";
                }
            }
            Session["lstsouscrip"]    = lsss;
            gvSouscription.DataSource = lsss;
            gvSouscription.DataBind();
        }
Esempio n. 9
0
 public void ModifierMDP(UtilisateurDB util)
 {
     using (DataAccesDataContext dbContext = new DataAccesDataContext())
     {
         Utilisateur newUtilisateur = new Utilisateur();
         newUtilisateur     = dbContext.Utilisateur.FirstOrDefault(w => w.login == util.login);
         newUtilisateur.Mdp = util.Mdp;
         dbContext.SubmitChanges();
     }
 }
Esempio n. 10
0
        public void modifierEtat(UtilisateurDB Utilisateur)
        {
            using (DataAccesDataContext dbContext = new DataAccesDataContext())
            {
                Utilisateur newUtilisateur = new Utilisateur();
                newUtilisateur = dbContext.Utilisateur.FirstOrDefault(w => w.code_utilisateur == Utilisateur.code_utilisateur);


                newUtilisateur.Etat = Utilisateur.Etat.ToString();

                dbContext.SubmitChanges();
            }
        }
        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            AstreeDonnees a    = new AstreeDonnees();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));

            if ((user.code_profil == 101) || (user.code_profil == 202))
            {
                Response.Redirect("DemanderReclamation.aspx");
            }
            else
            {
                Response.Redirect("AfficherReclamation.aspx");
            }
        }
        protected void Btnsave_Click(object sender, EventArgs e)
        {
            if (Txtpsw.Text == "")
            {
                txtPasse2.Text = "";
                MsgPasse.Text  = "Vous devez saisir votre mot de passe!";
                Txtpsw.Focus();
            }

            else if (txtpsw2.Text == "")
            {
                txtpsw2.Focus();
                MsgPasse.Text  = "";
                txtPasse2.Text = "Vous devez retaper votre mot de passe";
            }
            else if (txtpsw2.Text.Trim() != Txtpsw.Text.Trim())
            {
                txtpsw2.Focus();
                txtpsw2.Text   = "";
                MsgPasse.Text  = "";
                txtPasse2.Text = "Les deux mot de passe ne sont pas identique!";
            }
            else
            {
                System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
                System.Drawing.Image imag = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream);
                txtPasse2.Text = "";
                MsgPasse.Text  = "";
                AstreeDonnees astrDonnes = new AstreeDonnees();

                UtilisateurDB usr = astrDonnes.GetUser(Convert.ToInt16(Session["code_utilisateur"]));
                adresseDB     adr = astrDonnes.GetAdresse(usr).FirstOrDefault();

                adr.ville       = TxtVille.Text;
                adr.tel         = Txttel.Text;
                adr.gouvernerat = Txtgouvernerat.Text;
                usr.Mdp         = Txtpsw.Text;

                byte[] tab = ConvertImageToByteArray(imag, System.Drawing.Imaging.ImageFormat.Jpeg);;
                usr.Image = tab;

                astrDonnes.modifierUtilisateur(usr);
                astrDonnes.modifierAdresse(adr);
                //lblMsgSucces.Visible = true;
                //lblMsgSucces.Text = "Modification Terminée";
            }
        }
Esempio n. 13
0
 public void InsertUser(UtilisateurDB user)
 {
     using (DataAccesDataContext dbContext = new DataAccesDataContext())
     {
         Utilisateur utilisateur = new Utilisateur
         {
             code_utilisateur = user.code_utilisateur,
             code_profil      = user.code_profil,
             Mdp             = user.Mdp,
             Nom_utilisateur = user.Nom_utilisateur,
             Etat            = user.Etat,
             login           = user.login,
         };
         dbContext.Utilisateur.InsertOnSubmit(utilisateur);
         dbContext.SubmitChanges();
     }
 }
        protected void gv_Reclamation_SelectedIndexChanged(object sender, EventArgs e)
        {
            Btnsave.Visible = false;
            AstreeDonnees a = new AstreeDonnees();

            GridViewRow   row  = gv_Reclamation.SelectedRow;
            serviceDB     serv = a.GetServices().Where(w => w.code_service == Convert.ToInt32(row.Cells[1].Text)).FirstOrDefault();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(serv.codeUtilisateur));

            TxtCode.Text = serv.codeUtilisateur.ToString();


            List <destinationDB> lstDestination = a.GetDestination();

            destinationDB dest = lstDestination.Where(w => w.codeDest == Convert.ToInt16(row.Cells[5].Text.Trim())).FirstOrDefault();

            if (dest != null)
            {
                ddlDest.SelectedItem.Text = dest.libelleDest;
            }

            TxtCommentaire.Text = row.Cells[4].Text.Trim();

            notificationDB notif = a.GetNotification().Where(w => w.codeService == serv.code_service).FirstOrDefault();

            if (notif != null)
            {
                if (notif.etatNotif == "N")
                {
                    notif.etatNotif = "L";
                    a.maj_notification(notif);
                    row.ForeColor = System.Drawing.Color.Black;

                    Label x = (Label)Master.FindControl("lblNotifReclamation") as Label;

                    List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etatNotif.Trim() == "N") && (w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"]))).ToList();

                    x.Text = lsNotification.Where(w => w.libelleService.Trim() == "Reclamation").Count().ToString();

                    Label nbNotification = (Label)Master.FindControl("nbNotification") as Label;
                    nbNotification.Text = (Convert.ToInt16(nbNotification.Text) - 1).ToString();
                }
            }
            BindGrid();
        }
Esempio n. 15
0
        public void modifierUtilisateur(UtilisateurDB Utilisateur)
        {
            using (DataAccesDataContext dbContext = new DataAccesDataContext())
            {
                Utilisateur newUtilisateur = new Utilisateur();
                newUtilisateur = dbContext.Utilisateur.FirstOrDefault(w => w.code_utilisateur == Utilisateur.code_utilisateur);

                newUtilisateur.code_utilisateur = Utilisateur.code_utilisateur;
                newUtilisateur.code_profil      = Utilisateur.code_profil;
                newUtilisateur.Mdp             = Utilisateur.Mdp;
                newUtilisateur.Nom_utilisateur = Utilisateur.Nom_utilisateur;
                newUtilisateur.Etat            = Utilisateur.Etat.ToString();
                newUtilisateur.login           = Utilisateur.login;
                newUtilisateur.Image           = Utilisateur.Image;

                dbContext.SubmitChanges();
            }
        }
Esempio n. 16
0
        private void getBranche()
        {
            AstreeDonnees a    = new AstreeDonnees();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));

            List <statistiquesDB> lsStat = a.GetStatistiques().Where(w => w.Agence == user.code_partenaire.ToString()).ToList();
            var           lst2           = lsStat.Select(w => w.Branche);
            List <string> lstBranche     = lst2.Distinct().ToList();

            List <ListItem> itemsBranche = new List <ListItem>();

            itemsBranche.Add(new ListItem("--Choisir--", "--Choisir--"));
            foreach (string x in lstBranche)
            {
                itemsBranche.Add(new ListItem(x, x));
            }

            ddlBranche.Items.AddRange(itemsBranche.ToArray());
        }
Esempio n. 17
0
        private void getAnnee()
        {
            AstreeDonnees a    = new AstreeDonnees();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));

            List <statistiquesDB> lsStat = a.GetStatistiques().Where(w => w.Agence == user.code_partenaire.ToString()).ToList();
            var            lst           = lsStat.Select(w => w.Annee);
            List <double?> lstAnnee      = lst.Distinct().ToList();

            List <ListItem> itemsAnnee = new List <ListItem>();

            itemsAnnee.Add(new ListItem("--Choisir", "--Choisir"));
            foreach (int x in lstAnnee)
            {
                itemsAnnee.Add(new ListItem(x.ToString(), x.ToString()));
            }

            ddlAnnee.Items.AddRange(itemsAnnee.ToArray());
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["code_utilisateur"] == null)
            {
                Response.Redirect("login.aspx");
            }
            if (!this.IsPostBack)
            {
                this.BindGrid();
                AstreeDonnees a    = new AstreeDonnees();
                UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                profilDB      P    = a.Getprofil(Convert.ToInt32(user.code_profil));

                // if (Session["code_profil"].Equals("505"))
                if (user.code_profil == 505)
                {
                    Btnreponse.Visible = true;
                }
            }
        }
Esempio n. 19
0
        protected void ddlBranche_SelectedIndexChanged(object sender, EventArgs e)
        {
            ddlSousBranche.Items.Clear();
            AstreeDonnees a    = new AstreeDonnees();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));

            List <statistiquesDB> lsStat     = a.GetStatistiques().Where(w => w.Agence == user.code_partenaire.ToString()).ToList();
            var             lst              = lsStat.Where(w => w.Branche == ddlBranche.SelectedValue).Select(w => w.SousBranche);
            List <string>   lstSousBranche   = lst.Distinct().ToList();
            List <ListItem> itemsSousBranche = new List <ListItem>();

            itemsSousBranche.Add(new ListItem("--Choisir--", "--Choisir--"));
            foreach (string x in lstSousBranche)
            {
                itemsSousBranche.Add(new ListItem(x, x));
            }

            ddlSousBranche.Items.AddRange(itemsSousBranche.ToArray());

            getCharte();
        }
        private void BindGrid()
        {
            //afficher just les devis !!

            AstreeDonnees a    = new AstreeDonnees();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));

            List <serviceDB> ls = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Devis") && (w.codeUtilisateur == user.code_utilisateur)).OrderBy(w => w.etat).OrderByDescending(w => w.code_service).ToList();

            foreach (serviceDB x in ls)
            {
                if (x.libelleBranche.Trim() == "Choisir")
                {
                    x.libelleBranche = "";
                }
                if (x.libelleSousbranche.Trim() == "Choisir")
                {
                    x.libelleSousbranche = "";
                }
            }
            Session["lstDevis"] = ls;
            gv_Devis.DataSource = ls;
            gv_Devis.DataBind();
        }
        private void BindGrid()
        {
            AstreeDonnees a = new AstreeDonnees();


            UtilisateurDB    user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
            List <serviceDB> ls   = new List <serviceDB>();

            //Gestionnaire
            if (user.code_profil != 101 && user.code_profil != 202)
            {
                ls = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Devis")).OrderBy(w => w.etat).ToList();
            }
            //Agent et courtier
            else
            {
                ls = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Devis") && (w.codeUtilisateur == user.code_utilisateur)).OrderByDescending(w => w.etatNotif).ToList();
            }

            List <serviceDB>      lsServ   = new List <serviceDB>();
            List <notificationDB> lstNotif = a.GetNotification();

            Session["lstDevis"] = ls;
            gv_Devis.DataSource = ls;
            gv_Devis.DataBind();


            foreach (GridViewRow row in gv_Devis.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox cb = (row.Cells[0].FindControl("Accepter") as CheckBox);

                    serviceDB serv = ls.Where(w => w.code_service == Convert.ToInt16(row.Cells[1].Text.ToString().Trim())).FirstOrDefault();
                    if (serv != null)
                    {
                        if (serv.etat.ToString().Trim() == "A")
                        {
                            //Gestionnaire
                            if (user.code_profil != 101 && user.code_profil != 202)
                            {
                                row.ForeColor = System.Drawing.Color.Red;
                            }
                            //Agent ou Courtier
                            else
                            {
                                row.ForeColor = System.Drawing.Color.Black;
                            }
                        }
                        if (serv.etat.ToString().Trim() == "V")
                        {
                            cb.Checked = true;

                            //Gestionnaire
                            if (user.code_profil != 101 && user.code_profil != 202)
                            {
                                row.ForeColor = System.Drawing.Color.Black;
                            }
                            //Agent ou Courtier
                            else
                            {
                                if (serv.etatNotif.ToString().Trim() == "N")
                                {
                                    row.ForeColor = System.Drawing.Color.Green;
                                }

                                if (serv.etatNotif.ToString().Trim() == "L")
                                {
                                    row.ForeColor = System.Drawing.Color.Black;
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 22
0
        protected void btnajout(object sender, EventArgs e)
        {
            MsgProfil.Text     = "";
            MsgNom.Text        = "";
            MsgLogin.Text      = "";
            MsgPsw.Text        = "";
            lblMessage.Visible = false;
            lblMessage.Visible = false;
            Msgemail.Text      = "";
            bool ajouter = false;

            if (String.IsNullOrEmpty(txtnom.Text))
            {
                //lblMessage1.Visible = true;
                //lblMessage1.Text = "veuillez remplir votre nom";
                MsgNom.Text = "veuillez remplir le nom";
            }

            else if (String.IsNullOrEmpty(txtlogin.Text))
            {
                //lblMessage1.Visible = true;
                //lblMessage1.Text = "veuillez remplir votre login";
                MsgLogin.Text = "veuillez remplir le  login!";
            }
            else if (String.IsNullOrEmpty(txtpassword.Text))
            {
                //lblMessage1.Visible = true;
                //lblMessage1.Text = "veuillez remplir votre Password";
                MsgPsw.Text = "veuillez remplir le Password!";
            }
            else if (Convert.ToInt16(ddlprofil1.SelectedValue) == 0)
            {
                MsgProfil.Text = "Vous devez selectionner le profil!";
            }
            else if (String.IsNullOrEmpty(txtemail.Text))
            {
                Msgemail.Text = "Vous devez saisir l'email";
            }
            else
            {
                lblMessage1.Visible = false;
                AstreeDonnees a = new AstreeDonnees();


                List <UtilisateurDB> lstUser = a.GetUser();

                if (lstUser.Where(w => w.login == txtlogin.Text).Count() > 0)
                {
                    MsgLogin.Text = "Login existant";
                }
                else
                {
                    // lblMessage1.Visible = false;
                    ajouter = true;
                }
            }



            if (ajouter == true)
            {
                AstreeDonnees ad  = new AstreeDonnees();
                UtilisateurDB usr = new UtilisateurDB();
                adresseDB     adr = new adresseDB();


                if (MsgNom.Text == "" && MsgLogin.Text == "" && MsgProfil.Text == "")
                {
                    try
                    {
                        usr.Etat        = "A";
                        usr.code_profil = Convert.ToInt16(ddlprofil1.SelectedValue.ToString());
                        //  usr.code_partenaire = Convert.ToInt16(ddlpartenaire.SelectedValue.ToString());
                        usr.Nom_utilisateur = txtnom.Text;
                        usr.login           = txtlogin.Text;
                        usr.Mdp             = txtpassword.Text;


                        int nb  = ad.GetAdresse().Where(w => w.email.Trim() == txtemail.Text.Trim()).Count();
                        int nb1 = ad.GetPartenair().Where(w => w.code_adresse == 0 && w.code_partenaire == usr.code_partenaire).Count();
                        if (nb == 0 && nb1 != 0)
                        {
                            adr.email = txtemail.Text;
                            ad.InsertAdresse(adr);
                            adresseDB adr1 = ad.GetAdresse().Where(w => w.email.Trim() == txtemail.Text.Trim()).LastOrDefault();

                            partenaireDB part = ad.GetPartenair().Where(w => w.code_partenaire == usr.code_partenaire).FirstOrDefault();

                            part.code_adresse = adr1.code_adresse;
                            ad.modifierPartenaire(part);
                        }
                        else if (nb1 == 0)
                        {
                            txtemail.Enabled = true;
                            Msgemail.Text    = "le partenaire :" + ddlpartenaire.Text + " a déja un email";
                        }
                        else
                        {
                            txtemail.Enabled = true;
                            Msgemail.Text    = "l'email déja existe";
                        }

                        ad.InsertUser(usr);
                        partenaireDB part1  = ad.GetPartenair().Where(w => w.code_partenaire == Convert.ToInt16(ddlprofil1.SelectedValue.ToString())).FirstOrDefault();
                        adresseDB    adr2   = ad.GetAdresse().Where(w => w.code_adresse == part1.code_adresse).FirstOrDefault();
                        string       chaine = "le  Login est =" + txtlogin.Text + " et le mot de passe est = " + txtpassword.Text + "pour l'utilisateur =" + txtnom.Text;
                        lblMessage1.Visible = true;
                        lblMessage1.Text    = "L'utilisateur à été ajouter avec succés";
                        txtemail.Text       = "";
                        txtlogin.Text       = "";
                        txtnom.Text         = "";
                        txtpassword.Text    = "";
                        try
                        {
                            MailMessage       o       = new MailMessage("*****@*****.**", adr2.email, "Login et Mot de passe", chaine);
                            NetworkCredential netCred = new NetworkCredential("*****@*****.**", "");
                            SmtpClient        smtpobj = new SmtpClient("smtp.gmail.com", 25);
                            smtpobj.EnableSsl   = true;
                            smtpobj.Credentials = netCred;
                            smtpobj.Send(o);
                        }
                        catch
                        {
                            lblMessage.Visible = true;
                            lblMessage.Text    = "l'envoi de l'email n'a étét transmis ! verifiez l'adresse email!!";
                        }
                    }
                    catch (Exception ex)
                    {
                        lblMessage.Visible = true;
                        lblMessage.Text    = "L'ajout n'a pas été éffectuer !";
                    }
                }
            }
            DataBind();
            this.BindGrid();
        }
        protected void gv_Devis_SelectedIndexChanged1(object sender, EventArgs e)
        {
            AstreeDonnees a = new AstreeDonnees();

            Txtetat.Text = "";
            GridViewRow row = gv_Devis.SelectedRow;

            txtID.Text          = row.Cells[1].Text;
            txtproduit.Text     = row.Cells[2].Text;
            txtsousproduit.Text = row.Cells[3].Text;
            //    txtdatedemande.Text = row.Cells[4].Text;


            if (row.Cells[5].Text == "&nbsp;")
            {
                TxtPHT.Text = "0";
            }
            else
            {
                TxtPHT.Text = row.Cells[5].Text;
            }
            if (row.Cells[6].Text == "&nbsp;")
            {
                txtTaxe.Text = "0";
            }
            else
            {
                txtTaxe.Text = row.Cells[6].Text;
            }
            if (row.Cells[7].Text == "&nbsp;")
            {
                txtCP.Text = "0";
            }
            else
            {
                txtCP.Text = row.Cells[7].Text;
            }
            if (row.Cells[8].Text == "&nbsp;")
            {
                txtPT.Text = "0";
            }
            else
            {
                txtPT.Text = row.Cells[8].Text;
            }
            MessageLabel.Text = "You selected Devis numéro " + row.Cells[1].Text + ".";
            serviceDB ser = a.GetServices().Where(w => w.code_service == Convert.ToInt16(row.Cells[1].Text)).FirstOrDefault();
            CheckBox  cb  = (CheckBox)row.FindControl("Accepter");

            if (cb != null && cb.Checked)
            {
                Txtetat.Text = "VALIDEE";
                if (ser.etat.Trim() == "V")
                {
                    Btnreponse.Visible = false;
                }

                cb.Enabled = false;
                notificationDB notif = a.GetNotification().Where(w => w.codeService == Convert.ToInt16(txtID.Text)).FirstOrDefault();
                if (notif != null)
                {
                    if (notif.etatNotif == "N")
                    {
                        UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                        if (user.code_profil == 101 || user.code_profil == 202)
                        {
                            notif.etatNotif = "L";
                            a.maj_notification(notif);
                            row.ForeColor = System.Drawing.Color.Black;


                            Label x = (Label)Master.FindControl("lblDevis") as Label;

                            List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etatNotif.Trim() == "N") && (w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"]))).ToList();

                            x.Text = lsNotification.Where(w => w.libelleService.Trim() == "Devis").Count().ToString();

                            Label nbNotification = (Label)Master.FindControl("nbNotification") as Label;
                            nbNotification.Text = lsNotification.Count().ToString();
                        }
                    }
                }
            }
            else
            {
                UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));

                // if (Session["code_profil"].Equals("505"))
                if (user.code_profil == 505)
                {
                    Btnreponse.Visible = true;
                }
                cb.Enabled = true;

                //gestionnaire
                if (user.code_profil != 101 && user.code_profil != 202)
                {
                    serviceDB serv = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Devis") && (w.code_service == Convert.ToInt16(txtID.Text))).FirstOrDefault();


                    if (serv != null)
                    {
                        if (serv.etat.Trim() == "A")
                        {
                            //e.Row.BackColor = System.Drawing.Color.Red;
                            //row.ForeColor = System.Drawing.Color.Black;
                            // serv.etat = "L";
                            //  a.maj_devis(serv);
                            BindGrid();
                            // Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
                        }
                    }
                }
            }
        }
        protected void gvSouscription_SelectedIndexChanged(object sender, EventArgs e)
        {
            pnlDerogation.Visible = true;
            AstreeDonnees a = new AstreeDonnees();

            Txtetat.Text = "";

            GridViewRow row = gvSouscription.SelectedRow;

            txtId.Text          = row.Cells[1].Text;
            txttype.Text        = row.Cells[2].Text;
            txtproduit.Text     = row.Cells[3].Text;
            txtsousproduit.Text = row.Cells[4].Text;
            //  txtdatedemande.Text = row.Cells[5].Text;
            //txtnumcontrat.Text = row.Cells[6].Text;
            serviceDB serv = a.GetServices().Where(w => w.code_service == Convert.ToInt16(row.Cells[1].Text)).FirstOrDefault();

            CheckBox cb = (CheckBox)row.FindControl("AccepterSouscription");

            if (cb != null && cb.Checked)
            {
                Txtetat.Text = "VALIDEE";
                if (serv.etat.Trim() == "V")
                {
                    Btnreponse.Visible = false;
                }
                cb.Enabled = false;
                notificationDB notif = a.GetNotification().Where(w => w.codeService == Convert.ToInt16(txtId.Text)).FirstOrDefault();
                if (notif != null)
                {
                    if (notif.etatNotif == "N")
                    {
                        UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                        if (user.code_profil == 101 || user.code_profil == 202)
                        {
                            notif.etatNotif = "L";
                            a.maj_notification(notif);
                            row.ForeColor = System.Drawing.Color.Black;
                            // Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
                            Label x = (Label)Master.FindControl("lblNotifSouscription") as Label;

                            List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etatNotif.Trim() == "N") && (w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"]))).ToList();

                            x.Text = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 3).Count().ToString();

                            Label nbNotification = (Label)Master.FindControl("nbNotification") as Label;
                            nbNotification.Text = lsNotification.Count().ToString();
                        }
                    }
                }
            }
            else
            {
                UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                profilDB      P    = a.Getprofil(Convert.ToInt32(user.code_profil));

                // if (Session["code_profil"].Equals("505"))
                if (user.code_profil == 606)
                {
                    Btnreponse.Visible = true;
                }
                cb.Enabled = true;
            }
        }
        protected void gvSouscription_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvSouscription.PageIndex  = e.NewPageIndex;
            gvSouscription.DataSource = Session["lstsouscrip"];
            gvSouscription.DataBind();
            gvSouscription.SelectedIndex = -1;

            AstreeDonnees    a    = new AstreeDonnees();
            List <serviceDB> lsss = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Derogation") && (w.libelleType.Trim() == "Souscription")).ToList();

            foreach (GridViewRow row in gvSouscription.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    CheckBox cb = (row.Cells[0].FindControl("AccepterSouscription") as CheckBox);

                    serviceDB     serv = lsss.Where(w => w.code_service == Convert.ToInt16(row.Cells[1].Text.ToString().Trim())).FirstOrDefault();
                    UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));

                    if (serv != null)
                    {
                        if (serv.etat.ToString().Trim() == "A")
                        {
                            //Gestionnaire
                            if (user.code_profil != 101 && user.code_profil != 202)
                            {
                                row.ForeColor = System.Drawing.Color.Red;
                            }
                            //Agent ou Courtier
                            else
                            {
                                row.ForeColor = System.Drawing.Color.Black;
                            }
                        }
                        if (serv.etat.ToString().Trim() == "V")
                        {
                            cb.Checked = true;

                            //Gestionnaire
                            if (user.code_profil != 101 && user.code_profil != 202)
                            {
                                row.ForeColor = System.Drawing.Color.Black;
                            }
                            //Agent ou Courtier
                            else
                            {
                                if (serv.etatNotif.ToString().Trim() == "N")
                                {
                                    row.ForeColor = System.Drawing.Color.Green;
                                }

                                if (serv.etatNotif.ToString().Trim() == "L")
                                {
                                    row.ForeColor = System.Drawing.Color.Black;
                                }
                            }
                        }
                    }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["code_utilisateur"] == null)
            {
                Response.Redirect("login.aspx");
            }



            //ddltype.SelectedIndex = -1;
            if (!this.IsPostBack)
            {
                pnlDerogation.Visible = false;
                AstreeDonnees a = new AstreeDonnees();
                ddltype.DataSource = a.GetTypeService().Where(w => w.famille_type.Trim() == "Derogation").ToList();
                ddltype.DataBind();
                if (Session["remise"] == null)
                {
                }
                else
                {
                    if (Session["remise"].ToString() == "0")
                    {
                        ddltype.SelectedIndex  = 0;
                        pnlTaux.Visible        = true;
                        pnlDuree.Visible       = false;
                        gvRemise.Visible       = true;
                        gvSouscription.Visible = false;
                        gvProrogation.Visible  = false;
                    }
                }

                if (Session["prorogation"] == null)
                {
                }
                else
                {
                    if (Session["prorogation"].ToString() == "1")
                    {
                        ddltype.SelectedIndex  = 1;
                        pnlTaux.Visible        = false;
                        pnlDuree.Visible       = true;
                        gvRemise.Visible       = false;
                        gvSouscription.Visible = false;
                        gvProrogation.Visible  = true;
                    }
                }
                if (Session["souscription"] == null)
                {
                }
                else
                {
                    if (Session["souscription"].ToString() == "2")
                    {
                        ddltype.SelectedIndex  = 2;
                        pnlTaux.Visible        = false;
                        pnlDuree.Visible       = false;
                        gvRemise.Visible       = false;
                        gvSouscription.Visible = true;
                        gvProrogation.Visible  = false;
                    }
                }



                UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                profilDB      P    = a.Getprofil(Convert.ToInt32(user.code_profil));

                // if (Session["code_profil"].Equals("505"))
                if (user.code_profil == 606)
                {
                    Btnreponse.Visible = true;
                }
                this.BindGrid();


                if (ddltype.SelectedIndex == 0)
                {
                    pnlTaux.Visible        = true;
                    pnlDuree.Visible       = false;
                    gvRemise.Visible       = true;
                    gvSouscription.Visible = false;
                    gvProrogation.Visible  = false;
                }

                if (ddltype.SelectedIndex == 1)
                {
                    pnlTaux.Visible        = false;
                    pnlDuree.Visible       = true;
                    gvRemise.Visible       = false;
                    gvSouscription.Visible = false;
                    gvProrogation.Visible  = true;
                }

                if (ddltype.SelectedIndex == 2)
                {
                    pnlTaux.Visible        = false;
                    pnlDuree.Visible       = false;
                    gvRemise.Visible       = false;
                    gvSouscription.Visible = true;
                    gvProrogation.Visible  = false;
                }
            }
        }
        protected void gv_Devis_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            AstreeDonnees a    = new AstreeDonnees();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));


            if (user.code_profil == 101 || user.code_profil == 102)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    try
                    {
                        //AstreeDonnees a = new AstreeDonnees();

                        GridViewRow row  = e.Row;
                        serviceDB   serv = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Devis") && (w.code_service == Convert.ToInt32(row.Cells[1].Text))).FirstOrDefault();


                        if (serv != null)
                        {
                            if (serv.etatNotif == "N")
                            {
                                //e.Row.BackColor = System.Drawing.Color.Red;
                                e.Row.ForeColor = System.Drawing.Color.Red;
                            }
                        }
                    }
                    catch (Exception ex)
                    { }
                }
            }
            else
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    try
                    {
                        //AstreeDonnees a = new AstreeDonnees();

                        GridViewRow row  = e.Row;
                        serviceDB   serv = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Devis") && (w.code_service == Convert.ToInt32(row.Cells[1].Text))).FirstOrDefault();


                        if (serv != null)
                        {
                            if (serv.etat.Trim() == "A")
                            {
                                //e.Row.BackColor = System.Drawing.Color.Red;
                                e.Row.ForeColor = System.Drawing.Color.Red;
                            }
                            else
                            {
                                e.Row.ForeColor = System.Drawing.Color.Black;
                            }
                        }
                    }
                    catch (Exception ex)
                    { }
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {   //li
            //li
            AstreeDonnees    a = new AstreeDonnees();
            List <serviceDB> lsNotification1 = a.GetServices().Where(w => (w.libelleService != null) && (w.etatNotif.Trim() == "N") && (w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"]))).ToList();

            liCommandeInter.Visible       = false;
            liCommande.Visible            = false;
            liCommandeFournisseur.Visible = false;
            accueil.Visible                 = false;
            Commande.Visible                = false;
            EnvoiCommande.Visible           = false;
            liCommandeRepondreInter.Visible = false;
            liCommandeFour.Visible          = false;
            liCommandeRepondreFour.Visible  = false;
            liCommandeConsultInter.Visible  = false;
            liHistorique.Visible            = false;
            liCommandeConsultFour.Visible   = false;
            liDerogation.Visible            = false;
            liEnvoiDero.Visible             = false;
            liafficherDeroInter.Visible     = false;
            liConsulterDero.Visible         = false;
            liafficherDeroGest.Visible      = false;
            Devis.Visible                = false;
            liDemanderDevis.Visible      = false;
            liafficherDevisInter.Visible = false;
            liTraiterDevis.Visible       = false;
            liaffixherDevisGest.Visible  = false;

            liReclamation.Visible           = false;
            liEnvoyerReclamation.Visible    = false;
            liaffiherReclamation.Visible    = false;
            liConsulterStatistiques.Visible = false;
            liGestUser.Visible       = false;
            liGestProfil.Visible     = false;
            liGestPermission.Visible = false;
            //Notification
            liDevis.Visible = false;
            //liRepIndermidiaire.Visible = false;
            liRemise.Visible              = false;
            liProrogatin.Visible          = false;
            liSouscripton.Visible         = false;
            liCommande.Visible            = false;
            liCompteDesactive.Visible     = false;
            liCommandeInter.Visible       = false;
            liCommandeFournisseur.Visible = false;
            liCommandeInterFourn.Visible  = false;
            liAfficheReclamation.Visible  = false;

            // yjini erreur !
            if (Session["code_utilisateur"] == null)
            {
                Response.Redirect("login.aspx");
            }
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
            profilDB      P    = a.Getprofil(Convert.ToInt32(user.code_profil));

            TxtUserProfil.Text = user.Nom_utilisateur;
            TxtTitre.Text      = P.libelle;
            // if (Session["code_profil"].Equals("101"))
            //Agent
            if (user.code_profil == 101)
            {
                //Li
                liConsulterStatistiques.Visible = true;
                Commande.Visible               = true;
                EnvoiCommande.Visible          = true;
                liCommandeConsultInter.Visible = false;
                liDerogation.Visible           = true;
                liEnvoiDero.Visible            = true;
                liafficherDeroInter.Visible    = false;

                liReclamation.Visible        = true;
                liEnvoyerReclamation.Visible = true;
                liDevis.Visible       = false;
                liRemise.Visible      = true;
                liProrogatin.Visible  = true;
                liSouscripton.Visible = true;

                liConsulterStatistiques.Visible = true;

                liAfficheReclamation.Visible = true;
                liCommandeInter.Visible      = true;
                // List<notificationDB> lsNotification = a.GetNotification().Where(w => w.etatNotif == "N" && w.codeUtilisateur== Convert.ToInt16(Session["code_utilisateur"])).ToList();
                List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etatNotif.Trim() == "N") && (w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"]))).ToList();

                //int nb = lsNotification.Count();
                //if (nb>0) { nbNotification.Visible = true; }
                lblNotifRemise.Text       = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 1).Count().ToString();
                lblNotifProrogation.Text  = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 2).Count().ToString();
                lblNotifSouscription.Text = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 3).Count().ToString();

                lblDevis.Text = lsNotification.Where(w => w.libelleService.Trim() == "Devis").Count().ToString();
                lblNotifCommandeInter.Text = lsNotification.Where(w => w.libelleService.Trim() == "Commande" && w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"])).Count().ToString();

                List <serviceDB> lstNotifReclamation = a.GetServices().Where(w => w.libelleService.Trim() == "Reclamation" && w.etatNotif.Trim() == "N" && w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"])).ToList();
                lblNotifReclamation.Text = lstNotifReclamation.Count().ToString();


                nbNotification.Text = (Convert.ToInt16(lblDevis.Text) + Convert.ToInt16(lblNotifRemise.Text) + Convert.ToInt16(lblNotifProrogation.Text) + Convert.ToInt16(lblNotifReclamation.Text) + Convert.ToInt16(lblNotifCommandeInter.Text) + Convert.ToInt16(lblNotifSouscription.Text)).ToString();
            }
            //Courtier
            else if (user.code_profil == 202)
            {
                //LI

                Commande.Visible               = true;
                EnvoiCommande.Visible          = true;
                liCommandeConsultInter.Visible = false;
                liDerogation.Visible           = true;
                liEnvoiDero.Visible            = true;
                liafficherDeroInter.Visible    = false;
                Devis.Visible                = true;
                liDemanderDevis.Visible      = true;
                liafficherDevisInter.Visible = false;
                liReclamation.Visible        = true;
                liEnvoyerReclamation.Visible = true;
                // notification
                liCommandeInter.Visible = true;
                liDevis.Visible         = true;
                liRemise.Visible        = true;
                liProrogatin.Visible    = true;
                liSouscripton.Visible   = true;

                liConsulterStatistiques.Visible = false;

                liAfficheReclamation.Visible = true;
                nbNotification.Visible       = true;
                // List<notificationDB> lsNotification = a.GetNotification().Where(w => w.etatNotif == "N" && w.codeUtilisateur== Convert.ToInt16(Session["code_utilisateur"])).ToList();
                List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etatNotif.Trim() == "N") && (w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"]))).ToList();
                //nbNotification.Text = lsNotification.Count().ToString();
                int nb = lsNotification.Count();
                if (nb <= 0)
                {
                    nbNotification.Visible = false;
                }

                lblNotifRemise.Text       = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 1).Count().ToString();
                lblNotifProrogation.Text  = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 2).Count().ToString();
                lblNotifSouscription.Text = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 3).Count().ToString();

                lblDevis.Text = lsNotification.Where(w => w.libelleService.Trim() == "Devis").Count().ToString();
                lblNotifCommandeInter.Text = lsNotification.Where(w => w.libelleService.Trim() == "Commande").Count().ToString();

                List <serviceDB> lstNotifReclamation = a.GetServices().Where(w => w.libelleService.Trim() == "Reclamation" && w.etatNotif.Trim() == "N" && w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"])).ToList();
                lblNotifReclamation.Text = lstNotifReclamation.Count().ToString();

                nbNotification.Text = (Convert.ToInt16(lblDevis.Text) + Convert.ToInt16(lblNotifRemise.Text) + Convert.ToInt16(lblNotifProrogation.Text) + Convert.ToInt16(lblNotifReclamation.Text) + Convert.ToInt16(lblNotifCommandeInter.Text) + Convert.ToInt16(lblNotifSouscription.Text)).ToString();
            }
            //Fournisseur
            else if (user.code_profil == 303)
            {
                Commande.Visible = true;
                liCommandeRepondreFour.Visible = true;
                liCommandeConsultFour.Visible  = false;
                //notification
                liCommandeFournisseur.Visible = true;

                liCommandeFournisseur.Visible = true;

                List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.codeDest == Convert.ToInt16(Session["code_utilisateur"]))).ToList();

                lsNotification = lsNotification.Where(w => w.etat.Trim() == "A").ToList();


                lblNotifCommandeFourn.Text = lsNotification.Where(w => w.libelleService.Trim() == "Commande").Count().ToString();
                nbNotification.Text        = lsNotification.Count().ToString();
            }
            //Gestionnaire Commande
            else if (user.code_profil == 404)
            {
                //Li
                Commande.Visible                = true;
                liHistorique.Visible            = true;
                liCommandeFour.Visible          = true;
                liCommandeRepondreInter.Visible = true;
                liReclamation.Visible           = true;
                liaffiherReclamation.Visible    = true;
                //notification
                liCommandeInterFourn.Visible = true;
                liCommandeInter.Visible      = false;

                liCommande.Visible = true;



                liAfficheReclamation.Visible = true;

                // List<notificationDB> lsNotification = a.GetNotification().Where(w => w.etatNotif == "N" && w.codeUtilisateur== Convert.ToInt16(Session["code_utilisateur"])).ToList();
                List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etat.Trim() == "A") && w.codeDest == 404).ToList();
                lblNotifCommande.Text = lsNotification.Where(w => w.libelleService.Trim() == "Commande" && w.etat.Trim() == "A" && w.codeDest == 404).Count().ToString();

                List <serviceDB> lsNotificationFourn = a.GetServices().Where(w => (w.libelleService != null) && (w.etat.Trim() == "V") && w.etatNotif.Trim() != "L" && w.codeDest != 404 && w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"])).ToList();
                lblNotifCommandeInterFourn.Text = lsNotificationFourn.Count().ToString();
                //lblNotifCommandeInterFourn.Text = lsNotificationFourn.Where(w => w.libelleService.Trim() == "Commande").Count().ToString();


                List <destinationDB> lstDestination    = a.GetDestination();
                List <serviceDB>     lstReclamation    = a.GetServices().Where(w => w.libelleService.Trim() == "Reclamation" && w.etat.Trim() == "A").ToList();
                List <serviceDB>     lstReclamationFin = new List <serviceDB>();
                foreach (serviceDB recl in lstReclamation)
                {
                    if (lstDestination.Where(w => w.codeDest == recl.codeDest && w.codeProfil == user.code_profil).Count() > 0)
                    {
                        lstReclamationFin.Add(recl);
                    }
                }

                lstReclamation = lstReclamationFin;

                lblNotifReclamation.Text = lstReclamation.Count().ToString();


                nbNotification.Text = (Convert.ToInt16(lblNotifCommandeInterFourn.Text) + Convert.ToInt16(lblNotifCommande.Text) + Convert.ToInt16(lblNotifReclamation.Text)).ToString();
            }
            //Gestionnaire Devis
            else if (user.code_profil == 505)
            {
                //LI
                Devis.Visible                = true;
                liTraiterDevis.Visible       = true;
                liaffixherDevisGest.Visible  = true;
                liReclamation.Visible        = true;
                liaffiherReclamation.Visible = true;
                //notification



                liDevis.Visible = true;

                liAfficheReclamation.Visible = true;
                List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etat.Trim() == "A")).ToList();
                lblDevis.Text = lsNotification.Where(w => w.libelleService.Trim() == "Devis").Count().ToString();



                List <destinationDB> lstDestination    = a.GetDestination();
                List <serviceDB>     lstReclamation    = a.GetServices().Where(w => w.libelleService.Trim() == "Reclamation" && w.etat.Trim() == "A").ToList();
                List <serviceDB>     lstReclamationFin = new List <serviceDB>();
                foreach (serviceDB recl in lstReclamation)
                {
                    if (lstDestination.Where(w => w.codeDest == recl.codeDest && w.codeProfil == user.code_profil).Count() > 0)
                    {
                        lstReclamationFin.Add(recl);
                    }
                }

                lstReclamation = lstReclamationFin;

                lblNotifReclamation.Text = lstReclamation.Count().ToString();


                nbNotification.Text = (Convert.ToInt16(lblDevis.Text) + Convert.ToInt16(lblNotifReclamation.Text)).ToString();
            }
            //Gestionnaire Dérogations
            else if (user.code_profil == 606)
            {
                //LI
                liDerogation.Visible         = true;
                liConsulterDero.Visible      = true;
                liafficherDeroGest.Visible   = false;
                liReclamation.Visible        = true;
                liaffiherReclamation.Visible = true;
                //notification
                liRemise.Visible      = true;
                liProrogatin.Visible  = true;
                liSouscripton.Visible = true;
                //  IntermidiaireProfil.Visible = true;


                liRemise.Visible      = true;
                liProrogatin.Visible  = true;
                liSouscripton.Visible = true;

                liAfficheReclamation.Visible = true;
                List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etat.Trim() == "A")).ToList();

                lblNotifRemise.Text       = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 1).Count().ToString();
                lblNotifProrogation.Text  = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 2).Count().ToString();
                lblNotifSouscription.Text = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 3).Count().ToString();



                List <destinationDB> lstDestination    = a.GetDestination();
                List <serviceDB>     lstReclamation    = a.GetServices().Where(w => w.libelleService.Trim() == "Reclamation" && w.etat.Trim() == "A").ToList();
                List <serviceDB>     lstReclamationFin = new List <serviceDB>();
                foreach (serviceDB recl in lstReclamation)
                {
                    if (lstDestination.Where(w => w.codeDest == recl.codeDest && w.codeProfil == user.code_profil).Count() > 0)
                    {
                        lstReclamationFin.Add(recl);
                    }
                }

                lstReclamation = lstReclamationFin;

                lblNotifReclamation.Text = lstReclamation.Count().ToString();


                nbNotification.Text = (Convert.ToInt16(lblNotifReclamation.Text) + Convert.ToInt16(lblNotifRemise.Text) + Convert.ToInt16(lblNotifProrogation.Text) + Convert.ToInt16(lblNotifSouscription.Text)).ToString();
            }



            //Admin
            else if (user.code_profil == 808)
            {
                //LI
                accueil.Visible          = true;
                liGestUser.Visible       = true;
                liGestProfil.Visible     = true;
                liGestPermission.Visible = true;
                //  IntermidiaireProfil.Visible = true;
                //notification
                liCompteDesactive.Visible = true;

                liGestUser.Visible   = true;
                liGestProfil.Visible = true;



                List <UtilisateurDB> lsNotification = a.GetUser().Where(w => w.Etat.Trim() == "N").ToList();
                nbNotification.Text = lsNotification.Count().ToString();

                lblNotifCompteDesactive.Text = lsNotification.Count().ToString();
            }
        }
Esempio n. 29
0
        protected void BtnEnvoyer_Click(object sender, EventArgs e)
        {

            try
            {
                MsgCodeF.Text = "";
                MsgObser.Text = "";
                MsgPrix.Text = "";
                MsgProduit.Text = "";
                MsgQte.Text = "";
                lblMsgSuccee.Text = "";


                AstreeDonnees a = new AstreeDonnees();
                UtilisateurDB User = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                serviceDB S = new serviceDB();

                S.libelleService = "Commande";
                S.etat = "A";
                if (Txtcode.Text == "")
                {

                    MsgCodeF.Visible = true;
                    MsgCodeF.Text = "Vous devez selectionner un fournisseur!";
                }
                else
                {
                    S.dateDemande = DateTime.Now;
                    S.codeDest = Convert.ToInt16(Txtcode.Text);
                    S.codeUtilisateur =Convert.ToInt16(Session["code_utilisateur"].ToString());
                    a.Insertservice(S);

                   

                  
                    List<serviceDB> lstService = a.GetServices();
                    serviceDB serv = lstService.Where(w => w.codeUtilisateur == User.code_utilisateur).LastOrDefault();

                    notificationDB notif = new notificationDB();
                    notif.codeService = serv.code_service;
                    notif.contenuNotification = serv.reponse;
                    notif.etatNotif = "N";// NON LU
                    notif.dateNotification = serv.dateReponse;
                    a.InsertNotification(notif);


                    DetailCommandeDB Detail = new DetailCommandeDB();
                    if (gv_listeCommande.Rows.Count > 0)
                    {


                        try
                        {
                            foreach (GridViewRow row in gv_listeCommande.Rows)
                            {

                                Detail.code_service = serv.code_service;
                                Detail.Id_produit = Convert.ToInt16(row.Cells[0].Text);

                                Detail.Qte = Convert.ToInt16(row.Cells[2].Text);
                                Detail.PU = Convert.ToInt16(row.Cells[3].Text);
                                if (TxtBesoin.Text == "" || TxtBesoin.Text == null)
                                {
                                    MsgObser.Visible = true;
                                    MsgObser.Text = "Vous devez saisir une observation!";
                                }
                                else
                                {
                                    Detail.Observation = TxtBesoin.Text;
                                    a.Inserer_Commande(Detail);
                                }
                            }
                            if (TxtBesoin.Text == "" || TxtBesoin.Text == null)
                            {
                                MsgObser.Visible = true;
                                MsgObser.Text = "Vous devez saisir une observation!";
                            }
                            else
                            {
                                lblMsgSuccee.Visible = true;
                                lblMsgSuccee.Text = "Commande envoyé avec succés!";
                                Txtcode.Text = "";
                                txtPrix.Text = "";
                                txtQte.Text = "";
                                TxtBesoin.Text = "";
                                // lblMsgSuccee.Text = "";
                            }
                            Session["lstCommande"] = null;

                        }
                        catch (Exception ex)
                        {
                            Response.Redirect("PageErreur.aspx");
                        }
                    }


                    else
                    {
                        MsgCodeF.Text = "";
                        txterror.Visible = true;
                        txterror.Text = "aucun article dans le panier!";
                    }
                }
            }


            catch (Exception ex)
            {
                Response.Redirect("PageErreur.aspx");

            }
        }
Esempio n. 30
0
        private void getCharte()
        {
            AstreeDonnees a    = new AstreeDonnees();
            UtilisateurDB user = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));


            List <statistiquesDB> lsStat = a.GetStatistiques().Where(w => w.Agence == user.code_partenaire.ToString()).ToList();

            string annee = "";

            if (ddlAnnee.SelectedIndex == 0)
            {
            }
            else
            {
                annee = ddlAnnee.SelectedValue;
                if (ddlBranche.SelectedIndex > 0)
                {
                    lsStat = a.GetStatistiques().Where(w => (w.Agence == user.code_partenaire.ToString()) && (w.Branche == ddlBranche.SelectedValue) && w.Annee == Convert.ToInt16(annee)).ToList();
                }
                else
                {
                    lsStat = a.GetStatistiques().Where(w => (w.Annee == Convert.ToInt16(annee) && (w.Agence == user.code_partenaire.ToString()))).ToList();
                }

                gv_statistiques.DataSource = lsStat;
                gv_statistiques.DataBind();
            }
            string branch = "";

            if (ddlBranche.SelectedIndex == 0)
            {
            }
            else
            {
                branch = ddlBranche.SelectedValue;
                if (ddlAnnee.SelectedIndex > 0)
                {
                    lsStat = a.GetStatistiques().Where(w => (w.Agence == user.code_partenaire.ToString()) && (w.Branche == branch.ToString()) && (w.Annee == Convert.ToInt16(annee))).ToList();
                }
                else
                {
                    lsStat = a.GetStatistiques().Where(w => (w.Agence == user.code_partenaire.ToString()) && (w.Branche == branch.ToString())).ToList();
                }

                string sousBranch = "";
                if (ddlSousBranche.SelectedIndex <= 0)
                {
                }
                else
                {
                    lsStat = a.GetStatistiques().Where(w => (w.Agence == user.code_partenaire.ToString()) && (w.Branche == branch.ToString()) && (w.SousBranche == ddlSousBranche.SelectedValue.ToString().Trim()) && (w.Annee == Convert.ToInt16(annee))).ToList();
                    gv_statistiques.DataSource = lsStat;
                    gv_statistiques.DataBind();
                }

                gv_statistiques.DataSource = lsStat;
                gv_statistiques.DataBind();
            }



            int i = 0;

            string[]  x = new string[lsStat.Count];
            decimal[] y = new decimal[lsStat.Count];
            decimal[] z = new decimal[lsStat.Count];
            decimal[] u = new decimal[lsStat.Count];
            decimal[] o = new decimal[lsStat.Count];
            string[]  b = new string[lsStat.Count];


            foreach (statistiquesDB t in lsStat)
            {
                if (t.Mois == 1)
                {
                    x[i] = "Janvier";
                }
                if (t.Mois == 2)
                {
                    x[i] = "Février";
                }
                if (t.Mois == 3)
                {
                    x[i] = "Mars";
                }
                if (t.Mois == 4)
                {
                    x[i] = "Avril";
                }
                if (t.Mois == 5)
                {
                    x[i] = "Mai";
                }
                if (t.Mois == 6)
                {
                    x[i] = "Juin";
                }
                if (t.Mois == 7)
                {
                    x[i] = "Juillet";
                }
                if (t.Mois == 8)
                {
                    x[i] = "Aout";
                }
                if (t.Mois == 9)
                {
                    x[i] = "Septembre";
                }
                if (t.Mois == 10)
                {
                    x[i] = "Octobre";
                }
                if (t.Mois == 11)
                {
                    x[i] = "Novembre";
                }
                if (t.Mois == 12)
                {
                    x[i] = "Décembre";
                }
                y[i] = Convert.ToDecimal(t.Sinistre);
                i    = i + 1;
                //if (ddlAnnee.SelectedValue.)
                //{

                //}
                chartSinistre.Series["serieSinistre"].Points.DataBindXY(x, y);
                //chartSinistre.Series["serieSinistre"].ChartType = SeriesChartType.Column;
                chartSinistre.Series["serieSinistre"].ChartTypeName = ddlChartType.SelectedValue;
                chartSinistre.ChartAreas["ChartAreaSinistre"].Area3DStyle.Enable3D    = cbUse3D.Checked;
                chartSinistre.ChartAreas["ChartAreaSinistre"].Area3DStyle.Inclination = Convert.ToInt32(rblInclinationAngle.SelectedValue);
                chartSinistre.Legends["Default"].Enabled = true;
            }

            ////Prime
            i = 0;
            foreach (statistiquesDB t in lsStat)
            {
                // x[i] = t.Mois;
                z[i] = Convert.ToDecimal(t.Prime);
                i    = i + 1;

                chartPrime.Series["seriePrime"].Points.DataBindXY(x, z);
                //chartPrime.Series["seriePrime"].ChartType = SeriesChartType.Column;
                chartPrime.Series["seriePrime"].ChartTypeName = ddlChartType.SelectedValue;
                chartPrime.ChartAreas["ChartAreaPrime"].Area3DStyle.Enable3D    = cbUse3D.Checked;
                chartPrime.ChartAreas["ChartAreaPrime"].Area3DStyle.Inclination = Convert.ToInt32(rblInclinationAngle.SelectedValue);
                chartPrime.Legends["Default"].Enabled = true;
            }
            ////Comission
            i = 0;
            foreach (statistiquesDB t in lsStat)
            {
                u[i] = Convert.ToDecimal(t.Comission);
                i    = i + 1;

                chartComission.Series["serieComission"].Points.DataBindXY(x, u);
                //chartPrime.Series["seriePrime"].ChartType = SeriesChartType.Column;
                chartComission.Series["serieComission"].ChartTypeName = ddlChartType.SelectedValue;
                chartComission.ChartAreas["ChartAreaComission"].Area3DStyle.Enable3D    = cbUse3D.Checked;
                chartComission.ChartAreas["ChartAreaComission"].Area3DStyle.Inclination = Convert.ToInt32(rblInclinationAngle.SelectedValue);
                chartComission.Legends["Default"].Enabled = true;
            }
            ////SP
            i = 0;
            foreach (statistiquesDB t in lsStat)
            {
                //x[i] = t.Mois;
                o[i] = Convert.ToDecimal(t.SP);
                i    = i + 1;

                chartSP.Series["serieSP"].Points.DataBindXY(x, o);
                //chartSP.Series["serieSP"].ChartType = SeriesChartType.Column;
                chartSP.Series["serieSP"].ChartTypeName = ddlChartType.SelectedValue;
                chartSP.ChartAreas["ChartAreaSP"].Area3DStyle.Enable3D    = cbUse3D.Checked;
                chartSP.ChartAreas["ChartAreaSP"].Area3DStyle.Inclination = Convert.ToInt32(rblInclinationAngle.SelectedValue);
                chartSP.Legends["Default"].Enabled = true;
            }

            // // // // // // // // // // // // // // // // // // // // //
            //        //Sinistre
            //        i = 0;
            //        foreach (statistiquesDB t in lsStat)
            //        {
            //            b[i] = t.Branche;
            //            y[i] = Convert.ToDecimal(t.Sinistre);
            //        i = i + 1;

            //        chartSinistre.Series["serieSinistre"].Points.DataBindXY(b, y);
            //        //chartSinistre.Series["serieSinistre"].ChartType = SeriesChartType.Column;
            //        chartSinistre.Series["serieSinistre"].ChartTypeName = ddlChartType.SelectedValue;
            //        chartSinistre.ChartAreas["ChartAreaSinistre"].Area3DStyle.Enable3D = cbUse3D.Checked;
            //        chartSinistre.ChartAreas["ChartAreaSinistre"].Area3DStyle.Inclination = Convert.ToInt32(rblInclinationAngle.SelectedValue);
            //        chartSinistre.Legends["Default"].Enabled = true;
            //    }

            //    ////Prime
            //    i = 0;
            //        foreach (statistiquesDB t in lsStat)
            //        {

            //            b[i] = t.Branche;
            //            z[i] = Convert.ToDecimal(t.Prime);
            //            i = i + 1;

            //            chartPrime.Series["seriePrime"].Points.DataBindXY(b, z);
            //            //chartPrime.Series["seriePrime"].ChartType = SeriesChartType.Column;
            //            chartPrime.Series["seriePrime"].ChartTypeName = ddlChartType.SelectedValue;
            //            chartPrime.ChartAreas["ChartAreaPrime"].Area3DStyle.Enable3D = cbUse3D.Checked;
            //            chartPrime.ChartAreas["ChartAreaPrime"].Area3DStyle.Inclination = Convert.ToInt32(rblInclinationAngle.SelectedValue);
            //            chartPrime.Legends["Default"].Enabled = true;
            //        }
            //////Comission
            //i = 0;
            //        foreach (statistiquesDB t in lsStat)
            //        {

            //            b[i] = t.Branche;
            //            u[i] = Convert.ToDecimal(t.Comission);
            //            i = i + 1;

            //            chartComission.Series["serieComission"].Points.DataBindXY(b, u);
            //            //chartPrime.Series["seriePrime"].ChartType = SeriesChartType.Column;
            //            chartComission.Series["serieComission"].ChartTypeName = ddlChartType.SelectedValue;
            //            chartComission.ChartAreas["ChartAreaComission"].Area3DStyle.Enable3D = cbUse3D.Checked;
            //            chartComission.ChartAreas["ChartAreaComission"].Area3DStyle.Inclination = Convert.ToInt32(rblInclinationAngle.SelectedValue);
            //            chartComission.Legends["Default"].Enabled = true;
            //        }

            //        ////SP
            //        i = 0;
            //        foreach (statistiquesDB t in lsStat)
            //        {

            //            b[i] = t.Branche;
            //            o[i] = Convert.ToDecimal(t.SP);
            //            i = i + 1;

            //            chartSP.Series["serieSP"].Points.DataBindXY(b, o);
            //            //chartSP.Series["serieSP"].ChartType = SeriesChartType.Column;
            //            chartSP.Series["serieSP"].ChartTypeName = ddlChartType.SelectedValue;
            //            chartSP.ChartAreas["ChartAreaSP"].Area3DStyle.Enable3D = cbUse3D.Checked;
            //            chartSP.ChartAreas["ChartAreaSP"].Area3DStyle.Inclination = Convert.ToInt32(rblInclinationAngle.SelectedValue);
            //            chartSP.Legends["Default"].Enabled = true;
            //        }
        }