Example #1
0
        public static String GetEval(String cno, int allpass, decimal mark, string conduct, int later, int absence, int truancy, out int EvalAddHonorInt)
        {
            cno = cno.ToUpper();
            string[] HonorEvalDESC_ARR    = { "品學兼優生\n", "品行優異生\n", "學業優異生\n", "勤學生\n" };
            int[]    HonorEvalAdjMark_ARR = { 3, 2, 2, 1 };
            int[]    SMg = { 75, 70 };
            int[]    PMg = { 85, 75 };
            int      mg1 = 85;
            int      mg2 = 75;

            if (cno[0] == 'P')
            {
                mg1 = PMg[0]; mg2 = PMg[1];
                HonorEvalAdjMark_ARR[0] = 0;
                HonorEvalAdjMark_ARR[1] = 0;
                HonorEvalAdjMark_ARR[2] = 0;
                HonorEvalAdjMark_ARR[3] = 0;
            }
            else if (cno[0] == 'S')
            {
                mg1 = SMg[0]; mg2 = SMg[1];
            }
            String res = "";

            EvalAddHonorInt = 0;
            int noOfcond = MK_Utils.NoOfConduct(conduct);

            if (allpass == 1)
            {
                if (mark >= mg1 && noOfcond >= 6)
                {
                    res            += HonorEvalDESC_ARR[0];
                    EvalAddHonorInt = HonorEvalAdjMark_ARR[0];
                }
                else if (noOfcond >= 6)
                {
                    res            += HonorEvalDESC_ARR[1];
                    EvalAddHonorInt = HonorEvalAdjMark_ARR[1];
                }
                else if (mark >= mg1 && noOfcond >= 4)
                {
                    res            += HonorEvalDESC_ARR[2];
                    EvalAddHonorInt = HonorEvalAdjMark_ARR[2];
                }
                else if (mark >= mg2 && noOfcond >= 4)
                {
                    res            += HonorEvalDESC_ARR[3];
                    EvalAddHonorInt = HonorEvalAdjMark_ARR[3];
                }
            }
            if (later == 0 && absence == 0 && truancy == 0)
            {
                res += "全勤生";
            }
            return(res);
        }
Example #2
0
        public static void outputJSON(DataSet ds, string pclassno, string term, string mg, string sess, string session, string pdate, string filter, TextWriter sw, bool namemask = false)
        {
            string          pattern = @"\d+";
            Regex           rx      = new Regex(pattern);
            MatchCollection matches = rx.Matches(filter);

            sw.WriteLine("[");
            DataTable tb     = ds.Tables["Table"];
            int       rowcnt = 0;

            for (int i = 0; i < tb.Rows.Count; i++)
            {
                //選擇輸出:1,2,3,4
                string seat = tb.Rows[i]["curr_seat"].ToString();
                if (matches.Count > 0)
                {
                    int crt = 0;
                    for (crt = 0; crt < matches.Count; crt++)
                    {
                        if (matches[crt].Value.Equals(seat))
                        {
                            break;
                        }
                    }
                    if (crt >= matches.Count)
                    {
                        continue;
                    }
                }

                if (rowcnt > 0)
                {
                    sw.WriteLine(",");
                }
                rowcnt++;
                sw.WriteLine("{");
                for (int j = 0; j < tb.Columns.Count; j++)
                {
                    if (j > 0)
                    {
                        sw.WriteLine(",");
                    }
                    if (namemask && (tb.Columns[j].ColumnName.Equals("stud_ref") || tb.Columns[j].ColumnName.Equals("dsej_ref") || tb.Columns[j].ColumnName.Equals("c_name") || tb.Columns[j].ColumnName.Equals("e_name") || tb.Columns[j].ColumnName.Equals("curr_class")))
                    {
                        sw.Write("{0}:\"{1}\"", tb.Columns[j].ColumnName, "---");
                    }
                    else
                    {
                        sw.Write("{0}:\"{1}\"", tb.Columns[j].ColumnName, tb.Rows[i][j]);
                    }
                }
                foreach (DataRow cRow in tb.Rows[i].GetChildRows("sr_py"))
                {
                    for (int j = 0; j < cRow.Table.Columns.Count; j++)
                    {
                        if (!cRow.Table.Columns[j].ColumnName.Equals("stud_ref"))
                        {
                            sw.Write(",{0}:\"{1}\"", cRow.Table.Columns[j].ColumnName, MK_Utils.str2html(cRow[j].ToString()));
                        }
                    }
                }
                foreach (DataRow cRow in tb.Rows[i].GetChildRows("sr_cd"))
                {
                    for (int j = 0; j < cRow.Table.Columns.Count; j++)
                    {
                        if (!cRow.Table.Columns[j].ColumnName.Equals("stud_ref"))
                        {
                            if (cRow.Table.Columns[j].DataType.Name.Equals("Decimal") ||
                                cRow.Table.Columns[j].DataType.Name.Equals("Int32") ||
                                cRow.Table.Columns[j].DataType.Name.Equals("Int16") ||
                                cRow.Table.Columns[j].DataType.Name.Equals("SByte")
                                )
                            {
                                sw.Write(",{0}:{1}", cRow.Table.Columns[j].ColumnName, cRow[j]);
                            }
                            else
                            {
                                sw.Write(",{0}:\"{1}\"", cRow.Table.Columns[j].ColumnName, MK_Utils.str2html(cRow[j].ToString()));
                            }
                        }
                    }
                }
                sw.WriteLine(",\"marks\":[");
                int rid = 0;
                foreach (DataRow cRow in tb.Rows[i].GetChildRows("sr_mk"))
                {
                    if (rid > 0)
                    {
                        sw.WriteLine(",");
                    }
                    sw.WriteLine("{");
                    for (int j = 0; j < cRow.Table.Columns.Count; j++)
                    {
                        if (j > 0)
                        {
                            sw.WriteLine(",");
                        }
                        if (cRow.Table.Columns[j].DataType.Name.Equals("Decimal"))
                        {
                            sw.Write("{0}:{1}", cRow.Table.Columns[j].ColumnName, cRow[j]);
                        }
                        else
                        {
                            sw.Write("{0}:\"{1}\"", cRow.Table.Columns[j].ColumnName, cRow[j]);
                        }
                    }
                    sw.WriteLine("}");
                    rid++;
                }
                sw.WriteLine("]");
                sw.WriteLine(",\"acmarks\":[");
                rid = 0;
                foreach (DataRow cRow in tb.Rows[i].GetChildRows("sr_ac"))
                {
                    if (rid > 0)
                    {
                        sw.WriteLine(",");
                    }
                    sw.WriteLine("{");
                    for (int j = 0; j < cRow.Table.Columns.Count; j++)
                    {
                        if (j > 0)
                        {
                            sw.WriteLine(",");
                        }
                        sw.Write("{0}:\"{1}\"", cRow.Table.Columns[j].ColumnName, MK_Utils.str2html(cRow[j].ToString()));
                    }
                    sw.WriteLine("}");
                    rid++;
                }
                sw.WriteLine("]");
                sw.WriteLine(",\"gcmarks\":[");
                rid = 0;
                foreach (DataRow cRow in tb.Rows[i].GetChildRows("sr_gc"))
                {
                    if (rid > 0)
                    {
                        sw.WriteLine(",");
                    }
                    sw.WriteLine("{");
                    for (int j = 0; j < cRow.Table.Columns.Count; j++)
                    {
                        if (j > 0)
                        {
                            sw.WriteLine(",");
                        }
                        sw.Write("{0}:\"{1}\"", cRow.Table.Columns[j].ColumnName, MK_Utils.str2html(cRow[j].ToString()));
                    }
                    sw.WriteLine("}");
                    rid++;
                }
                sw.WriteLine("]");

                sw.WriteLine("}");
            }
            sw.WriteLine("]");
        }
Example #3
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);
                    }
                }
            }
        }