private void btnTipo_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tx_tipo.Text) || tx_tipo.Text.Length <= 3)
            {
                lbMsg.Text = ("Ingrese Tipo de Producto.");
                tx_tipo.Focus();
                return;
            }
            TIPO_PRODUCTO tip = new TIPO_PRODUCTO();

            tip.DESCRIPCION = tx_tipo.Text;

            try
            {
                using (EntitiesHostal con = new EntitiesHostal())
                {
                    con.TIPO_PRODUCTO.Add(tip);
                    con.SaveChanges();
                }
                lbMsg.Text   = ("Tipo de Producto Ingresado.");
                tx_tipo.Text = "";
                CargarDatos();
            }
            catch (Exception ex)
            {
                lbMsg.Text = ("Tipo de Producto No ingresado Reintente.");
                Console.WriteLine("PRODUCTO;;;; " + ex);
                tx_tipo.Focus();
                return;
            }
        }
 public string ActualizarTipoProducto(int id, string nombre, int categoria)
 {
     try
     {
         TIPO_PRODUCTO   tipoProducto    = new TIPO_PRODUCTO();
         TipoProductoDAL tipoProductoDAL = new TipoProductoDAL();
         if (nombre != "" & nombre.Trim().Length > 1)
         {
             if (categoria > -1)
             {
                 tipoProducto.NOMBRE       = nombre.ToUpper();
                 tipoProducto.CATEGORIA_ID = categoria;
                 tipoProducto.ID           = id;
                 return(tipoProductoDAL.ActualizarTipoProducto(tipoProducto));
             }
             else
             {
                 return("La dirección debe tener al menos 2 caracteres");
             }
         }
         else
         {
             return("La razón social debe tener al menos 2 caracteres");
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemple #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            TIPO_PRODUCTO tIPO_PRODUCTO = db.TIPO_PRODUCTO.Find(id);

            db.TIPO_PRODUCTO.Remove(tIPO_PRODUCTO);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #4
0
 public ActionResult Edit([Bind(Include = "TIPO_PRODUCTO_ID,CODIGO_TIPO_PRODUCTO,DESCRIPCION")] TIPO_PRODUCTO tIPO_PRODUCTO)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tIPO_PRODUCTO).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tIPO_PRODUCTO));
 }
Exemple #5
0
        public ActionResult Create([Bind(Include = "TIPO_PRODUCTO_ID,CODIGO_TIPO_PRODUCTO,DESCRIPCION")] TIPO_PRODUCTO tIPO_PRODUCTO)
        {
            if (ModelState.IsValid)
            {
                db.TIPO_PRODUCTO.Add(tIPO_PRODUCTO);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tIPO_PRODUCTO));
        }
Exemple #6
0
        // GET: /TIPO_PRODUCTO/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TIPO_PRODUCTO tIPO_PRODUCTO = db.TIPO_PRODUCTO.Find(id);

            if (tIPO_PRODUCTO == null)
            {
                return(HttpNotFound());
            }
            return(View(tIPO_PRODUCTO));
        }
Exemple #7
0
        public bool Delete()
        {
            try
            {
                TIPO_PRODUCTO tproducto = CommonBC.DBConexion.TIPO_PRODUCTO.First(tp => tp.ID == this.Id);
                CommonBC.DBConexion.TIPO_PRODUCTO.Remove(tproducto);
                CommonBC.DBConexion.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #8
0
        public bool Read()
        {
            try
            {
                TIPO_PRODUCTO tproducto = CommonBC.DBConexion.TIPO_PRODUCTO.First(tp => tp.ID == this.Id);
                this.Secuencia         = (int)tproducto.SECUENCIA;
                this.Descripcion       = tproducto.DESCRIPCION;
                this.FamiliaProductoId = (int)tproducto.FAMILIA_PRODUCTO_ID;

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #9
0
 public bool delete()
 {
     try
     {
         using (var comun = new Common().modelo)
         {
             TIPO_PRODUCTO tp = comun.TIPO_PRODUCTO.Where(tpp => tpp.TP_ID == this.id).First();
             comun.TIPO_PRODUCTO.Remove(tp);
             comun.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #10
0
        public bool Update()
        {
            try
            {
                TIPO_PRODUCTO tproducto = CommonBC.DBConexion.TIPO_PRODUCTO.First(tp => tp.ID == this.Id);
                tproducto.SECUENCIA           = this.Secuencia;
                tproducto.DESCRIPCION         = this.Descripcion;
                tproducto.FAMILIA_PRODUCTO_ID = this.FamiliaProductoId;
                CommonBC.DBConexion.Entry(tproducto).State = System.Data.EntityState.Modified;
                CommonBC.DBConexion.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #11
0
        public static TipoProducto getByIdStatic(decimal id)
        {
            try
            {
                TipoProducto p = new TipoProducto();
                using (var comun = new Common().modelo)
                {
                    TIPO_PRODUCTO pp = comun.TIPO_PRODUCTO.First(tpp => tpp.TP_ID == id);

                    p.id     = pp.TP_ID;
                    p.nombre = pp.TP_NOMBRE;
                }
                return(p);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
Exemple #12
0
 public bool save()
 {
     try
     {
         TIPO_PRODUCTO tp = new TIPO_PRODUCTO();
         tp.TP_ID     = id;
         tp.TP_NOMBRE = nombre;
         using (var comun = new Common().modelo)
         {
             comun.TIPO_PRODUCTO.Add(tp);
             comun.SaveChanges();
         }
         return(true);
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
Exemple #13
0
        public bool Create()
        {
            try
            {
                TIPO_PRODUCTO tproducto = new TIPO_PRODUCTO();
                tproducto.ID                  = this.Id;
                tproducto.SECUENCIA           = this.Secuencia;
                tproducto.DESCRIPCION         = this.Descripcion;
                tproducto.FAMILIA_PRODUCTO_ID = this.FamiliaProductoId;
                CommonBC.DBConexion.TIPO_PRODUCTO.Add(tproducto);
                CommonBC.DBConexion.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }