protected void BtnAjoutDevis_Click(object sender, EventArgs e)
        {
            //lblMessage1.Text = "Demande envoyer avec succées";

            AstreeDonnees    ad    = new AstreeDonnees();
            serviceDB        devis = new serviceDB();
            List <serviceDB> ls    = ad.GetServices().Where(w => w.libelleService.Trim() == "Devis" && w.codeUtilisateur == Convert.ToInt16(Session["code_utilisateur"].ToString())).ToList();

            if (ddlproduit.SelectedIndex == 0)
            {
                MsgError.Visible = true;
                MsgError.Text    = "Vous devez selectionner un produit";
            }
            else
            {
                //devis = ad.GetServices().Where(w => w.libelleService.Trim() == "Devis").FirstOrDefault();
                devis.libelleService = "Devis";
                devis.idBranche      = Convert.ToInt16(ddlproduit.SelectedValue.ToString());
                devis.idSousBranche  = Convert.ToInt16(ddlsousproduit.SelectedValue.ToString());

                devis.etat            = "A";
                devis.dateDemande     = DateTime.Now;
                devis.idType          = 5;
                devis.codeUtilisateur = Convert.ToInt16(Session["code_utilisateur"].ToString());

                serviceDB ser = ls.Where(w => (w.libelleBranche.Trim() == ddlproduit.SelectedItem.Text.Trim()) && (w.libelleSousbranche.Trim() == ddlsousproduit.SelectedItem.Text.Trim())).FirstOrDefault();
                if (ser == null)
                {
                    ad.Insertservice(devis);
                    lblMsgSucces.Visible = true;
                    lblMsgSucces.Text    = "Demande devis envoyée avec succés";
                    BindGrid();
                }
                else
                {
                    lblMsgSucces.Visible = true;
                    lblMsgSucces.Text    = "Vous avez déja envoyer cette demande";
                    BindGrid();
                }
            }
        }
示例#2
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 Btnsave_Click(object sender, EventArgs e)
        {
            //AstreeDonnees a = new AstreeDonnees();
            //serviceDB S = new serviceDB();

            ////serviceDB S1 = new serviceDB();
            //// S1 = a.GetServices().Where(w=>w.libelleService.Trim()=="Reclamation").FirstOrDefault();
            //S.libelleService = "Reclamation";
            //S.etat = "A";
            //S.idType = Convert.ToInt16(ddlRec.SelectedValue);
            //S.dateDemande = DateTime.Now;
            //S.contenuReclamation = TxtCommentaire.Text;
            //S.codeDest = Convert.ToInt16(ddlDest.SelectedValue);
            //S.codeUtilisateur = Convert.ToInt16(TxtCode.Text);
            //S.idSousBranche = 1;
            //a.Insertservice(S);
            //BindGrid();

            try
            {
                MsgContenu.Text = "";
                AstreeDonnees a = new AstreeDonnees();
                serviceDB     S = new serviceDB();
                S.libelleService = "Reclamation";
                S.etat           = "A";
                S.dateDemande    = DateTime.Now;
                if (TxtCommentaire.Text == "")
                {
                    MsgddlDest.Visible = false;
                    MsgContenu.Visible = true;
                    MsgContenu.Text    = "Vous devez saisir votre réclamation!";
                }
                else if (ddlDest.SelectedIndex == 0)
                {
                    MsgContenu.Visible = false;
                    MsgddlDest.Visible = true;
                    MsgddlDest.Text    = "Vous devez selectionner la destination! ";
                }

                else
                {
                    MsgContenu.Visible   = false;
                    MsgddlDest.Visible   = false;
                    S.contenuReclamation = TxtCommentaire.Text;
                    S.codeDest           = Convert.ToInt16(ddlDest.SelectedValue);
                    S.codeUtilisateur    = Convert.ToInt16(TxtCode.Text);
                    S.idSousBranche      = 1;
                    a.Insertservice(S);
                    BindGrid();
                    lblMsgSucces.Visible  = true;
                    lblMsgSucces.Text     = "La demande a été transmis avec succés";
                    ddlDest.SelectedIndex = 0;
                    TxtCommentaire.Text   = "";
                }
            }

            catch
            {
                Response.Redirect("PageErreur.aspx");
            }
        }
        protected void BtnEnvoyer_Click(object sender, EventArgs e)
        {
            try
            {
                AstreeDonnees a    = new AstreeDonnees();
                UtilisateurDB User = a.GetUser(Convert.ToInt16(Session["code_utilisateur"].ToString()));
                serviceDB     S    = new serviceDB();
                if (ddlProduit.SelectedIndex == 0)
                {
                    MsgQte.Visible  = false;
                    MsgProduit.Text = "Vous devez séléctionner un produit!";
                }
                else if (TxtQte.Text == "")
                {
                    MsgProduit.Visible = false;
                    MsgQte.Text        = "Vous devez donner la quantité!";
                    MsgQte.Visible     = true;
                }

                else
                {
                    //    description.Visible = true;
                    //    description.Text = "Vous devez remplir tout les champs! ";

                    S.libelleService = "Commande";
                    S.etat           = "A";
                    // 1 c'est le code du bureau d'ordre
                    S.codeDest        = 404;
                    S.dateDemande     = DateTime.Now;
                    S.codeUtilisateur = User.code_utilisateur;
                    a.Insertservice(S);
                    List <serviceDB> lstService = a.GetServices().Where(w => w.codeUtilisateur == User.code_utilisateur && w.libelleService.Trim() == "Commande").ToList();
                    serviceDB        serv       = lstService.OrderByDescending(w => w.code_service).FirstOrDefault();

                    DetailCommandeDB Detail = new DetailCommandeDB();
                    try
                    {
                        foreach (GridViewRow row in gv_listeCommande.Rows)
                        {
                            Detail.code_service = serv.code_service;
                            Detail.Id_produit   = Convert.ToInt16(row.Cells[0].Text);
                            //Detail.code_dest = serv.codeDest;
                            Detail.Qte         = Convert.ToInt16(row.Cells[2].Text);
                            Detail.PU          = 0;
                            Detail.Observation = "";
                            a.Inserer_Commande(Detail);
                            description.Visible = true;
                            description.Text    = "Commande envoyé avec succée";
                            BindGrid();
                        }
                        Session["lstPanier"] = null;
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }


            catch (Exception ex)
            {
                string msg = ex.Message;
            }
        }
示例#5
0
        //protected void BtnAjoutDerogation_Click(object sender, EventArgs e)
        //{
        //    lblMessage1.Text = "";
        //    if (String.IsNullOrEmpty(ddltype.Text))
        //    {
        //        lblMessage1.Visible = true;
        //        lblMessage1.Text = "veuillez choisir le type ";
        //    }
        //    else if (String.IsNullOrEmpty(ddlproduit.Text))
        //    {


        //        lblMessage1.Visible = true;
        //        lblMessage1.Text = "veuillez choisir  le produit";
        //    }
        //    else if (String.IsNullOrEmpty(ddlsousproduit.Text))
        //    {


        //        lblMessage1.Visible = true;
        //        lblMessage1.Text = "veuillez spécifier le produit";
        //    }
        //    else if (String.IsNullOrEmpty(txtnumcontrat.Text))
        //    {
        //        lblMessage1.Visible = true;
        //        lblMessage1.Text = "veuillez remplir votre numéro du contrat";
        //    }
        //    else if (ddltype.SelectedIndex == 0)
        //    {
        //        if ((String.IsNullOrEmpty(txttaux.Text)) || (Convert.ToInt16(txttaux.Text) > 15))//n7eb tst taux mayfoutech 15%
        //        {
        //            lblMessage1.Visible = true;
        //            lblMessage1.Text = "veuillez remplir le taux";
        //            txtduree.Text = "0";

        //        }
        //    }
        //    else if (ddltype.SelectedIndex == 1)
        //    {
        //        if (String.IsNullOrEmpty(txtduree.Text))
        //        {


        //            lblMessage1.Visible = true;
        //            lblMessage1.Text = "veuillez remplir la durée";
        //            txttaux.Text = "0";
        //        }
        //    }



        //    if (lblMessage1.Text == "")
        //    {
        //        lblMessage1.Visible = false;



        //        AstreeDonnees ad = new AstreeDonnees();
        //        serviceDB drg = new serviceDB();

        //        drg.numContrat = Convert.ToInt16(txtnumcontrat.Text);
        //        if (txttaux.Text == "")
        //        {
        //            drg.taux = 0;
        //        }
        //        else
        //        {
        //            drg.taux = Convert.ToInt16(txttaux.Text);
        //        }

        //        drg.idSousBranche = Convert.ToInt16(ddlsousproduit.SelectedValue.ToString());
        //        drg.idType = Convert.ToInt16(ddltype.SelectedValue.ToString());
        //        drg.etat = "A";
        //        drg.dateDemande = DateTime.Now;

        //        if (txtduree.Text == "")
        //        {
        //            drg.duree = 0;
        //        }
        //        else
        //        {
        //            drg.duree = Convert.ToInt16(txtduree.Text);
        //        }
        //        drg.libelleService = "Derogation";
        //        drg.codeUtilisateur = Convert.ToInt16(Session["code_utilisateur"].ToString());
        //        ad.Insertservice(drg);
        //        lblMsgSucces.Visible = true;
        //        lblMsgSucces.Text = "Dérogation envoyée avec succés";
        //        BindGrid();

        //        //////Notification
        //        //notificationDB notif = new notificationDB();
        //        //notif.codeService = drg.code_service;
        //        //notif.contenuNotification = drg.reponse;
        //        //notif.etat = "N";// NON LU
        //        //notif.dateNotification = drg.dateReponse;
        //        //ad.InsertNotification(notif);


        //    }

        //}
        protected void BtnAjoutDerogation_Click(object sender, EventArgs e)
        {
            lblMsg.Text     = "";
            MsgddlType.Text = "";
            MsgddlP.Text    = "";
            MsgddlSP.Text   = "";
            MsgDuree.Text   = "";
            MsgTaux.Text    = "";
            MsgContrat.Text = "";
            string typeDerogation = "Remise";

            if (ddltype.SelectedIndex == 1)
            {
                typeDerogation = "Prorogation";
            }
            if (ddltype.SelectedIndex == 2)
            {
                typeDerogation = "Souscription";
            }
            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() == typeDerogation) && (w.codeUtilisateur == user.code_utilisateur)).ToList();

            if (String.IsNullOrEmpty(ddltype.Text))
            {
                MsgddlType.Visible = true;
                MsgddlType.Text    = "veuillez choisir le type ";
            }
            else if (String.IsNullOrEmpty(ddlproduit.Text) || ddlproduit.SelectedIndex == 0)
            {
                MsgddlP.Visible = true;
                MsgddlP.Text    = "veuillez choisir  le produit";
            }
            else if (String.IsNullOrEmpty(ddlsousproduit.Text))
            {
                MsgddlSP.Visible = true;
                MsgddlSP.Text    = "veuillez spécifier le produit";
            }
            else if (String.IsNullOrEmpty(txtnumcontrat.Text))
            {
                if (ddltype.SelectedIndex != 2)
                {
                    MsgContrat.Visible = true;
                    MsgContrat.Text    = "veuillez remplir votre numéro du contrat";
                }
            }
            else if (ddltype.SelectedIndex == 0)
            {
                if ((String.IsNullOrEmpty(txttaux.Text)) || (Convert.ToInt16(txttaux.Text) > 15))//n7eb tst taux mayfoutech 15%
                {
                    MsgTaux.Visible = true;
                    MsgTaux.Text    = "veuillez remplir le taux";
                    txtduree.Text   = "0";
                }
                //else if ((Convert.ToInt16(txttaux.Text).GetType()!= typeof(int))) {
                //    MsgTaux.Text = "le taux doit étre un entier";
                //}
            }
            else if (ddltype.SelectedIndex == 1)
            {
                if (String.IsNullOrEmpty(txtduree.Text))
                {
                    MsgDuree.Visible = true;
                    MsgDuree.Text    = "veuillez remplir la durée";
                    txttaux.Text     = "0";
                }
            }

            if (MsgddlType.Text == "" && MsgddlP.Text == "" && MsgddlSP.Text == "" && MsgDuree.Text == "" && MsgTaux.Text == "" && MsgContrat.Text == "" && lblMsg.Text == "")
            {
                MsgddlType.Visible = false;
                MsgddlP.Visible    = false;
                MsgddlSP.Visible   = false;
                MsgDuree.Visible   = false;
                MsgTaux.Visible    = false;
                MsgContrat.Visible = false;



                AstreeDonnees ad  = new AstreeDonnees();
                serviceDB     drg = new serviceDB();
                try
                {
                    if (ddltype.SelectedIndex != 2)
                    {
                        drg.numContrat = Convert.ToInt16(txtnumcontrat.Text);
                    }
                    else
                    {
                        drg.numContrat = 0;
                    }
                }
                catch (Exception ex)
                {
                    MsgContrat.Visible = true;
                    MsgContrat.Text    = "le N° contrat doit etre un entier";
                }

                if (txttaux.Text == "")
                {
                    drg.taux = 0;
                }
                else
                {
                    try
                    {
                        drg.taux = Convert.ToInt16(txttaux.Text);
                    }
                    catch
                    {
                        MsgTaux.Visible = true;
                        MsgTaux.Text    = "Le taux doit étre un entier";
                    }
                }

                drg.idSousBranche = Convert.ToInt16(ddlsousproduit.SelectedValue.ToString());
                drg.idType        = Convert.ToInt16(ddltype.SelectedValue.ToString());
                drg.etat          = "A";
                drg.dateDemande   = DateTime.Now;

                if (txtduree.Text == "")
                {
                    drg.duree = 0;
                }
                else
                {
                    try { drg.duree = Convert.ToInt16(txtduree.Text); }
                    catch
                    {
                        MsgDuree.Visible = true;
                        MsgDuree.Text    = "la durée doit étre un entier";
                    }
                }
                drg.libelleService  = "Derogation";
                drg.codeUtilisateur = Convert.ToInt16(Session["code_utilisateur"].ToString());
                int nb = 0;
                if (ddltype.SelectedIndex != 2)
                {
                    nb = ad.GetServices().Where(w => w.numContrat == drg.numContrat).Count();
                }
                else
                {
                    nb = 0;
                }
                //if (nb > 0)
                //{
                //    lblMsgSucces.Text = "Vous avez déja envoyer une demande pour ce N° de contrat!";
                //}
                //else
                //{
                if (MsgDuree.Text != "" || MsgTaux.Text != "" || MsgContrat.Text != "" || MsgddlP.Text != "" || MsgddlSP.Text != "")
                {
                    lblMsgSucces.Visible = true;
                    lblMsgSucces.Text    = "Impossible d'envoyer la demande! Vérifiez les champs";
                }
                else
                {
                    serviceDB ser = new serviceDB();
                    if (ddltype.SelectedIndex != 2)
                    {
                        ser = ls.Where(w => w.numContrat == drg.numContrat).FirstOrDefault();
                        if (ser == null)
                        {
                            ad.Insertservice(drg);
                            lblMsgSucces.Visible = true;
                            lblMsgSucces.Text    = "Dérogation envoyée avec succés";
                            BindGrid();
                        }
                        else
                        {
                            lblMsgSucces.Visible = true;
                            lblMsgSucces.Text    = "Demande déjà envoyée pour ce contrat";
                            BindGrid();
                        }
                    }
                    else if (ddltype.SelectedIndex == 2)
                    {
                        int nb1 = ad.GetServices().Where(w => w.idBranche == ser.idBranche && w.idSousBranche == ser.idSousBranche && w.idType == 3).Count();
                        if (nb1 > 1)
                        {
                            lblMsg.Visible = true;
                            lblMsg.Text    = "Vous avez déja envoyé une souscription pour ce produit ";
                        }

                        else
                        {
                            ad.Insertservice(drg);
                            lblMsgSucces.Visible = true;
                            lblMsgSucces.Text    = "Dérogation envoyée avec succés";
                            BindGrid();
                        }
                    }
                }
                //}
            }
        }