示例#1
0
        public static int AgregarProductos(entProductos obj)
        {
            int        indicador = 0;
            SqlCommand cmd       = null;

            try
            {
                daoConexion   cn  = new daoConexion();
                SqlConnection cnx = cn.conectar();
                cmd = new SqlCommand("SP_TRANSAC_PRODUCTOS", cnx);
                cmd.Parameters.AddWithValue("@Operacion", obj.Operacion);
                cmd.Parameters.AddWithValue("@id", obj.id);
                cmd.Parameters.AddWithValue("@nombre", obj.nombre);
                cmd.Parameters.AddWithValue("@descripcion", obj.descripcion);
                cmd.Parameters.AddWithValue("@valor", obj.valor);
                cmd.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                cmd.ExecuteNonQuery();
                indicador = 1;
            }
            catch (Exception ex)
            {
                throw ex;
                //indicador = 0;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(indicador);
        }
示例#2
0
 protected void btnguardar_Click(object sender, EventArgs e)
 {
     try
     {
         if (txbnombre.Value != "" || txbdesc.Value != "" || txbval.Value != "")
         {
             entProductos obj = new entProductos();
             obj.Operacion   = 1;
             obj.id          = Convert.ToInt32(Session["IdProducto"]);
             obj.nombre      = txbnombre.Value;
             obj.descripcion = txbdesc.Value;
             obj.valor       = txbval.Value;
             if (negProductos.AgregarProductos(obj) == 1)
             {
                 ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "Guardado()", true);
                 LimpiarCampos();
                 pnlagregarproducto.Visible = false;
                 btnnuevopro.Visible        = true;
                 CargarGrillaProductos();
                 Session["IdProducto"] = "0";
             }
         }
         else
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "Popup", "sindatos()", true);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#3
0
        public static entProductos ListarProductosEditar(int operacion, int idpro)
        {
            SqlCommand    cmd = null;
            SqlDataReader dr  = null;
            entProductos  obj = null;

            try
            {
                daoConexion   cn  = new daoConexion();
                SqlConnection cnx = cn.conectar();
                cmd = new SqlCommand("SP_TRANSAC_PRODUCTOS", cnx);
                cmd.Parameters.AddWithValue("@Operacion", operacion);
                cmd.Parameters.AddWithValue("@id", idpro);
                cmd.Parameters.AddWithValue("@nombre", "");
                cmd.Parameters.AddWithValue("@descripcion", "");
                cmd.Parameters.AddWithValue("@valor", "");
                cmd.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                dr  = cmd.ExecuteReader();
                obj = new entProductos();
                dr.Read();
                entProductos c = new entProductos();
                obj.id          = Convert.ToInt32(dr["id"].ToString());
                obj.nombre      = dr["nombre"].ToString();
                obj.descripcion = dr["descripcion"].ToString();
                obj.valor       = dr["valor"].ToString();
            }
            catch (Exception e)
            {
                throw e;
                //listacom = null;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(obj);
        }
示例#4
0
        public static List <entProductos> ListarProductos()
        {
            SqlCommand          cmd      = null;
            SqlDataReader       dr       = null;
            List <entProductos> listapro = null;

            try
            {
                daoConexion   cn  = new daoConexion();
                SqlConnection cnx = cn.conectar();
                cmd             = new SqlCommand("SP_CARGAR_PRODUCTOS", cnx);
                cmd.CommandType = CommandType.StoredProcedure;
                cnx.Open();
                dr       = cmd.ExecuteReader();
                listapro = new List <entProductos>();
                while (dr.Read())
                {
                    entProductos c = new entProductos();
                    c.id          = Convert.ToInt32(dr["id"].ToString());
                    c.nombre      = dr["nombre"].ToString();
                    c.descripcion = dr["descripcion"].ToString();
                    c.valor       = dr["valor"].ToString();

                    listapro.Add(c);
                }
            }
            catch (Exception e)
            {
                throw e;
                //listacom = null;
            }
            finally
            {
                cmd.Connection.Close();
            }
            return(listapro);
        }
示例#5
0
 protected void btneditar_Click(object sender, EventArgs e)
 {
     try
     {
         Button      btneditar     = (Button)sender;
         TableCell   grvproductose = (TableCell)btneditar.Parent;
         GridViewRow row           = (GridViewRow)grvproductose.Parent;
         grvproductos.SelectedIndex = row.RowIndex;
         int fila  = row.RowIndex;
         int idpro = int.Parse(grvproductos.Rows[fila].Cells[0].Text);
         Session["IdProducto"] = idpro;
         int          operacion = 2;
         entProductos obj       = negProductos.ListarProductosEditar(operacion, idpro);
         txbnombre.Value            = obj.nombre;
         txbdesc.Value              = obj.descripcion;
         txbval.Value               = obj.valor;
         pnlagregarproducto.Visible = true;
         btnnuevopro.Visible        = false;
     }
     catch (Exception EX)
     {
         throw EX;
     }
 }
示例#6
0
 public static int AgregarProductos(entProductos obj)
 {
     return(daoProductos.AgregarProductos(obj));
 }