Example #1
0
        private static void Calc(DataSet ds, Hashtable ngtbl, string cno)
        {
            DataTable tb = ds.Tables["Table"];

            for (int i = 0; i < tb.Rows.Count; i++)
            {
                MK_Stud_Total_REC st         = new MK_Stud_Total_REC();
                int            groupid       = 0;
                int            curr_groupid  = 0;
                List <DataRow> group_courses = new List <DataRow>();
                foreach (DataRow cRow in tb.Rows[i].GetChildRows("sr_mk"))
                {
                    if (groupid == 0)
                    {
                        curr_groupid = int.Parse(cRow["groupid"].ToString());
                        groupid      = curr_groupid;
                        group_courses.Add(cRow);
                    }
                    else
                    {
                        curr_groupid = int.Parse(cRow["groupid"].ToString());
                        if (groupid == 100)
                        {
                            CalcGroup(group_courses, ref st, ngtbl);
                            group_courses.Clear();
                            group_courses.Add(cRow);
                            groupid = curr_groupid;
                        }
                        else if (groupid != curr_groupid)
                        {
                            CalcGroup(group_courses, ref st, ngtbl);
                            group_courses.Clear();
                            group_courses.Add(cRow);
                            groupid = curr_groupid;
                        }
                        else if (groupid == curr_groupid)
                        {
                            group_courses.Add(cRow);
                        }
                    }
                }
                CalcGroup(group_courses, ref st, ngtbl);
                foreach (DataRow cRow in tb.Rows[i].GetChildRows("sr_cd"))
                {
                    cRow["mark1"]         = Math.Round(st.m1 / st.gcnt, 2, MidpointRounding.AwayFromZero);
                    cRow["mark2"]         = Math.Round(st.m2 / st.gcnt, 2, MidpointRounding.AwayFromZero);
                    cRow["mark3"]         = Math.Round(st.m3 / st.gcnt, 2, MidpointRounding.AwayFromZero);
                    cRow["mark"]          = Math.Round(st.m / st.gcnt, 2, MidpointRounding.AwayFromZero);
                    cRow["total_crs_ncp"] = st.total_crs_ncp;
                    cRow["allpass1"]      = st.gcnt - st.allpass1 == 0 ? 1 : 0;
                    cRow["allpass2"]      = st.gcnt - st.allpass2 == 0 ? 1 : 0;
                    cRow["allpass3"]      = st.gcnt - st.allpass3 == 0 ? 1 : 0;
                    int EvalHonor = 0;
                    cRow["SchoolEval1"] = MK_Utils.GetEval(
                        cno,
                        st.gcnt - st.allpass1 == 0 ? 1 : 0,
                        decimal.Parse(cRow["mark1"].ToString()),
                        cRow["conduct1"].ToString(),
                        int.Parse(cRow["wrg_later1"].ToString()),
                        int.Parse(cRow["wrg_absence1"].ToString()),
                        int.Parse(cRow["wrg_truancy_t1"].ToString()),
                        out EvalHonor);
                    cRow["SE_HONOR1"]   = EvalHonor;
                    cRow["SchoolEval2"] = MK_Utils.GetEval(
                        cno,
                        st.gcnt - st.allpass2 == 0 ? 1 : 0,
                        decimal.Parse(cRow["mark2"].ToString()),
                        cRow["conduct2"].ToString(),
                        int.Parse(cRow["wrg_later2"].ToString()),
                        int.Parse(cRow["wrg_absence2"].ToString()),
                        int.Parse(cRow["wrg_truancy_t2"].ToString()),
                        out EvalHonor);
                    cRow["SE_HONOR2"]   = EvalHonor;
                    cRow["SchoolEval3"] = MK_Utils.GetEval(
                        cno,
                        st.gcnt - st.allpass3 == 0 ? 1 : 0,
                        decimal.Parse(cRow["mark"].ToString()),
                        cRow["conduct3"].ToString(),
                        int.Parse(cRow["wrg_later3"].ToString()),
                        int.Parse(cRow["wrg_absence3"].ToString()),
                        int.Parse(cRow["wrg_truancy_t3"].ToString()),
                        out EvalHonor);
                    cRow["SE_HONOR3"] = EvalHonor;
                    if (st.voca_cult_gcnt > 0)
                    {
                        cRow["voca_cult_avg1"] = Math.Round(st.voca_cult_avg1 / st.voca_cult_gcnt, 2, MidpointRounding.AwayFromZero);
                        cRow["voca_cult_avg2"] = Math.Round(st.voca_cult_avg2 / st.voca_cult_gcnt, 2, MidpointRounding.AwayFromZero);
                        cRow["voca_cult_avg3"] = Math.Round(st.voca_cult_avg3 / st.voca_cult_gcnt, 2, MidpointRounding.AwayFromZero);
                        cRow["voca_cult_avg"]  = Math.Round(st.voca_cult_avg / st.voca_cult_gcnt, 2, MidpointRounding.AwayFromZero);
                        cRow["voca_cult_mue"]  = Math.Round(st.voca_cult_mue / st.voca_cult_gcnt, 2, MidpointRounding.AwayFromZero);
                    }
                    if (st.voca_prof_gcnt > 0)
                    {
                        cRow["voca_prof_avg1"] = Math.Round(st.voca_prof_avg1 / st.voca_prof_gcnt, 2, MidpointRounding.AwayFromZero);
                        cRow["voca_prof_avg2"] = Math.Round(st.voca_prof_avg2 / st.voca_prof_gcnt, 2, MidpointRounding.AwayFromZero);
                        cRow["voca_prof_avg3"] = Math.Round(st.voca_prof_avg3 / st.voca_prof_gcnt, 2, MidpointRounding.AwayFromZero);
                        cRow["voca_prof_avg"]  = Math.Round(st.voca_prof_avg / st.voca_prof_gcnt, 2, MidpointRounding.AwayFromZero);
                        cRow["voca_prof_mue"]  = Math.Round(st.voca_prof_mue / st.voca_prof_gcnt, 2, MidpointRounding.AwayFromZero);
                    }
                }
            }
        }