Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                return;
            }


            string strId = Request.QueryString["id"];

            if (string.IsNullOrEmpty(strId))
            {
                return;
            }
            try
            {
                int contactoId = Convert.ToInt32(strId);
                entidadProducto = reglaNegocioProducto.Select(contactoId);


                NombreTextBox.Text          = entidadProducto.Nombre;
                PrecioTextBox.Text          = (entidadProducto.Precio).ToString();
                ProductoIdHiddenField.Value = strId;
            }
            catch (Exception ex)
            {
            }
        }
Exemple #2
0
        /// <summary>
        /// Creates a new instance of the tbl_producto class and populates it with data from the specified SqlDataReader.
        /// </summary>
        protected virtual EN_Tbl_producto MakeEN_Tbl_producto(SqlDataReader dataReader)
        {
            EN_Tbl_producto oeN_Tbl_producto = new EN_Tbl_producto();

            oeN_Tbl_producto.Producto_id = dataReader.IsDBNull(dataReader.GetOrdinal("producto_id"))? 0 : dataReader.GetInt32(dataReader.GetOrdinal("producto_id"));
            oeN_Tbl_producto.Nombre      = dataReader.IsDBNull(dataReader.GetOrdinal("nombre"))? String.Empty : dataReader.GetString(dataReader.GetOrdinal("nombre"));
            oeN_Tbl_producto.Precio      = dataReader.IsDBNull(dataReader.GetOrdinal("precio"))? 0 : dataReader.GetInt32(dataReader.GetOrdinal("precio"));

            return(oeN_Tbl_producto);
        }
Exemple #3
0
        /// <summary>
        /// Actualizar datos en la Entidad EN_Tbl_producto
        /// </summary>
        public string Update(EN_Tbl_producto tbl_producto)
        {
            string resultado = oAD_Tbl_producto.Update(tbl_producto);

            if (resultado.Contains("Error"))
            {
                return(resultado);
            }
            else
            {
                return(resultado);
            }
        }
Exemple #4
0
        /// <summary>
        /// Selects all records from the tbl_producto table.
        /// </summary>
        public virtual List <EN_Tbl_producto> SelectAllList()
        {
            using (SqlDataReader dataReader = SqlHelper.ExecuteReader(cn, CommandType.StoredProcedure, "sp_tbl_productoSelectAll"))
            {
                List <EN_Tbl_producto> tbl_productoList = new List <EN_Tbl_producto>();
                while (dataReader.Read())
                {
                    EN_Tbl_producto tbl_producto = MakeEN_Tbl_producto(dataReader);
                    tbl_productoList.Add(tbl_producto);
                }

                return(tbl_productoList);
            }
        }
Exemple #5
0
        /// <summary>
        /// Actualizar filas en tbl_producto table.
        /// </summary>
        public virtual string Update(EN_Tbl_producto tbl_producto)
        {
            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@producto_id", (tbl_producto.Producto_id == 0)?Convert.DBNull:tbl_producto.Producto_id),
                new SqlParameter("@nombre", (tbl_producto.Nombre == String.Empty)?Convert.DBNull:tbl_producto.Nombre),
                new SqlParameter("@precio", (tbl_producto.Precio == 0)?Convert.DBNull:tbl_producto.Precio)
            };

            try
            {
                SqlHelper.ExecuteNonQuery(cn, CommandType.StoredProcedure, "sp_tbl_productoUpdate", parameters);
                return("Operacion Exitosa");
            }
            catch (Exception e)
            {
                return("Error: " + e);
            }
        }
Exemple #6
0
        /// <summary>
        /// Insertar filas dentro de la tablatbl_producto
        /// </summary>
        public virtual string Insert(EN_Tbl_producto tbl_producto)
        {
            SqlCommand comComando = new SqlCommand();

            comComando.Connection = cn;

            SqlParameter[] parameters = new SqlParameter[]
            {
                new SqlParameter("@nombre", (tbl_producto.Nombre == String.Empty)?Convert.DBNull:tbl_producto.Nombre),
                new SqlParameter("@precio", (tbl_producto.Precio == 0)?Convert.DBNull:tbl_producto.Precio)
            };

            try
            {
                int CodigoIdentity = -1;
                tbl_producto.Producto_id = (int)SqlHelper.ExecuteScalar(cn, CommandType.StoredProcedure, "sp_tbl_productoInsert", parameters);
                CodigoIdentity           = tbl_producto.Producto_id;
                return("Operacion Exitosa " + CodigoIdentity);
            }
            catch (Exception e)
            {
                return("Error: " + e);
            }
        }