Esempio n. 1
0
        private void btnguardar_Click(object sender, EventArgs e)
        {
            Producto oProducto = new Producto();

            oProducto.nombre      = txbnombre.Text;
            oProducto.descripcion = txbdescripcion.Text;
            oProducto.marca       = txbmarca.Text;
            oProducto.proveedor   = (int)cmbproveedores.SelectedValue;
            oProducto.rubro       = (int)cmbrubros.SelectedValue;
            oProducto.precio      = Convert.ToDecimal(txbprecio.Text);
            ProductoDao oProductoDao = new ProductoDao();

            if (oProductoDao.altaProducto(oProducto))
            {
                DialogResult guardado = MessageBox.Show("DATOS GUARDADOS, ¿Desea cargar un nuevo producto?", "CORRECTO", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (guardado == DialogResult.Yes)
                {
                    limpiarTexBox();
                }
                else
                {
                    AdministrarProducto iniciar = new AdministrarProducto();
                    iniciar.Show();
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Datos Incorrectos", "Error");
            }
        }
Esempio n. 2
0
        public void btnguardar_Click(object sender, EventArgs e)
        {
            Producto oProducto = new Producto();

            if (string.IsNullOrEmpty(txbnombre.Text) && string.IsNullOrEmpty(txbdescripcion.Text) && string.IsNullOrEmpty(txbmarca.Text) && string.IsNullOrEmpty(txbprecio.Text) && ((int)cmbproveedores.SelectedValue == 0) && ((int)cmbfamilias.SelectedValue) == 0 && ((int)cmbrubros.SelectedValue == 0))
            {
                MessageBox.Show("DEBE COMPLETAR INFORMACION", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                oProducto.Nombre           = txbnombre.Text.Trim();
                oProducto.Descripcion      = txbdescripcion.Text.Trim();
                oProducto.Marca            = txbmarca.Text.Trim();
                oProducto.Proveedor.Id     = (int)cmbproveedores.SelectedValue;
                oProducto.Rubro.Familia.Id = (int)cmbfamilias.SelectedValue;
                oProducto.Rubro.Id         = (int)cmbrubros.SelectedValue;
                oProducto.Precio           = Convert.ToDouble(txbprecio.Text);
                ProductoDao oProductoDao = new ProductoDao();
                if (oProductoDao.altaProducto(oProducto))
                {
                    DialogResult guardado = MessageBox.Show("DATOS GUARDADOS, ¿Desea cargar un nuevo producto?", "CORRECTO", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (guardado == DialogResult.Yes)
                    {
                        limpiarTexBox();
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    MessageBox.Show("Datos Incorrectos", "Error");
                }
            }
        }