public ActionResult Edit([Bind(Include = "CANAL1,CDESCRIPCION")] CANAL cANAL) { if (ModelState.IsValid) { db.Entry(cANAL).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cANAL)); }
// GET: CANAL/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CANAL cANAL = db.CANALs.Find(id); if (cANAL == null) { return(HttpNotFound()); } int pagina_id = 942;//ID EN BASE DE DATOS FnCommon.ObtenerConfPage(db, pagina_id, User.Identity.Name, this.ControllerContext.Controller); return(View(cANAL)); }
public ActionResult Create([Bind(Include = "CANAL1,CDESCRIPCION")] CANAL cANAL) { if (ModelState.IsValid) { var canalexiste = db.CANALs.Where(t => t.CANAL1 == cANAL.CANAL1).SingleOrDefault(); if (canalexiste == null) { db.CANALs.Add(cANAL); db.SaveChanges(); return(RedirectToAction("Index")); } else { ModelState.AddModelError("Error", "El canal ya existe"); int pagina_id = 941;//ID EN BASE DE DATOS FnCommon.ObtenerConfPage(db, pagina_id, User.Identity.Name, this.ControllerContext.Controller); return(View(cANAL)); } } return(View(cANAL)); }
public CLIENTE_MOD SelectCliente(string kunnr) { TAT001Entities db = new TAT001Entities(); CLIENTE_MOD id_cl = (from c in db.CLIENTEs join co in db.CONTACTOCs on new { c.VKORG, c.VTWEG, c.SPART, c.KUNNR } equals new { co.VKORG, co.VTWEG, co.SPART, co.KUNNR } into jjcont from co in jjcont.DefaultIfEmpty() where (c.KUNNR == kunnr & co.DEFECTO == true) select new CLIENTE_MOD { VKORG = c.VKORG, VTWEG = c.VTWEG, VTWEG2 = c.VTWEG, //RSG 05.07.2018 SPART = c.SPART, //RSG 28.05.2018------------------- NAME1 = c.NAME1, KUNNR = c.KUNNR, STCD1 = c.STCD1, PARVW = c.PARVW, BANNER = c.BANNER, CANAL = c.CANAL, PAYER_NOMBRE = co == null ? String.Empty : co.NOMBRE, PAYER_EMAIL = co == null ? String.Empty : co.EMAIL, }).FirstOrDefault(); if (id_cl == null) { id_cl = (from c in db.CLIENTEs where (c.KUNNR == kunnr) select new CLIENTE_MOD { VKORG = c.VKORG, VTWEG = c.VTWEG, VTWEG2 = c.VTWEG, //RSG 05.07.2018 SPART = c.SPART, //RSG 28.05.2018------------------- NAME1 = c.NAME1, KUNNR = c.KUNNR, STCD1 = c.STCD1, PARVW = c.PARVW, BANNER = c.BANNER, CANAL = c.CANAL, PAYER_NOMBRE = String.Empty, PAYER_EMAIL = String.Empty, }).FirstOrDefault(); } if (id_cl != null) { //Obtener el cliente //CANAL canal = db.CANALs.Where(ca => ca.BANNER == id_cl.BANNER && ca.KUNNR == kunnr).FirstOrDefault(); CANAL canal = db.CANALs.Where(ca => ca.CANAL1 == id_cl.CANAL).FirstOrDefault(); id_cl.VTWEG = ""; //if (canal == null) //{ // string kunnrwz = kunnr.TrimStart('0'); // string bannerwz = id_cl.BANNER.TrimStart('0'); // canal = db.CANALs.Where(ca => ca.BANNER == bannerwz && ca.KUNNR == kunnrwz).FirstOrDefault(); //} if (canal != null) { //id_cl.VTWEG = canal.CANAL1 + " - " + canal.CDESCRIPCION; id_cl.VTWEG = canal.CDESCRIPCION; } //Obtener el tipo de cliente var clientei = (from c in db.TCLIENTEs join ct in db.TCLIENTETs on c.ID equals ct.PARVW_ID where c.ID == id_cl.PARVW && c.ACTIVO == true select ct).FirstOrDefault(); id_cl.PARVW = ""; if (clientei != null) { id_cl.PARVW = clientei.TXT50; } } return(id_cl); }