Пример #1
0
        public object FindAll()
        {
            string query   = "SELECT id FROM venta ORDER BY id DESC LIMIT 1";
            int    ventaId = 0;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                ventaId = Convert.ToInt32(reader["id"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(ventaId);
        }
Пример #2
0
        public object UltimoPago(int id)
        {
            var    pagar = new UltimoPagoViewModels();
            string query = "SELECT A.saldo_anterior, A.saldo_actual, A.monto, A.fecha_pagar, A.fecha_cancelada, A.venta_id, B.cuota FROM pagos A"
                           + " INNER JOIN finan_venta B ON A.venta_id = B.venta_id WHERE A.venta_id = @id ORDER BY A.id DESC LIMIT 1";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    connection.Open();
                    command.Connection = connection;
                    command.Parameters.AddWithValue("@id", id);
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            pagar.Saldo_Anterior  = Convert.ToDouble(reader["saldo_anterior"]);
                            pagar.Saldo_Actual    = Convert.ToDouble(reader["saldo_actual"]);
                            pagar.Monto           = Convert.ToDouble(reader["monto"]);
                            pagar.Fecha_Pagar     = Convert.ToDateTime(reader["fecha_pagar"]);
                            pagar.Fecha_Cancelada = Convert.ToDateTime(reader["fecha_cancelada"]);
                            pagar.Venta_id        = Convert.ToInt16(reader["venta_id"]);
                            pagar.Cuota           = Convert.ToDouble(reader["cuota"]);
                        }
                    }
                }
            }
            return(pagar);
        }
Пример #3
0
        public object FindForId(int id)
        {
            var    lotestado = new EstadoLoteViewModels();
            string query     = " SELECT id, estado FROM estado_lote WHERE id= " + id;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lotestado.id     = Convert.ToInt32(reader["id"]);
                                lotestado.estado = Convert.ToString(reader["estado"]);
                            }
                        }
                    } catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lotestado);
            //asdf
        }
Пример #4
0
        public object FindForId(int id)
        {
            var    listaMoras = new List <MoraViewModels>();
            string query      = "SELECT monto, fecha, estado FROM moras WHERE venta_id = @id";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        command.Parameters.AddWithValue("@id", id);
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                listaMoras.Add(new MoraViewModels()
                                {
                                    Monto  = Convert.ToDouble(reader["monto"]),
                                    Fecha  = Convert.ToDateTime(reader["fecha"]),
                                    Estado = Convert.ToInt16(reader["estado"])
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(listaMoras);
        }
Пример #5
0
        public object FindForId(int id)
        {
            var    gastos = new GastosViewModels();
            string query  = "SELECT id, fecha, cantidad, descripcion, id_lotifi, id_empleado FROM gastos WHERE id = @id";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Parameters.AddWithValue("@id", id);
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                gastos.id              = Convert.ToInt16(reader["id"]);
                                gastos.fecha           = Convert.ToDateTime(reader["fecha"]);
                                gastos.cantidad        = Convert.ToDouble(reader["cantidad"]);
                                gastos.descripcion     = reader["descripcion"].ToString();
                                gastos.lotificadora_id = Convert.ToInt16(reader["id_lotifi"]);
                                gastos.empleado_id     = Convert.ToInt16(reader["id_empleado"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(gastos);
        }
Пример #6
0
        private DateTime FechaUltimaMora(int id)
        {
            DateTime fechaUltimaMora = new DateTime();
            string   query           = "SELECT fecha FROM moras WHERE venta_id = @venta_id" +
                                       " ORDER BY fecha DESC LIMIT 1";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Parameters.AddWithValue("@venta_id", id);
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                fechaUltimaMora = Convert.ToDateTime(reader["fecha"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex);
                    }
                }
            }
            return(fechaUltimaMora);
        }
Пример #7
0
        public object FindForId(int id)
        {
            var    pagar = new List <ClientesPagarViewModels>();
            string query = "SELECT a.nombre, a.apellido, b.id FROM Cliente a, Venta b WHERE a.id = b.cliente_id AND a.id = @id";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        command.Parameters.AddWithValue("@id", id);
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                pagar.Add(new ClientesPagarViewModels()
                                {
                                    nombre   = Convert.ToString(reader["nombre"]),
                                    apellido = Convert.ToString(reader["apellido"]),
                                    idventa  = Convert.ToInt32(reader["id"])
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(pagar);
        }
Пример #8
0
        public object FindForId(int id)
        {
            var    estado = new EstadoEmpViewModels();
            string query  = "SELECT id, estadoemp FROM estadoemp WHERE id = " + id;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                estado.id      = Convert.ToInt16(reader["id"]);
                                estado.nestado = reader["estadoemp"].ToString();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(estado);
        }
Пример #9
0
        public object FindForId(int id)
        {
            string query = "SELECT cuota FROM finan_venta WHERE venta_id = @id";
            double cuota = 0;

            using (var connection = PostConnection.Connection())
            {
                using (var command = _database.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        command.Parameters.AddWithValue("@id", id);
                        using (var reader = command.ExecuteReader())
                        {
                            cuota = Convert.ToDouble(reader["cuota"]);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(cuota);
        }
Пример #10
0
        public object FindForId(int id)
        {
            var    lotificadora = new LotificadoraViewModels();
            string query        = "SELECT id, nombre, direccion, telefono, tasa_interes, tasa_mora FROM lotificadora WHERE id = " + id;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lotificadora.id           = Convert.ToInt16(reader["id"]);
                                lotificadora.nombre       = reader["nombre"].ToString();
                                lotificadora.direccion    = reader["direccion"].ToString();
                                lotificadora.telefono     = Convert.ToInt32(reader["telefono"]);
                                lotificadora.tasa_interes = Convert.ToDouble(reader["tasa_interes"]);
                                lotificadora.tasa_mora    = Convert.ToDouble(reader["tasa_mora"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lotificadora);
        }
Пример #11
0
        public object FindAll()
        {
            var    lista = new List <ManzanaLoteViewModels>();
            string query = "SELECT id, manzana FROM manzana";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lista.Add(new ManzanaLoteViewModels()
                                {
                                    id      = Convert.ToInt32(reader["id"]),
                                    manzana = reader["manzana"].ToString(),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lista);
        }
Пример #12
0
        //        public int Delete(int id)

        public object FindAll()
        {
            var    lista = new List <CargoEmpViewModels>();
            string query = "SELECT id, nombrecargo, sueldo FROM cargo";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lista.Add(new CargoEmpViewModels()
                                {
                                    id          = Convert.ToInt16(reader["id"]),
                                    nombrecargo = reader["nombrecargo"].ToString(),
                                    sueldo      = Convert.ToDouble(reader["sueldo"]),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lista);
        }
Пример #13
0
        public object FindForId(int id)
        {
            var    cargo = new CargoEmpViewModels();
            string query = "SELECT id, nombrecargo, sueldo FROM cargo WHERE id = " + id;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                cargo.id          = Convert.ToInt16(reader["id"]);
                                cargo.nombrecargo = reader["nombrecargo"].ToString();
                                cargo.sueldo      = Convert.ToDouble(reader["sueldo"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(cargo);
        }
Пример #14
0
        public object FindForId(int id)
        {
            var    lotemanzana = new ManzanaLoteViewModels();
            string query       = " SELECT id, manzana FROM manzana WHERE id = " + id;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lotemanzana.id      = Convert.ToInt32(reader["id"]);
                                lotemanzana.manzana = reader["manzana"].ToString();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lotemanzana);
        }
Пример #15
0
        public object FindAll()
        {
            string query      = "SELECT id, descripcion FROM tipo_venta";
            var    tipo_venta = new List <TipoVentaViewModels>();

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                tipo_venta.Add(new TipoVentaViewModels()
                                {
                                    Id          = Convert.ToInt16(reader["id"]),
                                    Descripcion = reader["descripcion"].ToString(),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(tipo_venta);
        }
Пример #16
0
        public object FindAll()
        {
            var    lista = new List <EstadoCliViewModels>();
            string query = "SELECT id, estado FROM estado_cliente";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lista.Add(new EstadoCliViewModels()
                                {
                                    id     = Convert.ToInt16(reader["id"]),
                                    estado = reader["estado"].ToString(),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lista);
        }
Пример #17
0
        public object FindForId(int id)
        {
            var    referenciaemp = new ReferenciaEmpViewModels();
            string query         = "SELECT id, nombre, apellido, telefono, direccion, id_emp FROM referenciaemp WHERE id = " + id;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                referenciaemp.id        = Convert.ToInt16(reader["id"]);
                                referenciaemp.nombre    = reader["nombre"].ToString();
                                referenciaemp.apellido  = reader["apellido"].ToString();
                                referenciaemp.tel       = Convert.ToInt32(reader["telefono"]);
                                referenciaemp.direccion = reader["direccion"].ToString();
                                referenciaemp.id_emp    = Convert.ToInt16(reader["id_emp"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(referenciaemp);
        }
Пример #18
0
        public object FindAll()
        {
            var    lista = new List <LoteViewModels>();
            string query = "select id, numero, largo, ancho, mts_cuadrados, precio, manzana, lotificadora, estado from viewlote";

            //   string query = "SELECT no_lote, largo, ancho, mts_cuadrados, precio_lote, manzana_id, lotificadora_id, estado_id from lote ";
            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())

                        {
                            while (reader.Read())
                            {
                                lista.Add(new LoteViewModels()
                                {
                                    id            = Convert.ToInt32(reader["id"]),
                                    numero        = Convert.ToInt32(reader["numero"]),
                                    largo         = Convert.ToDouble(reader["largo"]),
                                    ancho         = Convert.ToDouble(reader["ancho"]),
                                    mts_cuadrados = Convert.ToDouble(reader["mts_cuadrados"]),
                                    precio        = Convert.ToDouble(reader["precio"]),
                                    manzana       = Convert.ToString(reader["manzana"]),
                                    lotificadora  = Convert.ToString(reader["lotificadora"]),
                                    estado        = Convert.ToString(reader["estado"]),


                                    // @no_lote,@largo,@ancho,@mts_cuadrados,@precio_lote,@manzana_id,@interes_id,@estado_id
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lista);
        }
Пример #19
0
        public object FindAll()
        {
            var lista = new List <EmpleadosIngresoViewModels>();

            string query = "SELECT id, nombre, apellido, dpi, telefono, sexo, fecha_nac, direccion, id_cargo, id_estadoemp FROM empleados";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lista.Add(new EmpleadosIngresoViewModels()
                                {
                                    id          = Convert.ToInt16(reader["id"]),
                                    nombre_e    = reader["nombre"].ToString(),
                                    apellido_e  = reader["apellido"].ToString(),
                                    dpi_e       = Convert.ToInt64(reader["dpi"]),
                                    tel_e       = Convert.ToInt32(reader["telefono"]),
                                    sexo_e      = Convert.ToInt16(reader["sexo"]),
                                    fecha_nac_e = Convert.ToDateTime(reader["fecha_nac"]),
                                    dire_e      = reader["direccion"].ToString(),
                                    cargo_e     = Convert.ToInt16(reader["id_cargo"]),
                                    estado_e    = Convert.ToInt16(reader["id_estadoemp"]),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lista);
        }
Пример #20
0
        public object FindAll()
        {
            var lista = new List <ClienteInsertViewModels>();

            string query = "SELECT id, nombre, apellido, dpi, telefono, fecha,sexo, direccion, estado_id FROM Cliente";

            using (var conection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        conection.Open();
                        command.Connection = conection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lista.Add(new ClienteInsertViewModels()
                                {
                                    id        = Convert.ToInt32(reader["id"]),
                                    nombre    = Convert.ToString(reader["nombre"]),
                                    apellido  = Convert.ToString(reader["apellido"]),
                                    dpi       = Convert.ToString(reader["dpi"]),
                                    telefono  = Convert.ToString(reader["telefono"]),
                                    fecha     = Convert.ToDateTime(reader["fecha"]),
                                    sexo      = Convert.ToString(reader["sexo"]),
                                    direccion = Convert.ToString(reader["direccion"]),
                                    estado    = Convert.ToInt32(reader["estado_id"]),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lista);
        }
Пример #21
0
        public object FindAll()
        {
            var    lista = new List <BeneficiarioViewModels>();
            string query = " select id, nombre, apellido, dpi, telefono, direccion, sexo, id_cliente from beneficiario ";

            using (var conection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        conection.Open();
                        command.Connection = conection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lista.Add(new BeneficiarioViewModels()
                                {
                                    Id        = Convert.ToInt32(reader["id"]),
                                    Nombre    = reader["nombre"].ToString(),
                                    Apellido  = reader["apellido"].ToString(),
                                    Dpi       = reader["dpi"].ToString(),
                                    Telefono  = Convert.ToInt32(reader["telefono"]),
                                    Direccion = reader["direccion"].ToString(),
                                    Sexo      = reader["sexo"].ToString(),
                                    ClienteId = Convert.ToInt32(reader["id_cliente"]),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }

            return(lista);
        }
Пример #22
0
        public object FindForId(int id)
        {
            var    lotify = new LoteIngresoViewModels();
            string query  = "SELECT id, no_lote, largo, ancho, mts_cuadrados, precio_lote, manzana_id, lotificadora_id, estado_id  FROM lote  WHERE id = @id";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        command.Parameters.AddWithValue("@id", id);
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lotify.id              = Convert.ToInt32(reader["id"]);
                                lotify.numero          = Convert.ToInt32(reader["no_lote"]);
                                lotify.largo           = Convert.ToDouble(reader["largo"]);
                                lotify.ancho           = Convert.ToDouble(reader["ancho"]);
                                lotify.mts_cuadrados   = Convert.ToDouble(reader["mts_cuadrados"]);
                                lotify.precio_lote     = Convert.ToDouble(reader["precio_lote"]);
                                lotify.manzana_id      = Convert.ToInt32(reader["manzana_id"]);
                                lotify.lotificadora_id = Convert.ToInt32(reader["lotificadora_id"]);
                                lotify.estado_id       = Convert.ToInt32(reader["estado_id"]);
                            }
                        }
                    }


                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lotify);
        }
Пример #23
0
        public object FindAll()
        {
            var    promociones = new List <PromocionViewModels>();
            string query       = "SELECT id, cantidad, descripcion, fecha_inicio, fecha_fin, loti_id " +
                                 "FROM promociones WHERE now() <= fecha_fin+1";

            //select* from promociones WHERE loti_id = 1 AND(now() BETWEEN fecha_inicio AND fecha_fin + 1
            using (var connection = PostConnection.Connection())
            {
                using (var command = _database.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                promociones.Add(new PromocionViewModels()
                                {
                                    Id             = Convert.ToInt16(reader["id"]),
                                    Cantidad       = Convert.ToDouble(reader["cantidad"]),
                                    Descripcion    = reader["descripcion"].ToString(),
                                    FechaInicio    = Convert.ToDateTime(reader["fecha_inicio"]),
                                    FechaFin       = Convert.ToDateTime(reader["fecha_fin"]),
                                    LotificadoraId = Convert.ToInt16(reader["loti_id"])
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(promociones);
        }
Пример #24
0
        public object FindAll()
        {
            var    lista = new List <VistaGastoViewModels>();
            string query = "SELECT id, fecha, cantidad, descripcion, lotificadora, nombre, apellido FROM viewgastos";

            //string query = "SELECT id, fecha, cantidad, descripcion, id_lotifi, id_empleado FROM gastos";
            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lista.Add(new VistaGastoViewModels()
                                {
                                    id           = Convert.ToInt16(reader["id"]),
                                    Fecha        = Convert.ToDateTime(reader["fecha"]),
                                    cantidad     = Convert.ToDouble(reader["cantidad"]),
                                    descripcion  = reader["descripcion"].ToString(),
                                    lotificadora = reader["lotificadora"].ToString(),
                                    nombre       = reader["nombre"].ToString(),
                                    apellido     = reader["apellido"].ToString(),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lista);
        }
Пример #25
0
        public object FindForId(int id)
        {
            var    empleado = new EmpleadosIngresoViewModels();
            string query    = "SELECT id, nombre, apellido, dpi, telefono, sexo, fecha_nac, direccion, id_cargo, id_estadoemp FROM empleados WHERE id = " + id;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        command.Parameters.AddWithValue("@idemp", id);
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                empleado.id          = Convert.ToInt16(reader["id"]);
                                empleado.nombre_e    = reader["nombre"].ToString();
                                empleado.apellido_e  = reader["apellido"].ToString();
                                empleado.dpi_e       = Convert.ToInt64(reader["dpi"]);
                                empleado.tel_e       = Convert.ToInt32(reader["telefono"]);
                                empleado.sexo_e      = Convert.ToInt16(reader["sexo"]);
                                empleado.fecha_nac_e = Convert.ToDateTime(reader["fecha_nac"]);
                                empleado.dire_e      = reader["direccion"].ToString();
                                empleado.cargo_e     = Convert.ToInt16(reader["id_cargo"]);
                                empleado.estado_e    = Convert.ToInt16(reader["id_estadoemp"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(empleado);
        }
Пример #26
0
        public object FindForId(int id)
        {
            var    listaMoras = new List <PagosSelectViewModels>();
            string query      = "SELECT saldo_anterior, saldo_actual, monto, fecha_a_pagar, fecha_cancelada " +
                                "FROM pagos WHERE venta_id = @id";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        command.Parameters.AddWithValue("@id", id);
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                listaMoras.Add(new PagosSelectViewModels()
                                {
                                    SaldoAnterior  = Convert.ToDouble(reader["saldo_anterior"]),
                                    SaldoActual    = Convert.ToDouble(reader["saldo_actual"]),
                                    Monto          = Convert.ToDouble(reader["monto"]),
                                    FechaPagar     = Convert.ToDateTime(reader["fecha_a_pagar"]),
                                    FechaCancelada = Convert.ToDateTime(reader["fecha_cancelada"])
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(listaMoras);
        }
Пример #27
0
        public object FindForId(int id)
        {
            var    cliente = new ClienteInsertViewModels();
            string query   = "SELECT id, nombre, apellido, dpi, telefono, fecha,sexo, direccion, estado_id FROM cliente WHERE id= " + id;

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        command.Parameters.AddWithValue("@id", id);
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                cliente.id        = Convert.ToInt32(reader["id"]);
                                cliente.nombre    = Convert.ToString(reader["nombre"]);
                                cliente.apellido  = Convert.ToString(reader["apellido"]);
                                cliente.dpi       = Convert.ToString(reader["dpi"]);
                                cliente.telefono  = Convert.ToString(reader["telefono"]);
                                cliente.fecha     = Convert.ToDateTime(reader["fecha"]);
                                cliente.sexo      = Convert.ToString(reader["sexo"]);
                                cliente.direccion = Convert.ToString(reader["direccion"]);
                                cliente.estado    = Convert.ToInt32(reader["estado_id"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(cliente);
        }
Пример #28
0
        public object FindForId(int id)
        {
            var    promo = new PromocionViewModels();
            string query = "SELECT id, cantidad, descripcion, fecha_inicio, fecha_fin, loti_id" +
                           " FROM promociones WHERE id = @id";

            using (var connection = PostConnection.Connection())
            {
                using (var command = _database.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        command.Parameters.AddWithValue("@id", id);
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                promo.Id             = Convert.ToInt16(reader["id"]);
                                promo.Cantidad       = Convert.ToDouble(reader["cantidad"]);
                                promo.Descripcion    = reader["descripcion"].ToString();
                                promo.FechaInicio    = Convert.ToDateTime(reader["fecha_inicio"]);
                                promo.FechaFin       = Convert.ToDateTime(reader["fecha_fin"]);
                                promo.LotificadoraId = Convert.ToInt16(reader["loti_id"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }

            return(promo);
        }
Пример #29
0
        public object FindForId(int id)
        {
            var    paramsMora = new CalcularMoraViewModels();
            string query      = "SELECT saldo, fecha, cuota, mora FROM calc_demorados WHERE venta_id = @venta_id"
                                + " ORDER BY fecha DESC LIMIT 1";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Parameters.AddWithValue("@venta_id", id);
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                paramsMora.Saldo    = Convert.ToDouble(reader["saldo"]);
                                paramsMora.Fecha    = Convert.ToDateTime(reader["fecha"]);
                                paramsMora.Cuota    = Convert.ToDouble(reader["cuota"]);
                                paramsMora.TasaMora = Convert.ToDouble(reader["mora"]);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            DateTime fechaUltimaMora = FechaUltimaMora(id);

            paramsMora.Fecha = paramsMora.Fecha < fechaUltimaMora ? fechaUltimaMora : paramsMora.Fecha;
            return(paramsMora);
        }
Пример #30
0
        public object FindAll()
        {
            var    lista = new List <ReferenciaEmpViewModels>();
            string query = "SELECT id, nombre, apellido, telefono, direccion, id_emp FROM referenciaemp";

            using (var connection = PostConnection.Connection())
            {
                using (var command = db.Command(query))
                {
                    try
                    {
                        connection.Open();
                        command.Connection = connection;
                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                lista.Add(new ReferenciaEmpViewModels()
                                {
                                    id        = Convert.ToInt16(reader["id"]),
                                    nombre    = reader["nombre"].ToString(),
                                    apellido  = reader["apellido"].ToString(),
                                    tel       = Convert.ToInt32(reader["telefono"]),
                                    direccion = reader["direccion"].ToString(),
                                    id_emp    = Convert.ToInt16(reader["id_emp"]),
                                });
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
            return(lista);
        }