Exemple #1
0
        /**
         * Con esta funcion se realiza una busqueda que devuelve varios registros,
         * ordenandolos en una lista que incluye un array de datos para que el objeto realice
         * las operaciones correspodientes con la informacion devuelta
         * */
        public List <string[]> buscarVarios(string consulta)
        {
            Datos           selecciona = new Datos();
            SqlDataReader   lector;
            List <string[]> datos = new List <string[]>();

            if (selecciona.Conectar())
            {
                selecciona.construye_reader(consulta);
                lector = selecciona.ejecuta_reader();

                if (lector.Read() == true)//verifica que el data reader tengan datos aunque sean null
                {
                    do
                    {
                        string[] valores = null;
                        if (!(lector.IsDBNull(0))) //verifica que no sean datos null
                        {
                            valores = new string[lector.FieldCount];
                            for (int i = 0; i < lector.FieldCount; i++)
                            {
                                //Verificamos que tipo de dato devuelve la consulta y lo convertimos a string
                                //Agregar tipos de datos de acuerdo a las necesidades.
                                if (lector[i] is string)
                                {
                                    valores[i] = lector.GetString(i);
                                }
                                else if (lector[i] is int)
                                {
                                    valores[i] = lector.GetInt32(i).ToString();
                                }
                                else if (lector[i] is DateTime)
                                {
                                    valores[i] = lector.GetDateTime(i).ToString();
                                }
                            }
                            datos.Add(valores);
                        }
                    } while (lector.Read());
                    selecciona.desconectar();
                    selecciona.dr.Close();

                    return(datos);
                }
                else
                {
                    return(datos);
                }
            }
            else
            {
                return(datos);
            }
        }
Exemple #2
0
        public int CargarObjetosString(
            System.Web.UI.WebControls.TextBox TxtNomRespExp,
            System.Web.UI.WebControls.TextBox TxtCargoRespExp,
            System.Web.UI.WebControls.TextBox TxtTelRespExp,
            System.Web.UI.WebControls.TextBox TxtEmailRespExp,
            String consulta)
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            TxtNomRespExp.Text   = "";
            TxtCargoRespExp.Text = "";
            TxtTelRespExp.Text   = "";
            TxtEmailRespExp.Text = "";

            try
            {
                if (selecciona.Conectar())
                {
                    selecciona.construye_reader(consulta);
                    lector = selecciona.ejecuta_reader();

                    if (lector.Read() == true)     //verifica que el data reader tengan datos aunque sean null
                    {
                        if (!(lector.IsDBNull(0))) //veririfca que no sean datos null
                        {
                            TxtNomRespExp.Text   = lector.GetString(0);
                            TxtCargoRespExp.Text = lector.GetString(1);
                            TxtTelRespExp.Text   = lector.GetString(2);
                            TxtEmailRespExp.Text = lector.GetString(3);
                        }
                        selecciona.desconectar();
                        selecciona.dr.Close();
                        return(1);
                    }
                    else
                    {
                        return(-1);
                    }
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Se genero el siguiente error\nen tiempo de ejecución:\n" + e.Message);
                return(-1);
            }
        }
Exemple #3
0
        public documentos Buscar(String Consulta, documentos MiDoc)//buscando documentos
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            if (selecciona.Conectar())
            {
                selecciona.construye_reader(Consulta);
                lector = selecciona.ejecuta_reader();

                if (lector.Read() == true)//verifica que el data reader tengan datos aunque sean null
                {
                    do
                    {
                        if (!(lector.IsDBNull(0))) //veririfca que no sean datos null
                        {
                            MiDoc.clasif_expe        = lector.GetString(0);
                            MiDoc.id_doc             = lector.GetString(1);
                            MiDoc.tipo_doc           = lector.GetString(2);
                            MiDoc.estatus_doc        = lector.GetString(3);
                            MiDoc.prioridad          = lector.GetString(4);
                            MiDoc.id_remitente       = lector.GetString(5);
                            MiDoc.no_doc             = lector.GetString(6);
                            MiDoc.fecha_doc          = lector.GetDateTime(7);
                            MiDoc.id_destinatario    = lector.GetString(8);
                            MiDoc.fecha_rec_doc      = lector.GetDateTime(9);
                            MiDoc.hora_rec_doc       = lector.GetDateTime(10);
                            MiDoc.asunto_doc         = lector.GetString(11);
                            MiDoc.obser_doc          = lector.GetString(12);
                            MiDoc.desc_anexos        = lector.GetString(13);
                            MiDoc.no_fojas           = lector.GetInt32(14);
                            MiDoc.id_delegado        = lector.GetString(15);
                            MiDoc.estatus_delegado   = lector.GetString(16);
                            MiDoc.fecha_delegado_doc = lector.GetDateTime(17);
                        }
                    } while (lector.Read());
                    selecciona.desconectar();
                    selecciona.dr.Close();

                    return(MiDoc);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #4
0
        public void ConsultaProdcto(GridView gv, DateTime fi, DateTime ff)
        {
            Datos         consulta = new Datos();
            SqlDataReader lector;

            if (consulta.Conectar())
            {
                consulta.construye_reader("SELECT Descripcion, Cantidad,pzasBEstado,pzasDefec,Fecha,Stock FROM  Persona INNER JOIN Empleado on Empleado.idEmpleado = Persona.idPersona INNER JOIN ProdctTer on ProdctTer.idEmpleado= Empleado.idEmpleado INNER JOIN Producto on Producto.idProducto = ProdctTer.idProducto WHERE Fecha BETWEEN '" + Convert.ToDateTime(fi).ToShortDateString() + "'AND'" + Convert.ToDateTime(ff).ToShortDateString() + "'");
                lector        = consulta.ejecuta_reader();
                gv.DataSource = lector;
                gv.DataBind();
                consulta.dr.Close();
                consulta.desconectar();
            }
        }
Exemple #5
0
        public int cargar_TextBoxString(System.Web.UI.WebControls.TextBox txt, string consulta)
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            txt.Text = "";

            try
            {
                if (selecciona.Conectar())
                {
                    selecciona.construye_reader(consulta);
                    lector = selecciona.ejecuta_reader();

                    if (lector.Read() == true)     //verifica que el data reader tengan datos aunque sean null
                    {
                        if (!(lector.IsDBNull(0))) //veririfca que no sean datos null
                        {
                            txt.Text = lector.GetString(0);
                            //txt.Text = lector.GetInt32(0).ToString();
                        }
                        selecciona.desconectar();
                        selecciona.dr.Close();
                        return(1);
                    }
                    else
                    {
                        return(-1);
                    }
                }
                else
                {
                    return(-1);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("Se genero el siguiente error\nen tiempo de ejecución:\n" + e.Message);
                return(-1);
            }
        }
Exemple #6
0
        public int cargar_DropDownListString(
            DropDownList cmbNom,
            DropDownList cmbId,
            string consulta)
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            cmbNom.Items.Clear();
            cmbId.Items.Clear();
            cmbNom.Items.Add("Selecciona");
            cmbId.Items.Add("Selecciona");
            if (selecciona.Conectar())
            {
                selecciona.construye_reader(consulta);
                lector = selecciona.ejecuta_reader();

                if (lector.Read() == true)//verifica que el data reader tengan datos aunque sean null
                {
                    do
                    {
                        if (!(lector.IsDBNull(0))) //veririfca que no sean datos null
                        {
                            cmbNom.Items.Add(lector.GetString(0).ToString());
                            cmbId.Items.Add(lector.GetString(1).ToString());
                        }
                    } while (lector.Read());
                    selecciona.desconectar();
                    selecciona.dr.Close();
                    return(1);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                return(-1);
            }
        }
Exemple #7
0
        internal int muestra_idProductos(System.Web.UI.WebControls.DropDownList DDLisy)
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            if (selecciona.Conectar())
            {
                selecciona.construye_reader("select * from Producto");
                lector = selecciona.ejecuta_reader();
                while (lector.Read())
                {
                    DDLisy.Items.Add(lector.GetInt32(0).ToString());
                }
                selecciona.desconectar();
                selecciona.dr.Close();
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Exemple #8
0
        public int carga_nombres(DropDownList cmb)
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            if (selecciona.Conectar())
            {
                selecciona.construye_reader("select Nombre from Producto");
                lector = selecciona.ejecuta_reader();
                while (lector.Read())
                {
                    cmb.Items.Add(lector.GetString(0).ToString());
                }
                selecciona.desconectar();
                selecciona.dr.Close();
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Exemple #9
0
        /// <summary>
        /// /esta es la implementacion de la clase
        /// </summary>
        /// <returns></returns>

        /*public int alta()
         * {
         *  SqlCommand Comando;
         *  Datos inserta = new Datos();
         *  int regresa = 0;
         *  if (inserta.Conectar())
         *  {
         *      String comando = "Insert into Producto (Descripcion, NombreProd, StatusProd)" +
         *      "values ('" + Descripcion + "','" + Nombre + "','" + "Alta" + "')";
         *      Comando = inserta.construye_command(comando);
         *      if ((inserta.ejecutanonquery()) != 0)
         *          regresa = 1;
         *      else
         *          regresa = 0;
         *      Comando.Connection.Close();
         *      inserta.desconectar();
         *  }
         *  else
         *      regresa = -1;
         *  return regresa;
         * }
         */
        public int cargar_DropDownListString(DropDownList cmb, string consulta)
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            if (selecciona.Conectar())
            {
                selecciona.construye_reader(consulta);
                lector = selecciona.ejecuta_reader();
                while (lector.Read())
                {
                    //cmb.Items.Add(lector.GetInt32(0).ToString());
                    cmb.Items.Add(lector.GetString(0));
                }
                selecciona.desconectar();
                selecciona.dr.Close();
                return(1);
            }
            else
            {
                return(-1);
            }
        }
Exemple #10
0
        public Producto busca_producto(String nom)
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            if (selecciona.Conectar())
            {
                selecciona.construye_reader("select * from Producto");
                lector = selecciona.ejecuta_reader();
                while (lector.Read())
                {
                    if (lector.GetString(1).ToString() == nom)
                    {
                        idProducto  = Convert.ToInt32(lector.GetInt32(0).ToString());
                        Descripcion = lector.GetString(1).ToString();
                        Nombre      = lector.GetString(2).ToString();
                        return(this);
                    }
                }
                selecciona.desconectar();
                selecciona.dr.Close();
            }
            return(null);
        }
Exemple #11
0
        public UnidadIoC Buscar(String Consulta, UnidadIoC MiUnidad)//buscando Caja
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            if (selecciona.Conectar())
            {
                selecciona.construye_reader(Consulta);
                lector = selecciona.ejecuta_reader();

                if (lector.Read() == true)//verifica que el data reader tengan datos aunque sean null
                {
                    do
                    {
                        if (!(lector.IsDBNull(0))) //veririfca que no sean datos null
                        {
                            MiUnidad.IDUnidad    = lector.GetString(0);
                            MiUnidad.Descripcion = lector.GetString(1);
                            MiUnidad.IDCharola   = lector.GetString(2);
                        }
                    } while (lector.Read());
                    selecciona.desconectar();
                    selecciona.dr.Close();

                    return(MiUnidad);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Exemple #12
0
        public Expediente Buscar(String Consulta, Expediente MiExp)//buscando expediente
        {
            Datos         selecciona = new Datos();
            SqlDataReader lector;

            if (selecciona.Conectar())
            {
                selecciona.construye_reader(Consulta);
                lector = selecciona.ejecuta_reader();

                if (lector.Read() == true)//verifica que el data reader tengan datos aunque sean null
                {
                    do
                    {
                        if (!(lector.IsDBNull(0))) //veririfca que no sean datos null
                        {
                            MiExp.Clasificación           = lector.GetString(0);
                            MiExp.idFondo                 = lector.GetString(1);
                            MiExp.idseccion               = lector.GetString(2);
                            MiExp.idserie                 = lector.GetString(3);
                            MiExp.no_exp                  = lector.GetInt32(4);
                            MiExp.año                     = lector.GetInt32(5);
                            MiExp.id_unid_admva_resp      = lector.GetString(6);
                            MiExp.id_area_prod            = lector.GetString(7);
                            MiExp.id_resp_exp             = lector.GetString(8);
                            MiExp.resumen_exp             = lector.GetString(9);
                            MiExp.asunto_exp              = lector.GetString(10);
                            MiExp.funcion_exp             = lector.GetString(11);
                            MiExp.acceso_exp              = lector.GetString(12);
                            MiExp.val_prim_exp            = lector.GetString(13);
                            MiExp.fec_ext_ini_exp         = lector.GetDateTime(14);
                            MiExp.fec_ext_fin_exp         = lector.GetDateTime(15);
                            MiExp.no_legajo_exp           = lector.GetInt32(16);
                            MiExp.no_fojas_exp            = lector.GetInt32(17);
                            MiExp.vinc_otro_exp           = lector.GetString(18);
                            MiExp.id_exp_vincd            = lector.GetString(19);
                            MiExp.formato_Soporte         = lector.GetString(20);
                            MiExp.plazo_conservacion_exp  = lector.GetInt32(21);
                            MiExp.tipo_exp                = lector.GetString(22);
                            MiExp.destino_final_exp       = lector.GetString(23);
                            MiExp.valores_secundarios_exp = lector.GetString(24);
                            MiExp.id_ubic_topog           = lector.GetString(25);
                            MiExp.IdEdificio              = lector.GetString(26);
                            MiExp.IdPisoEd                = lector.GetString(27);
                            MiExp.IdPasillo               = lector.GetString(28);
                            MiExp.IdEstante               = lector.GetString(29);
                            MiExp.IdCharola               = lector.GetString(30);
                            MiExp.IdUnidInsCaja           = lector.GetString(31);
                            MiExp.fecha_alta_exp          = lector.GetDateTime(32);
                            MiExp.id_capturista_exp       = lector.GetString(33);
                            MiExp.id_autorizador_exp      = lector.GetString(34);
                        }
                    } while (lector.Read());
                    selecciona.desconectar();
                    selecciona.dr.Close();

                    return(MiExp);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }