Ejemplo n.º 1
0
        private void bt_consultar_Click(object sender, EventArgs e)
        {
            l_mensajes.Text = string.Empty;
            if (txt_idprod.Text.Equals(""))
            {
                l_mensajes.Text = "Ingresar id de Producto";
                txt_idprod.Focus();
            }
            else
            {
                int idProd;
                if (int.TryParse(txt_idprod.Text, out idProd))
                {
                    if (idProd > 0)
                    {
                        ControladorProducto      cp  = new ControladorProducto();
                        ControladorDetalleBoleta cdb = new ControladorDetalleBoleta();
                        int res = cp.existeProducto(idProd);
                        switch (res)
                        {
                        case 0:
                            l_mensajes.Text = "Datos del Producto NO existen en BD";
                            break;

                        case 1:

                            int estado = cp.ConsultarUnProducto(idProd);;
                            switch (estado)
                            {
                            case 1:
                                Producto p = new Producto();
                                p = cp.obtenerDatosProducto();
                                txt_nombre.Text     = p.NomProd;
                                txt_stock.Text      = p.Stock.ToString();
                                txt_preciounit.Text = p.Precio.ToString();
                                txt_cantidad.Value  = 1;
                                bt_guardar.Enabled  = true;
                                bt_eliminar.Enabled = true;
                                break;

                            default:
                                l_mensajes.Text = "NO existe Conexión BD. Contacte a ...";
                                break;
                            }
                            break;

                        default:
                            l_mensajes.Text = "Error al conectarse a BD. Contacte a ...";
                            break;
                        }
                    }
                    else
                    {
                        l_mensajes.Text = "Ingresar id de Producto > 0";
                        txt_idprod.Focus();
                    }
                }
                else
                {
                    l_mensajes.Text = "Ingresar id de Producto numerico entero";
                    txt_idprod.Focus();
                }
            }
        }
Ejemplo n.º 2
0
        private void bt_consultar_Click(object sender, EventArgs e)
        {
            l_mensajes.Text = string.Empty;
            if (tb_idProd.Text.Equals(""))
            {
                l_mensajes.Text = "Ingresar id de Producto";
                tb_idProd.Focus();
            }
            else
            {
                int idProd;
                if (int.TryParse(tb_idProd.Text, out idProd))
                {
                    if (idProd > 0)
                    {
                        ControladorProducto cp = new ControladorProducto();
                        int res = cp.existeProducto(idProd);
                        switch (res)
                        {
                        case 0:
                            l_mensajes.Text = "Datos del Producto NO existen en BD";
                            break;

                        case 1:
                            int estado = cp.ConsultarUnProducto(idProd);
                            switch (estado)
                            {
                            case 1:
                                Producto p = new Producto();
                                p = cp.obtenerDatosProducto();
                                tb_nombre.Text    = p.NomProd;
                                cb_origen.Text    = p.Origen;
                                tb_porc.Text      = p.Porcentaje.ToString();
                                cb_aroma.Text     = p.Aroma;
                                cb_inclusion.Text = p.Inclusion;
                                cb_choc.Text      = p.Chocolatero;
                                tb_preUn.Text     = p.Precio.ToString();
                                tb_stock.Text     = p.Stock.ToString();
                                habilitar();
                                break;

                            default:
                                l_mensajes.Text = "NO existe Conexión BD. Contacte a ...";
                                break;
                            }
                            break;

                        default:
                            l_mensajes.Text = "Error al conectarse a BD. Contacte a ...";
                            break;
                        }
                    }
                    else
                    {
                        l_mensajes.Text = "Ingresar id de Producto > 0";
                        tb_idProd.Focus();
                    }
                }
                else
                {
                    l_mensajes.Text = "Ingresar id de Producto numerico entero";
                    tb_idProd.Focus();
                }
            }
        }