Esempio n. 1
0
 public void Inserer_Commande(DetailCommandeDB Detail)
 {
     using (DataAccesDataContext dbContext = new DataAccesDataContext())
     {
         DetailCommande newCommande = new DetailCommande
         {
             code_service = Detail.code_service,
             id_produit   = Detail.Id_produit,
             Observation  = Detail.Observation,
             PU           = Detail.PU,
             Qte          = Detail.Qte,
             QteLivree    = Detail.QteLivree == null ? 0 : Detail.QteLivree
         };
         dbContext.DetailCommande.InsertOnSubmit(newCommande);
         dbContext.SubmitChanges();
     }
 }
Esempio n. 2
0
        public string maj_DetailCommande(DetailCommandeDB detail)
        {
            try
            {
                using (DataAccesDataContext ctx = new DataAccesDataContext())
                {
                    DetailCommande det = (from c in ctx.DetailCommande
                                          where c.code_service == detail.code_service && c.id_produit == detail.Id_produit
                                          select c).FirstOrDefault();

                    det.QteLivree = detail.QteLivree;
                    det.reponse   = detail.reponse;

                    ctx.SubmitChanges();
                }
                return("OK");
            }
            catch (Exception e)
            {
                return(e.Message);
            }
        }
Esempio n. 3
0
        private void BindGridListeProduit()
        {
            try
            {
                txterror.Visible = false;
                AstreeDonnees a = new AstreeDonnees();
                DetailCommandeDB detail = new DetailCommandeDB();
                List<DetailCommandeDB> lstCommande = new List<DetailCommandeDB>();
                if (Convert.ToInt16(ddlListeP.SelectedValue) == 0)
                {
                    MsgProduit.Visible = true;
                    MsgProduit.Text = "Vous devez choisir un article!";
                }
                else
                {
                    detail.Id_produit = Convert.ToInt16(ddlListeP.SelectedValue);
                    detail.LibelleProduit = ddlListeP.Text;
                }
                if (txtQte.Text == "")
                {
                    MsgPrix.Text = "";
                    MsgQte.Visible = true;
                    MsgQte.Text = "Vous devez choisir la quantité!";
                }
                else if (txtPrix.Text == "")
                {
                    MsgQte.Text = "";
                    MsgPrix.Visible = true;
                    MsgPrix.Text = "Vous devez choisir le prix unitaire!";
                }
                else
                {
                    detail.PU = Convert.ToInt16(txtPrix.Text);
                    detail.Qte = Convert.ToInt16(txtQte.Text);
                }



                if (txtQte.Text != "" && txtQte.Text != null && txtPrix.Text != "" && txtPrix.Text != null)
                {
                    if (Session["lstCommande"] != null)
                    {
                        lstCommande = (List<DetailCommandeDB>)Session["lstCommande"];
                        if (lstCommande.Where(w => w.Id_produit == Convert.ToInt16(ddlListeP.SelectedValue)).Count() > 0)
                        {
                            MsgPrix.Text = "";
                            MsgQte.Text = "";
                            txterror.Visible = true;
                            txterror.Text = "Vous avez déja selectionné cet article";
                        }
                        else
                        {
                            lstCommande.Add(detail);
                        }

                    }
                    else
                    {


                        lstCommande.Add(detail);




                    }
                    gv_listeCommande.DataSource = lstCommande;
                    gv_listeCommande.DataBind();
                    Session["lstCommande"] = lstCommande;
                }
                else
                {
                    //txterror.Visible = true;
                    //txterror.Text = "Vous avez remplir tout les champs!";
                }
            }
            catch
            {
                Response.Redirect("PageErreur.aspx");
            }

        }
Esempio n. 4
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. 5
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 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;
            }
        }
        private void BindGridListeProduit()
        {
            txterror.Visible = false;
            AstreeDonnees           a           = new AstreeDonnees();
            DetailCommandeDB        detail      = new DetailCommandeDB();
            List <DetailCommandeDB> lstCommande = new List <DetailCommandeDB>();

            detail.Id_produit     = Convert.ToInt16(ddlProduit.SelectedValue);
            detail.LibelleProduit = ddlProduit.Text;

            try
            {
                detail.Qte  = Convert.ToInt16(TxtQte.Text);
                MsgQte.Text = "";
                if (Session["lstPanier"] != null)
                {
                    lstCommande = (List <DetailCommandeDB>)Session["lstPanier"];
                    if (lstCommande.Where(w => w.Id_produit == Convert.ToInt16(ddlProduit.SelectedValue)).Count() > 0)
                    {
                        txterror.Visible = true;
                        txterror.Text    = "Vous avez déja selectionné cet article";
                    }
                    else
                    {
                        liste.Visible = false;
                        if (MsgQte.Text == "")
                        {
                            liste.Visible = true;
                            lstCommande.Add(detail);
                        }
                        else
                        {
                            MsgQte.Text = "La quantité doit étre un entier!";
                        }
                    }
                }
                else
                {
                    liste.Visible = false;
                    if (MsgQte.Text == "")
                    {
                        liste.Visible = true;
                        lstCommande.Add(detail);
                    }
                    else
                    {
                        MsgQte.Text = "La quantité doit étre un entier!";
                    }
                }

                gv_listeCommande.DataSource = lstCommande;
                gv_listeCommande.DataBind();
                Session["lstPanier"] = lstCommande;
            }
            catch (Exception ex)
            {
                liste.Visible  = false;
                MsgQte.Visible = true;
                MsgQte.Text    = "La quantité doit étre un entier!";
            }
        }