Ejemplo n.º 1
0
        public bool buscarContrato(string documento)
        {
            bool OK = false;
            SELECTED = Prestamo.ConvertToPrestamo(dbPrestamo.getContratoByDoc(documento));
            if (SELECTED != null)
            {
                ACCION = eOperacion.SEARCH;
                SELECTED.ITEMS_PRESTAMO = dbPrestamo.getItemsPrestamo(SELECTED);

                PRESTAMO = SELECTED.Copy();
                cargarDatosCliente(null);
                cargarDatosPrestamo();
                bloquear();
                actualizarPrecios();
                OK = true;

                btnGuardar.Enabled = false;
                btnCancelar.Enabled = false;
                btnEditar.Enabled = true;
                btnEliminar.Enabled = true;
                btnLog.Enabled = true;
                btnReimprimir.Enabled = true;
                btnPrintKITCO.Enabled = true;
            }
            else
            {
                OK = false;
            }
            return OK;
        }
Ejemplo n.º 2
0
        public bool delete(Prestamo prestamo, string sucursal, string empleado, string sistema)
        {
            bool OK = true;
            try
            {
                string sql = "prendasal.SP_DELETE_PRESTAMO";
                MySqlCommand cmd = new MySqlCommand(sql, conn.conection);
                cmd.CommandType = CommandType.StoredProcedure;
                MySqlParameter idprestamo = cmd.Parameters.Add("idprestamo", MySqlDbType.Int32);
                idprestamo.Direction = ParameterDirection.Input;

                MySqlParameter suc = cmd.Parameters.Add("suc", MySqlDbType.VarChar, 2);
                suc.Direction = ParameterDirection.Input;
                MySqlParameter emp = cmd.Parameters.Add("emp", MySqlDbType.VarChar, 15);
                emp.Direction = ParameterDirection.Input;
                MySqlParameter sys = cmd.Parameters.Add("sys", MySqlDbType.VarChar, 20);
                sys.Direction = ParameterDirection.Input;

                idprestamo.Value = prestamo.ID_PRESTAMO;

                suc.Value = sucursal;
                emp.Value = empleado;
                sys.Value = sistema;

                cmd.ExecuteNonQuery();
                MessageBox.Show("REGISTRO DE PRESTAMO ELIMINADO", "OPERACION FINALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception e)
            {
                OK = false;
                MessageBox.Show(e.Message, "ERROR AL ELIMINAR PRESTAMO ", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return OK;
        }
Ejemplo n.º 3
0
        public IHttpActionResult PutPrestamo(int id, Prestamo prestamo)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != prestamo.Id)
            {
                return BadRequest();
            }

            db.Entry(prestamo).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!PrestamoExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Ejemplo n.º 4
0
 public ConfirmarContrato(Prestamo p , eOperacion operacion)
 {
     InitializeComponent();
     dbUser = new DBUsuario();
     dbContrato = new DBPrestamo();
     ACCION = operacion;
     PRESTAMO = p;
     mostrarDatos();
 }
Ejemplo n.º 5
0
 public ContratosForm()
 {
     InitializeComponent();
     dbPrendasal = new DBPRENDASAL();
     dbUser = new DBUsuario();
     dbCliente = new DBCliente();
     dbPrestamo = new DBPrestamo ();
     dbCatalogo = new DBCatalogo();
     PRESTAMO = new Prestamo();
 }
Ejemplo n.º 6
0
        public IHttpActionResult PostPrestamo(Prestamo prestamo)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Prestamos.Add(prestamo);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = prestamo.Id }, prestamo);
        }
Ejemplo n.º 7
0
 public CdMusica()
 {
     IdCd = 0;
     Interprete = string.Empty;
     Titulo = string.Empty;
     FechaPublicacion = new DateTime();
     Genero = string.Empty;
     Discografica = string.Empty;
     canciones = new List<Cancion>();
     prestamo = new Prestamo();
     Ubicacion = string.Empty;
     Caratula = string.Empty;
 }
Ejemplo n.º 8
0
        public bool update(Prestamo prestamo, string sucursal, string empleado, string sistema)
        {
            bool OK = true;
            try
            {
                string sql = "prendasal.SP_UPDATE_PRESTAMO";
                MySqlCommand cmd = new MySqlCommand(sql, conn.conection);
                cmd.CommandType = CommandType.StoredProcedure;

                MySqlParameter idprestamo = cmd.Parameters.Add("idprestamo", MySqlDbType.Int32);
                idprestamo.Direction = ParameterDirection.Input;
                MySqlParameter suc_prestamo = cmd.Parameters.Add("suc_prestamo", MySqlDbType.VarChar, 2);
                suc_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter cli_prestamo = cmd.Parameters.Add("cli_prestamo", MySqlDbType.VarChar, 15);
                cli_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter fecha_prestamo = cmd.Parameters.Add("fecha_prestamo", MySqlDbType.Date);
                fecha_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter tipo_prestamo = cmd.Parameters.Add("tipo_prestamo", MySqlDbType.Int32);
                tipo_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter doc_prestamo = cmd.Parameters.Add("doc_prestamo", MySqlDbType.VarChar, 20);
                doc_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter pago_prestamo = cmd.Parameters.Add("pago_prestamo", MySqlDbType.Int32);
                pago_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter tasa_prestamo = cmd.Parameters.Add("tasa_prestamo", MySqlDbType.Decimal);
                tasa_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter plazo_prestamo = cmd.Parameters.Add("plazo_prestamo", MySqlDbType.Int32);
                plazo_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter plazovenc_prestamo = cmd.Parameters.Add("plazovenc_prestamo", MySqlDbType.Int32);
                plazovenc_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter total_prestamo = cmd.Parameters.Add("total_prestamo", MySqlDbType.Decimal);
                total_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter cat_prestamo = cmd.Parameters.Add("cat_prestamo", MySqlDbType.VarChar, 50);
                cat_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter nivel_prestamo = cmd.Parameters.Add("nivel_prestamo", MySqlDbType.Int32);
                nivel_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter nota_prestamo = cmd.Parameters.Add("nota_prestamo", MySqlDbType.VarChar, 100);
                nota_prestamo.Direction = ParameterDirection.Input;
                MySqlParameter items_prestamo = cmd.Parameters.Add("items_prestamo", MySqlDbType.LongText);
                items_prestamo.Direction = ParameterDirection.Input;

                MySqlParameter suc = cmd.Parameters.Add("suc", MySqlDbType.VarChar, 2);
                suc.Direction = ParameterDirection.Input;
                MySqlParameter emp = cmd.Parameters.Add("emp", MySqlDbType.VarChar, 15);
                emp.Direction = ParameterDirection.Input;
                MySqlParameter sys = cmd.Parameters.Add("sys", MySqlDbType.VarChar, 20);
                sys.Direction = ParameterDirection.Input;

                idprestamo.Value = prestamo.ID_PRESTAMO;
                suc_prestamo.Value = prestamo.COD_SUC;
                cli_prestamo.Value = prestamo.COD_CLIENTE;
                fecha_prestamo.Value = prestamo.FECHA.Date;
                tipo_prestamo.Value = (int)prestamo.TIPO;
                doc_prestamo.Value = prestamo.DOCUMENTO;
                pago_prestamo.Value = (int)prestamo.TIPO_PAGO;
                tasa_prestamo.Value = prestamo.TASA_MENSUAL;
                plazo_prestamo.Value = prestamo.PLAZO_CONTRATO;
                plazovenc_prestamo.Value = prestamo.PLAZO_VENC;
                total_prestamo.Value = prestamo.TOTAL;
                cat_prestamo.Value = prestamo.CATEGORIA.ToString();
                nivel_prestamo.Value = (int)prestamo.NIVEL;
                nota_prestamo.Value = prestamo.NOTA;

                items_prestamo.Value = buildItemsPrestamo(prestamo);

                suc.Value = sucursal;
                emp.Value = empleado;
                sys.Value = sistema;

                cmd.ExecuteNonQuery();
                MessageBox.Show("PRESTAMO ACTUALIZADO", "OPERACION FINALIZADA", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception e)
            {
                OK = false;
                MessageBox.Show(e.Message, "ERROR AL ACTUALIZAR PRESTAMO", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return OK;
        }
Ejemplo n.º 9
0
 private string buildItemsPrestamo(Prestamo prestamo)
 {
     string items = "";
     foreach (DataRow row in prestamo.ITEMS_PRESTAMO.Rows)
     {
         items = items + row.Field<string>("COD_ITEM") + ">"
             + row.Field<decimal>("CANTIDAD") + ">"
             + row.Field<string>("DESCRIPCION") + ">"
             + row.Field<decimal>("MONTO") + "&";
     }
     return items;
 }
Ejemplo n.º 10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hola Mundo");
            Cuenta cuenta = new Cuenta();

            cuenta.Seleccionar("*****@*****.**");
            cuenta.Perfiles();
            Perfil perfil = new Perfil();

            perfil.Seleccionar(1);

            Item item = new Item();

            //item.Crear();
            item.Seleccionar(1);
            perfil.Disponibilidad(item, false);
            item.Autores();
            Prestamo prestamo = new Prestamo();

            item.Titulo = "222";
            prestamo.Seleccionar(1);
            Comentario comentario = new Comentario()
            {
                Texto = "Texto N", Perfil = perfil, Prestamo = prestamo
            };

            comentario.Crear();
            comentario.Texto = "Texto NxN";
            comentario.Modificar();
            comentario.Eliminar();
            Comentario comentario2 = new Comentario();

            comentario2.Seleccionar(1);
            perfil.HistorialPrestamista(0, 10);
            perfil.HistorialPrestamista(0, 10);
            perfil.MisItems();
            Ubicacion ubicacion = new Ubicacion();

            ubicacion.Seleccionar(1);
            Estanteria estant = new Estanteria();

            estant.Buscar("Titulo 8", ubicacion, 1, 10, 2749);
            estant.LosMasCabrones(5);
            //prestamo.Eliminar_Comentario(comentario);
            //Console.WriteLine(string.Format("ID: {0}", item.Crear()));
            //item.Titulo = "2323";
            //item.Modificar();
            item.Agregar("perro", "Hola");
            item.Propiedades();
            item.Modificar("anio", "1111");
            item.Remove("anio");
            Console.WriteLine(string.Format("ENUM {0}", (int)EstadoPrestamo.Enviado));
            //item.Eliminar();
            //item.Seleccionar(1);
            //Console.WriteLine(string.Format("ID: {0}, Titutlo: {1}", item.Id, item.Titulo));
            //item.Autores();
            //Autor autor = new Autor() { Nombre = "Nuevo" };
            //autor.Crear();
            //item.Autor_item_crear(autor);
            //item.Autor_item_eliminar(autor);
            //item.Remove("anio");
            //autor.Nombre = "PEDRO";
            //autor.Modificar();
            //autor.Eliminar();
            //perfil2.Eliminar();
            //cuenta.Eliminar();
            Console.ReadLine();
        }
Ejemplo n.º 11
0
 public Prestamo Create(Prestamo prestamo)
 {
     return(ApplicationDbContext.applicationDbContext.Prestamos.Add(prestamo));
 }
Ejemplo n.º 12
0
 public void Post([FromBody] Prestamo prestamo)
 {
     _IPrestamosServices.AgregarPrestamo(prestamo.Fechainicio, prestamo.Fechafin, prestamo.IdPropietario, prestamo.IdPrestador, prestamo.Idaeronave);
 }
Ejemplo n.º 13
0
        private void CANCELAR(object sender, EventArgs e)
        {
            switch (ACCION)
            {
                case eOperacion.INSERT:
                    NUEVO(null, null);
                    break;
                case eOperacion.UPDATE:
                    ACCION = eOperacion.SEARCH;
                    PRESTAMO = SELECTED.Copy();
                    cargarDatosCliente(null);
                    cargarDatosPrestamo();
                    bloquear();

                    btnGuardar.Enabled = false;
                    btnCancelar.Enabled = false;
                    btnEditar.Enabled = true;
                    btnEliminar.Enabled = true;
                    btnLog.Enabled = true;
                    btnReimprimir.Enabled = true;
                    btnPrintKITCO.Enabled = true;
                    break;
            }
        }
Ejemplo n.º 14
0
        public Prestamo RegistrarPrestamo(Prestamo prestamo)
        {
            String _sql = @"INSERT INTO [dbo].[tb_prestamo]
                                ([estado]
                                ,[fec_reserva]
                                ,[fec_ini_pre]
                                ,[fec_fin_pre]
                                ,[fec_devolucion]
                                ,[observacion]
                                ,[per_id]
                                ,[adm_id])
                            VALUES
                                (@Estado
                                ,@FechaReserva
                                ,@FechaPrestamo
                                ,@FechaEntrega
                                ,@FechaDevolucion
                                ,@Observacion
                                ,@Persona
                                ,@UsuarioCreacion)

                            select SCOPE_IDENTITY() as id 
                            ";

            Prestamo _pres = null;
            Conexion _cnx  = new Conexion();

            int _IdPersona = ObtenerPersonaId(prestamo.Persona.Codigo);

            SqlCommand _cmd = new SqlCommand(_sql, _cnx.ObtenerConexion());

            _cmd.CommandTimeout = 100000;
            _cmd.Parameters.AddWithValue("@Estado", prestamo.Estado);

            // _cmd.Parameters.Add(new SqlParameter { ParameterName = "@FechaReserva", SqlDbType = SqlDbType.DateTime, Value = prestamo.FechaReserva == null });

            if (prestamo.FechaReserva == null)
            {
                _cmd.Parameters.AddWithValue("@FechaReserva", DBNull.Value);
            }
            else
            {
                _cmd.Parameters.AddWithValue("@FechaReserva", prestamo.FechaReserva);
            }

            _cmd.Parameters.AddWithValue("@FechaPrestamo", prestamo.FechaPrestamo);
            _cmd.Parameters.AddWithValue("@FechaEntrega", prestamo.FechaEntrega);

            if (prestamo.FechaDevolucion == null)
            {
                _cmd.Parameters.AddWithValue("@FechaDevolucion", DBNull.Value);
            }
            else
            {
                _cmd.Parameters.AddWithValue("@FechaDevolucion", prestamo.FechaDevolucion);
            }

            //_cmd.Parameters.Add(new SqlParameter { ParameterName = "@FechaDevolucion", SqlDbType = SqlDbType.DateTime, Value = prestamo.FechaDevolucion });

            if (prestamo.Observacion == null)
            {
                _cmd.Parameters.AddWithValue("@Observacion", DBNull.Value);
            }
            else
            {
                _cmd.Parameters.AddWithValue("@Observacion", prestamo.Observacion);
            }

            //_cmd.Parameters.Add(new SqlParameter { ParameterName= "@Observacion",SqlDbType = SqlDbType.VarChar,Value= prestamo.Observacion } );

            _cmd.Parameters.AddWithValue("@Persona", _IdPersona);
            _cmd.Parameters.AddWithValue("@UsuarioCreacion", prestamo.UsuarioCreacion);
            _cnx.AbrirConexion();

            int _id = Convert.ToInt32(_cmd.ExecuteScalar());

            if (_id > 0)
            {
                _sql = @"INSERT INTO [dbo].[tb_prestamo_det]
                       ([pres_id]
                        ,[mat_id]
                        ,[cant])
                    VALUES
                        (@PrestamoId
                        ,@MaterialId
                        ,@Cantidad)
                    ";
                foreach (Material item in prestamo.Materiales)
                {
                    int _MaterialId = ObtenerMaterialId(item.Codigo);

                    _cmd.CommandText = _sql;
                    _cmd.Parameters.Clear();
                    _cmd.Parameters.AddWithValue("@PrestamoId", _id);
                    _cmd.Parameters.AddWithValue("@MaterialId", _MaterialId);
                    _cmd.Parameters.AddWithValue("@Cantidad", 1);

                    _cmd.ExecuteNonQuery();
                }
                _pres = ObtenerPrestamo("PR-" + _id.ToString());
            }

            _cnx.CerrarConexion();
            return(_pres);
        }
Ejemplo n.º 15
0
        public List <Prestamo> getPrestamo(int idCliente)
        {
            List <Prestamo> prestamos = new List <Prestamo>();
            var             cn        = dbc.getConnection();

            try
            {
                cn.Open();
                var sql = "SELECT * FROM prestamo WHERE idCliente = " + idCliente;
                var cmd = new SqlCommand(sql, cn);
                var dr  = cmd.ExecuteReader();
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        prestamo = new Prestamo(
                            dr.GetInt32(0),
                            dr.GetInt32(1),
                            dr.GetDouble(2),
                            Convert.ToDouble(dr.GetDecimal(3)),
                            dr.GetInt32(4),
                            dr.GetInt32(5),
                            dr.GetDouble(6),
                            dr.GetBoolean(7),
                            dr.GetInt32(8),
                            dr.GetInt32(9),
                            dr.GetDateTime(10),
                            dr.GetDateTime(11));
                        prestamos.Add(prestamo);
                    }
                }
                dr.Close();
                foreach (var prestamo in prestamos)
                {
                    List <PagoPrestamo> pagos = new List <PagoPrestamo>();
                    sql = "SELECT * FROM pagos_prestamo p WHERE p.idPrestamo = " + prestamo.id;
                    var cmd2 = new SqlCommand(sql, cn);
                    var dr2  = cmd2.ExecuteReader();
                    if (dr2.HasRows)
                    {
                        while (dr2.Read())
                        {
                            var pago = new PagoPrestamo(dr2.GetInt32(1), dr2.GetInt32(2), dr2.GetString(3), dr2.GetDouble(4), dr2.GetBoolean(5), dr2.GetDateTime(6));
                            pagos.Add(pago);
                        }
                        prestamo.pagos = pagos;
                    }
                    dr2.Close();
                }

                Debug.WriteLine("===================QUERY==================");
                Debug.WriteLine(sql);
                Debug.WriteLine("===================QUERY==================");
            }
            catch (System.Exception e)
            {
                Debug.WriteLine("===================GET PAGO PRESTAMO==================");
                Debug.WriteLine("DEBUGGER::" + e.Message);
                Debug.WriteLine("DEBUGGER::" + e.StackTrace);
                Debug.WriteLine("DEBUGGER::" + e);
                Debug.WriteLine("=========================================================");
            }finally
            {
                cn.Close();
            }

            return(prestamos);
        }
Ejemplo n.º 16
0
        public Prestamo Traer(int registro)
        {
            Prestamo result = mapper.Traer(registro);

            return(result);
        }
Ejemplo n.º 17
0
        public void BuscarTest()
        {
            Prestamo prestamo = PrestamosBLL.Buscar(1);

            Assert.IsNotNull(prestamo);
        }
Ejemplo n.º 18
0
        public Prestamo RegistrarPrestamo(Prestamo prestamo)
        {
            if ((prestamo == null) ||
                (prestamo.Persona == null) ||
                (prestamo.Estado == null || prestamo.Estado <= 0) ||
                (string.IsNullOrEmpty(prestamo.Persona.Codigo) || string.IsNullOrWhiteSpace(prestamo.Persona.Codigo)) ||
                (prestamo.Materiales == null)

                )
            {
                throw new FaultException <ParametroException>(
                          new ParametroException {
                    Codigo = "201", Mensaje = "Datos incompletos"
                },
                          new FaultReason("Datos incompletos")
                          );
            }

            IPersonaService _servicesPersona = new PersonaService();
            Persona         _persona         = _servicesPersona.ObtenerPersona(prestamo.Persona.Codigo);

            if (_persona == null)
            {
                throw new FaultException <RepetidoException>(
                          new RepetidoException {
                    Codigo = "101", Mensaje = "Código de Persona no Existe."
                },
                          new FaultReason("Código de Persona no Existe.")
                          );
            }

            if (_persona.MontoDeuda > 0)
            {
                throw new FaultException <ParametroException>(
                          new ParametroException {
                    Codigo = "205", Mensaje = "Peronal con deuda"
                },
                          new FaultReason("Peronal con deuda")
                          );
            }

            if (prestamo.Materiales.Count <= 0)
            {
                throw new FaultException <ParametroException>(
                          new ParametroException {
                    Codigo = "202", Mensaje = "No existe Materiales"
                },
                          new FaultReason("No existe Materiales")
                          );
            }

            if (prestamo.Materiales.Count > 3)
            {
                throw new FaultException <ParametroException>(
                          new ParametroException {
                    Codigo = "203", Mensaje = "Solo se permite hasta 3 materiales por registro"
                },
                          new FaultReason("Solo se permite hasta 3 materiales por registro")
                          );
            }

            IMaterialService _MaterialService = new MaterialService();

            foreach (Material item in prestamo.Materiales)
            {
                Material _material = _MaterialService.ObtenerMaterial(item.Codigo);
                if (_material == null)
                {
                    throw new FaultException <RepetidoException>(
                              new RepetidoException {
                        Codigo = "101", Mensaje = "Código de material no Existe. Material : " + item.Codigo
                    },
                              new FaultReason("Código de material no Existe. Material : " + item.Codigo)
                              );
                }

                if (_material.Flag == 0)
                {
                    throw new FaultException <ParametroException>(
                              new ParametroException {
                        Codigo = "103", Mensaje = "Material Inactivo. Material : " + item.Codigo
                    },
                              new FaultReason("Material Inactivo. Material : " + item.Codigo)
                              );
                }

                if (_material.Stock < 1)
                {
                    throw new FaultException <ParametroException>(
                              new ParametroException {
                        Codigo = "203", Mensaje = "No hay stock para el material : " + item.Codigo
                    },
                              new FaultReason("No hay stock para el material : " + item.Codigo)
                              );
                }
            }

            Prestamo _prestamo = _prestamoBL.RegistrarPrestamo(prestamo);

            if (_prestamo != null)
            {
                _persona.NroLibros += _prestamo.Materiales.Count;
                _personaBL.ActualizarPersona(_persona);

                foreach (Material item in _prestamo.Materiales)
                {
                    Material _material = _materialBL.ObtenerMaterial(item.Codigo);
                    _material.Stock -= 1;
                    _materialBL.ModificarMaterial(_material);
                }
            }



            return(_prestamo);
        }
Ejemplo n.º 19
0
 public ResultadoOp RegistroPagos(Prestamo prestamo, LugarDePago lugar)
 {
     return(FlatMinor.RegistroPagos(prestamo, lugar));
 }
Ejemplo n.º 20
0
 public ResultadoOp ModificacionPrestamos(Prestamo Prestamo, bool eliminar)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 21
0
        public DataTable getHistorialPAC(Prestamo contrato)
        {
            MySqlDataReader reader;
            DataTable datos = new DataTable();
            try
            {
                string sql = "SELECT * FROM prendasal.view_pac WHERE ID_PRESTAMO = @idprestamo AND ESTADO != 0; ";
                MySqlCommand cmd = new MySqlCommand(sql, conn.conection);
                cmd.CommandType = CommandType.Text;

                MySqlParameter idprestamo = cmd.Parameters.Add("idprestamo", MySqlDbType.Int32);
                idprestamo.Direction = ParameterDirection.Input;

                idprestamo.Value = contrato.ID_PRESTAMO;

                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    datos.Load(reader);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "ERROR AL CONSULTAR HISTORIAL DE CONTRATO # " + contrato.DOCUMENTO, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return datos;
        }
Ejemplo n.º 22
0
        public Prestamo ObtenerPrestamo(string cod)
        {
            String _sql = @"
                            SELECT 
                                CONCAT('PR-',c.pres_id) Codigo
                                ,c.[estado] Estado
                                ,c.[fec_reserva] FechaReserva
                                ,c.[fec_ini_pre] FechaPrestamo
                                ,c.[fec_fin_pre] FechaEntrega
                                ,c.[fec_devolucion] FechaDevolucion
                                ,c.[observacion] Observacion
                                ,c.[per_id] Persona
                                ,c.[adm_id] UsuarioCreacion
                                ,convert(varchar(256),(select concat(',',m.mat_cod )
                                    from [tb_prestamo_det] p
                                        inner join tb_material m on p.mat_id=m.mat_id
                                    where p.pres_id = c.pres_id
                                    for xml path(''))
                                ) Materiales
                            FROM [dbo].[tb_prestamo] c with(nolock) 
                            WHERE CONCAT('PR-',c.pres_id) = @Codigo";

            Prestamo        _pres       = null;
            string          _mat        = string.Empty;
            List <Material> _materiales = new List <Material>();
            MaterialDAO     _matDao     = new MaterialDAO();

            Conexion _cnx = new Conexion();

            SqlCommand _cmd = new SqlCommand(_sql, _cnx.ObtenerConexion());

            _cmd.Parameters.AddWithValue("@Codigo", cod);

            _cnx.AbrirConexion();

            using (SqlDataReader _reader = _cmd.ExecuteReader())
            {
                if (_reader.Read())
                {
                    _pres = new Prestamo
                    {
                        Codigo          = _reader["Codigo"].ToString(),
                        Estado          = Convert.ToInt16(_reader["Estado"].ToString()),
                        FechaDevolucion = string.IsNullOrEmpty(_reader["FechaDevolucion"].ToString()) ? _dateNull: Convert.ToDateTime(_reader["FechaDevolucion"].ToString()),
                        FechaEntrega    = _reader["FechaEntrega"] == null ? _dateNull : Convert.ToDateTime(_reader["FechaEntrega"].ToString()),
                        FechaPrestamo   = _reader["FechaPrestamo"] == null ? _dateNull : Convert.ToDateTime(_reader["FechaPrestamo"].ToString()),
                        FechaReserva    = string.IsNullOrEmpty(_reader["FechaReserva"].ToString()) ? _dateNull : Convert.ToDateTime(_reader["FechaReserva"].ToString()),
                        Observacion     = _reader["Observacion"] == null ? string.Empty: _reader["Observacion"].ToString(),
                        PersonaId       = Convert.ToInt32(_reader["Persona"].ToString()),
                        UsuarioCreacion = Convert.ToInt32(_reader["UsuarioCreacion"].ToString())
                    };

                    _pres.Persona = new Persona {
                        Codigo = ObtenerPersonaCodigo(_pres.PersonaId.Value)
                    };
                    _mat = _reader["Materiales"] == null ? string.Empty : _reader["Materiales"].ToString();

                    foreach (string codmat in _mat.Split(','))
                    {
                        if (string.IsNullOrEmpty(codmat))
                        {
                            continue;
                        }
                        _materiales.Add(_matDao.ObtenerMaterial(codmat));
                    }

                    _pres.Materiales = _materiales;
                }
            }

            _cnx.CerrarConexion();
            return(_pres);
        }
Ejemplo n.º 23
0
        /// <summary>
        /// PRESTAMOS
        /// </summary>
        /// <param name="prestamo"></param>
        /// <returns></returns>

        public ResultadoOp AltaPrestamos(Prestamo prestamo)
        {
            return(FlatMinor.AltaPrestamos(prestamo));
        }
Ejemplo n.º 24
0
 public Prestamo create(Prestamo prestamo)
 {
     return(pRepo.create(prestamo));
 }
Ejemplo n.º 25
0
        public ActionResult <Prestamo> Get(int id)
        {
            Prestamo prestamo = _IPrestamosServices.ConsultarPrestamo(id);

            return(prestamo);
        }
Ejemplo n.º 26
0
 public Prestamo update(Prestamo prestamo)
 {
     return(pRepo.update(prestamo));
 }
 public ModificarEntidadErrorException(Prestamo entidad)
 {
     Message = $"Error al modificar el prestamo nro: {entidad.Numero}";
 }
Ejemplo n.º 28
0
 void IServicioWCF.AltaPrestamo(Prestamo pPrestamo)
 {
     FabricaLogica.GetLogicaPrestamo().Alta(pPrestamo);
 }
Ejemplo n.º 29
0
        public bool create(Prestamo prestamo)
        {
            try
            {
                //dm.Open();
                DBConexion.GetDBConexion().beginTransaction();

                string sql = string.Concat("INSERT INTO [dbo].[Prestamo] ",
                                           "           ([fechaPrestamo]   ",
                                           "           ,[fechaLimite]         ",
                                           "           ,[idSocio]         ",
                                           "           ,[idEstadoPrestamo]         ",
                                           "           ,[borrado])      ",
                                           "     VALUES                 ",
                                           "           (@fechaPrestamo   ",
                                           "           ,@fechaLimite     ",
                                           "           ,@idSocio     ",
                                           "           ,@idEstadoPrestamo     ",
                                           "           ,@borrado)       ");


                var parametros = new Dictionary <string, object>();
                parametros.Add("fechaPrestamo", prestamo.FechaPrestamo);
                parametros.Add("fechaLimite", prestamo.FechaLimite);
                parametros.Add("idSocio", prestamo.IdSocio);
                parametros.Add("idEstadoPrestamo", prestamo.IdEstadoPrestamo);
                parametros.Add("borrado", false);
                DBConexion.GetDBConexion().executeTransactionConParametros(sql, parametros);

                var newId = DBConexion.GetDBConexion().ConsultaSQLScalar(" SELECT @@IDENTITY"); //ver
                prestamo.IdPrestamo = Convert.ToInt32(newId);


                foreach (var itemPrestamo in prestamo.ListaDeDetalles)
                {
                    if (itemPrestamo.ToString() != null)
                    {
                        string sqlDetalle = string.Concat(" INSERT INTO [dbo].[DetallePrestamo] ",
                                                          "           ([idPrestamo]           ",
                                                          "           ,[idEjemplar]          ",
                                                          "           ,[idLibro]      ",
                                                          "           ,[fechaDevolucion]             ",
                                                          "           ,[borrado])             ",
                                                          "     VALUES                        ",
                                                          "           (@idPrestamo            ",
                                                          "           ,@idEjemplar           ",
                                                          "           ,@idLibro      ",
                                                          "           ,@fechaDevolucion              ",
                                                          "           ,@borrado)               ");

                        var paramDetalle = new Dictionary <string, object>();
                        paramDetalle.Add("idPrestamo", prestamo.IdPrestamo);
                        paramDetalle.Add("idEjemplar", itemPrestamo.IdEjemplar);
                        paramDetalle.Add("idLibro", itemPrestamo.IdLibro);
                        paramDetalle.Add("fechaDevolucion", itemPrestamo.FechaDevolucion);
                        paramDetalle.Add("borrado", false);

                        DBConexion.GetDBConexion().executeTransactionConParametros(sqlDetalle, paramDetalle);//
                    }
                }
                // dm.Commit();
            }
            catch (Exception ex)
            {
                //dm.Rollback();
                throw ex;
            }
            finally
            {
                // Cierra la conexión
                //dm.Close();
                DBConexion.GetDBConexion().CloseConnection();
            }
            return(true);
        }
        public int Sp_prestamo(Prestamo prestamo)
        {
            prestamoData = new PrestamoData();

            return(prestamoData.Sp_prestamo(prestamo));
        }
Ejemplo n.º 31
0
        private void NUEVO(object sender, EventArgs e)
        {
            ACCION = eOperacion.INSERT;
            PRESTAMO = new Prestamo();
            PRESTAMO.COD_SUC = HOME.Instance().SUCURSAL.COD_SUC;
            PRESTAMO.DOCUMENTO = dbPrestamo.nextContratoPrestamo(PRESTAMO.COD_SUC);
            PRESTAMO.FECHA = HOME.Instance().FECHA_SISTEMA;
            PRESTAMO.NIVEL = eNIVEL.PRENDASAL;
            PRESTAMO.TIPO = eTipoPrestamo.PRENDARIO;
            PRESTAMO.TIPO_PAGO = eTipoPago.EFECTIVO;
            PRESTAMO.ESTADO_CONTRATO = eEstadoContrato.ACTIVO;

            cargarTarjeta(new Tarjeta());

            cargarDatosCliente(null);
            cargarDatosPrestamo();
            desbloquear();
            txtDocCLI.Focus();

            btnGuardar.Enabled = true;
            btnCancelar.Enabled = true;
            btnEditar.Enabled = false;
            btnEliminar.Enabled = false;
            btnLog.Enabled = false;
            btnReimprimir.Enabled = false;
            btnPrintKITCO.Enabled = false;

            txtDocCLI.Focus();
        }
Ejemplo n.º 32
0
 public Prestamo UpdateSolicitud(Prestamo updatePrestamo)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 33
0
        public DataTable getKITCO(Prestamo prestamo)
        {
            MySqlDataReader reader;
            DataTable datos = new DataTable();
            try
            {
                string sql = "prendasal.SP_KITCO_PRESTAMO";
                MySqlCommand cmd = new MySqlCommand(sql, conn.conection);
                cmd.CommandType = CommandType.StoredProcedure;

                MySqlParameter idprestamo = cmd.Parameters.Add("idprestamo", MySqlDbType.Int32);
                idprestamo.Direction = ParameterDirection.Input;

                idprestamo.Value = prestamo.ID_PRESTAMO;

                reader = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    datos.Load(reader);
                }
                reader.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show("ERROR AL OBTENER DETALLE KITCO DE PRESTAMO", "ERROR EN CONSULTA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            return datos;
        }
Ejemplo n.º 34
0
 public void SeleccionarPrestamo(FormMode op, Prestamo oPrestamo)
 {
     formMode          = op;
     oPrestamoSelected = oPrestamo;
 }
Ejemplo n.º 35
0
        protected void GuardarButton_Click(object sender, EventArgs e)
        {
            if (Convert.ToInt32(CuentaDropDownList.SelectedValue) == 0)
            {
                return;
            }

            if (CuotasGridView.Rows.Count == 0)
            {
                Utilities.Utils.ShowToastr(this, "No se encuentra el ID", "Error", "error");
                return;
            }


            PrestamoBLL repositorio = new PrestamoBLL();
            Prestamo    prestamo    = LlenaClase();

            RepositorioBase <Cuentas> cuentas = new RepositorioBase <Cuentas>();

            var validar = cuentas.Buscar(Utilities.Utils.ToInt(CuentaDropDownList.SelectedValue));

            bool paso = false;


            if (validar != null)
            {
                if (Page.IsValid)
                {
                    if (prestamo.PrestamoID == 0)
                    {
                        paso = repositorio.Guardar(prestamo);
                    }

                    else
                    {
                        var verificar = repositorio.Buscar(Utilities.Utils.ToInt(PrestamoIDTextbox.Text));
                        if (verificar != null)
                        {
                            paso = repositorio.Modificar(prestamo);
                        }
                        else
                        {
                            Utilities.Utils.ShowToastr(this, "No se encuentra el ID", "Error", "error");
                            return;
                        }
                    }

                    if (paso)

                    {
                        Utilities.Utils.ShowToastr(this, "Cuenta Registrada", "Exito", "Exito");
                    }

                    else

                    {
                        Utilities.Utils.ShowToastr(this, "No se pudo Guardar", "Error", "error");
                    }
                    Limpiar();
                    return;
                }
            }
            else
            {
                Utilities.Utils.ShowToastr(this, "El numero de cuenta no existe", "Error", "Error");
                return;
            }
        }
Ejemplo n.º 36
0
        public static void Initialize(RentaPeli context)
        {
            context.Database.EnsureCreated();

            //Look for clientes
            if (context.Clientes.Any())
            {
                return; //DB has been seeded
            }

            var clients = new Client[]
            {
                new Client {
                    LastName = "Marquez", FirstName = "Jhojaira", Telephone = "75757364", Direction = "Col. Santa Julia"
                },
                new Client {
                    LastName = "Cruz", FirstName = "Fatima", Telephone = "65482547", Direction = "Col. Santa Lucia"
                },
                new Client {
                    LastName = "Fernandez", FirstName = "Karla", Telephone = "75897356", Direction = "Col. San Juan"
                },
                new Client {
                    LastName = "Morales", FirstName = "Jeronimo", Telephone = "78557964", Direction = "Barrio La Cruz"
                },
                new Client {
                    LastName = "Perez", FirstName = "Jennifer", Telephone = "74527364", Direction = "Col. El Molino"
                },
            };

            foreach (Client c in clients)
            {
                context.Clientes.Add(c);
            }
            context.SaveChanges();

            //Look for peliculas

            /* if (context.Peliculas.Any())
             * {
             *   return; //DB has been seeded
             * }*/

            var peliculas = new Pelicula[]
            {
                new Pelicula {
                    NombrePelicula = "Milagro en la celda 7", Año = 2019, Duracion = "2h 12min"
                },
                new Pelicula {
                    NombrePelicula = "Avengers: Endgame", Año = 2019, Duracion = "3h 2min"
                },
                new Pelicula {
                    NombrePelicula = "La Cabaña", Año = 2017, Duracion = "2h 13min"
                },
                new Pelicula {
                    NombrePelicula = "La Viuda", Año = 2018, Duracion = "1h 38min"
                },
                new Pelicula {
                    NombrePelicula = "Mentes Poderosas", Año = 2018, Duracion = "1h 43min"
                }
            };

            foreach (Pelicula p in peliculas)
            {
                context.Peliculas.Add(p);
            }
            ;

            context.SaveChanges();

            //Look for prestamos

            /*if (context.Prestamos.Any())
             * {
             *   return; //DB has been seeded
             * }*/

            var prestamos = new Prestamo[]
            {
                new Prestamo {
                    FechaPrestamo = DateTime.Parse("2021-01-08"), FechaDevolucion = DateTime.Parse("2021-01-11"), ClientID = 1, PeliculaID = 10
                },
                new Prestamo {
                    FechaPrestamo = DateTime.Parse("2021-01-09"), FechaDevolucion = DateTime.Parse("2021-01-11"), ClientID = 2, PeliculaID = 13
                },
                new Prestamo {
                    FechaPrestamo = DateTime.Parse("2021-01-15"), FechaDevolucion = DateTime.Parse("2021-01-17"), ClientID = 3, PeliculaID = 15
                },
                new Prestamo {
                    FechaPrestamo = DateTime.Parse("2021-01-28"), FechaDevolucion = DateTime.Parse("2021-01-30"), ClientID = 4, PeliculaID = 17
                },
                new Prestamo {
                    FechaPrestamo = DateTime.Parse("2021-01-28"), FechaDevolucion = DateTime.Parse("2021-01-31"), ClientID = 5, PeliculaID = 18
                }
            };

            foreach (Prestamo r in prestamos)
            {
                context.Prestamos.Add(r);
            }
            ;

            context.SaveChanges();
        }
Ejemplo n.º 37
0
    static void Main(string[] args)
    {
        AppaLiteModelContainer context = new AppaLiteModelContainer();

        Marca mrc1 = new Marca
        {
            Nombre = "Adidas",
            Icono = "Adidas.jpg"
        };

        context.Marcas.Add(mrc1);
        //context.SaveChanges();

        Articulo art1 = new Articulo
        {
            Referencia = "A12345",
            Descripcion = "Maraton 6",
            Talla = "6",
            Marca = mrc1
           // Prestamo =
         };

        context.Articulos.Add(art1);
        //context.SaveChanges();

        Local lcl1 = new Local
        {
            Nombre = "Cca 126",
            Icono = "126.jpg",
            Telefono = "3021234"

        };

        context.Locales.Add(lcl1);
        //context.SaveChanges();

        Local lcl2 = new Local
        {
            Nombre = "Cca 124",
            Icono = "124.jpg",
            Telefono = "3011235"
        };

        context.Locales.Add(lcl2);
        //context.SaveChanges();

        Empleado emp1 = new Empleado
        {
            Nombre = "Elbert Toledo",
            Cedula = "1234",
            Telefono = "3001236",
            Foto = "emp1.jpg",
        };

        context.Empleados.Add(emp1);
        //context.SaveChanges();

        Movimiento mvt1 = new Movimiento
        {
            Estado = "Prestado",
            Fecha = "10/08/2015",
            Hora = "2:30 Pm",
            Destino = lcl1,
            //Prestamo =ptm1 ,
        };

        emp1.Movimiento.Add(mvt1);

        context.Movimientos.Add(mvt1);
        //context.SaveChanges();

        Prestamo ptm1 = new Prestamo
        {
            Articulo = art1,
            Origen = lcl1,
          //  Movimientos

        };

           // mvt1.Prestamo = ptm1;
        ptm1.Articulo = art1;
        context.Prestamos.Add(ptm1);
        //context.SaveChanges();

        try
        {
            // doing here my logic
            context.SaveChanges();
        }
        catch (DbEntityValidationException dbEx)
        {

            foreach (var validationErrors in dbEx.EntityValidationErrors)
            {

                foreach (var validationError in validationErrors.ValidationErrors)
                {
                    Console.WriteLine("Property: {0} Error: {1}", validationError.
          PropertyName, validationError.ErrorMessage);
                }
            }
        }

        //context.SaveChanges();
    }
Ejemplo n.º 38
0
 public PrestamoDolar(Prestamo prestamo, PeriodicidadDePagos periodicidad)
     : this(prestamo.Monto, prestamo.Vencimiento, periodicidad)
 {
 }
Ejemplo n.º 39
0
 public void GenerarCronograma(Prestamo prestamo)
 {
     prestamo.GenerarCronograma();
 }
Ejemplo n.º 40
0
 public Prestamo CreateSolicitud(Prestamo createPrestamo)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 41
0
        public static string[] realizarPrestamo(Prestamo p, List <int> idEjemplares)
        {
            SqlConnection sqlCon = new SqlConnection(); // Con este objeto hacemos al conexion a la base de datos

            string[] respuesta;
            try
            {
                sqlCon = Conexion.getInstancia().CrearConexion(); //Utilizamos la variable tipo sql connection que obtenemos desde la clase conexion
                sqlCon.Open();

                using (SqlCommand cmdSP = new SqlCommand("sp_realizarPrestamo", sqlCon))
                {
                    cmdSP.CommandType = CommandType.StoredProcedure;

                    using (var table = new DataTable())
                    {
                        table.Columns.Add("idEjemplarActual", typeof(int));

                        foreach (int idEjemplarActual in idEjemplares)
                        {
                            table.Rows.Add(idEjemplarActual);
                        }


                        //Se definen los parámetros
                        cmdSP.Parameters.Add("@var_idEjemplares", SqlDbType.Structured).Value = table;
                        cmdSP.Parameters["@var_idEjemplares"].TypeName = "dbo.type_idEjemplar";

                        cmdSP.Parameters.Add("@var_idLaboratorio", SqlDbType.Int).Value   = p.Laboratorio.IdLaboratorio;
                        cmdSP.Parameters.Add("@var_idLaboratorista", SqlDbType.Int).Value = p.Laboratorista.idLaboratorista;
                        cmdSP.Parameters.Add("@var_idAlumno", SqlDbType.Int).Value        = p.Alumno.idAlumno;
                        cmdSP.Parameters.Add("@var_fechaLimite", SqlDbType.Date).Value    = p.FechaLimite;

                        cmdSP.Parameters.Add("@var_idPrestamo", SqlDbType.Int).Direction            = ParameterDirection.Output;
                        cmdSP.Parameters.Add("@var_clavePrestamo", SqlDbType.VarChar, 30).Direction = ParameterDirection.Output;
                        cmdSP.Parameters.Add("@var_validacionEjecucion", SqlDbType.Int).Direction   = ParameterDirection.Output;

                        cmdSP.ExecuteNonQuery();


                        //Se recuperan los valores de salida
                        p.IdPrestamo    = Convert.ToInt32(cmdSP.Parameters["@var_idPrestamo"].Value);
                        p.ClavePrestamo = Convert.ToString(cmdSP.Parameters["@var_clavePrestamo"].Value);
                        int validacion = Convert.ToInt32(cmdSP.Parameters["@var_validacionEjecucion"].Value);

                        respuesta = new string[] { Convert.ToString(validacion), p.ClavePrestamo };
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }
            finally
            { // Este codigo se va a ejecutar aunque haya alguna excepcion. **SIEMPRE SE CERRARÁ LA CONEXIÓN**
                if (sqlCon.State == ConnectionState.Open)
                {
                    sqlCon.Close();
                }
            }

            return(respuesta);
        }
        public ActionResult <Prestamo> Post(Prestamo prestamo)
        {
            PrestamosBLL.Guardar(prestamo);

            return(CreatedAtAction(nameof(Get), new { id = prestamo.PrestamoId }, prestamo));
        }