public ActionResult PremioEliminar(TBPremioModel model) { TBPremioModel obj = new TBPremioModel(); DAOPremio.PremioEliminar(model.intPremio); return(RedirectToAction("Index", "PremioNew")); }
public ActionResult PremioGuardarPartial(TBPremioModel model) { try { if (model.intPremio > 0) { model.intCampaña = model.SelectedCampañaNuevoEditarId; DAOPremio.Update(ref model); if (model.Error != null) { TempData["Error"] = model.Error; } } else { DAOPremio.Add(model); } } catch (Exception ex) { return(RedirectToAction("Index", "PremioNew")); } return(RedirectToAction("Index", "PremioNew")); }
public ActionResult Index() { TBPremioModel obj = CargaDatosInicial(); if (TempData["Error"] != null) { ViewBag.MensajeError = TempData["Error"].ToString(); } return(View(obj)); }
private static TBPremioModel CreateTBPremioFromDataRowShared(DataRow dr) { TBPremioModel objTBPremio = new TBPremioModel(); objTBPremio.intPremio = (int)dr["intPremio"]; objTBPremio.intCodigoSAP = (int)dr["intCodigoSAP"]; objTBPremio.intCodigoCorto = (int)dr["intCodigoCorto"]; objTBPremio.intOrden = (int)dr["intOrden"]; objTBPremio.vchTitulo = dr["vchTitulo"].ToString(); objTBPremio.vchDescripcion = dr["vchDescripcion"].ToString(); objTBPremio.smintStock = (Int32)dr["smintStock"]; objTBPremio.smintStockrReal = (Int32)dr["smintStockrReal"]; objTBPremio.smintPuntos = (Int32)dr["smintPuntos"]; if (dr["bitActivo"] != System.DBNull.Value) { objTBPremio.bitActivo = (bool)dr["bitActivo"]; } else { objTBPremio.bitActivo = false; } objTBPremio.dttmFecha = (DateTime)dr["dttmFecha"]; objTBPremio.intUsr = (int)dr["intUsr"]; if (dr["intNivel"] != System.DBNull.Value) { objTBPremio.intNivel = (int)dr["intNivel"]; } //else // objTBPremio.intNivel = null; if (dr["bitInicial"] != System.DBNull.Value) { objTBPremio.bitInicial = (bool)dr["bitInicial"]; } else { objTBPremio.bitInicial = false; } if (dr["intCampaña"] != System.DBNull.Value) { objTBPremio.intCampaña = (int)dr["intCampaña"]; } else { objTBPremio.intCampaña = null; } objTBPremio.AniosNuevoEditarId = Convert.ToInt32(dr["smintAnio"]); return(objTBPremio); }
public static void Update(ref TBPremioModel model) { SqlCommand command = new SqlCommand(); command.CommandText = "TBPremio_Update"; command.CommandType = CommandType.StoredProcedure; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; try { staticConnection.Open(); command.Parameters.AddWithValue("@intPremio", model.intPremio); command.Parameters.AddWithValue("@intCodigoSAP", model.intCodigoSAP); command.Parameters.AddWithValue("@intCodigoCorto", model.intCodigoCorto); command.Parameters.AddWithValue("@intOrden", model.intOrden); command.Parameters.AddWithValue("@vchTitulo", model.vchTitulo); command.Parameters.AddWithValue("@vchDescripcion", model.vchDescripcion); command.Parameters.AddWithValue("@smintStock", model.smintStock); command.Parameters.AddWithValue("@smintStockrReal", model.smintStockrReal); command.Parameters.AddWithValue("@smintPuntos", model.smintPuntos); command.Parameters.AddWithValue("@bitActivo", model.bitActivo); command.Parameters.AddWithValue("@dttmFecha", DateTime.Now); command.Parameters.AddWithValue("@intUsr", 1); command.Parameters.AddWithValue("@intNivel", model.intNivel); command.Parameters.AddWithValue("@bitInicial", model.bitInicial); command.Parameters.AddWithValue("@intCampaña", model.intCampaña); SqlParameter ParmError = new SqlParameter("@Error", SqlDbType.NVarChar, 50); ParmError.Direction = ParameterDirection.Output; command.Parameters.Add(ParmError); command.ExecuteNonQuery(); if (!Convert.IsDBNull(command.Parameters["@Error"].Value)) { model.Error = command.Parameters["@Error"].Value.ToString(); } } catch (Exception ex) { throw; } finally { command.Dispose(); } }
private TBPremioModel CargaDatosInicial() { TBPremioModel obj = new TBPremioModel(); List <SelectListItem> ListaCampaña = new List <SelectListItem>(); ListaCampaña.Add(new SelectListItem { Text = "--Seleccione una campaña--", Value = "0" }); obj.ListaCampaña = new SelectList(ListaCampaña, "Value", "Text"); obj.ListaNivelPremio = new List <NivelPremio>(); obj.ListaPremio = new List <TBPremioModel>(); obj.ListaAnios = new SelectList(DAOCampaña.ListaAñios(), "Value", "Text"); return(obj); }
public ActionResult PremioEliminarPartial(Int32 intPremio) { TBPremioModel obj = new TBPremioModel(); obj = DAOPremio.PremioPorIdPremio(intPremio); obj.ListaAnios = new SelectList(DAOCampaña.ListaAñios(), "Value", "Text"); obj.AniosNuevoEditarId = Convert.ToInt32(obj.AniosNuevoEditarId); obj.ListaCampaña = new SelectList(DAOCampaña.ListaCampañasPorAño(obj.AniosNuevoEditarId.ToString()), "Value", "Text"); obj.SelectedCampañaNuevoEditarId = Convert.ToInt32(obj.intCampaña); return(PartialView("PremioEliminarPartial", obj)); }
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)); }
public ActionResult UploadImg() { if (Request.Files.Count > 0) { //try //{ HttpFileCollectionBase files = Request.Files; HttpPostedFileBase archivo = files[0]; if (archivo == null || archivo.ContentLength == 0) { return(Json("Seleccione una Imagen.")); } else { if (archivo.FileName.EndsWith("jpg") || archivo.FileName.EndsWith("jpeg") || archivo.FileName.EndsWith("png")) { byte[] byteImg = null; using (BinaryReader br = new BinaryReader(archivo.InputStream)) { byteImg = br.ReadBytes(archivo.ContentLength); br.BaseStream.Read(byteImg, 0, archivo.ContentLength); } string intPremio = Request.Form["intPremio"].ToString(); Int32 SelectedCampañaId = Convert.ToInt32(Request.Form["intCampana"]); TBImage objImage = new TBImage(); objImage.vchNombre = archivo.FileName.ToString(); objImage.vchImagen = byteImg; objImage.intPremio = Convert.ToInt32(intPremio); objImage.vchExtencion = Path.GetExtension(archivo.FileName); DAOImage.Update(objImage); } ; } } TBPremioModel obj = CargaDatosInicial(); return(View("Index", obj)); }
public static TBPremioModel PremioPorIdPremio(int intPremio) { SqlCommand command = new SqlCommand(); command.CommandText = "TBPremio_SelectPorintPremio"; command.CommandType = CommandType.StoredProcedure; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; TBPremioModel obj = new TBPremioModel(); DataTable dt = new DataTable("tb"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.AddWithValue("@intPremio", intPremio); staticConnection.Open(); sqlAdapter.Fill(dt); if (dt.Rows.Count > 0) { obj = CreateTBPremioFromDataRowShared(dt.Rows[0]); } return(obj); } catch (Exception ex) { throw; } finally { staticConnection.Close(); command.Dispose(); } }
public ActionResult Busqueda(TBPremioModel objModel) { TBPremioModel obj = new TBPremioModel(); obj.ListaPremio = DAOPremio.ListaPremioPorCampaña(objModel.SelectedCampañaId); obj.ListaNivelPremio = DAOPremio.ListaNivelPorCampaña(objModel.SelectedCampañaId); List <TBCampañaModel> ListaCampaña = DAOCampaña.SelectAll(); obj.ListaCampaña = new SelectList(ListaCampaña, "intCampaña", "vchDescripcion"); obj.SelectedCampañaId = objModel.SelectedCampañaId; if (Request.IsAjaxRequest()) { return(PartialView("_DetallePremio", obj)); } return(View("Index", obj)); }
public static void Add(TBPremioModel model) { SqlCommand command = new SqlCommand(); command.CommandText = "TBPremio_Insert"; command.CommandType = CommandType.StoredProcedure; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; try { staticConnection.Open(); command.Parameters.AddWithValue("@intCodigoSAP", model.intCodigoSAP); command.Parameters.AddWithValue("@intCodigoCorto", model.intCodigoCorto); command.Parameters.AddWithValue("@intOrden", 0); command.Parameters.AddWithValue("@vchTitulo", model.vchTitulo); command.Parameters.AddWithValue("@vchDescripcion", model.vchDescripcion); command.Parameters.AddWithValue("@smintStock", model.smintStock); command.Parameters.AddWithValue("@smintStockrReal", model.smintStock); command.Parameters.AddWithValue("@smintPuntos", model.smintPuntos); command.Parameters.AddWithValue("@bitActivo", model.bitActivo); command.Parameters.AddWithValue("@dttmFecha", DateTime.Now); command.Parameters.AddWithValue("@intUsr", 1); command.Parameters.AddWithValue("@intNivel", model.intNivel); command.Parameters.AddWithValue("@bitInicial", model.bitInicial); command.Parameters.AddWithValue("@intCampaña", model.SelectedCampañaNuevoEditarId); command.ExecuteNonQuery(); } catch (Exception ex) { throw; } finally { staticConnection.Close(); command.Dispose(); } }
public ActionResult Index(TBPremioModel model) { return(View()); }
public ActionResult Index() { TBPremioModel obj = CargaDatosInicial(); return(View(obj)); }
public ActionResult PremioNuevoPartial() { TBPremioModel obj = CargaDatosInicial(); return(PartialView("PremioNuevoPartial", obj)); }
public static List <TBPremioModel> ListaPremioPorCampaña(Int32 intCampaña) { SqlCommand command = new SqlCommand(); command.CommandText = "TBPremio_PorCampaña"; command.CommandType = CommandType.StoredProcedure; SqlConnection staticConnection = StaticSqlConnection; command.Connection = staticConnection; DataTable dt = new DataTable("tb"); SqlDataAdapter sqlAdapter = new SqlDataAdapter(command); try { command.Parameters.AddWithValue("@intCampaña", intCampaña); staticConnection.Open(); sqlAdapter.Fill(dt); List <TBPremioModel> objLista = new List <TBPremioModel>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { TBPremioModel obj = new TBPremioModel(); obj.intPremio = Convert.ToInt32(row["intPremio"]); obj.intCodigoSAP = Convert.ToInt32(row["intCodigoSAP"]); obj.intCodigoCorto = Convert.ToInt32(row["intCodigoCorto"]); obj.intOrden = Convert.ToInt32(row["intOrden"]); obj.vchTitulo = (String)row["vchTitulo"]; obj.vchDescripcion = (String)row["vchDescripcion"]; obj.smintStock = Convert.ToInt32(row["smintStock"]); obj.smintStockrReal = Convert.ToInt32(row["smintStockrReal"]); obj.smintPuntos = Convert.ToInt32(row["smintPuntos"]); obj.bitActivo = (Boolean)row["bitActivo"]; obj.dttmFecha = (DateTime)row["dttmFecha"]; obj.intUsr = Convert.ToInt32(row["intUsr"]); obj.intNivel = Convert.ToInt32(row["intNivel"]); obj.intCampaña = Convert.ToInt32(row["intCampaña"]); obj.bitSeleccionado = Convert.ToBoolean(row["bitSeleccionado"]); obj.NombreImagen = row["NombreImagen"].ToString(); //if (row["Imagen"]!=null) //{ // obj.Imagen = (byte[])row["Imagen"]; //} obj.Imagen = Convert.IsDBNull(row["Imagen"]) ? null : (byte[])row["Imagen"]; //obj.intPedido = Convert.ToInt32(row["intPedido"]); //obj.intPedidoDetalle = Convert.ToInt32(row["intPedidoDetalle"]); objLista.Add(obj); } } return(objLista); } catch (Exception ex) { throw; } finally { staticConnection.Close(); command.Dispose(); } }