Exemplo n.º 1
0
        public bool Insertar(ENCanales oENCanal)
        {
            DbCommand oCommand = null /* TODO Change to default(_) if this is not a reference type */;

            try
            {
                oCommand = GenericDataAccess.CreateCommand(dataProviderName, connectionString, "usp_GenCanales_ins");
                GenericDataAccess.AgregarParametro(oCommand, "@argDescripcionCanal", oENCanal.DescripcionCanal, TipoParametro.STR, Direccion.INPUT);
                GenericDataAccess.AgregarParametro(oCommand, "@argIDSociedad", oENCanal.IdSociedad, TipoParametro.INT, Direccion.INPUT);
                GenericDataAccess.AgregarParametro(oCommand, "@argErrorCode", 1, TipoParametro.INT, Direccion.OUTPUT);
                if (GenericDataAccess.ExecuteNonQuery(oCommand) > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new Excepciones.ManejoExcepciones(ex);
            }
            finally
            {
                GenericDataAccess.CerrarConexion(oCommand, null /* TODO Change to default(_) if this is not a reference type */);
            }
        }
Exemplo n.º 2
0
        public ENCanales ObtenerUno(int id)
        {
            DbCommand oCommand   = null;
            ENCanales oENCanales = new ENCanales();

            try
            {
                oCommand = GenericDataAccess.CreateCommand(dataProviderName, connectionString, "usp_GenCanales_Sel_uno");
                GenericDataAccess.AgregarParametro(oCommand, "@argIDCanal", id, TipoParametro.INT, Direccion.INPUT);
                GenericDataAccess.AgregarParametro(oCommand, "@argErrorCode", 1, TipoParametro.INT, Direccion.OUTPUT);
                DbDataReader oDataReader = GenericDataAccess.ExecuteReader(oCommand);
                if (oDataReader.Read())
                {
                    //ENCanales oEnListaCanales = new ENCanales();
                    oENCanales.DescripcionCanal = oDataReader["DescripcionCanal"].ToString();
                    oENCanales.IDCanal          = Convert.ToInt32(oDataReader["IDCanal"]);
                    oENCanales.IdSociedad       = Convert.ToInt32(oDataReader["IdSociedad"]);
                    oENCanales.IdPersona        = Convert.ToInt32(oDataReader["IdPersona"]);
                    oENCanales.RazonSocial      = oDataReader["RazonSocial"].ToString();
                }
                return(oENCanales);
            }
            catch (Exception ex)
            {
                throw new Exception();
            }
            finally
            {
                GenericDataAccess.CerrarConexion(oCommand, null);
            }
        }
Exemplo n.º 3
0
 public ActionResult AddOrEdit(int id = 0)
 {
     if (id == 0)
     {
         ViewBag.IdSociedad = new SelectList(LNSociedades.ObtenerTodos().ToList(), "IdSociedad", "RazonSocial");
         var ENCanales = new ENCanales();
         return(View(ENCanales));
     }
     else
     {
         ENCanales mCanalEditar = LNCanales.ObtenerTodos().Find(smodel => smodel.IDCanal == id);
         ViewBag.IdSociedad = new SelectList(LNSociedades.ObtenerTodos().ToList(), "IdSociedad", "RazonSocial", mCanalEditar.IdSociedad);
         return(View(mCanalEditar));
     }
 }
Exemplo n.º 4
0
 public ActionResult AddOrEdit(ENCanales canal)
 {
     if (ModelState.IsValid)
     {
         if (canal.IDCanal > 0)
         {
             LNCanales.Actualizar(canal);
         }
         else
         {
             LNCanales.Insertar(canal);
         }
         return(RedirectToAction("Index", "Canales"));
     }
     return(View());
 }
Exemplo n.º 5
0
        public ActionResult AddOrEdit(int id = 0)

        {
            ENCanales oENCanales = null;

            ViewBag.IdSociedad = new SelectList(LNSociedades.ObtenerTodos().ToList(), "IdSociedad", "RazonSocial");
            if (id > 0)
            {
                oENCanales         = LNCanales.ObtenerUno(id);
                ViewBag.IdSociedad = new SelectList(LNSociedades.ObtenerTodos().ToList(), "IdSociedad", "RazonSocial", oENCanales.IdSociedad);
            }
            else
            {
                oENCanales = new ENCanales();
            }
            return(View(oENCanales));
        }
Exemplo n.º 6
0
 public ActionResult AddOrEdit(ENCanales pla)
 {
     if (pla.IDCanal == 0)
     {
         if (LNCanales.Insertar(pla))
         {
             ViewBag.Message = "Registro Grabado Correctamente";
             ModelState.Clear();
         }
         return(Json(new { success = true, message = "Grabado Correctamente" }, JsonRequestBehavior.AllowGet));
     }
     else
     {
         if (LNCanales.Actualizar(pla))
         {
             ViewBag.Message = "Registro Grabado Correctamente";
             ModelState.Clear();
         }
         return(Json(new { success = true, message = "Actualizado Correctamente" }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 7
0
 public static bool Actualizar(ENCanales oENCanales)
 {
     return((new ADCanales()).Actualizar(oENCanales));
 }
Exemplo n.º 8
0
 public static bool Insertar(ENCanales oENCanales)
 {
     return((new ADCanales()).Insertar(oENCanales));
 }