예제 #1
0
        public bool InsertarPrecioProducto(PrecioProductoBe preProductoBe)
        {
            _cnx.ConnectionString = _miConexion.GetCnx();
            _cmd.Connection = _cnx;
            _cmd.CommandType = CommandType.StoredProcedure;
            _cmd.CommandText = "SP_InsertPrecioProducto";

            try
            {
                _cmd.Parameters.Add(new SqlParameter("@Id_Producto", SqlDbType.Char, 7));
                _cmd.Parameters["@Id_Producto"].Value = preProductoBe.IdProducto;
                _cmd.Parameters.Add(new SqlParameter("@Precio", SqlDbType.Decimal));
                _cmd.Parameters["@Precio"].Value = preProductoBe.Precio;
                _cnx.Open();
                _cmd.ExecuteNonQuery();
                _vexito = true;
            }
            catch (SqlException)
            {
                _vexito = false;
            }
            finally
            {
                if (_cnx.State == ConnectionState.Open)
                {
                    _cnx.Close();
                }
                _cmd.Parameters.Clear();
            }
            return _vexito;
        }
예제 #2
0
 private void cboProducto_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (cboProducto.SelectedIndex !=-1)
     {
         txtPrecio.Clear();
         var idProd = cboProducto.SelectedValue.ToString();
         _miStPreProd = _miPreProd.ConsultarPrecio(idProd);
         txtPrecio.Text = _miStPreProd.Precio.ToString();
     }
 }
예제 #3
0
        public PrecioProductoBe ConsultarPrecio(string idProd)
        {
            var pProductoBe = new PrecioProductoBe();
            try
            {
                _cnx.ConnectionString = _miConexion.GetCnx();
                _cmd.Connection = _cnx;
                _cmd.CommandType = CommandType.StoredProcedure;
                _cmd.CommandText = "SP_ConsultaPrecio";

                _cmd.Parameters.Add(new SqlParameter("@Producto", SqlDbType.Char, 7));
                _cmd.Parameters["@Producto"].Value = idProd;
                _cnx.Open();
                var dtr = _cmd.ExecuteReader();

                if (dtr.HasRows)
                {
                    dtr.Read();
                    pProductoBe.IdProducto = dtr.GetValue(dtr.GetOrdinal("Id_Producto")).ToString();
                    pProductoBe.IdPrecioProducto =int.Parse(dtr.GetValue(dtr.GetOrdinal("Id_PrecioProducto")).ToString());
                    pProductoBe.Precio = double.Parse(dtr.GetValue(dtr.GetOrdinal("Precio")).ToString());
                    dtr.Close();
                }
            }
            catch (SqlException ex)
            {
                throw new Exception(ex.Message);
            }
            finally
            {
                if (_cnx.State == ConnectionState.Open)
                {
                    _cnx.Close();
                }
                _cmd.Parameters.Clear();
            }
            return pProductoBe;
        }
예제 #4
0
 public bool InsertarPrecioProducto(PrecioProductoBe pProdBe)
 {
     return _pProdAdo.InsertarPrecioProducto(pProdBe);
 }