// GET: Usuario public ActionResult Index() { IngresosEntities db = new IngresosEntities(); List <Usuario> lista = db.Usuario.Where(a => a.UserCar == "SISTEMAS").ToList(); return(View(lista)); }
public JsonResult GetAll() { using (var db = new IngresosEntities()) { try { var query = db.PubOrigen.ToList(); return(Json(new SelectList(query, "IdOrigen", "NomOrigen"))); } catch (Exception e) { return(null); } } }
//Json Estado ALL public JsonResult GetAll() { using (var db = new IngresosEntities()) { try { var query = db.EstadoRv.ToList(); return(Json(new SelectList(query, "Codigo", "Nombre"))); } catch (Exception e) { return(null); } } }
public ActionResult Login(Usuario u) { if (!ModelState.IsValid) { return(View("Login")); } try { using (IngresosEntities db = new IngresosEntities()) { var Hash = Encrypt.GetMD5(u.UserPass); var obj = db.Usuario.Where(uModel => uModel.IdUsuario.Equals(u.IdUsuario) && uModel.UserPass == Hash).FirstOrDefault(); if (obj == null) { u.MensajeError = "Credenciales no validas"; return(View("Login", u)); } else { Session["IdUsuario"] = obj.IdUsuario.ToString(); Session["UserNom"] = obj.UserNom.ToString(); Session["UserApe"] = obj.UserApe.ToString(); Session["UserCar"] = obj.UserCar.ToString(); return(RedirectToAction("Index")); } } } catch (Exception ex) { ModelState.AddModelError("Error al agregar al alumno", ex); return(View()); } }
public ActionResult Index() { using (var db = new IngresosEntities()) { try { var informacion = from AG in db.Agentes join TA in db.TipoAgente on AG.TipoAgente equals TA.IdTipo join TAGC in db.TipoAgencia on AG.TipoAgencia equals TAGC.Codigo join AGTM in db.AgentesMaster on AG.CodigoMaster equals AGTM.CodigoMaster where AG.Estado == "A" select new AgentesModel { Codigo = AG.Codigo, CodigoRes = AG.CodigoRes, CodigoInt = AG.CodigoInt, NombreAgenteMaster = AGTM.Nombre, NombreTipoAgencia = TAGC.Nombre, Nombre = AG.Nombre, NombreTipoAgente = TA.Nombre, Direccion = AG.Direccion, Localidad = AG.Localidad, RazonSocial = AG.RazonSocial, Ruc = AG.Ruc, Telefono1 = AG.Telefono1 }; //String valor = informacion.FirstOrDefault().ToString(); return(View(informacion.ToList().Take(10).OrderByDescending(ag => ag.Codigo))); } catch (Exception e) { return(null); } } }
public ActionResult Busqueda(string pcontable, string fecrep, string reporte, string numagente, string loc, string tventa, string estado) { var tventa_string = tventa; if (!string.IsNullOrEmpty(reporte)) { try { //NumReporte = Grupo NumReporte = Int32.Parse(reporte); } catch (Exception e) { ViewBag.ModalTitleHeader = "¡Error en la busqueda!"; ViewBag.ModalTipo = "modal-danger"; ViewBag.Error = "El numero de reporte ingresado no es valido"; ViewBag.ExceptionMsg = e; return(View("ReportesDeVenta")); } } if (!string.IsNullOrEmpty(numagente)) { try { NumAgente = Int32.Parse(numagente); } catch (Exception e) { ViewBag.ModalTitleHeader = "¡Error en la busqueda!"; ViewBag.ModalTipo = "modal-danger"; ViewBag.Error = "El numero de Agente ingresado no es valido"; ViewBag.ExceptionMsg = e; return(View("ReportesDeVenta")); } } if (!string.IsNullOrEmpty(estado)) { try { NumEstado = Int32.Parse(estado); } catch (Exception e) { ViewBag.ModalTitleHeader = "¡Error en la busqueda!"; ViewBag.ModalTipo = "modal-danger"; ViewBag.Error = "El estado ingresado no es valido"; ViewBag.ExceptionMsg = e; return(View("ReportesDeVenta")); } } if (!String.IsNullOrEmpty(pcontable)) { string[] dia_mes_anio = pcontable.Split('/'); var mes = dia_mes_anio[1].Trim(); var anio = dia_mes_anio[2].Trim(); var firstDay = DateTime.Parse("01/" + mes + "/" + anio); p_contable_ini = new DateTime(firstDay.Year, firstDay.Month, 1); p_contable_fin = p_contable_ini.AddMonths(1).AddDays(-1); } /* Si todos los campos estan vacios establece la fecha actual*/ if (String.IsNullOrEmpty(fecrep) && String.IsNullOrEmpty(numagente) && String.IsNullOrEmpty(reporte) && String.IsNullOrEmpty(pcontable) && String.IsNullOrEmpty(tventa)) { condicionaFecha = 1; dateini = DateTime.Now.Date; datefin = DateTime.Now.Date; } else if (!String.IsNullOrEmpty(fecrep)) { string[] fini_ffin = fecrep.Split('-'); var f_ini = fini_ffin[0].Trim(); var f_fin = fini_ffin[1].Trim(); dateini = DateTime.Parse(f_ini); datefin = DateTime.Parse(f_fin); condicionaFecha = 2; } using (var db = new IngresosEntities()) { try { DateTime firstDayOfMonth = today.AddDays(1 - today.Day); var query = from VC in db.VentasCabecera join EST in db.EstadoRv on VC.Estado equals EST.Codigo join AGT in db.Agentes on VC.Agente equals AGT.Codigo where ( (condicionaFecha == 1) ? VC.FechaReporte >= dateini && VC.FechaReporte <= datefin : true ) where ( (condicionaFecha == 2) ? VC.FechaReporte >= dateini && VC.FechaReporte <= datefin : true ) // where //( //(string.IsNullOrEmpty(pcontable) ? true : VC.FechaContable >= p_contable_ini // && VC.FechaContable <= p_contable_fin) //) where ( (string.IsNullOrEmpty(pcontable) ? true : VC.FechaContable >= p_contable_ini && VC.FechaContable <= p_contable_fin) ) //VC.FechaReporte >= new DateTime(2017, 1, 1) where ( (string.IsNullOrEmpty(numagente) ? true : VC.Agente == NumAgente) ) where ( (string.IsNullOrEmpty(reporte) ? true : VC.Grupo == NumReporte) ) where ( (string.IsNullOrEmpty(loc) ? true : AGT.Localidad == loc) ) where ( (string.IsNullOrEmpty(tventa) ? true : VC.Origen == tventa) ) where ( (string.IsNullOrEmpty(estado) ? true : EST.Codigo == NumEstado) ) select new VentasCabeceraModel { Tipo = VC.Tipo, Estado = EST.Nombre, Grupo = VC.Grupo, Localidad = AGT.Localidad, Agente = VC.Agente, NombreAgente = AGT.Nombre, FechaReporte = VC.FechaReporte, NroTkts = VC.NroTkts, Tarifa = VC.Tarifa, IgvTarifa = VC.IgvTarifa, OtrosIngresos = VC.OtrosIngresos, OtrosImp = VC.OtrosImp, Comision = VC.Comision, IgvComision = VC.IgvComision, Neto = VC.Contado + VC.Credito, Contado = VC.Contado, Credito = VC.Credito, OtrosCargos = VC.OtrosCargos, UsuarioReg = VC.UsuarioReg, SaldoDepo = VC.SaldoDepo, SaldoFactu = VC.SaldoFactu, SaldoFinal = VC.SaldoFinal }; ViewBag.Bool = true; return(View("ReportesDeVenta", query.ToList().OrderBy(g => g.Grupo).Take(1500))); } catch (Exception e) { return(null); } } //return View("ReportesDeVenta"); }