コード例 #1
0
        public int optenerIdPrestamo(PrestamosModel aprestamo)//decimal MontoPrestamo,String cuenta)
        {
            int id = 0;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();
                    SqlTransaction sqlTran = connection.BeginTransaction();
                    SqlCommand     command = connection.CreateCommand();
                    command.Transaction = sqlTran;
                    command.Parameters.AddWithValue("@Monto", aprestamo.Montoprestamo);
                    command.Parameters.AddWithValue("@Cuenta", aprestamo.Cuenta);
                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "PrestamosSelectIdByMontoYCuenta";

                    id = int.Parse(command.ExecuteScalar().ToString());

                    SqlDataReader reader    = command.ExecuteReader();
                    int           afectados = command.ExecuteNonQuery();
                    connection.Close();
                    connection.Dispose();
                    return(id);
                }
            }
            catch (Exception)
            {
                //throw;
                return(id);
            }
        }
コード例 #2
0
        private void buscarPrestamo(List <PrestamosModel> objetos)
        {
            string[][] orden = new string[6][];

            orden[0] = new string[] { "Id", "Codigo", "60" };
            orden[1] = new string[] { "Cuenta", "Cuenta", "180" };
            orden[2] = new string[] { "Fechaprestamo", "Fecha de Prestamo", "150" };
            orden[3] = new string[] { "Montoprestamo", "Monto", "100" };
            orden[4] = new string[] { "Plazomeses", "Meses", "80" };
            orden[5] = new string[] { "Usuario_creador", "Aprobado por", "100" };

            if (objetos != null)
            {
                using (Ayuda.FormHelp2 formHelp1 = new Ayuda.FormHelp2())
                {
                    formHelp1.setList(objetos, orden);
                    formHelp1.ShowDialog();

                    if (formHelp1.EstaAceptado())
                    {
                        var dato = formHelp1.getObject <PrestamosModel>();
                        if (dato != null)
                        {
                            this.clearForm();
                            this.gPrestamo = this.BLPrestamo.Prestamo_ObtenerUno(dato.Id);
                            this.gCuenta   = this.BLCuenta.Cuenta_ObtenerUno(dato.Cuenta);
                            this.prestamo2gui(this.gPrestamo);
                            this.modoNuevo();
                            this.modoEdicion();
                        }
                    }
                }
            }
        }
コード例 #3
0
        public bool crearCronogramaPagosB(PrestamosModel aprestamo)
        {
            int         ID       = optenerIdPrestamo(aprestamo);
            MontosCuota mtn      = new MontosCuota();
            Decimal     tea_     = aprestamo.Porcentaje_interes;
            Decimal     monto_   = aprestamo.Montoprestamo;
            int         plazo_   = aprestamo.Plazomeses;
            Decimal     interes_ = aprestamo.Interes_moratorio ?? 0;
            bool        Final    = false;

            mtn = calculaMontos(tea_, monto_, plazo_, interes_);

            List <CronogramaPagosModel> CronogramaPagosModellist = new List <CronogramaPagosModel>();

            for (int i = 0; i < aprestamo.Plazomeses; i++)
            {
                CronogramaPagosModel cuota = new CronogramaPagosModel();
                cuota.Monto               = Convert.ToDecimal(mtn.total);
                cuota.Prestamo            = ID;
                cuota.Interes             = Convert.ToDecimal(mtn.InteresMensual);
                cuota.DiaPago             = aprestamo.Fechaprestamo.AddMonths(i + 1);
                cuota.Saldo               = Convert.ToDecimal(mtn.total);
                cuota.Seguro              = Convert.ToDecimal(mtn.SeguroDesgravamen);
                cuota.FechaCancelado      = null;
                cuota.Fecha_creacion      = aprestamo.Fecha_creacion;
                cuota.Fecha_modificacion  = null;
                cuota.Usuario_creador     = aprestamo.Usuario_creador;
                cuota.Usuario_modificador = aprestamo.Usuario_modificador;
                CronogramaPagosModellist.Add(cuota);
                Final = cuotas.InsertCuotas(cuota);
            }
            return(Final);
        }
コード例 #4
0
        /// <summary>
        /// Saves a record to the prestamo table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Insert(PrestamosModel aprestamo)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@FechaPrestamo", aprestamo.Fechaprestamo);
                    command.Parameters.AddWithValue("@MontoPrestamo", aprestamo.Montoprestamo);
                    command.Parameters.AddWithValue("@Moneda", aprestamo.Moneda);
                    command.Parameters.AddWithValue("@PlazoMeses", aprestamo.Plazomeses);
                    command.Parameters.AddWithValue("@Porcentaje_Interes", aprestamo.Porcentaje_interes);
                    command.Parameters.AddWithValue("@Seguro", aprestamo.Seguro);
                    command.Parameters.AddWithValue("@Cuenta", aprestamo.Cuenta);
                    command.Parameters.AddWithValue("@Interes_Moratorio", aprestamo.Interes_moratorio == null ? (object)DBNull.Value : aprestamo.Interes_moratorio);
                    command.Parameters.AddWithValue("@FECHA_MODIFICACION", aprestamo.Fecha_modificacion == null ? (object)DBNull.Value : aprestamo.Fecha_modificacion);
                    command.Parameters.AddWithValue("@USUARIO_CREADOR", aprestamo.Usuario_creador == null ? (object)DBNull.Value : aprestamo.Usuario_creador);
                    command.Parameters.AddWithValue("@FECHA_CREACION", aprestamo.Fecha_creacion == null ? (object)DBNull.Value : aprestamo.Fecha_creacion);
                    command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", aprestamo.Usuario_modificador == null ? (object)DBNull.Value : aprestamo.Usuario_modificador);
                    command.Parameters.AddWithValue("@DiaPago", aprestamo.Diapago == null ? (object)DBNull.Value : aprestamo.Diapago);


                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "PrestamosInsert";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();
                    //condicion para aumentar afectados y no pase crearCronogramaPagosB
                    crearCronogramaPagos(aprestamo);

                    if (afectados < 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                //throw;
                return(false);
            }
        }
コード例 #5
0
        /// <summary>
        /// Updates a record to the PrestamosModel table.
        /// returns True if value saved successfully else false
        /// Throw exception with message value EXISTS if the data is duplicate
        /// </summary>
        public bool Update(PrestamosModel aPrestamosModel)
        {
            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlTransaction sqlTran = connection.BeginTransaction();

                    SqlCommand command = connection.CreateCommand();

                    command.Transaction = sqlTran;

                    command.Parameters.AddWithValue("@ID", aPrestamosModel.Id);
                    //command.Parameters.AddWithValue("@FechaPrestamosModel", aPrestamosModel.FechaPrestamosModel);
                    //command.Parameters.AddWithValue("@MontoPrestamosModel", aPrestamosModel.MontoPrestamosModel);
                    command.Parameters.AddWithValue("@Moneda", aPrestamosModel.Moneda);
                    command.Parameters.AddWithValue("@PlazoMeses", aPrestamosModel.Plazomeses);
                    command.Parameters.AddWithValue("@Porcentaje_Interes", aPrestamosModel.Porcentaje_interes);
                    command.Parameters.AddWithValue("@Seguro", aPrestamosModel.Seguro);
                    command.Parameters.AddWithValue("@Cuenta", aPrestamosModel.Cuenta);
                    command.Parameters.AddWithValue("@Interes_Moratorio", aPrestamosModel.Interes_moratorio == null ? (object)DBNull.Value : aPrestamosModel.Interes_moratorio);
                    command.Parameters.AddWithValue("@FECHA_MODIFICACION", aPrestamosModel.Fecha_modificacion == null ? (object)DBNull.Value : aPrestamosModel.Fecha_modificacion);
                    command.Parameters.AddWithValue("@USUARIO_CREADOR", aPrestamosModel.Usuario_creador == null ? (object)DBNull.Value : aPrestamosModel.Usuario_creador);
                    command.Parameters.AddWithValue("@USUARIO_MODIFICADOR", aPrestamosModel.Usuario_modificador == null ? (object)DBNull.Value : aPrestamosModel.Usuario_modificador);


                    command.CommandType = CommandType.StoredProcedure;
                    command.CommandText = "PrestamosModelUpdate";

                    int afectados = command.ExecuteNonQuery();

                    // Commit the transaction.
                    sqlTran.Commit();

                    connection.Close();
                    connection.Dispose();

                    if (afectados > 0)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #6
0
 private void prestamo2gui(PrestamosModel aprestamo)
 {
     this.txtCodigo.Text             = aprestamo.Id.ToString();
     this.txtCuenta.Text             = aprestamo.Cuenta;
     this.txtMontoPrestamo.Text      = aprestamo.Montoprestamo.ToString();
     this.txtMontoMora.Text          = aprestamo.Interes_moratorio.ToString();
     this.dtpFechaPrestamo.Value     = aprestamo.Fechaprestamo;
     this.cboMoneda.SelectedValue    = aprestamo.Moneda;
     this.nudPlazoMeses.Value        = aprestamo.Plazomeses;
     this.nudPorcentajeInteres.Value = aprestamo.Porcentaje_interes;
     this.nudDiaPago.Value           = (decimal)aprestamo.Diapago;
     this.chkEstado.Checked          = aprestamo.Seguro;
 }
コード例 #7
0
        /// <summary>
        /// Selects the Single object of PrestamosModel table.
        /// </summary>
        public PrestamosModel GetPrestamosModel(int aID)
        {
            PrestamosModel PrestamosModel = null;

            try
            {
                using (var connection = Util.ConnectionFactory.conexion())
                {
                    connection.Open();

                    SqlCommand command = connection.CreateCommand();

                    command.Parameters.AddWithValue("@ID", aID);


                    command.CommandType = CommandType.StoredProcedure;

                    command.CommandText = "PrestamosModelSelect";

                    SqlDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            int      ID = (int)(reader["ID"]);
                            DateTime FechaPrestamosModel = (DateTime)(reader["FechaPrestamosModel"]);
                            decimal  MontoPrestamosModel = (decimal)(reader["MontoPrestamosModel"]);
                            short    Moneda              = (short)(reader["Moneda"]);
                            short    PlazoMeses          = (short)(reader["PlazoMeses"]);
                            decimal  Porcentaje_Interes  = (decimal)(reader["Porcentaje_Interes"]);
                            int      Seguro              = (int)(reader["Seguro"]);
                            string   Cuenta              = (string)(reader["Cuenta"]);
                            decimal? Interes_Moratorio   = reader["Interes_Moratorio"] as decimal?;
                            DateTime?FECHA_MODIFICACION  = reader["FECHA_MODIFICACION"] as DateTime?;
                            int?     USUARIO_CREADOR     = reader["USUARIO_CREADOR"] as int?;
                            int?     USUARIO_MODIFICADOR = reader["USUARIO_MODIFICADOR"] as int?;

                            PrestamosModel = new PrestamosModel
                            {
                                Id = ID,
                                //FechaPrestamosModel = FechaPrestamosModel,
                                //MontoPrestamosModel = MontoPrestamosModel,
                                Moneda              = Moneda,
                                Plazomeses          = PlazoMeses,
                                Porcentaje_interes  = Porcentaje_Interes,
                                Seguro              = Seguro,
                                Cuenta              = Cuenta,
                                Interes_moratorio   = Interes_Moratorio,
                                Fecha_modificacion  = FECHA_MODIFICACION,
                                Usuario_creador     = USUARIO_CREADOR,
                                Usuario_modificador = USUARIO_MODIFICADOR,
                            };
                        }
                    }
                }

                return(PrestamosModel);
            }
            catch (Exception)
            {
                return(null);
            }
        }
コード例 #8
0
 public bool Prestamo_Editar(PrestamosModel aPrestamo)
 {
     return(BLPrestamo.Update(aPrestamo));
 }
コード例 #9
0
 public bool Prestamo_Crear(PrestamosModel aPrestamo)
 {
     return(BLPrestamo.Insert(aPrestamo));
 }
コード例 #10
0
 /// <summary>
 /// Updates a record to the prestamo table.
 /// returns True if value saved successfully else false
 /// Throw exception with message value EXISTS if the data is duplicate
 /// </summary>
 public bool Update(PrestamosModel aprestamo)
 {
     return(this.managerPrestamo.Update(aprestamo));
 }
コード例 #11
0
 /// <summary>
 /// Saves a record to the prestamo table.
 /// returns True if value saved successfully else false
 /// Throw exception with message value EXISTS if the data is duplicate
 /// </summary>
 public bool Insert(PrestamosModel aprestamo)
 {
     return(managerPrestamo.Insert(aprestamo));
 }