Ejemplo n.º 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);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void CalcGroup(List <DataRow> dr, ref MK_Stud_Total_REC st, Hashtable ngtbl)
        {
            decimal gm1     = 0M;
            decimal gm2     = 0M;
            decimal gm3     = 0M;
            decimal gm      = 0M;
            decimal gm_mue  = 0M;
            DataRow lastrow = null;

            foreach (DataRow r in dr)
            {
                lastrow       = r;
                r["total1"]   = 0;
                r["total2"]   = 0;
                r["total3"]   = 0;
                r["total"]    = 0;
                r["VOCA_MUE"] = 0;
                r["sub_c_p"]  = 0;
                r["eog"]      = 0;
                decimal tmpm1 = (decimal.Parse(r["t1"].ToString()) + decimal.Parse(r["e1"].ToString())) / 2;
                decimal tmpm2 = (decimal.Parse(r["t2"].ToString()) + decimal.Parse(r["e2"].ToString())) / 2;
                decimal tmpm3 = (decimal.Parse(r["t3"].ToString()) + decimal.Parse(r["e3"].ToString())) / 2;
                decimal tmpm  = tmpm1 * 0.3M + tmpm2 * 0.3M + tmpm3 * 0.4M;
                if (tmpm < 60 && decimal.Parse(r["pk"].ToString()) >= 60)
                {
                    r["P_X"] = 2;
                }
                else if (tmpm < 60)
                {
                    r["P_X"] = 1;
                }
                else
                {
                    r["P_X"] = 0;
                }
                gm1 += tmpm1 * int.Parse(r["rate"].ToString()) / 100;
                gm2 += tmpm2 * int.Parse(r["rate"].ToString()) / 100;
                gm3 += tmpm3 * int.Parse(r["rate"].ToString()) / 100;
                gm  += tmpm * int.Parse(r["rate"].ToString()) / 100;
                if (tmpm < 60 && tmpm < decimal.Parse(r["pk"].ToString()))
                {
                    gm_mue += decimal.Parse(r["pk"].ToString());
                }
                else
                {
                    gm_mue += tmpm * int.Parse(r["rate"].ToString()) / 100;
                }
            }
            gm1                 = Math.Round(gm1, 2, MidpointRounding.AwayFromZero);
            gm2                 = Math.Round(gm2, 2, MidpointRounding.AwayFromZero);
            gm3                 = Math.Round(gm3, 2, MidpointRounding.AwayFromZero);
            gm                  = Math.Round(gm, 2);     //, MidpointRounding.AwayFromZero);
            gm_mue              = Math.Round(gm_mue, 2); //, MidpointRounding.AwayFromZero);
            lastrow["total1"]   = gm1;
            lastrow["total2"]   = gm2;
            lastrow["total3"]   = gm3;
            lastrow["total"]    = gm;
            lastrow["VOCA_MUE"] = gm_mue;
            lastrow["eog"]      = 1;
            if (gm >= 60)
            {
                foreach (DataRow r in dr)
                {
                    r["P_X"] = 0;
                }
            }
            else if (gm < 60)
            {
                foreach (DataRow r in dr)
                {
                    if (int.Parse(r["P_X"].ToString()) == 1)
                    {
                        lastrow["sub_c_p"] = ngtbl[lastrow["c_ng_id"].ToString()];
                    }
                }
            }
            st.m1   += gm1;
            st.m2   += gm2;
            st.m3   += gm3;
            st.m    += gm;
            st.gcnt += 1;
            if (gm1 >= 60)
            {
                st.allpass1++;
            }
            if (gm2 >= 60)
            {
                st.allpass2++;
            }
            if (gm >= 60)
            {
                st.allpass3++;
            }
            if (gm < 60)
            {
                st.total_crs_ncp += decimal.Parse(lastrow["sub_c_p"].ToString());
            }
            if (lastrow["c_t_type"].ToString().Equals("職業文化"))
            {
                st.voca_cult_avg1 += gm1;
                st.voca_cult_avg2 += gm2;
                st.voca_cult_avg3 += gm3;
                st.voca_cult_avg  += gm;
                st.voca_cult_mue  += gm_mue;
                st.voca_cult_gcnt += 1;
            }
            if (lastrow["c_t_type"].ToString().Equals("職業專業"))
            {
                st.voca_prof_avg1 += gm1;
                st.voca_prof_avg2 += gm2;
                st.voca_prof_avg3 += gm3;
                st.voca_prof_avg  += gm;
                st.voca_prof_mue  += gm_mue;
                st.voca_prof_gcnt += 1;
            }
        }