private void BindGrid() { AstreeDonnees a = new AstreeDonnees(); List <serviceDB> ls = a.GetServices().Where(w => w.libelleService == "Commande" && w.codeDest == 404 && w.etat.Trim() == "A").ToList(); List <serviceDB> lsServ = new List <serviceDB>(); List <notificationDB> lstNotif = a.GetNotification(); gv_Commande.DataSource = ls; gv_Commande.DataBind(); foreach (GridViewRow row in gv_Commande.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") { row.ForeColor = System.Drawing.Color.Red; } if (serv.etat.ToString().Trim() == "V") { cb.Checked = true; row.ForeColor = System.Drawing.Color.Black; } } } } }
protected void gv_Commande_RowDataBound(object sender, GridViewRowEventArgs e) { 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() == "Commande") && (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) { } } }
protected void gv_Devis_PageIndexChanging(object sender, GridViewPageEventArgs e) { gv_Devis.PageIndex = e.NewPageIndex; gv_Devis.DataSource = Session["lstDevis"]; gv_Devis.DataBind(); gv_Devis.SelectedIndex = -1; AstreeDonnees a = new AstreeDonnees(); List <serviceDB> ls = a.GetServices().Where(w => (w.libelleService != null) && (w.libelleService.Trim() == "Devis")).ToList(); 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() == "V") { cb.Checked = true; } } } } }
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; } } } }
public void Insertservice(serviceDB ser) { using (DataAccesDataContext dbContext = new DataAccesDataContext()) { service service = new service { //code_service = ser.code_service, num_contrat = ser.numContrat == null ? 0 : ser.numContrat, taux = ser.taux == null ? 0 : ser.taux, id_sous_branche = ser.idSousBranche, id_type = ser.idType, etat = ser.etat == null ? "" : ser.etat, reponse = ser.reponse == null ? "" : ser.reponse, duree = ser.duree == null ? 0 : ser.duree, date_demande = ser.dateDemande == null ? null : ser.dateDemande, contenu_Reclamation = ser.contenuReclamation == null ? "" : ser.contenuReclamation, code_dest = ser.codeDest == null ? 0 : ser.codeDest, primeHTax = ser.primeHtax == null ? 0 : ser.primeHtax, coutPolice = ser.coutPolice == null ? 0 : ser.coutPolice, primeTotal = ser.primeTotal == null ? 0 : ser.primeTotal, libelleService = ser.libelleService == null ? "" : ser.libelleService, code_utilisateur = ser.codeUtilisateur == null ? 0 : ser.codeUtilisateur, //Id_produit = ser.Id_produit == null ? 0 : ser.Id_produit, //Qte = ser.Qte == null ? 0 : ser.Qte }; dbContext.service.InsertOnSubmit(service); dbContext.SubmitChanges(); } }
public string maj_devis(serviceDB serv) { try { using (DataAccesDataContext ctx = new DataAccesDataContext()) { service devis = (from c in ctx.service where c.code_service == serv.code_service select c).FirstOrDefault(); devis.etat = serv.etat; devis.date_Reponse = serv.dateReponse; devis.primeHTax = serv.primeHtax; devis.coutPolice = serv.coutPolice; devis.tax = serv.taxe; devis.primeTotal = serv.primeTotal; ctx.SubmitChanges(); } return("OK"); } catch (Exception e) { return(e.Message); } }
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(); }
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(); } } }
public string maj_Commande_fournisseur(serviceDB serv) { try { using (DataAccesDataContext ctx = new DataAccesDataContext()) { service service = (from c in ctx.service where c.code_service == serv.code_service select c).FirstOrDefault(); service.etat = serv.etat; service.date_Reponse = serv.dateReponse; service.reponse = serv.reponse; ctx.SubmitChanges(); } return("OK"); } catch (Exception e) { return(e.Message); } }
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 == " ") { TxtPHT.Text = "0"; } else { TxtPHT.Text = row.Cells[5].Text; } if (row.Cells[6].Text == " ") { txtTaxe.Text = "0"; } else { txtTaxe.Text = row.Cells[6].Text; } if (row.Cells[7].Text == " ") { txtCP.Text = "0"; } else { txtCP.Text = row.Cells[7].Text; } if (row.Cells[8].Text == " ") { 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 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 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(); } } } //} } }
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 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; } }
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 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!"; } }
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; } } } } } } }
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!"; } } }
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 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 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 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"; } }