public List<puestosDef> OrganizarPuestos(string idPeriodo, string idGrupo)
        {
            bdsigameEntities bd = new bdsigameEntities();
            List<matricula2> k = bd.matricula2.Where(t =>
             t.id_grupo == idGrupo).ToList();

            List<notas> n = bd.notas.Where(t =>
               t.id_grupo == idGrupo &&
               t.id_periodo == idPeriodo
               ).OrderBy(t => t.id_estudiante).ToList();
            if (k.Count != 0)
            {
                List<puestos> PuestoL = new List<puestos>();
                foreach (matricula2 item in k)
                {
                    float nota_prom = 0;
                    int conta = 0;
                    puestos Puesto = new puestos();
                    foreach (notas item2 in n)
                    {

                        if (item.id_estudiante.ToString() == item2.id_estudiante.ToString())
                        {
                            // aca ajustamos la nota al formato de c#, ya que  para manejarlas necesitamo que los valores tengan , y no .
                            
                            string cn = item2.nota_s.ToString();
                            if (cn != "0") //Hubu superacion
                            {
                                item2.nota = item2.nota_s.ToString();
                            }
                            else { item2.nota = item2.nota.ToString(); }
                            
                            Puesto.nota_prom = (Convert.ToSingle(item2.nota.ToString())) + nota_prom;
                            nota_prom = Puesto.nota_prom;
                            Puesto.id_estudiante = item2.id_estudiante.ToString();
                            conta = conta + 1;
                        }
                    }
                    Puesto.nota_prom = Puesto.nota_prom / conta;

                    PuestoL.Add(Puesto);
                }
                PuestoL = PuestoL.OrderByDescending(t => t.nota_prom).ToList();
                int No = 1;
                List<puestosDef> PuestoDef = new List<puestosDef>();
                foreach (puestos item in PuestoL)
                {
                    puestosDef PuestoD = new puestosDef();
                    PuestoD.No = No;
                    PuestoD.nota_prom = item.nota_prom;
                    PuestoD.id_estudiante = item.id_estudiante;
                    PuestoDef.Add(PuestoD);
                    No = No + 1;
                }
                return PuestoDef;

            }
            return null;
        }
        public List<puestosDef> OrganizarPuestosBoletinFinal(string idGrupo)
        {
            string[] Ano = idGrupo.Split('-');
            string ano = Ano[0];

            bdsigameEntities bd = new bdsigameEntities();
            List<matricula2> k = bd.matricula2.Where(t =>
            t.id_grupo == idGrupo).OrderBy(t => t.id_estudiante).ToList();

            // OBTENEMOS LAS ASIGNATURAS QUE TIENE ESE GRUPO
            List<matricula1> kk = bd.matricula1.Where(t =>
           t.id_grupo == idGrupo).ToList();

            List<notas> n = bd.notas.Where(t => t.id_grupo == idGrupo
               ).OrderBy(t => t.id_estudiante).ToList();

            if (k.Count != 0)
            {
                List<puestosFin> pl = new List<puestosFin>();
                List<puestos> PuestoL = new List<puestos>();
                int c = 0;
                foreach (matricula2 item in k) // CHEQUEO LOS ESTUDIANTES QUE CONTIENE EL GRUPO
                {
                    int conta = 0;
                    float nota_prom = 0;
                    float nota_promV = 0;

                    foreach (matricula1 item2 in kk) // CHEQUEO LAS ASIGNATURAS QUE CONTIENE EL GRUPO
                    {
                        int I = 0;
                        int II = 0;
                        int III = 0;
                        int IV = 0;
                        string eitem = item.id_estudiante.ToString();
                        string aitem2 = item2.id_asignatura.ToString();
                        notas NI = bd.notas.Where(t => t.id_grupo == idGrupo && t.id_estudiante == eitem &&
                                                  t.id_periodo == (ano+"-"+"I") && t.id_asignatura == aitem2).FirstOrDefault();
                        notas NII = bd.notas.Where(t => t.id_grupo == idGrupo && t.id_estudiante == eitem &&
                                                 t.id_periodo == (ano+"-"+"II") && t.id_asignatura == aitem2).FirstOrDefault();
                        notas NIII = bd.notas.Where(t => t.id_grupo == idGrupo && t.id_estudiante == eitem &&
                                                 t.id_periodo == (ano+"-"+"III") && t.id_asignatura == aitem2).FirstOrDefault();
                        notas NIV = bd.notas.Where(t => t.id_grupo == idGrupo && t.id_estudiante == eitem &&
                                                 t.id_periodo == (ano+"-"+"IV") && t.id_asignatura == aitem2).FirstOrDefault();

                        if (NI == null) // registramos como 0  si no hay nada
                        { I = 0; }
                        else
                        {
                            I = AjustarNenEnEnteros(NI.nota_s.ToString());
                            if (I == 0)//Quiere decir que NO hay superacion y configuramos con la nota principal
                            { I = AjustarNenEnEnteros(NI.nota.ToString()); }
                            else //Quiere decir que SI hay superacion y configuramos con la nota superada
                            { I = AjustarNenEnEnteros(NI.nota_s.ToString()); }
                        }
                        if (NII == null) // registramos como 0  si no hay nada
                        { II = 0; }
                        else
                        {
                            II = AjustarNenEnEnteros(NII.nota_s.ToString());
                            if (II == 0)//Quiere decir que NO hay superacion y configuramos con la nota principal
                            { II = AjustarNenEnEnteros(NII.nota.ToString()); }
                            else //Quiere decir que SI hay superacion y configuramos con la nota superada
                            { II = AjustarNenEnEnteros(NII.nota_s.ToString()); }
                        }

                        if (NIII == null) // registramos como 0  si no hay nada
                        { III = 0; }
                        else
                        {
                            III = AjustarNenEnEnteros(NIII.nota_s.ToString());
                            if (III == 0)//Quiere decir que NO hay superacion y configuramos con la nota principal
                            { III = AjustarNenEnEnteros(NIII.nota.ToString()); }
                            else //Quiere decir que SI hay superacion y configuramos con la nota superada
                            { III = AjustarNenEnEnteros(NIII.nota_s.ToString()); }
                        }

                        if (NIV == null) // registramos como 0  si no hay nada
                        { IV = 0; }
                        else
                        {
                            IV = AjustarNenEnEnteros(NIV.nota_s.ToString());
                            if (IV == 0)//Quiere decir que NO hay superacion y configuramos con la nota principal
                            { IV = AjustarNenEnEnteros(NIV.nota.ToString()); }
                            else //Quiere decir que SI hay superacion y configuramos con la nota superada
                            { IV = AjustarNenEnEnteros(NIV.nota_s.ToString()); }
                        }
                        nota_promV = (I + II + III + IV) / 4; // Esta seria la nota promedio de la asignatura en el periodo V
                        nota_prom = nota_promV + nota_prom; // Esta seria la nota final del estudiante para sus asignaturas
                        conta++;
                    }


                    nota_prom = nota_prom / conta; // Este seria el promedio del estudiante general en el V
                    puestos u = new puestos();
                    u.id_estudiante = item.id_estudiante.ToString();
                    u.nota_prom = nota_prom;
                    PuestoL.Add(u);
                    c = c + 1;
                }

                // AHORA ORGANIZAMOS
                PuestoL = PuestoL.OrderByDescending(t => t.nota_prom).ToList();
                int No = 1;
                List<puestosDef> PuestoDef = new List<puestosDef>();
                foreach (puestos item5 in PuestoL)
                {

                    puestosDef PuestoD = new puestosDef();
                    PuestoD.No = No;
                    PuestoD.nota_prom = item5.nota_prom;
                    PuestoD.id_estudiante = item5.id_estudiante.ToString();
                    PuestoDef.Add(PuestoD);
                    No = No + 1;
                }
                return PuestoDef;
            }
            else { return null; }
        }
Example #3
0
        public List<puestosDef> OrganizarPuestosBoletinFinal(string idGrupo)
        {
            string[] Ano = idGrupo.Split('-');
            string ano = Ano[0];
            bdsigameEntities bd = new bdsigameEntities();
            List<matricula2> k = bd.matricula2.Where(t =>
            t.id_grupo == idGrupo).OrderBy(t => t.id_estudiante).ToList();
            List<matricula1> kk = bd.matricula1.Where(t =>
            t.id_grupo == idGrupo).ToList();
            List<notas> n = bd.notas.Where(t => t.id_grupo == idGrupo
               ).OrderBy(t => t.id_estudiante).ToList();
            if (k.Count != 0)
            {
                List<puestosFin> pl = new List<puestosFin>();
                List<puestos> PuestoL = new List<puestos>();
                int c = 0;
                foreach (matricula2 item in k) 
                {
                    int conta = 0;
                    float nota_prom = 0;
                    float nota_promV = 0;

                    foreach (matricula1 item2 in kk) 
                    {
                        int I = 0; int II = 0; int III = 0; int IV = 0;
                        string eitem = item.id_estudiante.ToString();
                        string aitem2 = item2.id_asignatura.ToString();
                        notas NI = bd.notas.Where(t => t.id_grupo == idGrupo && t.id_estudiante == eitem &&
                                                  t.id_periodo == (ano + "-" + "I") && t.id_asignatura == aitem2).FirstOrDefault();
                        notas NII = bd.notas.Where(t => t.id_grupo == idGrupo && t.id_estudiante == eitem &&
                                                 t.id_periodo == (ano + "-" + "II") && t.id_asignatura == aitem2).FirstOrDefault();
                        notas NIII = bd.notas.Where(t => t.id_grupo == idGrupo && t.id_estudiante == eitem &&
                                                 t.id_periodo == (ano + "-" + "III") && t.id_asignatura == aitem2).FirstOrDefault();
                        notas NIV = bd.notas.Where(t => t.id_grupo == idGrupo && t.id_estudiante == eitem &&
                                                 t.id_periodo == (ano + "-" + "IV") && t.id_asignatura == aitem2).FirstOrDefault();
                        if (NI == null) 
                        { I = 0; }
                        else
                        {
                            I = AjustarNenEnEnteros(NI.nota_s.ToString());
                            if (I == 0)
                            { I = AjustarNenEnEnteros(NI.nota.ToString()); }
                            else 
                            { I = AjustarNenEnEnteros(NI.nota_s.ToString()); }
                        }
                        if (NII == null) 
                        { II = 0; }
                        else
                        {
                            II = AjustarNenEnEnteros(NII.nota_s.ToString());
                            if (II == 0)
                            { II = AjustarNenEnEnteros(NII.nota.ToString()); }
                            else 
                            { II = AjustarNenEnEnteros(NII.nota_s.ToString()); }
                        }
                        if (NIII == null)
                        { III = 0; }
                        else
                        {
                            III = AjustarNenEnEnteros(NIII.nota_s.ToString());
                            if (III == 0)
                            { III = AjustarNenEnEnteros(NIII.nota.ToString()); }
                            else 
                            { III = AjustarNenEnEnteros(NIII.nota_s.ToString()); }
                        }

                        if (NIV == null)
                        { IV = 0; }
                        else
                        {
                            IV = AjustarNenEnEnteros(NIV.nota_s.ToString());
                            if (IV == 0)
                            { IV = AjustarNenEnEnteros(NIV.nota.ToString()); }
                            else 
                            { IV = AjustarNenEnEnteros(NIV.nota_s.ToString()); }
                        }
                        nota_promV = (I + II + III + IV) / 4; 
                        nota_prom = nota_promV + nota_prom; 
                        conta++;
                    }
                    nota_prom = nota_prom / conta; 
                    puestos u = new puestos();
                    u.id_estudiante = item.id_estudiante.ToString();
                    u.nota_prom = nota_prom;
                    PuestoL.Add(u);
                    c = c + 1;
                }
                PuestoL = PuestoL.OrderByDescending(t => t.nota_prom).ToList();
                int No = 1;
                List<puestosDef> PuestoDef = new List<puestosDef>();
                foreach (puestos item5 in PuestoL)
                {
                    puestosDef PuestoD = new puestosDef();
                    PuestoD.No = No;
                    PuestoD.nota_prom = item5.nota_prom;
                    PuestoD.id_estudiante = item5.id_estudiante.ToString();
                    PuestoDef.Add(PuestoD);
                    No = No + 1;
                }
                return PuestoDef;
            }
            else { return null; }
        }