Example #1
0
        public static bool CreateForm(OdbcDataReader reader, Payment payment)
        {
            int fCount = reader.FieldCount;

            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name)
                {
                case "course_id": payment._courseID = reader.GetInt32(i);
                    break;

                case "sum_all_cost": payment._sumAllCost = reader.GetInt32(i);
                    break;

                case "sum_max_payable": payment._sumMaxPayable = reader.GetInt32(i);
                    break;

                case "sum_paid_cost": payment._sumPaidCost = reader.GetInt32(i);
                    break;

                case "last_paid_date": payment._lastPaidDate = new DateTime(reader.GetDate(i).Ticks);
                    break;

                case "paid_round": payment._paidRound = reader.GetInt32(i);
                    break;

                case "status": payment._status = reader.GetInt32(i);
                    break;

                // helper info
                case "bts_course_id": payment._btsCourseID = reader.GetString(i);
                    break;

                case "course_name": payment._courseName = reader.GetString(i);
                    break;

                case "course_start_date": payment._courseStartDate = new DateTime(reader.GetDate(i).Ticks);
                    break;

                case "course_end_date": payment._courseEndDate = new DateTime(reader.GetDate(i).Ticks);
                    break;

                case "paid_group_id": payment._paidGroupID = reader.GetInt32(i);
                    break;
                }
            }
            return(reader.HasRows);
        }
Example #2
0
        //obtener datos para el datagrid de encabezados de ordenes de compra
        public List <OrdenCompraEncabezado> llenarDGVOrdenCompraEncabezado()
        {
            List <OrdenCompraEncabezado> ordenCompraEncabezadoList = new List <OrdenCompraEncabezado>();

            try
            {
                string sComando = string.Format("SELECT id_orden_compra_encabezado, nombre_orden_compra, fecha_emision, ESTADO " +
                                                "FROM ordenes_compras_encabezado;");

                OdbcDataReader reader = transaccion.ConsultarDatos(sComando);

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        OrdenCompraEncabezado movimientoEncabezadoTmp = new OrdenCompraEncabezado();
                        movimientoEncabezadoTmp.ID_ORDEN_COMPRA_ENCABEZADO = reader.GetInt32(0);
                        movimientoEncabezadoTmp.NOMBRE_ORDEN_COMPRA        = reader.GetString(1);
                        movimientoEncabezadoTmp.FECHA_EMISION = reader.GetDate(2);
                        movimientoEncabezadoTmp.ESTADO        = reader.GetInt32(3);
                        ordenCompraEncabezadoList.Add(movimientoEncabezadoTmp);
                    }
                }
                return(ordenCompraEncabezadoList);
            }
            catch (OdbcException ex)
            {
                mensaje = new Mensaje("Error en la operacion con la Base de Datos: \n" + ex.Message);
                mensaje.Show();
                return(null);
            }
        }
Example #3
0
        public void obtenerAllEncabezados(DataGridView dgv)
        {
            transaccion transaccion = new transaccion();

            try
            {
                string sComando = string.Format("SELECT ID_ENCABEZADO, MEMBRESIA, FECHA_INICIO, ESTADO " +
                                                "FROM renta_encabezado;");

                OdbcDataReader reader = transaccion.ConsultarDatos(sComando);
                int            fila   = 0;
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        dgv.Rows.Add();
                        dgv.Rows[fila].Cells[0].Value = reader.GetInt32(0);
                        dgv.Rows[fila].Cells[1].Value = reader.GetInt32(1);
                        dgv.Rows[fila].Cells[2].Value = reader.GetDate(2);
                        dgv.Rows[fila].Cells[3].Value = reader.GetInt32(3);
                        fila++;
                    }
                }
                return;
            }
            catch (OdbcException ex)
            {
                MessageBox.Show(ex.ToString(), "Error al obtener Renta");
                return;
            }
        }
Example #4
0
        public static List <Hospitalization> getList(OdbcDataReader reader)
        {
            List <Hospitalization> list = new List <Hospitalization>();
            Hospitalization        hospitalizations;

            while (reader.Read())
            {
                hospitalizations       = new Hospitalization();
                hospitalizations.C_ID  = reader.GetInt32(0);
                hospitalizations.S_ID  = reader.GetInt32(1);
                hospitalizations.H_In  = reader.GetDate(2);
                hospitalizations.H_Out = reader.GetDate(3);
                hospitalizations.H_Sum = reader.GetFloat(4);
                list.Add(hospitalizations);
            }
            return(list);
        }
Example #5
0
        public List <SmsTable> GetSmsTable(string loanScheme, DateTime toDate, DateTime fromDate, string category)
        {
            List <SmsTable> table        = new List <SmsTable>();
            OdbcConnection  DbConnection = new OdbcConnection(initialiseDb('r', ""));

            OdbcCommand DbCommand = null;

            try
            {
                DbConnection.Open();
                DbCommand = DbConnection.CreateCommand();

                if (category.Equals("01") || category.Equals("05"))
                {
                    DbCommand.CommandText = "SELECT LON_CODE,END_DT,MNAME,RCONTACT,MBRMAST.MCODE FROM CCLNMAS INNER JOIN MBRMAST ON CCLNMAS.MCODE=MBRMAST.MCODE" +
                                            " WHERE END_DT >= #" + fromDate.Date + "# AND END_DT <= +#" + toDate.Date + "# AND mid(LON_CODE,1,3) = '" + loanScheme + "'";
                }
                else
                {
                    DbCommand.CommandText = "SELECT LON_CODE,END_DT,MNAME,RCONTACT,MBRMAST.MCODE FROM LOAN_MAS INNER JOIN MBRMAST ON LOAN_MAS.MCODE=MBRMAST.MCODE" +
                                            " WHERE END_DT >= #" + fromDate.Date + "# AND END_DT <= +#" + toDate.Date + "# AND mid(LON_CODE,1,3) = '" + loanScheme + "'";
                }
                OdbcDataReader DbReader = DbCommand.ExecuteReader();
                int            fCount   = DbReader.FieldCount;
                while (DbReader.Read())
                {
                    for (int i = 0; i < fCount; i++)
                    {
                        if (DbReader.GetValue(i + 3).ToString().Length == 10)
                        {
                            table.Add(new SmsTable()
                            {
                                LoanCode   = DbReader.GetValue(i).ToString(),
                                DueDate    = DbReader.GetDate(++i).ToString("MM-dd-yyyy"),
                                Name       = DbReader.GetValue(++i).ToString(),
                                MobileNo   = DbReader.GetValue(++i).ToString(),
                                MemberCode = DbReader.GetValue(++i).ToString(),
                                SendSMS    = true
                            });
                        }
                        else
                        {
                            i = i + 4;
                        }
                    }
                }
                DbReader.Close();
            }catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
            }
            if (DbCommand != null)
            {
                DbCommand.Dispose();
            }
            DbConnection.Close();
            return(table);
        }
Example #6
0
        //obtener datos de una orden de compra
        public OrdenCompraEncabezado obtenerOrdenEncabezado(int encabezado)
        {
            try
            {
                string sComando = string.Format("" +
                                                "select " +
                                                "id_orden_compra_encabezado, " +
                                                "nombre_orden_compra, " +
                                                "descripcion_orden_compra, " +
                                                "id_proveedor, " +
                                                "fecha_estimada_entrega, " +
                                                "fecha_emision, " +
                                                "entregado, " +
                                                "ESTADO " +
                                                "from " +
                                                "ordenes_compras_encabezado " +
                                                "where " +
                                                "id_orden_compra_encabezado = {0};",
                                                encabezado);

                OdbcDataReader reader = transaccion.ConsultarDatos(sComando);

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        ordenCompraEncabezado.ID_ORDEN_COMPRA_ENCABEZADO = reader.GetInt32(0);
                        ordenCompraEncabezado.NOMBRE_ORDEN_COMPRA        = reader.GetString(1);
                        ordenCompraEncabezado.DESCRIPCION_ORDEN_COMPRA   = reader.GetString(2);
                        ordenCompraEncabezado.PROVEEDOR = sql_proveedor.obtenerProveedor(reader.GetInt32(3));
                        ordenCompraEncabezado.FECHA_ESTIMADA_ENTREGA = reader.GetDate(4);
                        ordenCompraEncabezado.FECHA_EMISION          = reader.GetDate(5);
                        ordenCompraEncabezado.ENTREGADO = reader.GetInt32(6);
                        ordenCompraEncabezado.ESTADO    = reader.GetInt32(7);
                    }
                }
                return(ordenCompraEncabezado);
            }
            catch (OdbcException ex)
            {
                mensaje = new Mensaje("Error en la operacion con la Base de Datos: \n" + ex.Message);
                mensaje.Show();
                return(null);
            }
        }
Example #7
0
        public static List <Discount> getList(OdbcDataReader reader)
        {
            List <Discount> list = new List <Discount>();
            Discount        s;

            while (reader.Read())
            {
                s           = new Discount();
                s.ID        = reader.GetString(0);
                s.G_ID      = reader.GetString(1);
                s.DDiscount = reader.GetDouble(2);
                s.Start     = reader.GetDate(3);
                s.End       = reader.GetDate(4);

                list.Add(s);
            }
            return(list);
        }
Example #8
0
        public static bool CreateForm(OdbcDataReader reader, Teacher teacher)
        {
            int fCount = reader.FieldCount;

            for (int i = 0; i < fCount; i++)
            {
                string name = reader.GetName(i);

                // Map to DB field. Need to change if db changed
                switch (name)
                {
                case "teacher_id": teacher._teacherID = reader.GetInt32(i);
                    break;

                case "sex": teacher._sex = reader.GetString(i);
                    break;

                case "addr": teacher._addr = reader.GetString(i);
                    break;

                case "tel": teacher._tel = reader.GetString(i);
                    break;

                case "email": teacher._email = reader.GetString(i);
                    break;

                case "birthday":
                    teacher._birthday = new DateTime(reader.GetDate(i).Ticks);
                    break;

                case "firstname": teacher._firstname = reader.GetString(i);
                    break;

                case "surname": teacher._surname = reader.GetString(i);
                    break;

                case "citizen_id": teacher._citizenID = reader.GetString(i);
                    break;

                case "image": teacher._img = reader.GetString(i);
                    break;

                case "subject": teacher._subject = reader.GetString(i);
                    break;

                case "is_active": teacher._isActive = reader.GetInt32(i) > 0 ? true : false;
                    break;
                }
            }
            return(reader.HasRows);
        }
        public static List <StatisticDay> getList(OdbcDataReader reader)
        {
            List <StatisticDay> list = new List <StatisticDay>();
            StatisticDay        s;

            while (reader.Read())
            {
                s       = new StatisticDay();
                s.Date  = reader.GetDate(0);
                s.Price = reader.GetDouble(1);
                list.Add(s);
            }
            return(list);
        }
Example #10
0
    public static Match getNextMatch(OdbcConnection con)
    {
        Match          match  = null;
        OdbcCommand    cmd    = new OdbcCommand("SELECT TOP 1 * FROM partido ORDER BY fecha ASC;", con);
        OdbcDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            match = new Match(reader.GetInt32(0), reader.GetDate(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4));
        }
        match.parseMatch(con);
        con.Close();
        return(match);
    }
 private void button10_Click(object sender, EventArgs e)
 {
     if (textBox3.Text != "")
     {
         OdbcConnection conexion = TaquillaDB.getDB();
         try
         {
             string         sql    = string.Format("SELECT F.ID_FUNCION, P.NOMBRE_PELICULA, F.FECHA_FUNCION, S.DESCRIPCION_SUBTITULADO, I.DESCRIPCION_IDIOMA, H.DESCRIPCION_HORARIO, F.ID_SALA, FR.DESCRIPCION_FORMATO FROM FUNCION F, PELICULA P, SUBTITULADO S, IDIOMA I, HORARIO H, FORMATO FR WHERE F.ID_PELICULA = P.ID_PELICULA AND F.ID_SUBTITULADO = S.ID_SUBTITULADO AND F.ID_IDIOMA = I.ID_IDIOMA AND F.ID_HORARIO = H.ID_HORARIO AND F.ID_FORMATO = FR.ID_FORMATO AND ID_FUNCION = '{0}'", textBox3.Text);
             OdbcCommand    cmd    = new OdbcCommand(sql, conexion);
             OdbcDataReader reader = cmd.ExecuteReader();
             if (reader.Read())
             {
                 dateTimePicker2.Enabled  = true;
                 comboBox2.Enabled        = true;
                 comboBox10.Enabled       = true;
                 comboBox9.Enabled        = true;
                 comboBox6.Enabled        = true;
                 comboBox5.Enabled        = true;
                 comboBox12.Enabled       = true;
                 textBox3.Enabled         = false;
                 button10.Enabled         = false;
                 button2.Enabled          = false;
                 button7.Enabled          = true;
                 button6.Enabled          = true;
                 comboBox2.SelectedIndex  = comboBox2.FindString(reader.GetString(1));
                 dateTimePicker2.Value    = reader.GetDate(2);
                 comboBox10.SelectedIndex = comboBox10.FindString(reader.GetString(3));
                 comboBox9.SelectedIndex  = comboBox9.FindString(reader.GetString(4));
                 comboBox6.SelectedIndex  = comboBox6.FindString(reader.GetString(5));
                 comboBox5.SelectedIndex  = comboBox5.FindString(reader.GetString(6));
                 comboBox12.SelectedIndex = comboBox12.FindString(reader.GetString(7));
             }
             else
             {
                 MessageBox.Show("FUNCION NO ENCONTRADA!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
         conexion.Close();
     }
     else
     {
         MessageBox.Show("ESCRIBA UN ID FUNCION!", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
         textBox3.Focus();
     }
 }
        /// <summary>
        /// Gets a set of work order data based on the parameters to be set to a ListView object.
        /// </summary>
        /// <param name="StatusFilter"></param>
        /// <param name="ProductionTypeFilter"></param>
        /// <returns>A list of work order data sorted into ListViewItem's.</returns>
        public List <ListViewItem> GetWorkOrdersForSelectListView(string StatusFilter, string ProductionTypeFilter)
        {
            List <ListViewItem> items = new List <ListViewItem>();

            OdbcCommand cmdSelectWorkOrders = new OdbcCommand();
            string      qry = @" SELECT WorkOrderNo, ProductionType, ProductWarehouse, 
                            ProductNumber, ProductionLine, Status, 
                            NoBatches, PlannedDate, PlannedShift 
                            FROM PS_WORKORDERS
                            WHERE STATUS like ? AND ProductionType like ?
                            ORDER BY WorkOrderNo";

            try
            {
                cmdSelectWorkOrders             = Odbc.CreateCommand();
                cmdSelectWorkOrders.CommandText = qry;
                cmdSelectWorkOrders.Parameters.Add("@Status", OdbcType.Text).Value         = StatusFilter;
                cmdSelectWorkOrders.Parameters.Add("@ProductionType", OdbcType.Text).Value = ProductionTypeFilter;

                OdbcDataReader reader = cmdSelectWorkOrders.ExecuteReader();

                while (reader.Read())
                {
                    string won = reader.GetString(0);
                    string prt = reader.GetString(1);
                    string prw = reader.GetString(2);
                    string prn = reader.GetString(3);
                    string prl = reader.GetString(4);
                    string sta = reader.GetString(5);
                    var    nob = reader.GetValue(6);
                    string pld = reader.GetDate(7).ToString("yy-MM-dd");
                    string pls = reader.GetString(8);

                    ListViewItem item = new ListViewItem(new[] { won, prt, prw, prn, prl, sta, nob.ToString(), pld, pls });
                    items.Add(item);
                }
            }
            catch (OdbcException odbce)
            {
                Utilities.ShowError(odbce.Message, odbce.ToString());
            }
            catch (Exception e)
            {
                Utilities.ShowError(e.Message, e.ToString());
            }

            return(items);
        }
Example #13
0
        public static List <StaticGoods> getList(OdbcDataReader reader)
        {
            List <StaticGoods> list = new List <StaticGoods>();
            StaticGoods        s;

            while (reader.Read())
            {
                s       = new StaticGoods();
                s.G_ID  = reader.GetString(0);
                s.Date  = reader.GetDate(1);
                s.Price = reader.GetDouble(2);
                s.Num   = reader.GetDouble(3);
                list.Add(s);
            }
            return(list);
        }
Example #14
0
        public static List <Order> getList(OdbcDataReader reader)
        {
            List <Order> list = new List <Order>();
            Order        s;

            while (reader.Read())
            {
                s       = new Order();
                s.ID    = reader.GetString(0);
                s.Price = reader.GetDouble(1);
                s.Time  = reader.GetDate(2);
                s.E_ID  = reader.GetInt32(3);
                list.Add(s);
            }
            return(list);
        }
Example #15
0
        private void llenarComboBoxActivos()
        {
            lActivosId.Clear();
            lActivosNumPlaca.Clear();
            lActivosNumSerie.Clear();
            lActivosFechaCompra.Clear();
            lActivosValor.Clear();
            lActivosNombreEmpleado.Clear();
            lACtivoNombre.Clear();
            lACtivoUbicacion.Clear();
            cboActivo.Items.Clear();

            OdbcCommand sql = new OdbcCommand("Select tbl_activo.PK_idActivo " +
                                              ", tbl_activo.fecha_compra " +
                                              ", tbl_activo.valor " +
                                              ", tbl_empleado.nombre" +
                                              ", tbl_empleado.apellido" +
                                              ", tbl_inventario_hardware.numero_serie" +
                                              ", tbl_inventario_hardware.numero_placa" +
                                              ", tbl_inventario_hardware.nombre" +
                                              ", tbl_punto_venta.direccion" +
                                              " FROM tbl_activo INNER JOIN tbl_inventario_hardware " +
                                              " ON tbl_activo.PK_idActivo = TBL_inventario_hardware.PK_idActivo " +
                                              " INNER JOIN tbl_empleado " +
                                              " ON tbl_activo.cod_empleado_asignado = tbl_empleado.PK_idEmpleado " +
                                              " INNER JOIN tbl_auditoria_encabezado ON tbl_inventario_hardware.cod_area = tbl_auditoria_encabezado.cod_area" +
                                              " INNER JOIN tbl_punto_venta ON tbl_empleado.cod_punto_venta = tbl_punto_venta.PK_idPuntoVenta" +
                                              " WHERE tbl_auditoria_encabezado.estado = 0 " +
                                              " AND tbl_auditoria_encabezado.cod_area =" + sCodAuditoriaActual, con);

            OdbcDataReader almacena = sql.ExecuteReader();

            while (almacena.Read() == true)
            {
                cboActivo.Items.Add(almacena.GetString(0) + " - " + almacena.GetString(7));

                lActivosId.Add(almacena.GetString(0));
                lActivosFechaCompra.Add(almacena.GetDate(1).ToString());
                lActivosValor.Add(almacena.GetDouble(2).ToString());
                lActivosNombreEmpleado.Add(almacena.GetString(4) + ", " + almacena.GetString(3));
                lActivosNumSerie.Add(almacena.GetString(5));
                lActivosNumPlaca.Add(almacena.GetString(6));
                lACtivoNombre.Add(almacena.GetString(7));
                lACtivoUbicacion.Add(almacena.GetString(8));
            }
            almacena.Close();
        }
Example #16
0
        public static List <Test> getList(OdbcDataReader reader)
        {
            List <Test> list = new List <Test>();
            Test        tests;

            while (reader.Read())
            {
                tests          = new Test();
                tests.IT_ID    = reader.GetInt32(0);
                tests.C_ID     = reader.GetInt32(1);
                tests.IT_Name  = reader.GetString(2);
                tests.T_Date   = reader.GetDate(3);
                tests.IT_Price = reader.GetFloat(4);
                list.Add(tests);
            }
            return(list);
        }
Example #17
0
        public static Carte findByNumero(string numero)
        {
            Carte       carte = null;
            OdbcCommand cmd   = new OdbcCommand("select * from carte where Numero=?", AccesBd.getConnection());

            cmd.Parameters.Add("@numero", OdbcType.VarChar).Value = numero;
            OdbcDataReader dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                carte = new Carte {
                    Id = dr.GetInt32(0), Numero = dr.GetString(1), DateCreation = dr.GetDate(2), DateExpiration = dr.GetDate(3), Type = dr.GetString(4), Code = dr.GetString(5), Porteur = dr.GetString(6), Solde = dr.GetInt32(7), SoldeMin = dr.GetInt32(8)
                };
            }
            cmd.Dispose();
            return(carte);
        }
Example #18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OdbcConnection miConexion = conectarBD();

            if (miConexion != null)
            {
                try {
                    //Primero llenamos los eventos
                    String         query = String.Format("SELECT TOP (10) Deporte.nombre as Deporte, CAST(Evento.fecha as VARCHAR) as Fecha, CAST(Evento.hora as VARCHAR(5)) as Hora, Evento.descripcion as Descripción FROM Evento, Deporte WHERE Evento.fecha >= '{0}' AND Evento.idDep = Deporte.idDep", DateTime.Now.ToString("yyyy/MM/dd"));
                    OdbcCommand    cmd   = new OdbcCommand(query, miConexion);
                    OdbcDataReader rd    = cmd.ExecuteReader();
                    proximosEventosView.DataSource = rd;
                    proximosEventosView.DataBind();
                    //Para el dropdown list de eventos
                    query = String.Format("SELECT TOP(10) Evento.idEvento, Deporte.nombre, CAST(Evento.fecha as VARCHAR) as Fecha FROM Evento, Deporte WHERE Evento.fecha >= '{0}' AND Evento.idDep = Deporte.idDep", DateTime.Now.ToString("yyyy/MM/dd"));
                    cmd   = new OdbcCommand(query, miConexion);
                    rd    = cmd.ExecuteReader();
                    ListItem row;
                    String   texto;
                    eventosList.Items.Clear();
                    while (rd.Read())
                    {
                        row       = new ListItem();
                        texto     = rd.GetString(1) + " del día: " + rd.GetDate(2).ToString("dd/MM/yyyy");
                        row.Text  = texto;
                        row.Value = rd.GetInt16(0).ToString();
                        eventosList.Items.Add(row);
                    }

                    //Llenamos los Equipos
                    query = "SELECT Equipo.nombre as Equipo, Deporte.nombre as Deporte, Equipo.jugados as 'Partidos Juagdos', Equipo.ganados as 'Partidos Ganados', Equipo.perdidos as 'Partidos Perdidos' FROM Equipo, Deporte WHERE Equipo.idDep = Deporte.idDep";
                    cmd   = new OdbcCommand(query, miConexion);
                    rd    = cmd.ExecuteReader();
                    equiposView.DataSource = rd;
                    equiposView.DataBind();

                    //Cerramos la conexión
                    miConexion.Close();
                } catch (Exception ex) {                 //Por si hay errores con el odbc
                    String tipo   = "precaucion";
                    String script = forScripts(tipo, ex.Message.ToString());
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                }
            }
        }
        //obtener un solo movimiento encabezado
        public MovimientoEncabezado obtenerMovimientoEncabezado(int id_movimiento_inventario_encabezado)
        {
            SQL_TipoMovimiento   tipoMovimiento       = new SQL_TipoMovimiento();
            MovimientoEncabezado movimientoEncabezado = new MovimientoEncabezado();

            try
            {
                string sComando = string.Format("" +
                                                "SELECT " +
                                                "ID_MOVIMIENTO_INVENTARIO_ENCABEZADO, " +
                                                "ID_TIPO_MOVIMIENTO, " +
                                                "NOMBRE_MOVIMIENTO, " +
                                                "DESCRIPCION_MOVIMIENTO, " +
                                                "FECHA_MOVIMIENTO, " +
                                                "ESTADO " +
                                                "FROM movimientos_inventario_encabezado " +
                                                "WHERE ID_MOVIMIENTO_INVENTARIO_ENCABEZADO = {0}; ",
                                                id_movimiento_inventario_encabezado);

                OdbcDataReader reader = transaccion.ConsultarDatos(sComando);

                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        movimientoEncabezado.ID_MOVIMIENTO_ENCABEZADO = reader.GetInt32(0);
                        movimientoEncabezado.TIPO_MOVIMIENTO          = tipoMovimiento.obtenerTipoMovimiento(reader.GetInt32(1));
                        movimientoEncabezado.NOMBRE_MOVIMIENTO        = reader.GetString(2);
                        movimientoEncabezado.DESCRIPCION_MOVIMIENTO   = reader.GetString(3);
                        movimientoEncabezado.FECHA_MOVIMIENTO         = reader.GetDate(4);
                        movimientoEncabezado.ESTADO = reader.GetInt32(5);
                    }
                }
                return(movimientoEncabezado);
            }
            catch (OdbcException ex)
            {
                mensaje = new Mensaje("Error en la operacion con la Base de Datos: \n" + ex.Message);
                mensaje.Show();
                return(null);
            }

            return(null);
        }
Example #20
0
    public static List <Match> getMatchesByDate(String date, OdbcConnection con)
    {
        List <Match>   list   = new List <Match>();
        OdbcCommand    cmd    = new OdbcCommand(String.Format("SELECT * FROM partido WHERE fecha LIKE '%{0}%'", date), con);
        OdbcDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            list.Add(new Match(reader.GetInt32(0), reader.GetDate(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4)));
        }
        reader.Close();

        foreach (Match match in list)
        {
            match.parseMatch(con);
        }
        con.Close();
        return(list);
    }
Example #21
0
        public static List <GoodsIn> getList(OdbcDataReader reader)
        {
            List <GoodsIn> list = new List <GoodsIn>();
            GoodsIn        s;

            while (reader.Read())
            {
                s             = new GoodsIn();
                s.GI_ID       = reader.GetString(0);
                s.G_ID        = reader.GetString(1);
                s.S_ID        = reader.GetInt32(2);
                s.PriceIn     = reader.GetDouble(3);
                s.Num         = reader.GetDouble(4);
                s.Date        = reader.GetDate(5);
                s.OriginPlace = reader.GetString(6);
                list.Add(s);
            }
            return(list);
        }
Example #22
0
    public static List <Match> getMatches(OdbcConnection con)
    {
        List <Match>   list   = new List <Match>();
        OdbcCommand    cmd    = new OdbcCommand("SELECT * FROM partido;", con);
        OdbcDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            list.Add(new Match(reader.GetInt32(0), reader.GetDate(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4)));
        }
        reader.Close();

        foreach (Match match in list)
        {
            match.parseMatch(con);
        }
        con.Close();
        return(list);
    }
Example #23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OdbcConnection miConexion = conectarBD();

            if (miConexion != null)
            {
                try {
                    //Primero llenamos los eventos
                    String         query = String.Format("SELECT * FROM Evento, Deporte WHERE Evento.idEvento = '{0}' AND Evento.idDep = Deporte.idDep", Convert.ToInt16(Session["idEvento"]));
                    OdbcCommand    cmd   = new OdbcCommand(query, miConexion);
                    OdbcDataReader rd    = cmd.ExecuteReader();
                    rd.Read();
                    String fecha       = "Fecha: " + rd.GetDate(1);
                    String hora        = "Hora: " + rd.GetDateTime(2);
                    String lugar       = "Lugar: " + rd.GetString(3);
                    String descripcion = "Descrípción: " + rd.GetString(4);
                    Char   idDeporte   = rd.GetChar(5);
                    String deporte     = rd.GetString(7);
                    listEvento.Items.Add(fecha);
                    listEvento.Items.Add(hora);
                    listEvento.Items.Add(lugar);
                    listEvento.Items.Add(descripcion);
                    lbEquipo.Text = deporte;
                    rd.Close();

                    query = String.Format("Select nombre From Equipo Where idDep = '{0}'", idDeporte);
                    cmd   = new OdbcCommand(query, miConexion);
                    rd    = cmd.ExecuteReader();
                    while (rd.Read())
                    {
                        listParticipantes.Items.Add(rd.GetString(0));
                    }

                    //Cerramos la conexión
                    miConexion.Close();
                } catch (Exception ex) {                 //Por si hay errores con el odbc
                    String tipo   = "precaucion";
                    String script = forScripts(tipo, ex.Message.ToString());
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
                }
            }
        }
Example #24
0
        public static List <Employee> getList(OdbcDataReader reader)
        {
            List <Employee> list = new List <Employee>();
            Employee        employee;

            while (reader.Read())
            {
                employee             = new Employee();
                employee.ID          = reader.GetString(0);
                employee.Name        = reader.GetString(1);
                employee.Sex         = reader.GetString(2);
                employee.Phone       = reader.GetString(3);
                employee.Birth       = reader.GetDate(4);
                employee.BankAccount = reader[5].ToString();
                employee.Email       = reader[6].ToString();
                employee.Position    = reader.GetInt32(7);
                employee.PassWord    = reader.GetString(8);
                list.Add(employee);
            }
            return(list);
        }
Example #25
0
    public static List <Match> getPreviousMatches(String teamName, OdbcConnection con)
    {
        List <Match>   list   = new List <Match>();
        Team           team   = Team.getTeamByName(teamName, con, false);
        OdbcCommand    cmd    = new OdbcCommand(String.Format("SELECT * FROM partido WHERE fecha < GETDATE() AND (idLocal = {0} OR idVisitante = {0})", team.id), con);
        OdbcDataReader reader = cmd.ExecuteReader();

        while (reader.Read())
        {
            list.Add(new Match(reader.GetInt32(0), reader.GetDate(1), reader.GetInt32(2), reader.GetInt32(3), reader.GetInt32(4)));
        }

        reader.Close();

        foreach (Match match in list)
        {
            Console.Out.WriteLine(match.ToString());
            match.parseMatch(con);
        }
        con.Close();
        return(list);
    }
Example #26
0
        public List <string> CE_dispesa_realizada(string Query, string[] Coluna, string[] Filtros)
        {
            Ender_Banco    Conexao        = new Ender_Banco();
            List <string>  Valid          = new List <string>();
            OdbcConnection Data_Conection = new OdbcConnection(Conexao.Conexao_Banco);
            OdbcCommand    command        = new OdbcCommand(Query, Data_Conection);

            try
            {
                Data_Conection.Open();
                command.CommandText = Query;
                for (int cont = 0; cont < Coluna.Count(); cont++)
                {
                    command.Parameters.AddWithValue("@" + Coluna[cont], Filtros[cont]);
                }
                command.ExecuteNonQuery();
                OdbcDataReader Reader = command.ExecuteReader();
                while (Reader.Read())
                {
                    Valid.Add(Reader.GetInt64(0).ToString());
                    Valid.Add(Reader.GetString(1).ToString());
                    Valid.Add(Reader.GetString(2).ToString());
                    Valid.Add(Reader.GetString(3).ToString());
                    Valid.Add(Reader.GetInt16(4).ToString());
                    Valid.Add(Reader.GetInt64(5).ToString());
                    Valid.Add(Reader.GetDate(6).ToString("yyyy-MM-dd"));
                }
            }
            catch (OdbcException Erro)
            {
                Valid.Add(Erro.Message);
            }
            finally
            {
                Data_Conection.Close();
            }
            return(Valid);
        }
Example #27
0
        public static List <Storelist> getList(OdbcDataReader reader)
        {
            List <Storelist> list = new List <Storelist>();
            Storelist        s;

            while (reader.Read())
            {
                s              = new Storelist();
                s.G_ID         = reader.GetString(0);
                s.GI_ID        = reader.GetString(1);
                s.Num          = reader.GetDouble(2);
                s.ProducedDate = reader.GetDate(3);
                string         sql            = "select G_Store from goods where G_ID='" + s.G_ID + "'";
                OdbcConnection odbcConnection = DBManager.GetOdbcConnection();
                odbcConnection.Open();
                OdbcCommand    odbcCommand    = new OdbcCommand(sql, odbcConnection);
                OdbcDataReader odbcDataReader = odbcCommand.ExecuteReader(CommandBehavior.CloseConnection);
                odbcDataReader.Read();
                s.G_Store = odbcDataReader.GetInt32(0);
                list.Add(s);
            }
            return(list);
        }
Example #28
0
        /// <summary>
        /// Loads data from the current row in the kitlog database
        /// </summary>
        /// <param name="reader"></param>
        public void Load(OdbcDataReader reader)
        {
            shortDescription = reader.GetString(reader.GetOrdinal("short_description"));
            comments         = reader.GetString(reader.GetOrdinal("comments"));
            image1Caption    = reader.GetString(reader.GetOrdinal("caption_1"));
            image2Caption    = reader.GetString(reader.GetOrdinal("caption_2"));
            image3Caption    = reader.GetString(reader.GetOrdinal("caption_3"));
            dateOfWork       = reader.GetDate(reader.GetOrdinal("date_of_work"));
            image1           = ImageFromColumn("photo_1", reader);
            image2           = ImageFromColumn("photo_2", reader);
            image3           = ImageFromColumn("photo_3", reader);
            category         = reader.GetString(reader.GetOrdinal("expense_category_name"));
            manualRefNumber  = reader.GetString(reader.GetOrdinal("manual_ref_number"));
            hours            = Decimal.Round(Convert.ToDecimal(reader.GetDouble(reader.GetOrdinal("number_of_hours"))), 2, MidpointRounding.AwayFromZero);

            string dateOfWorkString = dateOfWork.ToString("yyyy-MM-dd");
            string fileDescription  = Regex.Replace(shortDescription.Replace(' ', '-'), "[^a-zA-Z0-9-]", "");
            string baseName         = dateOfWorkString + "-" + fileDescription;

            postFileName   = baseName + ".md";
            image1FileName = baseName + "-" + 1 + ".jpg";
            image2FileName = baseName + "-" + 2 + ".jpg";
            image3FileName = baseName + "-" + 3 + ".jpg";
        }
Example #29
0
        protected String[,] LoadStudentList(DBManager db)
        {
            // Load all information
            Course c = new Course();

            c.LoadFromDB(db);

            String sqlCount = "SELECT Count(*) FROM student";
            String sql      = "SELECT s.student_id, s.firstname, s.surname, s.nickname, s.sex, s.birthday, s.citizen_id, s.addr, s.email, s.tel, s.tel2, s.school, s.level, s.create_date, s.is_active";

            String sqlWhere = " FROM student s"
                              + " ORDER BY s.student_id";

            int num = db.QueryCount(sqlCount);

            String[,] result = new String[num, 14];

            int            n      = 0;
            OdbcDataReader reader = db.Query(sql + sqlWhere);

            while (reader.Read())
            {
                int fCount = reader.FieldCount;
                for (int i = 0; i < fCount; i++)
                {
                    string name = reader.GetName(i);
                    switch (name)
                    {
                    case "student_id": result[n, 0] = Student.GetStudentID(reader.GetInt32(i).ToString());
                        break;

                    case "firstname": result[n, 1] = reader.GetString(i);
                        break;

                    case "surname": result[n, 1] = result[n, 1] + " " + reader.GetString(i);
                        break;

                    case "nickname": result[n, 2] = reader.GetString(i);
                        break;

                    case "sex": result[n, 3] = reader.GetString(i);
                        break;

                    case "birthday": result[n, 4] = reader.GetDate(i).ToString();
                        break;

                    case "citizen_id": result[n, 5] = reader.GetString(i);
                        break;

                    case "addr": result[n, 6] = reader.GetString(i);
                        break;

                    case "email": result[n, 7] = reader.GetString(i);
                        break;

                    case "tel": result[n, 8] = "=\"" + reader.GetString(i) + "\"";
                        break;

                    case "tel2": result[n, 9] = "=\"" + reader.GetString(i) + "\"";
                        break;

                    case "school": result[n, 10] = reader.GetString(i);
                        break;

                    case "level": result[n, 11] = StringUtil.ConvertEducateLevel(reader.GetInt32(i));
                        break;

                    case "create_date": result[n, 12] = reader.GetDate(i).ToString();
                        break;

                    case "is_active": result[n, 13] = (reader.GetInt32(i) == 1 ? "ปกติ" : "ลบ");
                        break;
                    }
                }
                n++;
            }

            return(result);
        }
Example #30
0
        /// <summary>
        /// Selects a work order from the database
        /// </summary>
        /// <param name="workOrderNo">The work order number to select</param>
        public void SelectOrder(string workOrderNo)
        {
            var            selectQry = @"SELECT
                WorkOrderNo, ProductionType,ProductionLine,
                ProductWarehouse,ProductNumber,ProductDescription,
                PlannedUOM,PlannedQuantity,PlannedDate,PlannedShift,
                ProdLineCapacity,ReOrderPoint,NoBatches,BatchSize,
                CustomerOrderNo,FGWorkOrderNo,Status,ActualMftQty,ActualDate,ActualShift,
                Comments,CreationDate,CreationUser,LastModifiedDate,LastModifiedUser
                FROM PS_WORKORDERS WHERE WorkOrderNo = ?
            ";
            OdbcConnection odbc      = new OdbcConnection();
            OdbcCommand    cmd       = new OdbcCommand();

            int wo = 0;

            int.TryParse(workOrderNo, out wo);

            try
            {
                odbc.ConnectionString = Constants.GETODBCCONNECTIONSTRING(Company);
                odbc.Open();

                cmd             = odbc.CreateCommand();
                cmd.CommandText = selectQry;
                cmd.Parameters.Add("WorkOrderNo", OdbcType.Int).Value = wo;

                OdbcDataReader reader = cmd.ExecuteReader();

                reader.Read();

                #region Assign parameters with reader

                WorkOrderNo    = (int)reader.GetValue(0);// .GetString(0);
                ProductionType = reader.GetString(1);
                ProductionLine = reader.GetString(2);

                ProductWarehouse   = reader.GetString(3);
                ProductNumber      = reader.GetString(4);
                ProductDescription = reader.GetString(5);

                PlannedUOM      = reader.GetString(6);
                PlannedQuantity = reader.GetDecimal(7);
                PlannedDate     = reader.GetDate(8);
                PlannedShift    = reader.GetInt32(9);

                ProdLineCapacity = reader.GetInt32(10);
                ReOrderPoint     = reader.GetDecimal(11);
                NoBatches        = reader.GetDecimal(12);
                BatchSize        = reader.GetDecimal(13);

                CustomerOrderNo = reader.GetString(14);
                FGWorkOrderNo   = reader.GetString(15);
                Status          = reader.GetString(16);
                ActualMftQty    = reader.GetDecimal(17);
                ActualDate      = reader.GetDate(18);
                ActualShift     = reader.GetInt32(19);

                Comments         = reader.GetString(20);
                CreationDate     = reader.GetString(21);
                CreationUser     = reader.GetString(22);
                LastModifiedDate = reader.GetString(23);
                LastModifiedUser = reader.GetString(24);
                #endregion

                Validated = true;
            }
            catch (OdbcException odbce)
            {
                Utilities.ShowError(odbce.Message, odbce.ToString());
            }
            finally
            {
                cmd.Dispose();
                odbc.Close();
            }
        }