コード例 #1
0
ファイル: Datos.cs プロジェクト: ingalexis1496/distriboyaca
    public DataTable modificar_productos_cantidad(Eproducto producto)
    {
        DataTable        datos_producto = new DataTable();
        NpgsqlConnection conection      = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["Postgres"].ConnectionString);

        try
        {
            NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter("productos.f_modificar_producto_cantidad", conection);
            dataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            dataAdapter.SelectCommand.Parameters.Add("_nombre", NpgsqlDbType.Varchar).Value   = producto.Nombre;
            dataAdapter.SelectCommand.Parameters.Add("_cantidad", NpgsqlDbType.Integer).Value = producto.Cantidad;


            conection.Open();
            dataAdapter.Fill(datos_producto);
        }
        catch (Exception Ex)
        {
            throw Ex;
        }
        finally
        {
            if (conection != null)
            {
                conection.Close();
            }
        }
        return(datos_producto);
    }
コード例 #2
0
ファイル: Datos.cs プロジェクト: ingalexis1496/distriboyaca
    public void registrar_producto(Eproducto datos)
    {
        DataTable        producto  = new DataTable();
        NpgsqlConnection conection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["Postgres"].ConnectionString);

        try
        {
            NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter("productos.f_insertar_producto", conection);
            dataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            dataAdapter.SelectCommand.Parameters.Add("_nombre", NpgsqlDbType.Varchar).Value    = datos.Nombre;
            dataAdapter.SelectCommand.Parameters.Add("_serial", NpgsqlDbType.Varchar).Value    = datos.Serial;
            dataAdapter.SelectCommand.Parameters.Add("_tipo_prod", NpgsqlDbType.Varchar).Value = datos.Tipo_prod;
            dataAdapter.SelectCommand.Parameters.Add("_material", NpgsqlDbType.Varchar).Value  = datos.Material;
            dataAdapter.SelectCommand.Parameters.Add("_cantidad", NpgsqlDbType.Integer).Value  = datos.Cantidad;

            conection.Open();
            dataAdapter.Fill(producto);
        }
        catch (Exception Ex)
        {
            throw Ex;
        }
        finally
        {
            if (conection != null)
            {
                conection.Close();
            }
        }
    }
コード例 #3
0
ファイル: Datos.cs プロジェクト: ingalexis1496/distriboyaca
    public DataTable listar_por_serial(Eproducto encapsu)
    {
        DataTable        serial    = new DataTable();
        NpgsqlConnection conection = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["Postgres"].ConnectionString);

        try
        {
            NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter("productos.f_listar_por_serial", conection);
            dataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            dataAdapter.SelectCommand.Parameters.Add("_serial", NpgsqlDbType.Varchar).Value = encapsu.Serial;

            conection.Open();
            dataAdapter.Fill(serial);
        }
        catch (Exception Ex)
        {
            throw Ex;
        }
        finally
        {
            if (conection != null)
            {
                conection.Close();
            }
        }
        return(serial);
    }
コード例 #4
0
    public DataTable validarRegistroProducto(Eproducto produco)
    {
        DataTable        productoValido = new DataTable();
        NpgsqlConnection conection      = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["postgres"].ConnectionString);

        try
        {
            NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter("productos.f_validar_registro_producto", conection);
            dataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            dataAdapter.SelectCommand.Parameters.Add("_nombre_producto", NpgsqlDbType.Varchar).Value = produco.NombreProducto;
            dataAdapter.SelectCommand.Parameters.Add("_codigo_producto", NpgsqlDbType.Varchar).Value = produco.CodigoProducto;
            dataAdapter.SelectCommand.Parameters.Add("_color_producto", NpgsqlDbType.Varchar).Value  = produco.ColorProducto;
            conection.Open();
            dataAdapter.Fill(productoValido);
        }
        catch (Exception Ex)
        {
            throw Ex;
        }
        finally
        {
            if (conection != null)
            {
                conection.Close();
            }
        }
        return(productoValido);
    }
 protected void buscarB_Click(object sender, EventArgs e)
 {
     bvalidaL.Visible   = false;
     bNoValidaL.Visible = false;
     if (buscarTB.Text != "")
     {
         Eproducto  encapsular = new Eproducto();
         DAproducto funcion    = new DAproducto();
         encapsular.CodigoProducto = buscarTB.Text;
         productoValido            = funcion.buscarUsuario(encapsular);
         if (productoValido.Rows.Count > 0)
         {
             nombreL.Text             = "Nombre Producto: " + productoValido.Rows[0]["nombre_producto"].ToString();
             codigoL.Text             = "Codigo Producto: " + productoValido.Rows[0]["codigo_producto"].ToString();
             fotoProI.ImageUrl        = productoValido.Rows[0]["foto_producto"].ToString();
             formularioOculto.Visible = true;
         }
         else
         {
             bNoValidaL.Text    = "Sin resultados";
             bNoValidaL.Visible = true;
         }
     }
     else
     {
         bNoValidaL.Text    = "Llene todos los campos";
         bNoValidaL.Visible = true;
     }
 }
コード例 #6
0
    public void modificarProducto(Eproducto producto, int id)
    {
        DataTable        modificarProducto = new DataTable();
        NpgsqlConnection conection         = new NpgsqlConnection(ConfigurationManager.ConnectionStrings["postgres"].ConnectionString);

        try
        {
            NpgsqlDataAdapter dataAdapter = new NpgsqlDataAdapter("productos.f_modificar_producto", conection);
            dataAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
            dataAdapter.SelectCommand.Parameters.Add("_id_producto", NpgsqlDbType.Integer).Value         = id;
            dataAdapter.SelectCommand.Parameters.Add("_nombre_producto", NpgsqlDbType.Varchar).Value     = producto.NombreProducto;
            dataAdapter.SelectCommand.Parameters.Add("_codigo_producto", NpgsqlDbType.Varchar).Value     = producto.CodigoProducto;
            dataAdapter.SelectCommand.Parameters.Add("_color_producto", NpgsqlDbType.Varchar).Value      = producto.ColorProducto;
            dataAdapter.SelectCommand.Parameters.Add("_referencia_prodcuto", NpgsqlDbType.Varchar).Value = producto.ReferenciaProducto;
            dataAdapter.SelectCommand.Parameters.Add("_precio_producto", NpgsqlDbType.Double).Value      = producto.PrecioProducto;
            dataAdapter.SelectCommand.Parameters.Add("_cantidad_producto", NpgsqlDbType.Integer).Value   = producto.CantidadProducto;
            dataAdapter.SelectCommand.Parameters.Add("_foto_producto", NpgsqlDbType.Text).Value          = producto.FotoProducto;
            conection.Open();
            dataAdapter.Fill(modificarProducto);
        }
        catch (Exception Ex)
        {
            throw Ex;
        }
        finally
        {
            if (conection != null)
            {
                conection.Close();
            }
        }
    }
コード例 #7
0
    protected void BTN_buscar_Click(object sender, EventArgs e)
    {
        Eproducto encapsular     = new Eproducto();
        Datos     metodo         = new Datos();
        DataTable datos_producto = new DataTable();


        encapsular.Serial = (TB_serial.Text);


        datos_producto = metodo.listar_por_serial(encapsular);
        if (datos_producto.Rows.Count > 0)
        {
            LB_nombre.Visible     = true;
            LB_seri.Visible       = true;
            LB_tipo.Visible       = true;
            LB_material.Visible   = true;
            TB_nombre.Visible     = true;
            TB_seri.Visible       = true;
            TB_tipo.Visible       = true;
            TB_material.Visible   = true;
            BTN_modificar.Visible = true;

            TB_nombre.Text   = datos_producto.Rows[0]["nombre"].ToString();
            TB_seri.Text     = datos_producto.Rows[0]["serial_prod"].ToString();
            TB_tipo.Text     = datos_producto.Rows[0]["tipo_prod"].ToString();
            TB_material.Text = datos_producto.Rows[0]["material"].ToString();
            this.Page.Response.Write("<script language='JavaScript'>window.alert('Producto encontrado exitosamente');</script>");
        }
        else
        {
            this.Page.Response.Write("<script language='JavaScript'>window.alert('No existe');</script>");
        }
    }
コード例 #8
0
    protected void BTN_registrar_Click(object sender, EventArgs e)
    {
        Eproducto encapsular = new Eproducto();
        Datos     metodo     = new Datos();
        DataTable datos      = new DataTable();
        String    tipo;
        String    material;
        int       cont;

        encapsular.Nombre   = TB_nombre.Text;
        encapsular.Serial   = TB_serial.Text;
        encapsular.Cantidad = Convert.ToInt32(TB_cantidad.Text);

        datos = metodo.listar_por_serial(encapsular);


        if (datos.Rows[0]["nombre"].ToString() == TB_cantidad.Text)
        {
            metodo.modificar_productos_cantidad(encapsular);
            this.Page.Response.Write("<script language='JavaScript'>window.alert('producto listo');</script>");

            // datos.Rows[0]["cantidad"] += TB_cantidad.Text;
        }
        else
        {
            if (DDL_tipo_producto.SelectedValue == "1")
            {
                tipo = "Galón";
                encapsular.Tipo_prod = tipo;
            }
            if (DDL_tipo_producto.SelectedValue == "2")
            {
                tipo = "Medio Galón";
                encapsular.Tipo_prod = tipo;
            }
            if (DDL_tipo_producto.SelectedValue == "3")
            {
                tipo = "Pequeño";
                encapsular.Tipo_prod = tipo;
            }
            if (DDL_material.SelectedValue == "1")
            {
                material            = "plastico";
                encapsular.Material = material;
            }
            if (DDL_material.SelectedValue == "2")
            {
                material            = "metal";
                encapsular.Material = material;
            }


            metodo.registrar_producto(encapsular);

            this.Page.Response.Write("<script language='JavaScript'>window.alert('producto Registrado');</script>");
        }
    }
コード例 #9
0
    protected void BTN_modificar_Click(object sender, EventArgs e)
    {
        Eproducto encapsular = new Eproducto();
        Datos     metodo     = new Datos();

        encapsular.Nombre    = (TB_nombre.Text);
        encapsular.Serial    = (TB_serial.Text);
        encapsular.Tipo_prod = (TB_tipo.Text);
        encapsular.Material  = (TB_material.Text);
        metodo.modificar_producto(encapsular);

        this.Page.Response.Write("<script language='JavaScript'>window.alert('Datos Modificados');</script>");
    }
コード例 #10
0
 protected void buscarB_Click(object sender, EventArgs e)
 {
     bvalidaL.Visible   = false;
     bNoValidaL.Visible = false;
     if (buscarTB.Text != "")
     {
         Eproducto  encapsular     = new Eproducto();
         DAproducto funcion        = new DAproducto();
         DataTable  productoValido = new DataTable();
         encapsular.CodigoProducto = buscarTB.Text;
         productoValido            = funcion.buscarUsuario(encapsular);
         if (productoValido.Rows.Count > 0)
         {
             nombreTB.Text              = productoValido.Rows[0]["nombre_producto"].ToString();
             codigoTB.Text              = productoValido.Rows[0]["codigo_producto"].ToString();
             colorTB.Text               = productoValido.Rows[0]["color_producto"].ToString();
             referenciaTB.Text          = productoValido.Rows[0]["referencia_producto"].ToString();
             precioTB.Text              = productoValido.Rows[0]["precio_producto"].ToString();
             cantidadTB.Text            = productoValido.Rows[0]["cantidad_producto"].ToString();
             fotoI.ImageUrl             = productoValido.Rows[0]["foto_producto"].ToString();
             Session["id_producto"]     = productoValido.Rows[0]["id_producto"].ToString();
             Session["nombre_producto"] = nombreTB.Text;
             Session["codigo_producto"] = codigoTB.Text;
             Session["foto_producto"]   = productoValido.Rows[0]["foto_producto"].ToString();
             formularioOculto.Visible   = true;
         }
         else
         {
             bNoValidaL.Text    = "Sin resultados";
             bNoValidaL.Visible = true;
         }
     }
     else
     {
         bNoValidaL.Text    = "Llene el campo de busqueda";
         bNoValidaL.Visible = true;
     }
 }
コード例 #11
0
    protected void modificarB_Click(object sender, EventArgs e)
    {
        formularioOculto.Visible = true;
        validoL.Visible          = false;
        noValidoL.Visible        = false;
        // try
        //{
        if (nombreTB.Text != "" && codigoTB.Text != "" && colorTB.Text != "" && referenciaTB.Text != "" && precioTB.Text != "" && cantidadTB.Text != "")
        {
            Eproducto  encapsular     = new Eproducto();
            DAproducto funcion        = new DAproducto();
            DataTable  productoValido = new DataTable();
            encapsular.NombreProducto     = nombreTB.Text;
            encapsular.CodigoProducto     = codigoTB.Text;
            encapsular.ColorProducto      = colorTB.Text;
            encapsular.ReferenciaProducto = referenciaTB.Text;
            if (double.Parse(precioTB.Text) <= 0)
            {
                noValidoL.Text    = "Precio no valido";
                noValidoL.Visible = true;
            }
            else
            {
                encapsular.PrecioProducto = double.Parse(precioTB.Text);
                if (int.Parse(cantidadTB.Text) < 0)
                {
                    noValidoL.Text    = "Cantidad no valida";
                    noValidoL.Visible = true;
                }
                else
                {
                    encapsular.CantidadProducto = int.Parse(cantidadTB.Text);
                    encapsular.FotoProducto     = cargarImagen();
                    if (nombreTB.Text != Session["nombre_producto"].ToString() || codigoTB.Text != Session["codigo_producto"].ToString())
                    {
                        productoValido = funcion.validarRegistroProducto(encapsular);
                        if (productoValido.Rows.Count > 0)
                        {
                            noValidoL.Text    = "Datos no validos";
                            noValidoL.Visible = true;
                        }
                        else
                        {
                            funcion.modificarProducto(encapsular, int.Parse(Session["id_producto"].ToString()));
                            fotoI.ImageUrl  = cargarImagen();
                            validoL.Text    = "¡Modificacion exitosa!";
                            validoL.Visible = true;
                        }
                    }
                    else
                    {
                        funcion.modificarProducto(encapsular, int.Parse(Session["id_producto"].ToString()));
                        fotoI.ImageUrl  = cargarImagen();
                        validoL.Text    = "¡Modificacion exitosa!";
                        validoL.Visible = true;
                    }
                }
            }
        }
        else
        {
            noValidoL.Text    = "Llene todos los campos primero";
            noValidoL.Visible = true;
        }
        //}

        /*catch (Exception Ex)
         * {
         *  noValidoL.Text = "Los caracteres no son validos en el precio o la cantidad";
         *  noValidoL.Visible = true;
         * }*/
    }
コード例 #12
0
 protected void registrarB_Click(object sender, EventArgs e)
 {
     validoL.Visible   = false;
     noValidoL.Visible = false;
     try
     {
         if (nombreTB.Text != "" && codigoTB.Text != "" && colorTB.Text != "" && referenciaTB.Text != "" && precioTB.Text != "" && cantidadInicialTB.Text != "" && fotoFU.HasFile)
         {
             Eproducto  encapsular     = new Eproducto();
             DAproducto funcion        = new DAproducto();
             DataTable  productoValido = new DataTable();
             encapsular.NombreProducto     = nombreTB.Text;
             encapsular.CodigoProducto     = codigoTB.Text;
             encapsular.ColorProducto      = colorTB.Text;
             encapsular.ReferenciaProducto = referenciaTB.Text;
             if (double.Parse(precioTB.Text) <= 0)
             {
                 noValidoL.Text    = "Precio no valido";
                 noValidoL.Visible = true;
             }
             else
             {
                 encapsular.PrecioProducto = double.Parse(precioTB.Text);
                 if (int.Parse(cantidadInicialTB.Text) < 0)
                 {
                     noValidoL.Text    = "Cantidad no valida";
                     noValidoL.Visible = true;
                 }
                 else
                 {
                     encapsular.CantidadProducto = int.Parse(cantidadInicialTB.Text);
                     encapsular.FotoProducto     = cargarImagen();
                     productoValido = funcion.validarRegistroProducto(encapsular);
                     if (productoValido.Rows.Count > 0)
                     {
                         noValidoL.Text    = "Datos no validos";
                         noValidoL.Visible = true;
                     }
                     else
                     {
                         funcion.registrarProducto(encapsular);
                         nombreTB.Text          = "";
                         codigoTB.Text          = "";
                         colorTB.Text           = "";
                         referenciaTB.Text      = "";
                         precioTB.Text          = "";
                         cantidadInicialTB.Text = "";
                         validoL.Text           = "¡Registro exitoso!";
                         validoL.Visible        = true;
                     }
                 }
             }
         }
         else
         {
             noValidoL.Text    = "Llene todos los campos primero";
             noValidoL.Visible = true;
         }
     }
     catch (Exception Ex)
     {
         noValidoL.Text    = "Los caracteres no son validos en el precio o la cantidad";
         noValidoL.Visible = true;
     }
 }