public Affectation Store(Affectation affectation) { affectation.Datetime = DateTime.Now; _afdtechContext.Affectations.Add(affectation); _afdtechContext.SaveChanges(); return(affectation); }
public ActionResult addLot(Lot lot, int agent) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { Debug.WriteLine(lot); LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); LotService.Add(lot); LotService.Commit(); Affectation affectation = new Affectation { DateAffectation = DateTime.Now, LotId = lot.LotId, EmployeId = agent }; AffectationService.Add(affectation); AffectationService.Commit(); return(RedirectToAction("ConsulterClients", new { numLot = 0, sortOrder = 0 })); } } }
public async Task <ActionResult <Affectation> > PostAffectation(Affectation affectation) { _context.Affectations.Add(affectation); await _context.SaveChangesAsync(); return(CreatedAtAction("GetAffectation", new { id = affectation.AffectationId }, affectation)); }
public async Task <IActionResult> PutAffectation(int id, int id2, Affectation affectation) { if (id != affectation.IdFiliere && id2 != affectation.IdMatiere) { return(BadRequest()); } _context.Entry(affectation).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!AffectationExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
private void modifierToolStripMenuItem_Click(object sender, EventArgs e) { FRM_Produit_Commande frm = new FRM_Produit_Commande(this); Produit PR = new Produit(); Affectation QteAff = new Affectation(); if (dvgDetailCommande.CurrentRow != null) { frm.lblTitre.Text = "Modifier Produit"; frm.txtIdClientAffect.Text = IDCLIENT.ToString(); frm.txtIdExpediteur.Text = IDEXPEDITEUR.ToString(); frm.txtIdProduit.Text = dvgDetailCommande.CurrentRow.Cells[0].Value.ToString(); frm.lblnom.Text = dvgDetailCommande.CurrentRow.Cells[1].Value.ToString(); ////Importer le stock de produit depuis le datagrid produit////// int IDEX = IDEXPEDITEUR; int IDPROD = int.Parse(dvgDetailCommande.CurrentRow.Cells[0].Value.ToString()); QteAff = db.Affectations.Single(s => s.ID_Client == IDEX && s.ID_Produit == IDPROD); frm.lblstock.Text = QteAff.Quantite_affectee.ToString(); ////Importer inventaire de produit depuis le datagrid produit////// int IDP = int.Parse(dvgDetailCommande.CurrentRow.Cells[0].Value.ToString()); PR = db.Produits.Single(s => s.ID_Produit == IDP); frm.lblInv.Text = PR.NumInventaire.ToString();; frm.lblprix.Text = dvgDetailCommande.CurrentRow.Cells[3].Value.ToString(); frm.txtquantite.Text = dvgDetailCommande.CurrentRow.Cells[2].Value.ToString(); frm.txtremise.Text = dvgDetailCommande.CurrentRow.Cells[4].Value.ToString(); frm.txttotal.Text = dvgDetailCommande.CurrentRow.Cells[5].Value.ToString(); frm.ShowDialog(); } }
public ActionResult DeleteConfirmed(int id) { Affectation affectation = db.affectations.Find(id); db.affectations.Remove(affectation); db.SaveChanges(); return(RedirectToAction("Index")); }
public JsonResult Delete(int ID) { Affectation a = db.affectations.Find(ID); db.affectations.Remove(a); db.SaveChanges(); return(Json(0, JsonRequestBehavior.AllowGet)); }
public ActionResult updateLot(ClientAffecteViewModel cavm) { using (WakilRecouvContext WakilContext = new WakilRecouvContext()) { using (UnitOfWork UOW = new UnitOfWork(WakilContext)) { LotService LotService = new LotService(UOW); AffectationService AffectationService = new AffectationService(UOW); Lot newlot = LotService.GetById(cavm.Lot.LotId); newlot.Adresse = cavm.Lot.Adresse; newlot.Compte = cavm.Lot.Compte; newlot.DescIndustry = cavm.Lot.DescIndustry; newlot.Emploi = cavm.Lot.Emploi; newlot.IDClient = cavm.Lot.IDClient; newlot.NomClient = cavm.Lot.NomClient; newlot.NumLot = cavm.Lot.NumLot; newlot.PostCode = cavm.Lot.PostCode; newlot.SoldeDebiteur = cavm.Lot.SoldeDebiteur; newlot.TelFixe = cavm.Lot.TelFixe; newlot.TelPortable = cavm.Lot.TelPortable; newlot.Type = cavm.Lot.Type; newlot.Emploi = cavm.Lot.Emploi; LotService.Update(newlot); LotService.Commit(); Affectation affectation = AffectationService.GetById(cavm.Affectation.AffectationId); Debug.WriteLine(cavm.Affectation.EmployeId); if (affectation == null) { Affectation aff = new Affectation { EmployeId = cavm.Affectation.EmployeId, LotId = cavm.Lot.LotId, DateAffectation = DateTime.Now }; AffectationService.Add(aff); AffectationService.Commit(); } else { affectation.EmployeId = cavm.Affectation.EmployeId; affectation.LotId = cavm.Lot.LotId; affectation.DateAffectation = DateTime.Now; AffectationService.Update(affectation); AffectationService.Commit(); } return(RedirectToAction("ConsulterClients", new { numLot = 0, sortOrder = 0 })); } } }
protected void Page_Load(object sender, EventArgs e) { int.TryParse("" + Request.QueryString["UserId"], out UserIdQuery); if (UserIdQuery > 0) { if (DataMapping.Sub_Active(UserIdQuery, "PagePro") == true) //La page est accessible par superuser, par le membre propriétaire même si l'abonnement est inactif { member = DataMapping.GetMemberByUserID(UserIdQuery); if (member != null && member.id != null && member.id > 0 && member.nim > 0) { affectation = DataMapping.GetAffectation(member.nim, DateTime.Now.Year); content = DataMapping.GetContentPagePro(UserIdQuery); Binding_Panel2(); } else { //if (PortalSettings.HomeTabId > 0) //{ // Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); //} //else //{ // Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); //} } } else { //if (PortalSettings.HomeTabId > 0) //{ // Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); //} //else //{ // Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); //} } } else { //if (PortalSettings.HomeTabId > 0) //{ // Response.Redirect(Globals.NavigateURL(PortalSettings.HomeTabId), true); //} //else //{ // Response.Redirect(Globals.GetPortalDomainName(PortalSettings.PortalAlias.HTTPAlias, Request, true), true); //} } }
public string GetListeMembres(int cric, string critere, string top, string tri, int index, int max, bool onlyvisible, string username, string password, string device, string version, string fonction) { DateTime dt = DateTime.Now; string comment = ""; string code = "ok"; //envoyerTest(fonction); List <Member> lm = new List <Member>(); List <Membre> ln = new List <Membre>(); try { string token = ConnectFromAndroid(username, password, device, version, fonction); bool court = true; if (token == "1") { court = false; } lm = DataMapping.ListMembers(cric, critere, top, tri, index, max, onlyvisible, court); //DateTime now = DateTime.Now; //int year = 0; //int.TryParse(now.ToString("yyyy"), out year); foreach (Member m in lm) { m.photo = HttpContext.Current.Server.MapPath(m.GetPhoto()); //if (year > 0) //{ //Affectation aff = DataMapping.GetAffectation(m.nim, year); Affectation aff = DataMapping.GetAffectation(m.nim, Functions.GetRotaryYear()); if (aff != null && !string.IsNullOrEmpty(aff.function)) { m.fonction_rotarienne = aff.function; } //} ln.Add(memberToMembre(m)); } } catch (Exception ee) { code = "erreur"; comment = ee.ToString(); Functions.Error(ee); } string output = JsonConvert.SerializeObject(ln, Formatting.Indented); DataMapping.InsertLogWS(os, device, version, getIP(), dt, getDuree(dt), fonction, code, comment, username); return(output); }
public ActionResult Create(AffectationViewModel avm) { Affectation f = new Affectation() { DateEnvoi = DateTime.Now, Etat = Etat.envoyée, Mannequin = servicem.GetById(avm.CIN), }; serviAff.Add(f); serviAff.Commit(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,DateAffectation,DureeCours,ClasseId,ProfesseurId,MatiereId,QuantumHoraire")] Affectation affectation) { if (ModelState.IsValid) { db.Entry(affectation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ClasseId = new SelectList(db.classes, "Id", "Libelle", affectation.ClasseId); ViewBag.MatiereId = new SelectList(db.matieres, "Id", "Libelle", affectation.MatiereId); ViewBag.ProfesseurId = new SelectList(db.professeurs, "Id", "Prenom", affectation.ProfesseurId); return(View(affectation)); }
private AbstractExpression getExpression() { Affectation exp = null; if (Program.mainMontage.mapOfCalculExpressions.TryGetValue(this.name, out exp)) { return(exp.expression); } else { return(null); } }
public JsonResult Update(Affectation affectation) { Affectation aff = db.affectations.Find(affectation.Id); aff.DateAffectation = affectation.DateAffectation; aff.DureeCours = affectation.DureeCours; aff.ClasseId = affectation.ClasseId; aff.ProfesseurId = affectation.ProfesseurId; aff.MatiereId = affectation.MatiereId; aff.QuantumHoraire = affectation.QuantumHoraire; db.SaveChanges(); return(Json(1, JsonRequestBehavior.AllowGet)); }
public void Ajouter_Expedition(int client, int produit, int quantite) { clsE = new Affectation(); clsE.ID_Client = client; clsE.ID_Produit = produit; clsE = db.Affectations.SingleOrDefault(s => s.ID_Client == client && s.ID_Produit == produit); if (clsE != null) //if (db.Affectations.SingleOrDefault(s => s.ID_Client == client && s.ID_Produit == produit) != null)// si existe pas { clsE.Quantite_affectee = clsE.Quantite_affectee - quantite; db.SaveChanges(); } }
// GET: Affectations/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Affectation affectation = db.affectations.Find(id); if (affectation == null) { return(HttpNotFound()); } return(View(affectation)); }
public ActionResult <Affectation> Put(int id, Affectation affectation) { var a = _affectationDao.GetById(id); if (a == null) { return(NotFound()); } a.ConsultantId = affectation.ConsultantId; a.ProjectId = affectation.ProjectId; affectation.Datetime = DateTime.Now; return(_affectationDao.Update(a)); }
private void DataShow_CellContentClick_1(object sender, DataGridViewCellEventArgs e) { DataBases bd = new DataBases(); Debug.WriteLine("------" + DataShow.Columns[e.ColumnIndex].Name); if (DataShow.Columns[e.ColumnIndex].Name == "Supprimer") { if (DataShow.Rows[e.RowIndex].Cells[2].Value.ToString() == "non-affecter") { MessageBox.Show("pas d'affectation"); } else if (MessageBox.Show("Voulez-vous vraiment le supprimer\n" + DataShow.Rows[e.RowIndex].Cells[1].Value + "?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { if (bd.DeleteAffercation(DataShow.Rows[e.RowIndex].Cells[1].Value.ToString())) { MessageBox.Show("bien supprimer"); } else { MessageBox.Show("error"); } } } if (DataShow.Columns[e.ColumnIndex].Name == "Affecter_modifier") { String name = DataShow.Rows[e.RowIndex].Cells[0].Value.ToString(); String username = DataShow.Rows[e.RowIndex].Cells[1].Value.ToString(); Affectation l = new Affectation(this); l.chercheur.Text = name + " ," + username; IGetEquipes.IGetEquipes getEquipes = (IGetEquipes.IGetEquipes)Activator.GetObject(typeof(IGetEquipes.IGetEquipes), "tcp://localhost:8086/getEquipes"); try { List <Equipe> equipes = getEquipes.GetEquipes(); foreach (Equipe equipe in equipes) { l.equipes.Items.Add(equipe); } l.Show(); } catch { MessageBox.Show("verfier la cnx "); } } ClearData(); DataInTable(); }
protected void dataList_Members_ItemDataBound(object sender, DataListItemEventArgs e) { Affectation affectation = (Affectation)e.Item.DataItem; Member member = DataMapping.GetMemberByNim(affectation.nim); Image Image1 = (Image)e.Item.FindControl("Image1"); if (member != null) { Image1.ImageUrl = member.GetPhoto(); } else { Image1.ImageUrl = Const.MEMBERS_NOPHOTO_H; } Label LBL_Club = (Label)e.Item.FindControl("LBL_Club"); LBL_Club.Text = DataMapping.GetClub(affectation.cric).name; Label LBL_Nom = (Label)e.Item.FindControl("LBL_Nom"); LBL_Nom.Text = affectation.name; HyperLink HL_Contact = (HyperLink)e.Item.FindControl("HL_Contact"); if (member != null) { PortalSettings ps = PortalController.GetCurrentPortalSettings(); if (ps.UserInfo.Roles != null && ps.UserInfo.Roles.Count() > 0) { HL_Contact.NavigateUrl = "javascript:dnnModal.show('/AIS/contact.aspx?id=" + member.id + "&popUp=true',false,350,850,false);"; } else { HL_Contact.NavigateUrl = "javascript:dnnModal.show('/AIS/contact.aspx?id=" + member.id + "&popUp=true',false,350,500,false);"; } if (member.IsWoman() == true) { HL_Contact.Text = "La contacter"; } } else { HL_Contact.Visible = false; } }
// GET: Affectations/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Affectation affectation = db.affectations.Find(id); if (affectation == null) { return(HttpNotFound()); } ViewBag.ClasseId = new SelectList(db.classes, "Id", "Libelle", affectation.ClasseId); ViewBag.MatiereId = new SelectList(db.matieres, "Id", "Libelle", affectation.MatiereId); ViewBag.ProfesseurId = new SelectList(db.professeurs, "Id", "Prenom", affectation.ProfesseurId); return(View(affectation)); }
/// <summary> /// Permet de valider les modifications des AAR /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BT_Valider_Click(object sender, EventArgs e) { if (!(UserInfo.IsSuperUser || UserInfo.IsInRole(Const.ADMIN_ROLE) || UserInfo.IsInRole(Const.ROLE_ADMIN_CLUB) || UserInfo.IsInRole(Const.ROLE_ADMIN_DISTRICT) || DataMapping.isADG(Functions.GetCurrentMember().id))) { return; } int cric = Functions.CurrentCric; List <Affectation> affectations = new List <Affectation>(); foreach (Control row in Panel1.Controls) { if (row is DropDownList) { DropDownList dl = row as DropDownList; string[] ids = dl.ID.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); Affectation affectation = new Affectation(); affectation.cric = cric; affectation.function = ids[ids.Length - 1]; int nim = 0; int.TryParse("" + dl.SelectedValue, out nim); affectation.nim = nim; affectation.name = dl.SelectedIndex > 0 ? dl.Items[dl.SelectedIndex].Text : ""; if (affectation.name != "") { affectations.Add(affectation); } } } if (DataMapping.UpdateAffectationRY(cric, int.Parse(RB_AR.SelectedValue), affectations)) { Club c = AIS.DataMapping.GetClub(cric); string subject = "[Rotary 1730] Information"; string body = "Le bureau du club " + c.name + " vient d'être modifié pour l'année " + RB_AR.SelectedValue + "."; AIS.Functions.SendMail("*****@*****.**", subject, body); AIS.Functions.SendMail("*****@*****.**", subject, body); } }
public void Ajouter_Affectation(int client, int produit, int quantite) { clsA = new Affectation(); clsA.ID_Client = client; clsA.ID_Produit = produit; if (db.Affectations.SingleOrDefault(s => s.ID_Client == client && s.ID_Produit == produit) == null)// si existe pas { clsA.Quantite_affectee = quantite; db.Affectations.Add(clsA); db.SaveChanges(); } else { clsA = db.Affectations.SingleOrDefault(s => s.ID_Client == client && s.ID_Produit == produit); clsA.Quantite_affectee = clsA.Quantite_affectee + quantite; db.SaveChanges(); } }
private void modifierToolStripMenuItem_Click(object sender, EventArgs e) { FRM_Produit_Livraison frm = new FRM_Produit_Livraison(this); Produit PR = new Produit(); Affectation QteAff = new Affectation(); if (dvgDetailLivraison.CurrentRow != null) { frm.lblTitre.Text = "Modifier Livraison"; frm.txtIdClientAffect.Text = IDDEST.ToString(); frm.txtIdProduit.Text = dvgDetailLivraison.CurrentRow.Cells[0].Value.ToString(); frm.lblnom.Text = dvgDetailLivraison.CurrentRow.Cells[1].Value.ToString(); ////Importer inventaire de produit depuis le datagrid produit////// int IDP = int.Parse(dvgDetailLivraison.CurrentRow.Cells[0].Value.ToString()); PR = db.Produits.Single(s => s.ID_Produit == IDP); frm.lblInv.Text = PR.NumInventaire.ToString();; frm.txtquantite.Text = dvgDetailLivraison.CurrentRow.Cells[2].Value.ToString(); frm.ShowDialog(); } }
public async Task <ActionResult <Affectation> > PostAffectation(Affectation affectation) { _context.Affectation.Add(affectation); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (AffectationExists(affectation.IdFiliere)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetAffectation", new { id = affectation.IdFiliere }, affectation)); }
private static void ImportTache(IXLWorksheet sheet, ref int line, Tache t, JourEvenement jour, Planning p, FestivArtsContext ctx) { IXLRow timeRow = sheet.Row(line); line++; int maxB = t.GetMaxBenevoleByDay(jour.Id); Regex regex = new Regex("^([0-9]+)"); var aAjouter = new Dictionary <int, HashSet <int> >(); for (int l = 0; l < maxB; l++) { IXLRow r = sheet.Row(line); int i = ExcelUtils.FIRST_PLAN_COLUMN; foreach (CreneauDef d in jour.CreneauDefs.OrderBy(s => s.NoCreneau)) { var cell = r.Cell(i); string benStr = cell.Value.ToString(); if (!string.IsNullOrWhiteSpace(benStr)) { var m = regex.Match(benStr.Trim()); if (m.Success) { int id = int.Parse(m.Groups[0].Captures[0].Value); var b = ctx.Benevoles.FirstOrDefault(s => s.Id == id); if (b == null) { throw new ImportException(string.Format("Cell ({0}) Tache {1} : n° de bénévole introuvable : {2}'", cell.Address.ToStringRelative(true), t.Nom, benStr)); } var c = t.Creneaux.FirstOrDefault(s => s.CreneauDefId == d.Id); if (c == null) { throw new ImportException(string.Format("Cell ({0}) Tache {1} : creneau introuvable. Creneau def {2}'", cell.Address.ToStringRelative(true), t.Nom, d.Id)); } if (!aAjouter.ContainsKey(b.Id)) { aAjouter.Add(b.Id, new HashSet <int>()); } if (!aAjouter[b.Id].Contains(c.Id)) { aAjouter[b.Id].Add(c.Id); } } else { throw new ImportException(string.Format("Cell ({0}) ne correspond pas a un n° de bénévole : {1}'", cell.Address.ToStringRelative(true), benStr)); } } i++; } line++; } if (aAjouter.Count > 0) { var anciensA = ctx.Affectations.Where(s => s.Creneau.CreneauDef.JourId == jour.Id && s.PlanningId == p.Id && s.Creneau.TacheId == t.Id).ToList(); foreach (Affectation a in anciensA) { if (aAjouter.ContainsKey(a.BenevoleId) && aAjouter[a.BenevoleId].Contains(a.CreneauId)) { //L'affectation existait déjà, on ne fait rien aAjouter[a.BenevoleId].Remove(a.CreneauId); } else { //N'existe plus, on la supprime; ctx.Affectations.Remove(a); } } foreach (var kv in aAjouter.Where(s => s.Value.Count > 0).ToList()) { foreach (var v in kv.Value) { Affectation a = new Affectation() { BenevoleId = kv.Key, CreneauId = v, PlanningId = p.Id }; ctx.Affectations.Add(a); } } ctx.SaveChanges(); } }
static void Main(string[] args) { GestionProjet gs = new GestionProjet(); Ingenieur j1 = new Ingenieur() { Id = 1, Nom = "Dhia", Prenom = "Saadlaui", Email = "*****@*****.**", Specialite = Specialite.GL }; Ingenieur j2 = new Ingenieur() { Id = 1, Nom = "Amal", Prenom = "aaaaaaaaaaaa", Email = "aaaaaaaaaaaa", Specialite = Specialite.GL }; Ingenieur j3 = new Ingenieur() { Id = 1, Nom = "Dhia", Prenom = "Saadlaui", Email = "*****@*****.**", Specialite = Specialite.GL }; Ingenieur j4 = new Ingenieur() { Id = 1, Nom = "Dhia", Prenom = "Saadlaui", Email = "*****@*****.**", Specialite = Specialite.GL }; ChefProjet cf1 = new ChefProjet() { // here to fill object props }; ChefProjet cf2 = new ChefProjet() { // here to fill object props }; Affectation af1 = new Affectation() { // here to fill object props }; Affectation af2 = new Affectation() { // here to fill object props }; //TO TEST Extension Method // gs.AjoutProjet(new Projet(){Nom = "projet1"}); // METHOD 1 var Query = from AFF in gs.Affectations join chef in gs.ChefProjets on AFF.Projet.chef equals chef group AFF by AFF.Projet into g where g.Key.chef.Experiance > 7 select g; foreach (var aff in Query) { Console.WriteLine(aff.GetEnumerator()); } // METHOD 2 var innerJoinQuery = from chef in gs.ChefProjets where chef.Experiance > 7 select chef; foreach (var chef in innerJoinQuery) { foreach (var projet in chef.Projets) { Console.WriteLine(gs.Affectations.FindAll(affectation => affectation.Projet == projet)); } } Console.ReadKey(); }
public void ActualiserdvgAlerte() { dgvDate.Columns[5].DefaultCellStyle.Format = "dd/MM/yyyy"; db = new dbStockContext(); dgvDate.Rows.Clear(); var listerecherche = db.Produits.ToList(); if (combocategorieCtrl.SelectedItem != null && comboTypeCtrl.SelectedItem != null) { string CategRech = combocategorieCtrl.SelectedValue.ToString(); int IdCat; bool testCat = Int32.TryParse(CategRech, out IdCat); string TypeRech = comboTypeCtrl.SelectedValue.ToString(); int IdTyp; bool testTyp = Int32.TryParse(TypeRech, out IdTyp); string IdRech = txtrechercheInvProdCtrl.Text; int IdProd; bool testProd = Int32.TryParse(IdRech, out IdProd); listerecherche = listerecherche.Where(s => s.NumInventaire.IndexOf(txtrechercheInvProdCtrl.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && s.Nom_Produit.IndexOf(txtrechercheNomCtrl.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && IdTyp == s.ID_Type && IdCat == s.ID_Categorie).ToList(); } if (combocategorieCtrl.SelectedItem != null) { string CategRecherche = combocategorieCtrl.SelectedValue.ToString(); int IdCateg; bool testCateg = Int32.TryParse(CategRecherche, out IdCateg); listerecherche = listerecherche.Where(s => s.NumInventaire.IndexOf(txtrechercheInvProdCtrl.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && s.Nom_Produit.IndexOf(txtrechercheNomCtrl.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && IdCateg == s.ID_Categorie).ToList(); } if (comboTypeCtrl.SelectedItem != null) { string TypeRecherche = comboTypeCtrl.SelectedValue.ToString(); int IdType; bool testType = Int32.TryParse(TypeRecherche, out IdType); listerecherche = listerecherche.Where(s => s.NumInventaire.IndexOf(txtrechercheInvProdCtrl.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && s.Nom_Produit.IndexOf(txtrechercheNomCtrl.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && IdType == s.ID_Type).ToList(); } if (combocategorieCtrl.SelectedItem == null && comboTypeCtrl.SelectedItem == null) { listerecherche = listerecherche.Where(s => s.NumInventaire.IndexOf(txtrechercheInvProdCtrl.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && s.Nom_Produit.IndexOf(txtrechercheNomCtrl.Text, StringComparison.CurrentCultureIgnoreCase) != -1).ToList(); } Categorie Cat = new Categorie(); Type Typ = new Type();//ajout pout type Affectation IDAffect = new Affectation(); Client NomClient = new Client(); foreach (var Lis in listerecherche) { Cat = db.Categories.SingleOrDefault(s => s.ID_Categorie == Lis.ID_Categorie); Typ = db.Types.SingleOrDefault(s => s.ID_Type == Lis.ID_Type);//ajout type if (Lis.Date_Controle != "") { DateTime date = Convert.ToDateTime(Lis.Date_Controle.ToString()); DateTime dateDuJour = DateTime.Now; int nbJours = (date - dateDuJour).Days; if (Cat != null & Typ != null & nbJours <= 30)//si existe { if (db.Affectations.SingleOrDefault(s => s.ID_Produit == Lis.ID_Produit) != null) { IDAffect = db.Affectations.SingleOrDefault(s => s.ID_Produit == Lis.ID_Produit); NomClient = db.Clients.SingleOrDefault(s => s.ID_Client == IDAffect.ID_Client); dgvDate.Rows.Add(Lis.ID_Produit, Cat.Nom_Categorie, Typ.Nom_Type, Lis.NumInventaire, Lis.Nom_Produit, Lis.Date_Controle, nbJours, NomClient.Nom_Client + " " + NomClient.Prenom_Client);//cat.Nom pour afficher nom de cagorie depuis table categorie } else { NomClient = null; dgvDate.Rows.Add(Lis.ID_Produit, Cat.Nom_Categorie, Typ.Nom_Type, Lis.NumInventaire, Lis.Nom_Produit, Lis.Date_Controle, nbJours, NomClient);//cat.Nom pour afficher nom de cagorie depuis table categorie } } } } PL.USER_Dashboard.Instance.txtNbreDateCtrlAlerte.Text = (dgvDate.Rows.Count.ToString()); for (int i = 0; i < dgvDate.Rows.Count; i++) { if ((int)dgvDate.Rows[i].Cells[6].Value <= 0) { dgvDate.Rows[i].Cells[6].Style.BackColor = Color.DimGray; } else { dgvDate.Rows[i].Cells[6].Style.BackColor = Color.DarkGray; } dgvDate.ClearSelection(); } }
public void ActualiserdvgStock() { db = new dbStockContext(); dgvStock.Rows.Clear(); var listerecherche = db.Produits.ToList(); if (combocategorieStock.SelectedItem != null && combotypeStock.SelectedItem != null) { string CategRech = combocategorieStock.SelectedValue.ToString(); int IdCat; bool testCat = Int32.TryParse(CategRech, out IdCat); string TypeRech = combotypeStock.SelectedValue.ToString(); int IdTyp; bool testTyp = Int32.TryParse(TypeRech, out IdTyp); string IdRech = txtrechercheInvProdStock.Text; int IdProd; bool testProd = Int32.TryParse(IdRech, out IdProd); listerecherche = listerecherche.Where(s => s.NumInventaire.IndexOf(txtrechercheInvProdStock.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && s.Nom_Produit.IndexOf(txtrechercheNomStock.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && IdTyp == s.ID_Type && IdCat == s.ID_Categorie).ToList(); } if (combocategorieStock.SelectedItem != null) { string CategRecherche = combocategorieStock.SelectedValue.ToString(); int IdCateg; bool testCateg = Int32.TryParse(CategRecherche, out IdCateg); listerecherche = listerecherche.Where(s => s.NumInventaire.IndexOf(txtrechercheInvProdStock.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && s.Nom_Produit.IndexOf(txtrechercheNomStock.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && IdCateg == s.ID_Categorie).ToList(); } if (combotypeStock.SelectedItem != null) { string TypeRecherche = combotypeStock.SelectedValue.ToString(); int IdType; bool testType = Int32.TryParse(TypeRecherche, out IdType); listerecherche = listerecherche.Where(s => s.NumInventaire.IndexOf(txtrechercheInvProdStock.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && s.Nom_Produit.IndexOf(txtrechercheNomStock.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && IdType == s.ID_Type).ToList(); } if (combocategorieStock.SelectedItem == null && combotypeStock.SelectedItem == null) { listerecherche = listerecherche.Where(s => s.NumInventaire.IndexOf(txtrechercheInvProdStock.Text, StringComparison.CurrentCultureIgnoreCase) != -1 && s.Nom_Produit.IndexOf(txtrechercheNomStock.Text, StringComparison.CurrentCultureIgnoreCase) != -1).ToList(); } Categorie Cat = new Categorie(); Type Typ = new Type(); Affectation IDAffect = new Affectation(); //foreach (var Lis in db.Produits) foreach (var Lis in listerecherche) { Cat = db.Categories.SingleOrDefault(s => s.ID_Categorie == Lis.ID_Categorie); Typ = db.Types.SingleOrDefault(s => s.ID_Type == Lis.ID_Type); int Depot = 14; if (db.Affectations.SingleOrDefault(s => s.ID_Produit == Lis.ID_Produit && s.ID_Client == Depot) != null) // si produit affecte sur depot central ID = 10 { if ((Lis.Stock_Alerte) != "") // si un stock d'alerte est renseigne { if (Lis.ID_Type != 3) //si le produit n'est pas un unitaire { IDAffect = (db.Affectations.SingleOrDefault(s => s.ID_Produit == Lis.ID_Produit && s.ID_Client == Depot)); if (IDAffect.Quantite_affectee <= int.Parse(Lis.Stock_Alerte)) //si stock en alerte { dgvStock.Rows.Add(Lis.ID_Produit, Cat.Nom_Categorie, Typ.Nom_Type, Lis.NumInventaire, Lis.Nom_Produit, IDAffect.Quantite_affectee, Lis.Stock_Alerte); } } } } } PL.USER_Dashboard.Instance.txtNbreStockAlerte.Text = (dgvStock.Rows.Count.ToString()); for (int i = 0; i < dgvStock.Rows.Count; i++) { if ((int)dgvStock.Rows[i].Cells[5].Value == 0) { dgvStock.Rows[i].Cells[5].Style.BackColor = Color.DimGray; } else { dgvStock.Rows[i].Cells[5].Style.BackColor = Color.DarkGray; } dgvStock.ClearSelection(); } }
public bool Delete(Affectation affectation) { _afdtechContext.Affectations.Remove(affectation); _afdtechContext.SaveChanges(); return(true); }
public Affectation Update(Affectation affectation) { _afdtechContext.Affectations.Update(affectation); _afdtechContext.SaveChanges(); return(affectation); }