Example #1
0
        public int actualizarCompra(CL_Compra p_compr)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = string.Format("UPDATE COMPRA SET fechaCompra = '{0}'"
                                                + ", idUsuario={1} WHERE idCompra={2}"
                                                , p_compr.FechaCompra, p_compr.UsuarioCompra.IdUsuario, p_compr.IdCompra);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
Example #2
0
        public int agregarCompra(CL_Compra p_compr)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = string.Format("INSERT INTO COMPRA(fechaCompra,idUsuario)"
                                                + " VALUES('{0}',{1})"
                                                , p_compr.FechaCompra, p_compr.UsuarioCompra.IdUsuario);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
Example #3
0
        protected void btn_agregar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["tablaCompra"] == null)
                {
                    aux_table = new DataTable();
                    aux_table.Columns.Add("ID");
                    aux_table.Columns.Add("Nombre Producto");
                    aux_table.Columns.Add("Precio");
                    aux_table.Columns.Add("Cantidad");
                }
                else
                {
                    aux_table = (DataTable)Session["tablaCompra"];
                }

                DataRow dr = aux_table.NewRow();
                dr["ID"] = DropDownList1.SelectedValue;
                dr["Nombre Producto"] = DropDownList1.SelectedItem.Text;
                dr["Precio"]          = lbl_precio.Text;
                dr["Cantidad"]        = DropDownList2.SelectedItem.Text;

                aux_table.Rows.Add(dr);
                Session["tablaCompra"] = aux_table;
                gv_carro.DataSource    = aux_table;
                gv_carro.DataBind();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
            }
        }
Example #4
0
        public int maxId()
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT max(idCompra) as MAX FROM compra ;";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    resp = Convert.ToInt32(dr["MAX"].ToString());
                }
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
        public int agregarUsuario(CL_Usuario p_user)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "INSERT INTO USUARIO(Nombre,Apellido,Password,TipoUsuario,user,local,habilitado) "
                                  + "VALUES('" + p_user.Nombre + "','"
                                  + p_user.Apellido + "','"
                                  + p_user.Password + "','"
                                  + p_user.TipoUsuario + "','"
                                  + p_user.User + "','"
                                  + p_user.Local + "','HABILITADO'"
                                  + ")";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
        public int agregarProducto(CL_Producto p_prod)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = string.Format("INSERT INTO PRODUCTO(NombreProducto,PrecioProducto,EsCombo,DiaCombo,stock,habilitado)"
                                                + " VALUES('{0}',{1},'{2}','{3}',{4},'{5}')"
                                                , p_prod.NombreProducto, p_prod.PrecioProducto, p_prod.EsCombo, p_prod.DiaCombo, p_prod.Stock, p_prod.Habilitado);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
        protected void btn_actualizar_Click(object sender, EventArgs e)
        {
            try
            {
                CL_Producto aux_pro = serv.productoListar().Where(x => x.NombreProducto == ddl_producto.SelectedItem.Text).First();

                aux_pro.PrecioProducto = Convert.ToInt32(txt_precio.Text);
                aux_pro.Stock          = Convert.ToInt32(txt_stock.Text);
                string dia = Convert.ToDateTime(aux_pro.DiaCombo).ToString("yyyy-MM-dd");
                aux_pro.DiaCombo = dia;
                if (rb_si.Checked)
                {
                    aux_pro.Habilitado = "HABILITADO";
                }
                else
                {
                    aux_pro.Habilitado = "DESHABILITADO";
                }
                string xmlProducto = SerializeProducto <CL_Producto>(aux_pro);

                bool resp = serv.productoActualizar(xmlProducto);
                if (resp)
                {
                    lbl_mensaje.Text = "Producto Actualizado";
                }
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
            }
        }
        public int eliminarUsuario(int id)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE USUARIO SET habilitado='DESHABILITADO' WHERE idUsuario =" + id + "";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
        //SELECT DISTINCT(local) from usuario;

        public List <string> obtenerLocales()
        {
            List <string> lista = new List <string>();

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT DISTINCT(local) as local from usuario";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    string aux = "";
                    aux = dr["local"].ToString();
                    lista.Add(aux);
                }
                cone.Close();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(null);
            }
            return(lista);
        }
Example #10
0
        public int agregarDetalleCompra(CL_DetalleCompra p_detalle)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = string.Format("INSERT INTO DETALLECOMPRA(idCompra,idProducto,Cantidad)"
                                                + " VALUES({0},{1},{2})"
                                                , p_detalle.Compra.IdCompra, p_detalle.Producto.IdProducto, p_detalle.Cantidad);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
Example #11
0
        public int actualizarDetalleCompraCantidad(CL_DetalleCompra p_detalle)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = string.Format("UPDATE DETALLECOMPRA SET "
                                                + "Cantidad = {0}  WHERE idCompra = {1} and idProducto = {2}"
                                                , p_detalle.Cantidad, p_detalle.Compra.IdCompra, p_detalle.Producto.IdProducto);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }

            return(resp);
        }
        public int actualizarProducto(CL_Producto p_pro)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = string.Format("UPDATE PRODUCTO SET NombreProducto = '{0}'"
                                                + ", PrecioProducto={1} , EsCombo ='{2}' , DiaCombo = '{3}' , stock={4} ,habilitado = '{5}' WHERE idProducto = {6}"
                                                , p_pro.NombreProducto, p_pro.PrecioProducto, p_pro.EsCombo, p_pro.DiaCombo, p_pro.Stock, p_pro.Habilitado, p_pro.IdProducto);
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
        public int actualizarUsuario(CL_Usuario p_user)
        {
            int resp = 0;

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "UPDATE USUARIO SET Nombre='" + p_user.Nombre + "',"
                                  + "Apellido = '" + p_user.Apellido + "',"
                                  + "Password = '******',"
                                  + "TipoUsuario = '" + p_user.TipoUsuario + "', "
                                  + "user = '******',"
                                  + "local= '" + p_user.Local + "',"
                                  + "habilitado='" + p_user.Habilitado + "'"
                                  + "WHERE idUsuario =" + p_user.IdUsuario + "";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                resp = cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(0);
            }
            return(resp);
        }
Example #14
0
        protected void btn_grabar_Click(object sender, EventArgs e)
        {
            try
            {
                CL_Usuario user = new CL_Usuario();
                user.Nombre      = txt_nombre.Text;
                user.Apellido    = txt_apellido.Text;
                user.Local       = ddl_local.SelectedValue;
                user.Habilitado  = "HABILITADO";
                user.Password    = "******";
                user.TipoUsuario = "Personal";

                string xmlUser = SerializeUser <CL_Usuario>(user);

                bool resp = serv.usuarioGrabarXML(xmlUser);
                if (resp)
                {
                    lbl_mensaje.Text = "Usuario Agregado";
                }
                else
                {
                    lbl_mensaje.Text = "Usuario No Agregado";
                }
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
            }
        }
Example #15
0
 protected void btn_comprar_Click(object sender, EventArgs e)
 {
     try
     {
     }
     catch (Exception ex)
     {
         Logg.Mensaje(ex.Message);
     }
 }
 public List <CL_DetalleCompra> detalleCompraListar()
 {
     try
     {
         DAO_DetalleCompra dao_user = new DAO_DetalleCompra();
         return(dao_user.listarDetalleCompra());
     }
     catch (Exception ex)
     {
         Logg.Mensaje(ex.Message);
         return(null);
     }
 }
 public List <CL_Usuario> usuarioListar()
 {
     try
     {
         DAO_Usuario dao_user = new DAO_Usuario();
         return(dao_user.listarUsuarios());
     }
     catch (Exception ex)
     {
         Logg.Mensaje(ex.Message);
         return(null);
     }
 }
Example #18
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                CL_Usuario aux_user = (CL_Usuario)Session["objectUser"];
                CL_Compra  compra   = new CL_Compra();
                compra.UsuarioCompra = aux_user;
                string date = DateTime.Now.ToString("yyyy-MM-dd");
                compra.FechaCompra = date;
                //lbl_mensaje.Text = aux_user.IdUsuario + "|" + date;

                string compraSerialziado = Serialize <CL_Compra>(compra);

                bool resp = serv.compraAgregar(compraSerialziado);
                if (resp)
                {
                    List <CL_DetalleCompra> listaDetalleCompra = new List <CL_DetalleCompra>();
                    foreach (GridViewRow gvr in gv_carro.Rows)
                    {
                        CL_DetalleCompra aux_det = new CL_DetalleCompra();
                        CL_Producto      pro     = new CL_Producto();
                        pro.IdProducto   = Convert.ToInt32(gvr.Cells[0].Text);
                        aux_det.Producto = pro;
                        CL_Compra  com = new CL_Compra();
                        DAO_Compra dao = new DAO_Compra();
                        com.IdCompra     = dao.maxId();
                        aux_det.Compra   = com;
                        aux_det.Cantidad = Convert.ToInt32(gvr.Cells[3].Text);
                        listaDetalleCompra.Add(aux_det);
                    }
                    foreach (CL_DetalleCompra item in listaDetalleCompra)
                    {
                        string xmlDetalle = SerializeDetalle <CL_DetalleCompra>(item);
                        serv.detalleCompraAgregar(xmlDetalle);
                    }
                    lbl_mensaje.Text += "Compra Exitosa";

                    Session.Remove("tablaCompra");
                }
                else
                {
                    lbl_mensaje.Text += "Compra No Exitosa,Intentelo Mas Tarde";
                }
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
            }
        }
        public CL_Usuario usuarioLogin(string p_user, string p_password)
        {
            try
            {
                DAO_Usuario dao_us = new DAO_Usuario();

                CL_Usuario user = null;
                user = dao_us.listarUsuarios().Where(x => x.User == p_user && x.Password == p_password).First();
                return(user);
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                return(null);
            }
        }
        protected void btn_despedir_Click(object sender, EventArgs e)
        {
            try
            {
                CL_Usuario aux_user = serv.usuarioListar().Where(x => x.User == ddl_personal.SelectedValue).First();

                bool resp = serv.usuarioEliminar(aux_user.IdUsuario);
                if (resp)
                {
                    lbl_mensaje.Text = "Elimino Usuario";
                }
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
            }
        }
Example #21
0
        public List <CL_Compra> listarCompra()
        {
            List <CL_Compra> lista = new List <CL_Compra>();

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM COMPRA P INNER JOIN USUARIO U ON(P.IDUSUARIO=U.IDUSUARIO)";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    CL_Compra aux_compra = new CL_Compra();
                    aux_compra.IdCompra    = Convert.ToInt32(dr["idCompra"].ToString());
                    aux_compra.FechaCompra = Convert.ToDateTime(dr["fechaCompra"].ToString()).ToString("dd-MM-yyyy");
                    CL_Usuario aux_user = new CL_Usuario();
                    aux_user.IdUsuario       = Convert.ToInt32(dr["idUsuario"].ToString());
                    aux_user.Nombre          = dr["Nombre"].ToString();
                    aux_user.Apellido        = dr["Apellido"].ToString();
                    aux_user.TipoUsuario     = dr["TipoUsuario"].ToString();
                    aux_user.User            = dr["user"].ToString();
                    aux_user.Local           = dr["local"].ToString();
                    aux_user.Habilitado      = dr["habilitado"].ToString();
                    aux_compra.UsuarioCompra = aux_user;
                    lista.Add(aux_compra);
                }
                cone.Close();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(null);
            }
            return(lista);
        }
        public List <CL_Usuario> listarUsuarios()
        {
            List <CL_Usuario> lista = new List <CL_Usuario>();

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM USUARIO";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    CL_Usuario aux_user = new CL_Usuario();
                    aux_user.IdUsuario   = Convert.ToInt32(dr["idUsuario"].ToString());
                    aux_user.Nombre      = dr["Nombre"].ToString();
                    aux_user.Apellido    = dr["Apellido"].ToString();
                    aux_user.Password    = dr["Password"].ToString();
                    aux_user.TipoUsuario = dr["TipoUsuario"].ToString();
                    aux_user.User        = dr["user"].ToString();
                    aux_user.Local       = dr["local"].ToString();
                    aux_user.Habilitado  = dr["habilitado"].ToString();
                    lista.Add(aux_user);
                }
                cone.Close();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(null);
            }
            return(lista);
        }
        public List <CL_Producto> listarProductos()
        {
            List <CL_Producto> lista = new List <CL_Producto>();

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM PRODUCTO";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    CL_Producto aux_producto = new CL_Producto();
                    aux_producto.IdProducto     = Convert.ToInt32(dr["idProducto"].ToString());
                    aux_producto.NombreProducto = dr["NombreProducto"].ToString();
                    aux_producto.PrecioProducto = Convert.ToInt32(dr["PrecioProducto"].ToString());
                    aux_producto.EsCombo        = dr["EsCombo"].ToString();
                    aux_producto.Stock          = Convert.ToInt32(dr["stock"].ToString());
                    aux_producto.DiaCombo       = dr["DiaCombo"].ToString();
                    aux_producto.Habilitado     = dr["habilitado"].ToString();
                    lista.Add(aux_producto);
                }
                cone.Close();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(null);
            }
            return(lista);
        }
        protected void btn_actualizar_Click(object sender, EventArgs e)
        {
            try
            {
                CL_Usuario aux_user = serv.usuarioListar().Where(x => x.User == ddl_personal.SelectedValue).First();
                aux_user.Nombre   = txt_nombre.Text;
                aux_user.Apellido = txt_apellido.Text;
                aux_user.Local    = ddl_local.SelectedValue;
                string xmlUser = SerializeUser <CL_Usuario>(aux_user);

                bool resp = serv.usuarioActualizarXML(xmlUser);
                if (resp)
                {
                    lbl_mensaje.Text = "Actualizo Usuario";
                }
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
            }
        }
 public bool usuarioEliminar(int cod)
 {
     try
     {
         DAO_Usuario dao_user = new DAO_Usuario();
         int         resp     = dao_user.eliminarUsuario(cod);
         if (resp > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         Logg.Mensaje(ex.Message);
         return(false);
     }
 }
 public bool usuarioActualizarXML(string xmlUsuario)
 {
     try
     {
         CL_Usuario  aux_user = DeserializeUsuario <CL_Usuario>(xmlUsuario);
         DAO_Usuario dao_user = new DAO_Usuario();
         int         resp     = dao_user.actualizarUsuario(aux_user);
         if (resp > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         Logg.Mensaje(ex.Message);
         return(false);
     }
 }
 public bool detalleCompraActualizar(string xmlDetalleCompra)
 {
     try
     {
         CL_DetalleCompra  aux_user = DeserializeDetalleCompra <CL_DetalleCompra>(xmlDetalleCompra);
         DAO_DetalleCompra dao_user = new DAO_DetalleCompra();
         int resp = dao_user.agregarDetalleCompra(aux_user);
         if (resp > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         Logg.Mensaje(ex.Message);
         return(false);
     }
 }
 public bool productoActualizar(string xmlProducto)
 {
     try
     {
         CL_Producto  produc = DeserializeProducto <CL_Producto>(xmlProducto);
         DAO_Producto dao    = new DAO_Producto();
         int          resp   = dao.actualizarProducto(produc);
         if (resp > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         Logg.Mensaje(ex.Message);
         return(false);
     }
 }
Example #29
0
        public List <CL_DetalleCompra> listarDetalleCompra()
        {
            List <CL_DetalleCompra> lista = new List <CL_DetalleCompra>();

            try
            {
                MySqlCommand cmd = new MySqlCommand();
                cmd.CommandText = "SELECT * FROM COMPRA C INNER JOIN USUARIO U ON(C.IDUSUARIO=U.IDUSUARIO)"
                                  + " INNER JOIN DETALLECOMPRA D ON(D.IDCOMPRA=C.IDCOMPRA)"
                                  + " INNER JOIN PRODUCTO P ON(P.IDPRODUCTO=D.IDPRODUCTO)";
                cmd.CommandType = System.Data.CommandType.Text;
                cmd.Connection  = cone;
                if (cone.State != System.Data.ConnectionState.Open)
                {
                    cone.Open();
                }
                MySqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                {
                    CL_Compra aux_compra = new CL_Compra();
                    aux_compra.IdCompra    = Convert.ToInt32(dr["idCompra"].ToString());
                    aux_compra.FechaCompra = dr["fechaCompra"].ToString();
                    CL_Usuario aux_user = new CL_Usuario();
                    aux_user.IdUsuario       = Convert.ToInt32(dr["idUsuario"].ToString());
                    aux_user.Nombre          = dr["Nombre"].ToString();
                    aux_user.Apellido        = dr["Apellido"].ToString();
                    aux_user.TipoUsuario     = dr["TipoUsuario"].ToString();
                    aux_user.User            = dr["user"].ToString();
                    aux_user.Local           = dr["local"].ToString();
                    aux_user.Habilitado      = dr["habilitado"].ToString();
                    aux_compra.UsuarioCompra = aux_user;


                    CL_Producto aux_producto = new CL_Producto();
                    aux_producto.IdProducto     = Convert.ToInt32(dr["idProducto"].ToString());
                    aux_producto.NombreProducto = dr["NombreProducto"].ToString();
                    aux_producto.PrecioProducto = Convert.ToInt32(dr["PrecioProducto"].ToString());
                    aux_producto.EsCombo        = dr["EsCombo"].ToString();
                    aux_producto.Stock          = Convert.ToInt32(dr["stock"].ToString());
                    aux_producto.DiaCombo       = dr["DiaCombo"].ToString();
                    aux_producto.Habilitado     = dr["habilitado"].ToString();

                    CL_DetalleCompra aux_detalle = new CL_DetalleCompra();
                    aux_detalle.Producto = aux_producto;
                    aux_detalle.Compra   = aux_compra;
                    aux_detalle.Cantidad = Convert.ToInt32(dr["Cantidad"].ToString());

                    lista.Add(aux_detalle);
                }
                cone.Close();
            }
            catch (Exception ex)
            {
                Logg.Mensaje(ex.Message);
                if (cone.State != System.Data.ConnectionState.Closed)
                {
                    cone.Close();
                }
                ;
                return(null);
            }
            return(lista);
        }