コード例 #1
0
ファイル: AddProdForm.cs プロジェクト: Mav3ricK-99/1erParcial
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            string      nombreProd = this.txtBoxNombre.Text;
            ECategorias categoria  = (ECategorias)this.cmBoxCategoria.SelectedItem;
            float       precioProd;
            int         stockProd;

            if (float.TryParse(this.txtBoxPrecio.Text, out precioProd) && int.TryParse(this.txtBoxStock.Text, out stockProd))
            {
                Producto nuevoProducto = new Producto(nombreProd, precioProd, categoria, stockProd);
                if (Negocio.InvNegocio + nuevoProducto)
                {
                    MessageBox.Show($"Producto agregado al inventario |ID - {nuevoProducto.IdProducto}|", "Agregado!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show($"Ya hay un producto con el mismo nombre y con la misma Categoria.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("Verifique los datos Ingresados", "Error al cargar el producto");
            }
        }
コード例 #2
0
ファイル: Producto.cs プロジェクト: Mav3ricK-99/1erParcial
 public Producto(string nombreProducto, float precioProducto, ECategorias categoriaProducto, int stockProducto) : this(nombreProducto, precioProducto)
 {
     this.nombreProducto    = nombreProducto;
     this.precioProducto    = precioProducto;
     this.categoriaProducto = categoriaProducto;
     this.stockProducto     = stockProducto;
 }
コード例 #3
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            ECategorias obj = new ECategorias
            {
                ID          = lblID.Text.Length == 0 ? 0 : int.Parse(lblID.Text),
                Nombre      = txtNombre.Text.Trim().ToUpper(),
                Descripcion = txtDescripcion.Text.Trim().ToUpper(),
                Estado      = chkEstado.Checked
            };

            int rpta = 0;

            if (operacion == (byte)MisConstantes.OPERACION.Insercion)
            {
                rpta = new LCategorias().Create(obj);
            }
            else
            {
                rpta = new LCategorias().Update(obj);
            }

            if (rpta > 0)
            {
                MessageBox.Show("operacion realizada correctamente", "AVISO", MessageBoxButtons.OK, MessageBoxIcon.Information);

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            else
            {
                MessageBox.Show("la categoria ya existe");
            }
        }
コード例 #4
0
ファイル: Producto.cs プロジェクト: Mav3ricK-99/1erParcial
 public Producto()
 {
     this.nombreProducto    = "Sin nombre.";
     this.precioProducto    = -1;
     this.categoriaProducto = 0;
     this.stockProducto     = -1;
     this.cantVendidos      = 0;
 }
コード例 #5
0
        public int Create(ECategorias t)
        {
            using (SqlConnection cnx = new SqlConnection())
            {
                cnx.ConnectionString = MiCadena.CadenaCnx();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "usp_Categoria_ICreate";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@Nombre", t.Nombre);
                cmd.Parameters.AddWithValue("@Descripcion", t.Descripcion);
                cmd.Parameters.AddWithValue("@Estado", t.Estado);
                cmd.Connection = cnx;
                cnx.Open();


                int filasafectadas = cmd.ExecuteNonQuery();

                return(filasafectadas);
            }
        }
コード例 #6
0
ファイル: Producto.cs プロジェクト: Mav3ricK-99/1erParcial
 public Producto(string nombreProducto, float precioProducto, ECategorias categoriaProducto, int stockProducto, int cantVendidos) : this(nombreProducto, precioProducto, categoriaProducto, stockProducto)
 {
     this.cantVendidos = cantVendidos;
 }
コード例 #7
0
ファイル: LCategorias.cs プロジェクト: antonevj/HTGBodega
 public int Update(ECategorias t)
 {
     return(new DCategorias().Update(t));
 }
コード例 #8
0
ファイル: LCategorias.cs プロジェクト: antonevj/HTGBodega
 //llamar de DCategorias
 public int Create(ECategorias t)
 {
     return(new DCategorias().Create(t));
 }