Ejemplo n.º 1
0
        protected void gv_Detail_SelectedIndexChanged(object sender, EventArgs e)
        {
            GridViewRow row = gv_Detail.SelectedRow;
            //txtNum.Text = row.Cells[1].Text;
            //lblMessage.Text = "You selected Commande numéro " + row.Cells[1].Text + ".";
            Txtcode.Text = row.Cells[2].Text;
            txtQte.Text = row.Cells[6].Text;
            txtPrix.Text = row.Cells[5].Text;
            TxtBesoin.Text = row.Cells[7].Text;

            ddlListeP.SelectedItem.Text= row.Cells[4].Text;
            BtnEnvoyer.Visible = false;

            AstreeDonnees a = new AstreeDonnees();
            serviceDB serv = a.GetServices().Where(w=>w.code_service == Convert.ToInt16(row.Cells[1].Text)).FirstOrDefault();

            if (serv.etatNotif == "N")
            {
                List<notificationDB> lstNotif = new List<notificationDB>();
                lstNotif = a.GetNotification();
                notificationDB notif = lstNotif.Where(w=>w.codeService==serv.code_service).FirstOrDefault();             
                notif.etatNotif = "L";//  LU
                a.maj_notification(notif);
                foreach (GridViewRow grvRow in gv_Detail.Rows)
                {
                    if(row.Cells[1].Text== grvRow.Cells[1].Text)
                    {
                        grvRow.ForeColor = System.Drawing.Color.Black;
                    }
                    
                }
                
            }
        }
Ejemplo n.º 2
0
        public List <notificationDB> GetNotification()
        {
            try
            {
                DataAccesDataContext dbContext = new DataAccesDataContext();
                notificationDB       ls        = new notificationDB();
                var pm = (from c in dbContext.notification
                          join a in dbContext.service on c.code_service equals a.code_service


                          select new notificationDB
                {
                    codeNotification = c.code_notification,
                    contenuNotification = c.contenu_notification,
                    dateNotification = c.date_notification,
                    etatNotif = c.etat,
                    codeService = a.code_service,
                    libelleService = a.libelleService,
                    idType = Convert.ToInt16(a.id_type),
                    codeUtilisateur = Convert.ToInt16(a.code_utilisateur)
                });

                return(pm.ToList());
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                return(null);
            }
        }
        protected void gv_Commande_SelectedIndexChanged(object sender, EventArgs e)
        {
            AstreeDonnees a = new AstreeDonnees();

            GridViewRow row  = gv_Commande.SelectedRow;
            produitDB   prod = a.GetProduit().Where(w => w.LibelleProduit.Trim() == row.Cells[3].Text.ToString().Trim()).FirstOrDefault();

            Txtcode.Text             = row.Cells[2].Text;
            TxtQte.Text              = row.Cells[4].Text;
            ddlProduit.SelectedValue = prod.IdProduit.ToString();//;
            //Session["CodeServ"]
            //MessageLabel.Text = "You selected Devis numéro " + row.Cells[1].Text + ".";
            BtnEnvoyer.Visible = false;

            notificationDB notif = a.GetNotification().Where(w => w.codeService == Convert.ToInt16(row.Cells[1].Text)).FirstOrDefault();

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

                Label x = (Label)Master.FindControl("lblNotifCommandeInter") 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() == "Commande").Count().ToString();

                Label nbNotification = (Label)Master.FindControl("nbNotification") as Label;
                nbNotification.Text = lsNotification.Count().ToString();

                //Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
            }
        }
Ejemplo n.º 4
0
        protected void gv_Commande_SelectedIndexChanged(object sender, EventArgs e)
        {
            AstreeDonnees a = new AstreeDonnees();
            //txtetat.Text = "";
            GridViewRow row = gv_Commande.SelectedRow;

            txtNum.Text     = row.Cells[1].Text;
            lblMessage.Text = "Vous avez séléctionner la commande numéro " + row.Cells[1].Text + ".";
            //txtProduit.Text = row.Cells[2].Text;
            //txtQuantiteDemandee.Text= row.Cells[4].Text;



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

            if (cb != null && cb.Checked)
            {
                // txtetat.Text = "VALIDEE";
                Btnreponse.Visible = false;
                cb.Enabled         = false;
                notificationDB notif = a.GetNotification().Where(w => w.codeService == Convert.ToInt16(txtNum.Text)).FirstOrDefault();
                if (notif != null)
                {
                    notif.etatNotif = "L";
                    a.maj_notification(notif);
                }
                row.ForeColor = System.Drawing.Color.Black;
                Response.Redirect(HttpContext.Current.Request.Url.ToString(), true);
            }
            else
            {
                Btnreponse.Visible = true;
                //cb.Enabled = true;
            }



            List <DetailCommandeDB> ls = a.GetDetailCommande().Where(w => w.LibelleService.Trim() == "Commande" && w.code_dest == 404 && w.code_service == Convert.ToInt16(txtNum.Text)).ToList();

            if (ls.Count() > 0)
            {
                // PnlInfo.Visible = false;
                Pnl_GvDetail.Visible = true;
                gv_Detail.DataSource = ls;
                gv_Detail.DataBind();
            }

            else
            {
                Pnl_GvDetail.Visible = false;
                //PnlInfo.Visible = true;
                //msg.Text = "il n'existe aucune Demande pour cet fournisseur!";
            }
        }
Ejemplo n.º 5
0
 public void InsertNotification(notificationDB notif)
 {
     using (DataAccesDataContext dbContext = new DataAccesDataContext())
     {
         notification not = new notification
         {
             code_notification    = notif.codeNotification,
             contenu_notification = notif.contenuNotification,
             date_notification    = notif.dateNotification,
             etat         = notif.etatNotif,
             code_service = notif.codeService
         };
         dbContext.notification.InsertOnSubmit(not);
         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();
        }
Ejemplo n.º 7
0
        public string maj_notification(notificationDB notif)
        {
            try
            {
                using (DataAccesDataContext ctx = new DataAccesDataContext())
                {
                    notification notification = (from c in ctx.notification
                                                 where c.code_notification == notif.codeNotification
                                                 select c).FirstOrDefault();

                    notification.etat = notif.etatNotif;

                    ctx.SubmitChanges();
                }
                return("OK");
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Ejemplo n.º 8
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");

            }
        }
        protected void Btnreponse_Click(object sender, EventArgs e)
        {
            AstreeDonnees a = new AstreeDonnees();

            MsgTaxe.Text = "";
            MsgPH.Text   = "";
            MsgCP.Text   = "";

            lblSuccee.Text = "";
            lblerreur.Text = "";
            MsgEtat.Text   = "";
            if (txtproduit.Text != "")
            {
                List <serviceDB> lstService = a.GetServices();
                serviceDB        ser        = new serviceDB();
                ser = lstService.Where(w => w.code_service == Convert.ToInt16(txtID.Text)).FirstOrDefault();

                if (ser != null)
                {
                    if (Txtetat.Text != "VALIDEE")
                    {
                        MsgProduit.Visible = false;
                        MsgEtat.Visible    = true;
                        MsgEtat.Text       = "Vous devez valider le devis selectionné!";
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(TxtPHT.Text) || Convert.ToDecimal(TxtPHT.Text) == 0)
                        {
                            MsgPT.Visible   = false;
                            MsgTaxe.Visible = false;
                            MsgCP.Visible   = false;
                            MsgPH.Visible   = true;
                            MsgPH.Text      = "veuillez remplir le prime HT ";
                        }



                        else if (String.IsNullOrEmpty(txtTaxe.Text) || Convert.ToDecimal(txtTaxe.Text) == 0)
                        {
                            MsgCP.Visible   = false;
                            MsgPH.Visible   = false;
                            MsgPT.Visible   = false;
                            MsgTaxe.Visible = true;
                            MsgTaxe.Text    = "veuillez remplir le taxe ";
                        }
                        else if (String.IsNullOrEmpty(txtCP.Text) || Convert.ToDecimal(txtCP.Text) == 0)
                        {
                            MsgPH.Visible   = false;
                            MsgPT.Visible   = false;
                            MsgTaxe.Visible = false;
                            MsgCP.Visible   = true;
                            MsgCP.Text      = "veuillez remplir le coût police";
                        }

                        else if (MsgPH.Text != "" && MsgCP.Text != "" && MsgTaxe.Text != "")
                        {
                            lblerreur.Text = "Vous devez remplir tout les champs!";
                        }
                        else
                        {
                            try {
                                ser.etat        = "V";
                                ser.dateReponse = DateTime.Now;
                                ser.primeHtax   = Convert.ToDecimal(TxtPHT.Text);
                                ser.primeTotal  = Convert.ToDecimal(txtPT.Text);
                                ser.coutPolice  = Convert.ToDecimal(txtCP.Text);
                                ser.taxe        = Convert.ToDecimal(txtTaxe.Text);
                                a.maj_devis(ser);
                                BindGrid();
                                lblSuccee.Visible = true;
                                lblerreur.Visible = false;
                                lblSuccee.Text    = "La réponse envoyée avec succés! ";
                            }
                            catch
                            {
                                lblerreur.Visible = true;
                                lblSuccee.Visible = false;
                                lblerreur.Text    = " Les champs doivent être des entiers!";
                            }
                        }
                    }
                    Label x = (Label)Master.FindControl("lblDevis") as Label;
                    Label y = (Label)Master.FindControl("nbNotification") as Label;

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



                    y.Text = (Convert.ToInt16(y.Text.ToString()) - 1).ToString();


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

                        //lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etat.Trim() == "A")).ToList();
                        //x.Text = lsNotification.Where(w => w.libelleService.Trim() == "Devis" ).Count().ToString();



                        //y.Text = (Convert.ToInt16(y.Text.ToString()) - 1).ToString();



                        BindGrid();
                    }
                }
            }
            else
            {
                MsgEtat.Visible    = false;
                MsgProduit.Visible = true;
                MsgProduit.Text    = "Vous devez selectionner un devis!";
            }
        }
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 11
0
        protected void Btnreponse_Click(object sender, EventArgs e)
        {
            MsgNum.Text = "";
            AstreeDonnees a = new AstreeDonnees();

            //if (txtetat.Text == "VALIDEE")
            //{
            AstreeDonnees ad = new AstreeDonnees();

            if (txtNum.Text != "")
            {
                serviceDB ser = a.GetServices().Where(w => w.code_service == Convert.ToInt16(txtNum.Text)).FirstOrDefault();

                DetailCommandeDB detailComm = a.GetDetailCommande().Where(w => w.LibelleService.Trim() == "Commande" && w.code_dest == 404 && w.code_service == Convert.ToInt16(txtNum.Text) && w.LibelleProduit.Trim() == txtProduit.Text.Trim()).FirstOrDefault();
                if (txtQteLivree.Text == "")
                {
                    txtQteLivree.Text = "Vous devez remplir la quantité à livrée";
                }
                if (detailComm != null)
                {
                    detailComm.reponse   = txtReponse.Text;
                    detailComm.QteLivree = Convert.ToInt16(txtQteLivree.Text);
                    ad.maj_DetailCommande(detailComm);
                }
                List <DetailCommandeDB> lstDetailComm = a.GetDetailCommande().Where(w => w.LibelleService.Trim() == "Commande" && w.code_dest == 404 && w.code_service == Convert.ToInt16(txtNum.Text) && w.QteLivree == 0).ToList();

                if (ser != null && lstDetailComm.Count == 0)
                {
                    ser.etat         = "V";
                    ser.dateReponse  = DateTime.Now;
                    ser.reponse      = txtReponse.Text;
                    ser.code_service = Convert.ToInt16(txtNum.Text);
                    ser.QteLivree    = Convert.ToInt16(txtQteLivree.Text);
                    a.maj_Commande(ser);
                    gv_Detail.Visible = false;
                    Label x = (Label)Master.FindControl("lblNotifCommande") as Label;
                    Label y = (Label)Master.FindControl("lblNotifCommandeInterFourn") as Label;
                    Label z = (Label)Master.FindControl("nbNotification") as Label;

                    List <serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etat.Trim() == "A") && w.codeDest == 404).ToList();
                    x.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.codeDest != 404 && w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"])).ToList();

                    y.Text = lsNotificationFourn.Count().ToString();



                    z.Text = (Convert.ToInt16(z.Text.ToString()) - 1).ToString();


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

                    //    Label x = (Label)Master.FindControl("lblNotifCommande") as Label;
                    //    Label y = (Label)Master.FindControl("lblNotifCommandeInterFourn") as Label;
                    //Label z = (Label)Master.FindControl("nbNotification") as Label;

                    //List<serviceDB> lsNotification = a.GetServices().Where(w => (w.libelleService != null) && (w.etat.Trim() == "A") && w.codeDest == 404).ToList();
                    //    x.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.codeDest != 404 && w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"])).ToList();

                    //y.Text = lsNotificationFourn.Count().ToString();



                    //z.Text = (Convert.ToInt16(x.Text) + Convert.ToInt16(y.Text)).ToString();


                    BindGrid();
                }
            }
            else
            {
                MsgNum.Text = "Vous devez séléctionner une commande!";
            }
            // }
        }
        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 Btnreponse_Click(object sender, EventArgs e)
        {
            AstreeDonnees a = new AstreeDonnees();

            if (txtproduit.Text != "")
            {
                List <serviceDB> lstService = a.GetServices();
                serviceDB        ser        = new serviceDB();
                ser = lstService.Where(w => w.code_service == Convert.ToInt16(txtId.Text)).FirstOrDefault();
                if (ser != null)
                {
                    if (Txtetat.Text != "VALIDEE")
                    {
                        lblMsgSucces.Visible = false;
                        MsgProduit.Visible   = false;
                        MsgEtat.Visible      = true;
                        MsgEtat.Text         = "Vous devez valider le devis selectionné!";
                    }
                    else
                    {
                        if (String.IsNullOrEmpty(txtreponse.Text))
                        {
                            lblMsgSucces.Visible = false;
                            MsgEtat.Visible      = false;
                            Msgreponse.Visible   = true;
                            Msgreponse.Text      = "veuillez remplir la réponse ";
                        }
                        else
                        {
                            ser.etat = "V";

                            ser.dateReponse = DateTime.Now;



                            ser.reponse = txtreponse.Text;
                            a.maj_derogation(ser);
                            BindGrid();
                            MsgEtat.Visible      = false;
                            Msgreponse.Visible   = false;
                            lblMsgSucces.Visible = true;
                            lblMsgSucces.Text    = "Reponse envoyée avec succès ";

                            if (ser.etatNotif == "")
                            {
                                notificationDB notif = new notificationDB();
                                notif.codeService         = ser.code_service;
                                notif.contenuNotification = ser.reponse;
                                notif.etatNotif           = "N";// NON LU
                                notif.dateNotification    = ser.dateReponse;
                                a.InsertNotification(notif);
                                Label b = (Label)Master.FindControl("nbNotification") as Label;

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

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

                                x.Text = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 1).Count().ToString();
                                //b.Text = x.Text;
                                Label y = (Label)Master.FindControl("lblNotifProrogation") as Label;

                                y.Text = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 2).Count().ToString();
                                //b.Text = y.Text;
                                Label z = (Label)Master.FindControl("lblNotifSouscription") as Label;
                                z.Text = lsNotification.Where(w => w.libelleService.Trim() == "Derogation" && w.idType == 3).Count().ToString();

                                //b.Text = z.Text;

                                b.Text = (Convert.ToInt16(b.Text.ToString()) - 1).ToString();
                            }
                        }
                    }
                }
                else
                {
                    MsgEtat.Visible    = false;
                    MsgProduit.Visible = true;
                    MsgProduit.Text    = "Vous devez selectionner un devis!";
                }
            }
        }
Ejemplo n.º 14
0
        protected void BtnRepondre_Click(object sender, EventArgs e)
        {
            try
            {
                AstreeDonnees        a         = new AstreeDonnees();
                serviceDB            reclam    = a.GetServices().Where(w => w.libelleService.Trim() == "Reclamation" && w.etat.Trim() == "A" && w.code_service == Convert.ToInt16(myCode.Text)).FirstOrDefault();
                DataAccesDataContext dbcontext = new DataAccesDataContext();


                if (reclam != null)
                {
                    if (String.IsNullOrEmpty(message.Text))
                    {
                        msgerror.Visible = true;
                        msgerror.Text    = "veuillez remplir la réponse ";
                        lundi(sender, e);
                    }
                    else
                    {
                        reclam.dateReponse = DateTime.Now;
                        reclam.etat        = "V";
                        reclam.reponse     = message.Text;
                        a.maj_reclamation(reclam);
                        message.Text = "écrivez votre réponse ici...";

                        lundi(sender, e);


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



                        UtilisateurDB        user              = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].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;
                        Label y = (Label)Master.FindControl("nbNotification") as Label;

                        Label x = (Label)Master.FindControl("lblNotifReclamation") as Label;
                        x.Text = lstReclamation.Count().ToString();
                        y.Text = (Convert.ToInt16(y.Text.ToString()) - 1).ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                lundi(sender, e);
                msgerror.Visible = true;
                msgerror.Text    = "Il n'existe aucunne réclamation selectionner";
            }
        }