Ejemplo n.º 1
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            String Mensaje = "";

            if (txtProducto.Text.Trim() != "")
            {
                if (txtMarca.Text.Trim() != "")
                {
                    if (txtPVenta.Text.Trim() != "")
                    {
                        if (txtStock.Text.Trim() != "")
                        {
                            if (Program.Evento == 0)
                            {
                                P.IdCategoria    = Convert.ToInt32(cbxCategoria.SelectedValue);
                                P.ProductoNombre = txtProducto.Text;
                                P.Marca          = txtMarca.Text;
                                P.Precio         = Convert.ToInt32(txtPVenta.Text);
                                P.Stock          = Convert.ToInt32(txtStock.Text);
                                Mensaje          = P.RegistrarProductos();
                                if (Mensaje == "Este Producto ya ha sido Registrado.")
                                {
                                    MessageBoxEx.Show(Mensaje, "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                                else
                                {
                                    MessageBoxEx.Show(Mensaje, "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                    Limpiar();
                                }
                            }
                            else
                            {
                                P.IdP            = Convert.ToInt32(txtIdP.Text);
                                P.IdCategoria    = Convert.ToInt32(cbxCategoria.SelectedValue);
                                P.ProductoNombre = txtProducto.Text;
                                P.Marca          = txtMarca.Text;
                                P.Precio         = Convert.ToInt32(txtPVenta.Text);
                                P.Stock          = Convert.ToInt32(txtStock.Text);
                                MessageBoxEx.Show(P.ActualizarProductos(), "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                Limpiar();
                                this.Close();
                            }
                        }
                        else
                        {
                            MessageBoxEx.Show("Por Favor Ingrese Stock del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtStock.Focus();
                        }
                    }
                }
                else
                {
                    MessageBoxEx.Show("Por Favor Ingrese Marca del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtMarca.Focus();
                }
            }
            else
            {
                MessageBoxEx.Show("Por Favor Ingrese Nombre del Producto.", "Sistema de Ventas.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtProducto.Focus();
            }
            ListadoProductos LP = new ListadoProductos();

            LP.timer1.Start();
            listadoView.CargarListado();
        }