Пример #1
0
        protected void btnAgregar_Click(object sender, EventArgs e)
        {
            NegocioProducto neg    = new NegocioProducto();
            int             stock  = Convert.ToInt32(TxtStock.Text);
            bool            estado = false;
            decimal         Precio = Convert.ToDecimal(txtprecio.Text);

            estado = neg.agregarProducto(txtcodpro.Text, Precio, stock, txtcategoria.Text, txtcategoria.Text, txtImagen.Text);
            if (estado == true)
            {
                lblSelecciono.Text = "se agrego producto";
            }
            else
            {
                lblSelecciono.Text = "NO se agrego producto";
            }
        }
Пример #2
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            NegocioProducto negP = new NegocioProducto();

            if (negP.existeProducto(this.txtCodMc.Text.Trim(), this.txtCodPrelude.Text.Trim()) == true)
            {
                MessageBox.Show(this, "¡El producto que intenta ingresar ya existe!", "Error de duplicacion");
                return;
            }

            if (this.txtNombre.Text.Trim().Equals(""))
            {
                MessageBox.Show(this, "Ingrese el nombre del producto", "Error, falta informacion");
                return;
            }

            if (this.txtCodMc.Text.Trim().Equals("") && this.txtCodPrelude.Text.Trim().Equals(""))
            {
                MessageBox.Show(this, "Debe ingresar almenos un codigo", "Error, falta informacion");
                return;
            }
            if (this.cmbCuenta.SelectedIndex == 0)
            {
                MessageBox.Show(this, "Seleccione la cuenta", "Error, falta informacion");
                return;
            }
            if (this.cmbProveedor.SelectedIndex == 0)
            {
                MessageBox.Show(this, "Seleccione un proveedor", "Error, falta informacion");
                return;
            }

            if (this.cmbTipoEquip.SelectedIndex == 0)
            {
                MessageBox.Show(this, "Seleccione un tipo de equipamiento", "Error, falta informacion");
                return;
            }

            Producto p = new Producto();

            p.NOMBRE = this.txtNombre.Text.Trim();


            p.CODIGOMC      = this.txtCodMc.Text.Trim();
            p.CODIGOPRELUDE = this.txtCodPrelude.Text.Trim();

            //
            String[] numeros = this.cmbCuenta.SelectedItem.ToString().Split(' ');

            String numero = numeros[numeros.Length - 1];

            String fin  = numero.Split('(')[1];
            String fin2 = fin.Split(')')[0];

            //
            p.CUENTA = fin2;
            p.TIPOEQUIPAMIENTO_NOMBRE = this.cmbTipoEquip.SelectedItem.ToString();
            p.PROVEEDOR_NOMBRE        = this.cmbProveedor.SelectedItem.ToString();

            negP.agregarProducto(p);

            MessageBox.Show(this, "Producto: " + p.NOMBRE + "\n¡Agregado con exito!", "¡Exito!");


            limpiarCampos();
        }