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"); } }
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; }
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"); } }
public Producto() { this.nombreProducto = "Sin nombre."; this.precioProducto = -1; this.categoriaProducto = 0; this.stockProducto = -1; this.cantVendidos = 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); } }
public Producto(string nombreProducto, float precioProducto, ECategorias categoriaProducto, int stockProducto, int cantVendidos) : this(nombreProducto, precioProducto, categoriaProducto, stockProducto) { this.cantVendidos = cantVendidos; }
public int Update(ECategorias t) { return(new DCategorias().Update(t)); }
//llamar de DCategorias public int Create(ECategorias t) { return(new DCategorias().Create(t)); }