Beispiel #1
0
        private void btnSeleccionar_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgvNiveles.SelectedRows.Count == 1)
                {
                    Int32 ID;
                    ID  = Convert.ToInt32(dgvNiveles.CurrentRow.Cells[0].Value);
                    pID = ID;
                    pGS = GruposDB.ObtenerGrupos(ID);
                    // Obtener cantidad Inscritos

                    CantidadInscritos = GruposDB.ObtenerTotalInscritos(ID);


                    DateTime FechaI, FechaA;

                    FechaI = GruposDB.ObtenerFechaInicio(ID);
                    FI     = FechaI;

                    FechaA = DateTime.Today;
                    if (rbMensual.Checked == true)
                    {
                        FechaPP = FechaI.AddMonths(1);
                    }
                    else
                    {
                        FechaPP = FechaI.AddDays(7);
                    }

                    if (pGS != null)
                    {
                        txtNivel.Text        = pGS.Nivel;
                        txtNivel.Enabled     = false;
                        btnRegistrar.Enabled = true;
                    }
                }
                else
                {
                    MessageBox.Show("Seleccione un Nivel de la Lista", "Registro de Estudiantes", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message, "Registro de Estudiantes", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #2
0
        private decimal calcCap(string cred, int diasatras)
        {
            string   consulcre;
            DateTime hoy = DateTime.Now, FechaI, FechaV, FechaC;
            decimal  res = 0;

            FechaI    = hoy.AddDays(-diasatras);
            consulcre = "Select id_tipo_credito,Monto,interes,plazo,Date_format(fecha_conc,'%d-%M-%Y') as FechaC, Date_format(fecha_venci,'%d-%M-%Y') as FechaV,Saldo_cap from credito where cod_credito=" + cred;
            DataTable cre = new DataTable();

            cre = buscar(consulcre);
            string  tipo    = cre.Rows[0][0].ToString();
            decimal monto   = Convert.ToDecimal(cre.Rows[0][1]);
            decimal interes = Convert.ToDecimal(cre.Rows[0][2]);
            int     plazo   = Convert.ToInt32(cre.Rows[0][3]);

            FechaC = Convert.ToDateTime(cre.Rows[0][4]);
            FechaV = Convert.ToDateTime(cre.Rows[0][5]);
            decimal saldoC = Convert.ToDecimal(cre.Rows[0][6]);

            TimeSpan diferencia;

            int  dias;
            bool pasado = false;

            if (hoy >= FechaV)
            {
                pasado = true;
            }

            if (tipo == "1")
            {
                diferencia = hoy - FechaI;
                dias       = diferencia.Days;
                dias       = DiasSinFin(dias, FechaI);
                if (pasado)
                {
                    res = saldoC;
                }
                else
                {
                    res = monto / plazo * dias;
                }
            }
            else if (tipo == "2")
            {
                diferencia = hoy - FechaI;
                dias       = diferencia.Days;
                dias       = DiasSinFin(dias, FechaI);
                if (pasado)
                {
                    res = saldoC;
                }
                else
                {
                    res = 0;
                }
            }
            else if (tipo == "3")
            {
                int retraso = 0;
                // retraso++;
                diferencia = hoy - FechaI;
                FechaI     = FechaI.AddMonths(retraso);
                while (FechaI.AddMonths(retraso) < hoy)
                {
                    retraso++;
                }
                if (pasado)
                {
                    res = saldoC;
                }
                else
                {
                    res = monto / plazo * retraso;
                }
            }
            else if (tipo == "4")
            {
                int retraso = 0;
                retraso++;
                diferencia = hoy - FechaI;
                FechaI     = FechaI.AddMonths(retraso);
                while (FechaI.AddMonths(retraso) < hoy)
                {
                    retraso++;
                }
                if (pasado)
                {
                    res = saldoC;
                }
                else
                {
                    res = monto / plazo / 12 * retraso;
                }
            }

            return(res);
        }