public ActionResult Edit([Bind(Include = "SOCIEDAD_ID,CAMPO,PORC_AD,PERIODOS,ACTIVO")] CONFDIST_CAT cONFDIST_CAT, string bools) { try { ////CONFDIST_CAT cf = db.CONFDIST_CAT.Where(i => i.SOCIEDAD_ID == cONFDIST_CAT.SOCIEDAD_ID && i.CAMPO == cONFDIST_CAT.CAMPO && i.PERIODOS == cONFDIST_CAT.PERIODOS).FirstOrDefault(); CONFDIST_CAT cf = db.CONFDIST_CAT.Where(i => i.SOCIEDAD_ID == cONFDIST_CAT.SOCIEDAD_ID).FirstOrDefault(); cf.PORC_AD = false; cf.ACTIVO = true; cf.CAMPO = cONFDIST_CAT.CAMPO; cf.PERIODOS = cONFDIST_CAT.PERIODOS; if (cf.PERIODOS == null) { cf.PERIODOS = 1; } if (ModelState.IsValid) { db.Entry(cf).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Details", new { id = cf.SOCIEDAD_ID })); } } catch (Exception e) { ViewBag.error = e.ToString(); } int pagina = 873; //ID EN BASE DE DATOS using (TAT001Entities db = new TAT001Entities()) { string u = User.Identity.Name; //string u = "admin"; var user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault(); ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList(); ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList(); ViewBag.usuario = user; ViewBag.returnUrl = Request.Url.PathAndQuery;; ViewBag.rol = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50; ViewBag.Title = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50; ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList(); ViewBag.textos = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(871) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList(); try { string p = Session["pais"].ToString(); ViewBag.pais = p + ".svg"; } catch { //ViewBag.pais = "mx.svg"; //return RedirectToAction("Pais", "Home"); } Session["spras"] = user.SPRAS_ID; } List <bool> lstb = new List <bool>(); lstb.Add(true); lstb.Add(false); ViewBag.CAMPO = new SelectList(db.CAMPOZKE24, "CAMPO", "CAMPO", cONFDIST_CAT.CAMPO); ViewBag.SOCIEDAD_ID = new SelectList(db.SOCIEDADs, "BUKRS", "BUKRS", cONFDIST_CAT.SOCIEDAD_ID); ViewBag.bools = new SelectList(lstb); return(View(cONFDIST_CAT)); }
// GET: ccat/Edit/5 public ActionResult Edit(string id) { int pagina_id = 873; //ID EN BASE DE DATOS FnCommon.ObtenerConfPage(db, pagina_id, User.Identity.Name, this.ControllerContext.Controller, 871); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ////var per = Convert.ToInt32(pr); CONFDIST_CAT cONFDIST_CAT = db.CONFDIST_CAT.Where(i => i.SOCIEDAD_ID == id).FirstOrDefault(); if (cONFDIST_CAT == null) { return(HttpNotFound()); } List <bool> lstb = new List <bool>(); lstb.Add(true); lstb.Add(false); ViewBag.CAMPO = new SelectList(db.CAMPOZKE24, "CAMPO", "CAMPO", cONFDIST_CAT.CAMPO); ViewBag.SOCIEDAD_ID = new SelectList(db.SOCIEDADs, "BUKRS", "BUKRS", cONFDIST_CAT.SOCIEDAD_ID); ViewBag.bools = new SelectList(lstb, cONFDIST_CAT.PORC_AD); return(View(cONFDIST_CAT)); }
public ActionResult DeleteConfirmed(string id, string cp, string pr) { int per = Convert.ToInt32(pr); CONFDIST_CAT cONFDIST_CAT = db.CONFDIST_CAT.Where(i => i.SOCIEDAD_ID == id && i.CAMPO == cp && i.PERIODOS == per).FirstOrDefault(); cONFDIST_CAT.ACTIVO = false; db.Entry(cONFDIST_CAT).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: ccat/Edit/5 public ActionResult Edit(string id, string cp, string pr) { int pagina = 873; //ID EN BASE DE DATOS using (TAT001Entities db = new TAT001Entities()) { string u = User.Identity.Name; //string u = "admin"; var user = db.USUARIOs.Where(a => a.ID.Equals(u)).FirstOrDefault(); ViewBag.permisos = db.PAGINAVs.Where(a => a.ID.Equals(user.ID)).ToList(); ViewBag.carpetas = db.CARPETAVs.Where(a => a.USUARIO_ID.Equals(user.ID)).ToList(); ViewBag.usuario = user; ViewBag.returnUrl = Request.Url.PathAndQuery;; ViewBag.rol = user.PUESTO.PUESTOTs.Where(a => a.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50; ViewBag.Title = db.PAGINAs.Where(a => a.ID.Equals(pagina)).FirstOrDefault().PAGINATs.Where(b => b.SPRAS_ID.Equals(user.SPRAS_ID)).FirstOrDefault().TXT50; ViewBag.warnings = db.WARNINGVs.Where(a => (a.PAGINA_ID.Equals(pagina) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList(); ViewBag.textos = db.TEXTOes.Where(a => (a.PAGINA_ID.Equals(871) || a.PAGINA_ID.Equals(0)) && a.SPRAS_ID.Equals(user.SPRAS_ID)).ToList(); try { string p = Session["pais"].ToString(); ViewBag.pais = p + ".svg"; } catch { //ViewBag.pais = "mx.svg"; //return RedirectToAction("Pais", "Home"); } Session["spras"] = user.SPRAS_ID; } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } var per = Convert.ToInt32(pr); CONFDIST_CAT cONFDIST_CAT = db.CONFDIST_CAT.Where(i => i.SOCIEDAD_ID == id && i.CAMPO == cp && i.PERIODOS == per).FirstOrDefault(); if (cONFDIST_CAT == null) { return(HttpNotFound()); } List <bool> lstb = new List <bool>(); lstb.Add(true); lstb.Add(false); ViewBag.CAMPO = new SelectList(db.CAMPOZKE24, "CAMPO", "CAMPO", cONFDIST_CAT.CAMPO); ViewBag.SOCIEDAD_ID = new SelectList(db.SOCIEDADs, "BUKRS", "BUKRS", cONFDIST_CAT.SOCIEDAD_ID); ViewBag.bools = new SelectList(lstb, cONFDIST_CAT.PORC_AD); return(View(cONFDIST_CAT)); }
public CONFDIST_CAT getCatConf(string soc) { TAT001Entities db = new TAT001Entities(); CONFDIST_CAT conf = new CONFDIST_CAT(); try { conf = db.CONFDIST_CAT.Where(c => c.SOCIEDAD_ID == soc && c.ACTIVO == true).FirstOrDefault(); } catch (Exception) { } return(conf); }
public JsonResult categoriasCliente(string vkorg, string spart, string kunnr, string soc_id) { TAT001Entities db = new TAT001Entities(); if (kunnr == null) { kunnr = ""; } //if (catid == null) //{ // catid = ""; //} var jd = (dynamic)null; //Obtener los materiales IEnumerable <MATERIAL> matl = Enumerable.Empty <MATERIAL>(); try { matl = db.MATERIALs.Where(m => m.ACTIVO == true);//.Select(m => m.ID).ToList(); } catch (Exception e) { } var spras = Session["spras"].ToString(); //Validar si hay materiales if (matl != null) { CLIENTE cli = new CLIENTE(); List <CLIENTE> clil = new List <CLIENTE>(); try { cli = db.CLIENTEs.Where(c => c.KUNNR == kunnr & c.VKORG == vkorg & c.SPART == spart).FirstOrDefault(); //Saber si el cliente es sold to, payer o un grupo if (cli != null) { //Es un soldto if (cli.KUNNR != cli.PAYER && cli.KUNNR != cli.BANNER) { //cli.VKORG = cli.VKORG+" "; clil.Add(cli); } } } catch (Exception e) { } var cie = clil.Cast <CLIENTE>(); // IEnumerable<CLIENTE> cie = clil as IEnumerable<CLIENTE>; //Obtener el numero de periodos para obtener el historial int nummonths = 3; int imonths = nummonths * -1; //Obtener el rango de los periodos incluyendo el año DateTime ff = DateTime.Today; DateTime fi = ff.AddMonths(imonths); string mi = fi.Month.ToString(); //.ToString("MM"); string ai = fi.Year.ToString(); //.ToString("yyyy"); string mf = ff.Month.ToString(); // ("MM"); string af = ff.Year.ToString(); // "yyyy"); int aii = 0; try { aii = Convert.ToInt32(ai); } catch (Exception e) { } int mii = 0; try { mii = Convert.ToInt32(mi); } catch (Exception e) { } int aff = 0; try { aff = Convert.ToInt32(af); } catch (Exception e) { } int mff = 0; try { mff = Convert.ToInt32(mf); } catch (Exception e) { } if (cie != null) { //Obtener el historial de compras de los clientesd var matt = matl.ToList(); //kunnr = kunnr.TrimStart('0').Trim(); var pres = db.PRESUPSAPPs.Where(a => a.VKORG.Equals(vkorg) & a.SPART.Equals(spart) & a.KUNNR == kunnr & (a.GRSLS != null | a.NETLB != null)).ToList(); var cat = db.MATERIALGPTs.Where(a => a.SPRAS_ID.Equals(spras)).ToList(); //foreach (var c in cie) //{ // c.KUNNR = c.KUNNR.TrimStart('0').Trim(); //} CONFDIST_CAT conf = getCatConf(soc_id); if (conf.CAMPO == "GRSLS") { jd = (from ps in pres join cl in cie on ps.KUNNR equals cl.KUNNR join m in matt on ps.MATNR equals m.ID join mk in cat on m.MATERIALGP_ID equals mk.MATERIALGP_ID where (ps.ANIO >= aii && ps.PERIOD >= mii) && (ps.ANIO <= aff && ps.PERIOD <= mff) && (ps.VKORG == cl.VKORG && ps.VTWEG == cl.VTWEG && ps.SPART == cl.SPART //&& ps.VKBUR == cl.VKBUR && //ps.VKGRP == cl.VKGRP && ps.BZIRK == cl.BZIRK ) && ps.BUKRS == soc_id && ps.GRSLS > 0 select new { m.MATERIALGP_ID, mk.TXT50 }).ToList(); } else { jd = (from ps in pres join cl in cie on ps.KUNNR equals cl.KUNNR join m in matt on ps.MATNR equals m.ID join mk in cat on m.MATERIALGP_ID equals mk.MATERIALGP_ID where (ps.ANIO >= aii && ps.PERIOD >= mii) && (ps.ANIO <= aff && ps.PERIOD <= mff) && (ps.VKORG == cl.VKORG && ps.VTWEG == cl.VTWEG && ps.SPART == cl.SPART //&& ps.VKBUR == cl.VKBUR && //ps.VKGRP == cl.VKGRP && ps.BZIRK == cl.BZIRK ) && ps.BUKRS == soc_id && ps.NETLB > 0 select new { m.MATERIALGP_ID, mk.TXT50 }).ToList(); } } } //var jll = db.PRESUPSAPPs.Select(psl => new { MATNR = psl.MATNR.ToString() }).Take(7).ToList(); var list = new List <MATERIALGPT>(); if (jd.Count > 0) { //MATERIALGPT c = db.MATERIALGPTs.Where(a => a.SPRAS_ID.Equals(spras) & a.MATERIALGP_ID.Equals("000")).FirstOrDefault(); //MATERIALGPT cc = new MATERIALGPT(); //cc.SPRAS_ID = c.SPRAS_ID; //cc.MATERIALGP_ID = c.MATERIALGP_ID; //cc.TXT50 = c.TXT50; //list.Add(cc); MATERIALGPT c = db.MATERIALGPTs.Where(a => a.SPRAS_ID.Equals(spras) & a.MATERIALGP_ID.Equals("000")).FirstOrDefault(); MATERIALGPT cc = new MATERIALGPT(); //B20180625 MGC 2018.07.02 if (c != null) //B20180625 MGC 2018.07.02 { cc.SPRAS_ID = c.SPRAS_ID; cc.TXT50 = c.TXT50; } else { cc.MATERIALGP_ID = "000"; } list.Add(cc); } foreach (var line in jd) { bool ban = true; foreach (var line2 in list) { if (line.MATERIALGP_ID == line2.MATERIALGP_ID) { ban = false; } } if (ban) { MATERIALGPT c = new MATERIALGPT(); c.MATERIALGP_ID = line.MATERIALGP_ID; c.TXT50 = line.TXT50; list.Add(c); } } JsonResult jl = Json(list, JsonRequestBehavior.AllowGet); return(jl); }