public ActionResult PerfilIndex(string PerfilId) { using (var db = new DBPremioEntities()) { if (PerfilId == null) { if (idAuxPerfil == null) { PerfilId = "1"; List <SP_Perfil> perfil = db.Database.SqlQuery <SP_Perfil>("GetPerfil").ToList(); ViewBag.Perfil = ToSelectList(perfil, PerfilId); return(View(db.Database.SqlQuery <SP_MenuIDPerfil>("GetMenuIDPerfil @intPerfil", new SqlParameter("intPerfil", int.Parse(PerfilId))).ToList())); } else { List <SP_Perfil> perfil = db.Database.SqlQuery <SP_Perfil>("GetPerfil").ToList(); ViewBag.Perfil = ToSelectList(perfil, idAuxPerfil); return(View(db.Database.SqlQuery <SP_MenuIDPerfil>("GetMenuIDPerfil @intPerfil", new SqlParameter("intPerfil", int.Parse(idAuxPerfil))).ToList())); } } else { List <SP_Perfil> perfil = db.Database.SqlQuery <SP_Perfil>("GetPerfil").ToList(); ViewBag.Perfil = ToSelectList(perfil, PerfilId); return(View(db.Database.SqlQuery <SP_MenuIDPerfil>("GetMenuIDPerfil @intPerfil", new SqlParameter("intPerfil", int.Parse(PerfilId))).ToList())); } } }
public ActionResult InicioIndex() { using (var db = new DBPremioEntities()) { return(View(db.Database.SqlQuery <SP_GetPremio>("GetPremio").ToList())); } }
public ActionResult Edit(SP_GetUsuario usr) { using (var db = new DBPremioEntities()) { //try //{ List <SP_Perfil> perfil = db.Database.SqlQuery <SP_Perfil>("GetPerfil").ToList(); ViewBag.Perfil = ToSelectList(perfil); db.Database.ExecuteSqlCommand("UpdateUsuario @intCodigo, @vchUsuario, @vchNombre, @bitActivo, @intPerfil", new SqlParameter("intCodigo", usr.intCodigo), new SqlParameter("vchUsuario", usr.vchUsuario), new SqlParameter("vchNombre", usr.vchNombre), new SqlParameter("bitActivo", usr.bitActivo), new SqlParameter("intPerfil", usr.intPerfil)); nombreUsr = usr.vchNombre; return(Json(new { success = true })); //return RedirectToAction("UsuarioIndex", "Usuario", new { @nombre = usr.vchNombre }); //} //catch (Exception) //{ // return View(usr); // throw; //} } }
public ActionResult UsuarioIndex(string nombre, string codigo) { using (var db = new DBPremioEntities()) { if (nombre == null) { if (nombreUsr == null) { nombre = ""; codigo = ""; return(View(db.Database.SqlQuery <SP_GetUsuario>("GetUsuario @vchNombre, @vchUsuario", new SqlParameter("vchNombre", nombre), new SqlParameter("vchUsuario", codigo) ).ToList())); } else { codigo = ""; return(View(db.Database.SqlQuery <SP_GetUsuario>("GetUsuario @vchNombre, @vchUsuario", new SqlParameter("vchNombre", nombreUsr), new SqlParameter("vchUsuario", codigo)).ToList())); } } else { return(View(db.Database.SqlQuery <SP_GetUsuario>("GetUsuario @vchNombre, @vchUsuario", new SqlParameter("vchNombre", nombre), new SqlParameter("vchUsuario", codigo)).ToList())); } } }
public ActionResult AgregarConsultoras() { try { using (var db = new DBPremioEntities()) { var sql = "SELECT COUNT(*) FROM dbo.TConsultoraTemp"; int total = db.Database.SqlQuery <int>(sql).First(); if (total == 0) { return(Json("Debe subir primero el listado de las Consultoras con el archivo Excel.")); } db.Database.ExecuteSqlCommand("InsertConsultoras @intCodigo", new SqlParameter("intCodigo ", int.Parse(HttpContext.User.Identity.Name))); return(Json("Se actualizó los datos de las Consultoras correctamente.")); } } catch (Exception ex) { return(Json("No se puedo Insertar a las Consultoras.")); throw; } }
public ActionResult SeguimientoIndex(SP_GetListaPedidoDir plan) { //TRAEMOS TODAS LAS CNS QUE FINALIZARON SU PEDIDO SEGUN EL PLAN using (var db = new DBPremioEntities()) { List <SP_GetListaPlan> Lplan = db.Database.SqlQuery <SP_GetListaPlan>("GetListaPlan").ToList(); ViewBag.Plan = ToSelectList(Lplan, "1"); if (plan.intCodigo == 0) { List <SP_GetListaPedidoDir> listaDir = new List <SP_GetListaPedidoDir>(); return(View(listaDir)); } else { string nombPlan = db.Database.SqlQuery <string>("SELECT vchPlan FROM TPremio WHERE intCodigo = " + plan.intCodigo).FirstOrDefault(); return(View(db.Database.SqlQuery <SP_GetListaPedidoDir>("GetListaPedidoDir @intUsr, @vchPlan", new SqlParameter("intUsr", int.Parse(HttpContext.User.Identity.Name)), new SqlParameter("vchPlan", nombPlan) ).ToList())); } } }
public ActionResult UsuarioIndex() { using (var db = new DBPremioEntities()) { return(View(db.Database.SqlQuery <SP_GetUsuario>("GetUsuario @vchNombre", new SqlParameter("vchNombre", "")).ToList())); } }
// GET: Perfil public ActionResult PerfilIndex() { using (var db = new DBPremioEntities()) { List <SP_Perfil> perfil = db.Database.SqlQuery <SP_Perfil>("GetPerfil").ToList(); ViewBag.Perfil = ToSelectList(perfil, "1"); return(View(db.Database.SqlQuery <SP_MenuIDPerfil>("GetMenuIDPerfil @intPerfil", new SqlParameter("intPerfil", 1)).ToList())); } }
public ActionResult Create(SP_GetMensaje ms) { using (var db = new DBPremioEntities()) { db.Database.ExecuteSqlCommand("InsertMensaje @vchMensaje, @intUsr", new SqlParameter("vchMensaje", ms.vchMensaje), new SqlParameter("intUsr", int.Parse(HttpContext.User.Identity.Name))); return(Json(new { success = true })); } }
public ActionResult Edit(int id = 0) { using (var db = new DBPremioEntities()) { SP_GetMensaje mensaje = db.Database.SqlQuery <SP_GetMensaje>("GetMensajeID @intCodigo", new SqlParameter("intCodigo", id)).FirstOrDefault(); ViewBag.Title = "Editar Mensaje"; return(PartialView(mensaje)); } }
public ActionResult Edit(int id = 0) { using (var db = new DBPremioEntities()) { SP_MenuIDPerfil menu = db.Database.SqlQuery <SP_MenuIDPerfil>("GetMenuID @intID", new SqlParameter("intID", id)).FirstOrDefault(); ViewBag.Title = "Editar Menu"; return(PartialView(menu)); } }
public ActionResult Create() { using (var db = new DBPremioEntities()) { List <SP_Perfil> perfil = db.Database.SqlQuery <SP_Perfil>("GetPerfil").ToList(); ViewBag.Perfil = ToSelectList(perfil); } ViewBag.Title = "Crear Usuario"; return(PartialView()); }
public ActionResult Edit(SP_MenuIDPerfil menu) { using (var db = new DBPremioEntities()) { db.Database.ExecuteSqlCommand("UpdateMenuPerfil @intID, @bitAcceso", new SqlParameter("intID", menu.intID), new SqlParameter("bitAcceso", menu.bitAcceso)); idAuxPerfil = menu.intPerfil.ToString(); return(Json(new { success = true })); } }
public ActionResult SeguimientoIndex() { using (var db = new DBPremioEntities()) { List <SP_GetListaPlan> plan = db.Database.SqlQuery <SP_GetListaPlan>("GetListaPlan").ToList(); ViewBag.Plan = ToSelectList(plan, "1"); List <SP_GetListaPedidoDir> listaDir = new List <SP_GetListaPedidoDir>(); return(View(listaDir)); } }
public ActionResult Edit(int id = 0) { using (var db = new DBPremioEntities()) { SP_GetUsuario banco = db.Database.SqlQuery <SP_GetUsuario>("GetUsuarioID @intCodigo", new SqlParameter("intCodigo", id)).FirstOrDefault(); List <SP_Perfil> perfil = db.Database.SqlQuery <SP_Perfil>("GetPerfil").ToList(); ViewBag.Perfil = ToSelectList(perfil); ViewBag.Title = "Editar Usuario"; return(PartialView(banco)); } }
public ActionResult InicioPedidoIndex() { try { using (var db = new DBPremioEntities()) { db.Database.ExecuteSqlCommand("DeletePedidoTemp @intUsr", new SqlParameter("intUsr", int.Parse(HttpContext.User.Identity.Name))); //obtenemos el nombre de la consultora var sql = "SELECT vchNombre FROM dbo.TUsuario Where intCodigo = " + int.Parse(HttpContext.User.Identity.Name); string nombreCNS = db.Database.SqlQuery <string>(sql).FirstOrDefault(); ViewBag.Consultora = nombreCNS; //obtenemos los puntos de disponibles int puntoDisponibles = db.Database.SqlQuery <int>("GetPuntosDisponibles @intUsr", new SqlParameter("intUsr", int.Parse(HttpContext.User.Identity.Name))).FirstOrDefault(); ViewBag.puntoDisponibles = puntoDisponibles; // obtenemos el mensaje para la consultora. try { sql = "SELECT vchMensaje from TMensaje WHERE bitActivo = 1 and vchTipo = 'Mensaje Bienvenida'"; string mensaje = db.Database.SqlQuery <string>(sql).FirstOrDefault(); ViewBag.mensaje = mensaje; } catch (Exception) { ViewBag.mensaje = ""; } // verificamos si ya finalizo el pedido int pedidoExiste = db.Database.SqlQuery <int>("GetPedidoExisteUsr @intUsr", new SqlParameter("intUsr", int.Parse(HttpContext.User.Identity.Name))).FirstOrDefault(); ViewBag.pedidoExiste = pedidoExiste; return(View(db.Database.SqlQuery <SP_GetPremio>("GetPremioConsultora").ToList())); } } catch (Exception) { using (var db = new DBPremioEntities()) { List <SP_GetPremio> premioError = new List <SP_GetPremio>(); return(View(premioError)); } } }
public ActionResult EliminarGanadoras() { try { using (var db = new DBPremioEntities()) { db.Database.ExecuteSqlCommand("DeleteGanadoras"); return(Json("Se eliminó correctamente las Ganadoras.")); } } catch (Exception) { return(Json("No se pudo eliminar a las Ganadoras.")); throw; } }
public ActionResult Create(SP_GetUsuario usr) { using (var db = new DBPremioEntities()) { List <SP_Perfil> perfil = db.Database.SqlQuery <SP_Perfil>("GetPerfil").ToList(); ViewBag.Perfil = ToSelectList(perfil); db.Database.ExecuteSqlCommand("InsertUsuario @vchUsuario, @vchNombre, @intPerfil", new SqlParameter("vchUsuario", usr.vchUsuario), new SqlParameter("vchNombre", usr.vchNombre), new SqlParameter("intPerfil", usr.intPerfil)); nombreUsr = usr.vchNombre; return(Json(new { success = true })); } }
public ActionResult Inicio() { TBPremioModel obj = new TBPremioModel(); using (var db = new DBPremioEntities()) { obj.ListaNivelPremio = db.Database.SqlQuery <NivelPremio>("TBPremio_GetNiveles").ToList(); HttpCookie cookie = this.ControllerContext.HttpContext.Request.Cookies["Cookie"]; obj.ListaPremio = DAOPremio.PremioPorIdConsultora(Convert.ToInt32(cookie.Value)); var sql = "SELECT vchMensaje from TMensaje WHERE bitActivo = 1 and vchTipo = 'Mensaje Bienvenida'"; string mensaje = db.Database.SqlQuery <string>(sql).FirstOrDefault(); ViewBag.mensaje = mensaje; } return(View(obj)); }
// GET: Mensaje public ActionResult MensajeIndex() { using (var db = new DBPremioEntities()) { SP_GetMensaje mensajeCant = new SP_GetMensaje(); List <SP_GetMensaje> mensaje = db.Database.SqlQuery <SP_GetMensaje>("GetMensaje").ToList(); mensajeCant = db.Database.SqlQuery <SP_GetMensaje>("GetMensajeActivoCant").FirstOrDefault(); mensaje.ElementAt(0).Cantidad = mensajeCant.Cantidad; //if (mensajeCant.Cantidad > 1) //{ // ViewBag.cantidad = "Solo se Permite un mensaje Activo. Seleccione solo uno."; //} return(View(mensaje)); } }
public ActionResult AgregarCalendario() { try { using (var db = new DBPremioEntities()) { db.Database.ExecuteSqlCommand("AgregarCalendario @intCodUsuario", new SqlParameter("intCodUsuario", int.Parse(HttpContext.User.Identity.Name))); return(Json("Se actualizó los datos de Calendario correctamente.")); } } catch (Exception) { return(Json("No se puedo Realizar la Actualización de los Datos de Calendario.")); throw; } }
// GET: LoginCNS public ActionResult LoginCNSIndex() { List <SP_GetPremio> premio = new List <SP_GetPremio>(); using (var db = new DBPremioEntities()) { premio = db.Database.SqlQuery <SP_GetPremio>("GetPremioExiste").ToList(); } ViewBag.CantPremio = premio.Count; csLogin login = new csLogin { Usuario = "", Contrasena = "" }; return(View(login)); }
public ActionResult Edit(SP_GetMensaje ms) { using (var db = new DBPremioEntities()) { try { db.Database.ExecuteSqlCommand("UpdateMensaje @intCodigo, @vchMensaje, @bitActivo", new SqlParameter("intCodigo", ms.intCodigo), new SqlParameter("vchMensaje", ms.vchMensaje), new SqlParameter("bitActivo", ms.BitActivo)); return(Json(new { success = true })); } catch (Exception) { return(Json(new { success = false })); throw; } } }
public FileResult downloadFile() { using (XLWorkbook wb = new XLWorkbook()) { DataTable dt = new DataTable(); using (var db = new DBPremioEntities()) { List <SP_GetUsuariosReporte> lCalendario = db.Database.SqlQuery <SP_GetUsuariosReporte>("GetUsuarios").ToList(); dt = ToDataTable(lCalendario); } wb.Worksheets.Add(dt, "Calendario"); using (MemoryStream stream = new MemoryStream()) { wb.SaveAs(stream); return(File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Calendario_" + DateTime.Now.ToString() + ".xlsx")); } } }
public ActionResult ValidarIngreso(string usr, string password) { try { //creamos una clase de tipo cLoginWS que hace referencia al Web Service de corporación //llamamos al metodo de validar usuario, nos devuelve valores 0 ó 1; cLoginWS ws = new cLoginWS(); Datos data = ws.getUsuario("3", usr, password).detalle.respuesta.datos; string login = ""; if (data.flagValidacion == "0" || data.flagValidacion == null) { login = data.usuario; //ModelState.AddModelError(string.Empty, "Datos de Usuario o Contraseña incorrectos."); return(Json("Datos de Usuario o Contraseña incorrectos.")); } GetUsuarioXUsuario gusr = new GetUsuarioXUsuario(); UsuarioPerfilModel m = new UsuarioPerfilModel(); m = gusr.GetUsuarioPerfil(usr); if (m == null) { //ModelState.AddModelError(string.Empty, "Datos incorrectos. Usuario " + user.Usuario + " no registrado en el sistema."); return(Json("Datos incorrectos. Usuario " + usr + " no registrado en el sistema.")); } List <SP_GetPremio> premio = new List <SP_GetPremio>(); using (var db = new DBPremioEntities()) { premio = db.Database.SqlQuery <SP_GetPremio>("GetPremioExiste").ToList(); } if (premio.Count == 0) { //ModelState.AddModelError(string.Empty, "No existe ningún GANAMAS activo."); return(Json("No existe ningún GANAMAS activo.")); } // verificamos si ya finalizo el pedido int pedidoExiste = 0; using (var db = new DBPremioEntities()) { pedidoExiste = db.Database.SqlQuery <int>("GetPedidoExisteUsr @intUsr", new SqlParameter("intUsr", int.Parse(m.intCodigo.ToString()))).FirstOrDefault(); } if (pedidoExiste > 0) { //ViewBag.pedidoExiste = pedidoExiste; return(Json("Querida Consultora Independiente ya elegiste tu premio de forma existosa, ¡espéralo en las próximas semanas!")); } else { //FormsAuthentication.RedirectFromLoginPage(m.intCodigo.ToString(), true); //return RedirectToAction("InicioPedidoIndex", "InicioPedido"); return(Json("ok," + m.intCodigo.ToString())); } //93197 //FormsAuthentication.RedirectFromLoginPage("93197", true); } catch (Exception ex) { ModelState.AddModelError(string.Empty, "Datos de Usuario o Contraseña incorrectos."); return(Json("Datos de Usuario o Contraseña incorrectos.")); throw; } }
public ActionResult UploadFiles() { string plan = ""; using (var db = new DBPremioEntities()) { //SP_GetPremio premio = plan = db.Database.SqlQuery <string>("GetPremioPlan").FirstOrDefault(); //plan = premio.vchPlan; } if (plan == "") { return(Json("Es obligatorio cargar los premios primero antes que las Consultoras.")); } if (Request.Files.Count > 0) { try { HttpFileCollectionBase files = Request.Files; HttpPostedFileBase archivo = files[0]; if (archivo == null || archivo.ContentLength == 0) { return(Json("Seleccione un archivo Excel.")); } else { if (archivo.FileName.EndsWith("xls") || archivo.FileName.EndsWith("xlsx")) { string filename = "Ganadoras.xlsx"; string absolutePath = Server.MapPath("../Upload/" + filename); if (System.IO.File.Exists(absolutePath)) { System.IO.File.Delete(absolutePath); } archivo.SaveAs(Server.MapPath("../Upload/") + filename); if (System.IO.File.Exists(absolutePath)) { string rutaExcel = Server.MapPath("../Upload/" + filename); DataTable dt = new DataTable("Ganadoras"); var existingFile = new FileInfo(rutaExcel); using (var package = new ExcelPackage(existingFile)) { ExcelWorkbook workBook = package.Workbook; if (workBook != null) { if (workBook.Worksheets.Count > 0) { ExcelWorksheet worksheet = workBook.Worksheets.First(); ExcelCellAddress startCell = worksheet.Dimension.Start; ExcelCellAddress endCell = worksheet.Dimension.End; for (int col = startCell.Column; col <= endCell.Column; col++) { object col1Header1 = worksheet.Cells[1, col].Value; //1 dt.Columns.Add("" + col1Header1 + ""); } for (int row = 2; row <= endCell.Row; row++) { DataRow dr = dt.NewRow(); int x = 0; for (int col = startCell.Column; col <= endCell.Column; col++) { if (worksheet.Cells[row, col].Value != null) { dr[x++] = worksheet.Cells[row, col].Value; } else { return(Json("Campo vacío en la fila " + row + " columna " + col)); } if (col == 4) { if (worksheet.Cells[row, col].Value.ToString() != plan) { return(Json("El Plan cargado no Existe. Revise la fila " + row + " columna " + col)); } } if (col == 6) { if (worksheet.Cells[row, col].Value.ToString() != plan) { return(Json("La Regla cargada no coincide con el Plan en la fila " + row + " columna " + col)); } } List <int> columnas = new List <int> { 1, 2, 3, 7, 8 }; if (columnas.Contains(col)) { int entero = 0; bool sw = int.TryParse(worksheet.Cells[row, col].Value.ToString(), out entero); if (!sw) { return(Json("Debe ser un número en la fila " + row + " columna " + col)); } } // validamos que no se repita la consultora en la Tabla TConsultora //if (col == 1) //{ // using (var db = new DBPremioEntities()) // { // var sql = "SELECT COUNT(*) FROM dbo.TGanadoras where intCodigoCNS = " + worksheet.Cells[row, col].Value.ToString(); // int total = db.Database.SqlQuery<int>(sql).First(); // if (total != 0) // return Json("La consultora con Código " + worksheet.Cells[row, col].Value.ToString() + " ya existe."); // sql = "SELECT COUNT(*) FROM dbo.TConsultora where intCodigoCNS = " + worksheet.Cells[row, col].Value.ToString(); // total = db.Database.SqlQuery<int>(sql).First(); // if (total == 0) // return Json("La consultora con Código " + worksheet.Cells[row, col].Value.ToString() + " No existe en la Tabla Consultoras. Suba el Archivo excel de las Consultoras."); // } //} } dt.Rows.Add(dr); } } } } return(Json("Status de Importacion: Se subio correctamente el archivo de las Ganadoras.")); //string errorbulkcopy; //bool resultadobulkcopy; //resultadobulkcopy = CBulk.CopiarDatosBulkGanadoras(dt, "TGanadorasTemp", out errorbulkcopy); //if (resultadobulkcopy) //{ // return Json("Status de Importacion: Se subio correctamente el archivo de las Ganadoras."); //} //else //{ // return Json("Status de Importacion: Hubo un error al Importar! Verifique archivo de Excel." + errorbulkcopy); //} } else { return(Json("El Archivo no Existe.")); } } else { return(Json("Tipo incorrecto de Archivo.")); } } } catch (Exception ex) { return(Json("Error occurred. Error details: " + ex.Message)); } } else { return(Json("Seleccione un Archivo Excel.")); } }