Beispiel #1
0
        /// <summary>
        /// 透過學生類別取得 UDT 內設定不排名學生.ID
        /// </summary>
        /// <returns></returns>
        public static List <string> GetNonRankStudentIDFromUDTByStudentTag(List <StudentTagRecord> StudTagRecList, SchoolType ST)
        {
            List <string> TagNameList = new List <string>();
            List <string> retVal      = new List <string>();

            TagNameList = (from data in UDTTransfer.GetDataFromUDT_StudTypeWeight() where data.CheckNonRank == true && data.SchoolType == ST.ToString() select data.StudentType).ToList();

            foreach (StudentTagRecord StudTagRec in StudTagRecList)
            {
                if (TagNameList.Contains(StudTagRec.FullName))
                {
                    retVal.Add(StudTagRec.RefStudentID);
                }
            }
            return(retVal);
        }
Beispiel #2
0
        /// <summary>
        /// 透過學生類別取得 UDT 內設定特種身分 學生.ID,特種身分
        /// </summary>
        /// <param name="StudTagRecList"></param>
        /// <param name="ST"></param>
        /// <returns></returns>
        public static Dictionary <string, string> GetStudentSpcTypeFormUDTByStudentTag(List <StudentTagRecord> StudTagRecList, SchoolType ST)
        {
            Dictionary <string, UserDefData_StudTypeWeight> retVal = new Dictionary <string, UserDefData_StudTypeWeight>();
            Dictionary <string, UserDefData_StudTypeWeight> weight = new Dictionary <string, UserDefData_StudTypeWeight>();
            Dictionary <string, string> retVal1 = new Dictionary <string, string>();

            foreach (UserDefData_StudTypeWeight udd in UDTTransfer.GetDataFromUDT_StudTypeWeight().Where(x => x.SchoolType == ST.ToString()))
            {
                if (udd.AddWeight < 0)
                {
                    continue;
                }

                if (!weight.ContainsKey(udd.StudentType))
                {
                    weight.Add(udd.StudentType, udd);
                }
            }

            foreach (StudentTagRecord StudTagRec in StudTagRecList)
            {
                if (weight.ContainsKey(StudTagRec.FullName))
                {
                    if (retVal.ContainsKey(StudTagRec.RefStudentID))
                    {
                        // 當有2個以上,取其高
                        if (retVal[StudTagRec.RefStudentID].AddWeight < weight[StudTagRec.FullName].AddWeight)
                        {
                            retVal[StudTagRec.RefStudentID] = weight[StudTagRec.FullName];
                        }
                    }
                    else
                    {
                        retVal.Add(StudTagRec.RefStudentID, weight[StudTagRec.FullName]);
                    }
                }
            }

            foreach (KeyValuePair <string, UserDefData_StudTypeWeight> dd in retVal)
            {
                // 回傳特種身分
                retVal1.Add(dd.Key, dd.Value.JoinStudType);
            }

            return(retVal1);
        }
Beispiel #3
0
        /// <summary>
        /// 載入畫面資料
        /// </summary>
        private void LoadDataToDataGridView()
        {
            // 取得 UDT 內的設定值
            _udd = UDTTransfer.GetDataFromUDT_StudTypeWeight();

            //// 清除舊資料
            //foreach (UserDefData_StudTypeWeight ud in _udd)
            //    ud.Deleted = true;
            //UDTTransfer.DeleteDataToUDT_StudTypeWeight(_udd);
            try
            {
                int rowIdx = 0;
                // 高中
                foreach (UserDefData_StudTypeWeight ud in _udd.Where(x => x.SchoolType == "高中"))
                {
                    dgvSHWeight.Rows.Add();
                    dgvSHWeight.Rows[rowIdx].Cells[JoinStudType.Index].Value     = ud.JoinStudType.ToString();
                    dgvSHWeight.Rows[rowIdx].Cells[StudType.Index].Value         = ud.StudentType.ToString();
                    dgvSHWeight.Rows[rowIdx].Cells[AddWeight.Index].Value        = ud.AddWeight.ToString();
                    dgvSHWeight.Rows[rowIdx].Cells[checkNonRank.Index].Value     = ud.CheckNonRank;
                    dgvSHWeight.Rows[rowIdx].Cells[JoinStudTypeCode.Index].Value = ud.JoinStudTypeCode;
                    rowIdx++;
                }

                // 五專
                rowIdx = 0;
                foreach (UserDefData_StudTypeWeight ud in _udd.Where(x => x.SchoolType == "五專"))
                {
                    dgvSH5Weight.Rows.Add();
                    dgvSH5Weight.Rows[rowIdx].Cells[JoinStudType5.Index].Value     = ud.JoinStudType.ToString();
                    dgvSH5Weight.Rows[rowIdx].Cells[StudType5.Index].Value         = ud.StudentType.ToString();
                    dgvSH5Weight.Rows[rowIdx].Cells[AddWeight5.Index].Value        = ud.AddWeight.ToString();
                    dgvSH5Weight.Rows[rowIdx].Cells[checkNonRank5.Index].Value     = ud.CheckNonRank;
                    dgvSH5Weight.Rows[rowIdx].Cells[JoinStudTypeCode5.Index].Value = ud.JoinStudTypeCode;
                    rowIdx++;
                }
            }
            catch (Exception ex)
            { }
        }
Beispiel #4
0
        /// <summary>
        /// 透過學生類別取得 UDT 內設定加分比重 學生.ID,比重
        /// </summary>
        /// <param name="StudTagRecList"></param>
        /// <param name="ST"></param>
        /// <returns></returns>
        public static Dictionary <string, decimal> GetStudentAddWeightFormUDTByStudentTag(List <StudentTagRecord> StudTagRecList, SchoolType ST)
        {
            Dictionary <string, decimal> retVal = new Dictionary <string, decimal>();
            Dictionary <string, decimal> weight = new Dictionary <string, decimal>();

            foreach (UserDefData_StudTypeWeight udd in UDTTransfer.GetDataFromUDT_StudTypeWeight().Where(x => x.SchoolType == ST.ToString()))
            {
                if (udd.AddWeight < 0)
                {
                    continue;
                }

                if (!weight.ContainsKey(udd.StudentType))
                {
                    weight.Add(udd.StudentType, udd.AddWeight);
                }
            }

            foreach (StudentTagRecord StudTagRec in StudTagRecList)
            {
                if (weight.ContainsKey(StudTagRec.FullName))
                {
                    if (retVal.ContainsKey(StudTagRec.RefStudentID))
                    {
                        // 當有2個以上,取其高
                        if (retVal[StudTagRec.RefStudentID] < weight[StudTagRec.FullName])
                        {
                            retVal[StudTagRec.RefStudentID] = weight[StudTagRec.FullName];
                        }
                    }
                    else
                    {
                        retVal.Add(StudTagRec.RefStudentID, weight[StudTagRec.FullName]);
                    }
                }
            }
            return(retVal);
        }
Beispiel #5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            // 驗證資料
            foreach (DataGridViewRow dgvr in dgvSHWeight.Rows)
            {
                if (dgvr.Cells[AddWeight.Index].ErrorText != "")
                {
                    FISCA.Presentation.Controls.MsgBox.Show("資料有誤,無法儲存!");
                    return;
                }
            }

            foreach (DataGridViewRow dgvr in dgvSH5Weight.Rows)
            {
                if (dgvr.Cells[AddWeight5.Index].ErrorText != "")
                {
                    FISCA.Presentation.Controls.MsgBox.Show("資料有誤,無法儲存!");
                    return;
                }
            }

            // 清除舊資料
            foreach (UserDefData_StudTypeWeight ud in _udd)
            {
                ud.Deleted = true;
            }
            UDTTransfer.DeleteDataToUDT_StudTypeWeight(_udd);

            // 新增資料
            List <UserDefData_StudTypeWeight> InsertData = new List <KH_StudentScoreSummaryReport.UserDefData_StudTypeWeight>();

            foreach (DataGridViewRow dgvr in dgvSHWeight.Rows)
            {
                if (dgvr.IsNewRow)
                {
                    continue;
                }
                UserDefData_StudTypeWeight ud = new KH_StudentScoreSummaryReport.UserDefData_StudTypeWeight();
                ud.SchoolType = "高中";
                if (dgvr.Cells[JoinStudType.Index].Value != null)
                {
                    ud.JoinStudType = dgvr.Cells[JoinStudType.Index].Value.ToString();
                }
                if (dgvr.Cells[StudType.Index].Value != null)
                {
                    ud.StudentType = dgvr.Cells[StudType.Index].Value.ToString();
                }
                decimal dd; bool bl;
                if (dgvr.Cells[AddWeight.Index].Value != null)
                {
                    if (decimal.TryParse(dgvr.Cells[AddWeight.Index].Value.ToString(), out dd))
                    {
                        ud.AddWeight = dd;
                    }
                }
                if (dgvr.Cells[checkNonRank.Index].Value != null)
                {
                    if (bool.TryParse(dgvr.Cells[checkNonRank.Index].Value.ToString(), out bl))
                    {
                        ud.CheckNonRank = bl;
                    }
                }

                if (dgvr.Cells[JoinStudTypeCode.Index].Value != null)
                {
                    ud.JoinStudTypeCode = dgvr.Cells[JoinStudTypeCode.Index].Value.ToString();
                }

                InsertData.Add(ud);
            }

            foreach (DataGridViewRow dgvr in dgvSH5Weight.Rows)
            {
                if (dgvr.IsNewRow)
                {
                    continue;
                }
                UserDefData_StudTypeWeight ud = new KH_StudentScoreSummaryReport.UserDefData_StudTypeWeight();
                ud.SchoolType = "五專";
                if (dgvr.Cells[JoinStudType5.Index].Value != null)
                {
                    ud.JoinStudType = dgvr.Cells[JoinStudType5.Index].Value.ToString();
                }

                if (dgvr.Cells[StudType5.Index].Value != null)
                {
                    ud.StudentType = dgvr.Cells[StudType5.Index].Value.ToString();
                }

                decimal dd; bool bl;
                if (dgvr.Cells[AddWeight5.Index].Value != null)
                {
                    if (decimal.TryParse(dgvr.Cells[AddWeight5.Index].Value.ToString(), out dd))
                    {
                        ud.AddWeight = dd;
                    }
                }
                if (dgvr.Cells[checkNonRank5.Index].Value != null)
                {
                    if (bool.TryParse(dgvr.Cells[checkNonRank5.Index].Value.ToString(), out bl))
                    {
                        ud.CheckNonRank = bl;
                    }
                }

                if (dgvr.Cells[JoinStudTypeCode5.Index].Value != null)
                {
                    ud.JoinStudTypeCode = dgvr.Cells[JoinStudTypeCode5.Index].Value.ToString();
                }

                InsertData.Add(ud);
            }

            if (InsertData.Count > 0)
            {
                UDTTransfer.InsertDataToUDT_StudTypeWeight(InsertData);
                FISCA.Presentation.Controls.MsgBox.Show("儲存完成");
                this.Close();
            }
        }