Example #1
0
        /// <summary> Elimina un de credito de la base de datos. </summary>
        /// <param name="tobjMunicipio"> Un objeto del tipo credito. </param>
        /// <returns> Un string que indica si se ejecuto o no el metodo. </returns>
        public String gmtdEliminar(tblCredito tobjCredito)
        {
            if (tobjCredito.intCodigoCre == 0)
            {
                return("- Debe de ingresar el código del prestamo a eliminar.");
            }

            tblCredito cre = new daoCreditos().gmtdConsultar(tobjCredito.intCodigoCre);

            if (cre.strNombrePre == null)
            {
                return("- Este crédito no aparece registrado.");
            }

            if (new daoCreditos().gmtdSabersihaycuotaspagadasdeuncredito(cre.intCodigoCre))
            {
                return("- Este crédito ya tiene cuotas pagadas y no se puede eliminar.");
            }

            tobjCredito.intCodigoRec = new blCreditos().gmtdConsultar(tobjCredito.intCodigoCre).intCodigoRec;

            tobjCredito.log = metodos.gmtdLog("Elimina el crédito " + tobjCredito.intCodigoCre.ToString(), tobjCredito.strFormulario);

            return(new daoCreditos().gmtdEliminar(tobjCredito));
        }
        /// <summary> Inserta un credito. </summary>
        /// <param name="tobjMunicipio"> Un objeto del tipo tblCredito. </param>
        /// <returns> Un string que indica si se ejecuto o no la operación. </returns>
        public string gmtdInsertar(tblCredito tobjCredito)
        {
            String strRetornar;

            try
            {
                using (dbExequial2010DataContext recibosEgresos = new dbExequial2010DataContext())
                {
                    tblEgresosEgreso egresoEgreso = new tblEgresosEgreso();
                    egresoEgreso.decIva             = 0;
                    egresoEgreso.decRetencion       = 0;
                    egresoEgreso.decValorBruto      = tobjCredito.decMonto;
                    egresoEgreso.decValorIva        = 0;
                    egresoEgreso.decValorNeto       = tobjCredito.decMonto;
                    egresoEgreso.decValorRetencion  = 0;
                    egresoEgreso.strCodOtrosEgresos = "0001";
                    egresoEgreso.strDescripcion     = "Se le registro el crédito " + tobjCredito.intCodigoCre.ToString() + " Linea: " + tobjCredito.strNombreLinea;

                    tblEgreso egreso = new tblEgreso();
                    egreso.bitEgreso     = true;
                    egreso.decTotal      = tobjCredito.decMonto;
                    egreso.dtmFechaAnu   = Convert.ToDateTime("1/1/1900");
                    egreso.dtmFechaRec   = new daoUtilidadesConfiguracion().gmtdCapturarFechadelServidor();
                    egreso.strApellido   = tobjCredito.strApellido1Pre + " " + tobjCredito.strApellido2Pre;
                    egreso.strCedulaEgre = tobjCredito.strCedulaPre;
                    egreso.strFormulario = tobjCredito.strFormulario;
                    egreso.strLetras     = new blConfiguracion().montoenLetras(tobjCredito.decMonto.ToString());
                    egreso.strNombre     = tobjCredito.strNombrePre;
                    egreso.strMaquina    = tobjCredito.strComputador;
                    egreso.strUsuario    = tobjCredito.strUsuario;

                    List <tblEgresosEgreso> lstEgresosDetalle = new List <tblEgresosEgreso>();
                    lstEgresosDetalle.Add(egresoEgreso);

                    egreso.egresoEgreso = lstEgresosDetalle;
                    XmlDocument xml       = blRecibosEgresos.SerializeServicio(egreso);
                    string      strEgreso = new daoRecibosEgresos().gmtdInsertar(xml);
                    tobjCredito.intCodigoRec = Convert.ToInt32(strEgreso);
                }

                using (dbExequial2010DataContext tipo = new dbExequial2010DataContext())
                {
                    tipo.tblCreditos.InsertOnSubmit(tobjCredito);
                    tipo.tblLogdeActividades.InsertOnSubmit(tobjCredito.log);
                    tipo.SubmitChanges();
                }

                strRetornar = "Registro Insertado. Se registro el egreso # " + tobjCredito.intCodigoRec.ToString();
            }
            catch (Exception ex)
            {
                EventLog even = new EventLog();
                even.Source = "Exequial2010";
                even.WriteEntry(ex.Message, EventLogEntryType.Information);
                new dao().gmtdInsertarError(ex);
                strRetornar = "- Ocurrió un error al insertar el registro.";
            }
            return(strRetornar);
        }
Example #3
0
        /// <summary> Crea un objeto del tipo aplicación de acuerdo a la información de los texbox. </summary>
        /// <returns> Un objeto del tipo aplicación. </returns>
        private tblCredito crearObj()
        {
            tblCredito credito = new tblCredito();

            credito.bitAhorrado  = this.chkAhorros.Checked;
            credito.decAbono     = 0;
            credito.decAhorrado  = Convert.ToDecimal(this.txtAhorrado.Text);
            credito.decDebe      = Convert.ToDecimal(this.txtMonto.Text);
            credito.decIntereses = Convert.ToDecimal(this.txtIntereses.Text);
            credito.decMonto     = Convert.ToDecimal(this.txtMonto.Text);
            credito.dtmFechaPre  = this.dtpFechaPre.Value;
            credito.intCodigoCre = Convert.ToInt32(this.txtCodigo.Text);
            credito.intCodigoSoc = Convert.ToInt32(this.txtSocio.Text);
            credito.intCuotas    = Convert.ToInt32(this.txtMeses.Text);
            credito.intPagarePre = Convert.ToInt32(this.txtPagare.Text);
            credito.intCuotas    = Convert.ToInt32(this.txtMeses.Text);
            if (this.txtNombreCodeudor1.Text.Trim() != "")
            {
                credito.intTipoGarantia = 1;
            }
            if (Convert.ToInt32(this.txtAhorrado.Text) > 0)
            {
                credito.intTipoGarantia = 2;
            }
            if (this.rdbHipotecaria.Checked || this.rdbPrendaria.Checked)
            {
                credito.intTipoGarantia = 3;
            }
            credito.strApellido1Pre                  = this.txtApellidoPre1.Text.Trim();
            credito.strApellido2Pre                  = this.txtApellidoPre2.Text.Trim();
            credito.strApellidoCde                   = this.txtApellidoCodeudor1.Text.Trim();
            credito.strApellidoCde2                  = this.txtApellidoCodeudor2.Text.Trim();
            credito.strCedulaCde                     = this.txtCedulaCodeudor1.Text.Trim();
            credito.strCedulaCde2                    = this.txtCedulaCodeudor2.Text.Trim();
            credito.strCedulaPre                     = this.txtCedula.Text.Trim();
            credito.strCodigoPar                     = this.cboPar.SelectedValue.ToString();
            credito.strCodLineadeCredito             = this.cboLinea.SelectedValue.ToString();
            credito.strDescripcionGarantiadelCredito = this.txtDescripcionGarantia.Text.Trim();
            credito.strDireccion                     = this.txtDireccion.Text.Trim();
            credito.strFormadeCobroPre               = this.cboPago.Text;
            credito.strFrecuenciaPre                 = this.cboFrecuencia.Text;
            credito.strFormulario                    = this.Name;
            credito.strNombreCde                     = this.txtNombreCodeudor1.Text.Trim();
            credito.strNombreCde2                    = this.txtNombreCodeudor2.Text.Trim();
            credito.strNombrePre                     = this.txtNombre.Text.Trim();
            credito.strTelefono        = this.txtTelefono.Text.Trim();
            credito.strTelefonoCde     = this.txtTelefonoCodeudor1.Text.Trim();
            credito.strTelefonoCde2    = this.txtTelefonoCodeudor2.Text.Trim();
            credito.strNombreLinea     = this.cboLinea.Text;
            credito.strComputador      = Environment.MachineName;
            credito.strUsuario         = propiedades.strLogin;
            credito.dtmFechaExpedicion = this.dtmFechaExpedicion.Value;
            credito.strLugarExpedicion = this.txtLugardeExpedicion.Text;
            return(credito);
        }
Example #4
0
        /// <summary> Calcula las fecha de un crédito. </summary>
        /// <param name="tobjCredito"> Un objeto con los datos del crédito. </param>
        /// <param name="tintCuotas"> El número de cuotas del credito. </param>
        /// <returns> Un lista con las fechas del crédito. </returns>
        private List <DateTime> pGenerarFechasdeCuotasAutomaticamente(tblCredito tobjCredito)
        {
            DateTime dtmFechaini = tobjCredito.dtmFechaPre;
            DateTime dtmFechaCuo;
            DateTime dtmFechaCuoQuincena;
            int      intCuotas = 0;

            lstFechas = new List <DateTime>();

            switch (tobjCredito.strFrecuenciaPre)
            {
            case "Mensual":
                intCuotas = tobjCredito.intCuotas;
                for (int a = 1; a <= intCuotas; a++)
                {
                    dtmFechaCuo = dtmFechaini.AddMonths(a);
                    this.pGenerarFechas(intCuotas, dtmFechaCuo);
                }
                break;

            case "Termino":
                intCuotas = tobjCredito.intCuotas;
                for (int a = 1; a <= intCuotas; a++)
                {
                    dtmFechaCuo = dtmFechaini.AddMonths(a);
                    this.pGenerarFechas(intCuotas, dtmFechaCuo);
                }
                break;

            case "Quincenal":
                intCuotas = tobjCredito.intCuotas * 2;
                for (int a = 1; a <= intCuotas / 2; a++)
                {
                    dtmFechaCuo = dtmFechaini.AddMonths(a);
                    this.pGenerarFechas(intCuotas, dtmFechaCuo);
                    dtmFechaCuoQuincena = dtmFechaCuo.AddDays(15);
                    this.pGenerarFechas(intCuotas, dtmFechaCuoQuincena);
                }
                break;

            case "Decadal":
                intCuotas = tobjCredito.intCuotas * 3;
                for (int a = 1; a <= intCuotas; a++)
                {
                    dtmFechaCuo = dtmFechaini.AddDays(10);
                    this.pGenerarFechas(intCuotas, dtmFechaCuo);
                }
                break;
            }
            return(lstFechas);
        }
Example #5
0
 private void txtIntereses_Leave(object sender, EventArgs e)
 {
     if (this.txtMonto.Text.Trim() != "" && this.txtMonto.Text.Trim() != "0" &&
         this.txtIntereses.Text.Trim() != "" && this.txtIntereses.Text.Trim() != "0" &&
         this.txtMeses.Text.Trim() != "" && this.txtMeses.Text.Trim() != "0" &&
         this.cboFrecuencia.Text != "")
     {
         tblCredito credito = new tblCredito();
         credito.strFrecuenciaPre = this.cboFrecuencia.Text;
         credito.decMonto         = Convert.ToDecimal(this.txtMonto.Text);
         credito.decIntereses     = Convert.ToDecimal(this.txtIntereses.Text);
         credito.intCuotas        = Convert.ToInt32(this.txtMeses.Text);
         this.txtValorCuota.Text  = new blCreditos().gmtCalcularValordeCuota(credito).ToString("#,#00.00");
     }
 }
        /// <summary> Elimina un de credito de la base de datos. </summary>
        /// <param name="tobjMunicipio"> Un objeto del tipo credito. </param>
        /// <returns> Un string que indica si se ejecuto o no el metodo. </returns>
        public String gmtdEliminar(tblCredito tobjCredito)
        {
            String strResultado;

            try
            {
                using (dbExequial2010DataContext tipo = new dbExequial2010DataContext())
                {
                    tblCredito cre_old = tipo.tblCreditos.SingleOrDefault(p => p.intCodigoCre == tobjCredito.intCodigoCre);
                    cre_old.dtmFechaAnu = new daoUtilidadesConfiguracion().gmtdCapturarFechadelServidor();
                    cre_old.bitAnulado  = true;
                    tipo.tblLogdeActividades.InsertOnSubmit(tobjCredito.log);
                    tipo.SubmitChanges();
                }

                using (dbExequial2010DataContext recibosEgresos = new dbExequial2010DataContext())
                {
                    if (tobjCredito.intCodigoRec != 0)
                    {
                        tblEgreso egr = recibosEgresos.tblEgresos.SingleOrDefault(p => p.intCodigoEgr == tobjCredito.intCodigoRec);
                        egr.bitAnulado  = true;
                        egr.dtmFechaAnu = new daoUtilidadesConfiguracion().gmtdCapturarFechadelServidor();

                        recibosEgresos.tblLogdeActividades.InsertOnSubmit(metodos.gmtdLog("Elimino el egreso " + tobjCredito.intCodigoRec.ToString(), "FrmPrestamos"));

                        recibosEgresos.SubmitChanges();
                    }
                }

                strResultado = "Registro Eliminado";
            }
            catch (Exception ex)
            {
                new dao().gmtdInsertarError(ex);
                strResultado = "- No se puede eliminar el registro.";
            }
            return(strResultado);
        }
Example #7
0
 /// <summary> Calcula el valor de cada cuota de un credito. </summary>
 /// <param name="tobjCredito"> Un objeto del tipo crédito. </param>
 /// <returns> El valor de cada cuota. </returns>
 public double gmtCalcularValordeCuota(tblCredito tobjCredito)
 {
     return(new blCreditos().gmtCalcularValordeCuota(tobjCredito));
 }
Example #8
0
 /// <summary> Inserta un credito. </summary>
 /// <param name="tobjMunicipio"> Un objeto del tipo credito. </param>
 /// <returns> Un string que indica si se ejecuto o no la operación. </returns>
 public string gmtdInsertar(tblCredito tobjCredito)
 {
     return(new blCreditos().gmtdInsertar(tobjCredito));
 }
Example #9
0
 /// <summary> Elimina un de credito de la base de datos. </summary>
 /// <param name="tobjMunicipio"> Un objeto del tipo credito. </param>
 /// <returns> Un string que indica si se ejecuto o no el metodo. </returns>
 public String gmtdEliminar(tblCredito tobjCredito)
 {
     return(new blCreditos().gmtdEliminar(tobjCredito));
 }
Example #10
0
        /// <summary> Consulta el monto de un crédito. </summary>
        /// <param name="tintPrestamo"> Código del crédito a consultar. </param>
        /// <returns> El monto de un crédito. </returns>
        public decimal gmtdConsultarMonto(int tintPrestamo)
        {
            tblCredito credito = this.gmtdConsultar(tintPrestamo);

            return(credito.decMonto);
        }
Example #11
0
        /// <summary> Inserta un credito. </summary>
        /// <param name="tobjMunicipio"> Un objeto del tipo credito. </param>
        /// <returns> Un string que indica si se ejecuto o no la operación. </returns>
        public string gmtdInsertar(tblCredito tobjCredito)
        {
            if (tobjCredito.intCodigoCre == 0)
            {
                return("- Debe de ingresar el código del crédito.");
            }

            if (tobjCredito.strNombrePre == "" || tobjCredito.strNombrePre == null)
            {
                return("- Debe de ingresar el primer apellido.");
            }

            if (tobjCredito.strApellido1Pre == "" || tobjCredito.strApellido1Pre == null)
            {
                return("- Debe de ingresar el primer apellido.");
            }

            if (tobjCredito.intPagarePre == 0)
            {
                return("- Debe de ingresar el número del pagaré.");
            }

            if (tobjCredito.decIntereses == 0)
            {
                return("- Debe de ingresar el porcentaje de interes del crédito.");
            }

            if (tobjCredito.decMonto == 0)
            {
                return("- Debe de ingresar el monto del credito.");
            }

            if (tobjCredito.intCuotas == 0)
            {
                return("- Debe de ingresar el número de cuotas del crédito.");
            }

            tobjCredito.decDebe     = tobjCredito.decMonto;
            tobjCredito.decAbono    = 0;
            tobjCredito.dtmFechaPre = new daoUtilidadesConfiguracion().gmtdCapturarFechadelServidor();

            switch (tobjCredito.intTipoGarantia)
            {
            case 1:
                if (tobjCredito.strApellidoCde == "" || tobjCredito.strApellidoCde == null)
                {
                    return("- Debe de ingresar el apellido del codeudor");
                }

                if (tobjCredito.strNombreCde == "" || tobjCredito.strNombreCde == null)
                {
                    return("- Debe de ingresar el nombre del codeudor");
                }

                if (tobjCredito.strCedulaCde == "" || tobjCredito.strCedulaCde == null)
                {
                    return("- Debe de ingresar la cédula del codeudor");
                }
                break;

            case 2:
                if (tobjCredito.decAhorrado == 0)
                {
                    return("- Debe de ingresar valor del ahorro para respaldar el credito");
                }
                break;

            case 3:
                if (tobjCredito.strDescripcionGarantiadelCredito == null || tobjCredito.strDescripcionGarantiadelCredito == "")
                {
                    return("- Debe de ingresar la descripción de la garantia del credito");
                }
                break;
            }

            if (tobjCredito.strCedulaPre == "" || tobjCredito.strCedulaPre == null)
            {
                return("- Debe de ingresar la cédula del deudor.");
            }

            if (tobjCredito.strCodigoPar == "" || tobjCredito.strCodigoPar == null)
            {
                return("- Debe de seleccionar el par.");
            }

            if (tobjCredito.strCodLineadeCredito == "" || tobjCredito.strCodLineadeCredito == null)
            {
                return("- Debe de seleccionar la linea de crédito.");
            }

            if (tobjCredito.strDireccion == "" || tobjCredito.strDireccion == null)
            {
                return("- Debe de ingresar la dirección.");
            }

            if (tobjCredito.strFormadeCobroPre == "" || tobjCredito.strFormadeCobroPre == null)
            {
                return("- Debe de seleccionar la forma de cobro del crédito. ");
            }

            if (tobjCredito.strFrecuenciaPre == "" || tobjCredito.strFrecuenciaPre == null)
            {
                return("- Debe de seleccionar la frecuencia del rédito. ");
            }

            if (tobjCredito.strTelefono == "" || tobjCredito.strTelefono == null)
            {
                return("- Debe de escribir el teléfono del deudor. ");
            }

            tblCredito cre = new daoCreditos().gmtdConsultar(tobjCredito.intCodigoCre);

            if (cre.strNombrePre == null)
            {
                tobjCredito.bitAnulado  = false;
                tobjCredito.dtmFechaAnu = Convert.ToDateTime("1/1/1900");
                tobjCredito.log         = metodos.gmtdLog("Ingresa el crédito " + tobjCredito.intCodigoCre.ToString(), tobjCredito.strFormulario);

                double dblValorCuota = this.gmtCalcularValordeCuota(tobjCredito);

                List <tblCreditosCuota> lstCuotas = new List <tblCreditosCuota>();
                pGenerarFechasdeCuotasAutomaticamente(tobjCredito);
                try
                {
                    decimal decMonto = tobjCredito.decMonto;
                    for (int a = 1; a <= tobjCredito.intCuotas; a++)
                    {
                        double dblIntereses = Convert.ToDouble(tobjCredito.decIntereses) / 100;
                        dblIntereses = Convert.ToDouble(decMonto) * dblIntereses;
                        double           dblCapital = dblValorCuota - dblIntereses;
                        tblCreditosCuota cuota      = new tblCreditosCuota();
                        cuota.bitPagada       = false;
                        cuota.decCapital      = (decimal)dblCapital;
                        cuota.decIntereses    = (decimal)dblIntereses;
                        cuota.decSaldoCapital = decMonto;
                        cuota.decValorCuo     = (decimal)dblValorCuota;
                        cuota.dtmFechaCuo     = lstFechas[a - 1];
                        cuota.intCodigoCre    = tobjCredito.intCodigoCre;
                        cuota.intCuota        = a;
                        cuota.strDatosdePago  = "No Pagada";
                        cuota.dtmFechaPago    = Convert.ToDateTime("1/1/1900");
                        tobjCredito.tblCreditosCuotas.Add(cuota);
                        decMonto = decMonto - Convert.ToInt32(dblCapital);
                    }
                }
                catch (Exception ex)
                {
                    new dao.dao().gmtdInsertarError(ex);
                    return("- Hubo un error calculando las cuotas y el sistema no puede continuar.");
                }

                return(new daoCreditos().gmtdInsertar(tobjCredito));
            }
            else
            {
                return("- Este registro ya aparece ingresado.");
            }
        }
Example #12
0
        /// <summary> Calcula el valor de cada cuota de un credito. </summary>
        /// <param name="tobjCredito"> Un objeto del tipo crédito. </param>
        /// <returns> El valor de cada cuota. </returns>
        public double gmtCalcularValordeCuota(tblCredito tobjCredito)
        {
            double dblValor        = 0;
            int    intNumeroCuotas = tobjCredito.intCuotas;

            if (tobjCredito.decIntereses != 0)
            {
                decimal decMonto     = tobjCredito.decMonto;
                decimal decIntereses = Convert.ToDecimal(tobjCredito.decIntereses / 100);

                switch (tobjCredito.strFrecuenciaPre)
                {
                case "Termino":
                    //intNumeroCuotas = intNumeroCuotas;
                    break;

                case "Mensual":
                    //intNumeroCuotas = intNumeroCuotas;
                    break;

                case "Quincenal":
                    intNumeroCuotas = intNumeroCuotas * 2;
                    break;

                case "Decadal":
                    intNumeroCuotas = intNumeroCuotas * 3;
                    break;

                case "Semanal":
                    intNumeroCuotas = intNumeroCuotas * 4;
                    break;
                }
                //double dblElevar = this.fElevar((1 + dblIntereses), intCuotas);
                double dblElevar = Math.Pow(Convert.ToDouble(1 + decIntereses), intNumeroCuotas);

                dblValor = Convert.ToDouble(tobjCredito.decMonto) * Convert.ToDouble(decIntereses) * (dblElevar / (dblElevar - 1));
            }
            else
            {
                decimal decMontoCero = tobjCredito.decMonto;
                switch (tobjCredito.strFrecuenciaPre)
                {
                case "Termino":
                    //intNumeroCuotas = intNumeroCuotas;
                    break;

                case "Mensual":
                    //intNumeroCuotas = intNumeroCuotas;
                    break;

                case "Quincenal":
                    intNumeroCuotas = intNumeroCuotas * 2;
                    break;

                case "Decadal":
                    intNumeroCuotas = intNumeroCuotas * 3;
                    break;
                }

                dblValor = Convert.ToDouble(decMontoCero) / intNumeroCuotas;
            }
            return(dblValor);
        }