Ejemplo n.º 1
0
        /// <summary>
        /// 儲存異動名冊
        /// </summary>
        /// <param name="StudUpdateRecBRec"></param>
        public static void SetStudUpdateRecBatchRec(BL.StudUpdateRecBatchRec StudUpdateRecBRec, bool isInsert)
        {
            SHUpdateRecordBatchRecord shurbr = new SHUpdateRecordBatchRecord();

            shurbr.ADDate            = StudUpdateRecBRec.ADDate;
            shurbr.ADNumber          = StudUpdateRecBRec.ADNumber;
            Global._GSchoolCode      = K12.Data.School.Code;
            Global._GSchoolName      = K12.Data.School.ChineseName;
            Global._GUpdateBatchType = StudUpdateRecBRec.UpdateType;
            Global._GSchoolYear      = StudUpdateRecBRec.SchoolYear.ToString();
            Global._GSemester        = StudUpdateRecBRec.Semester.ToString();
            Global._GDocName         = StudUpdateRecBRec.Name;
            // 將 XElement 轉型 XmlElement
            shurbr.Content    = new XmlDocument().ReadNode(ConvertStudUpdateRecDocToXML(StudUpdateRecBRec.StudUpdateRecDocList).CreateReader()) as XmlElement;
            shurbr.ID         = StudUpdateRecBRec.ID;
            shurbr.Name       = StudUpdateRecBRec.Name;
            shurbr.SchoolYear = StudUpdateRecBRec.SchoolYear;
            shurbr.Semester   = StudUpdateRecBRec.Semester;
            if (isInsert)
            {
                SHUpdateRecordBatch.Insert(shurbr);
            }
            else
            {
                SHUpdateRecordBatch.Update(shurbr);
            }
        }
 /// <summary>
 /// 登入文號
 /// </summary>
 public UpdateRecordADN(string id)
 {
     InitializeComponent();
     // 取得名冊
     GovDoc = DAL.DALTransfer.GetStudUpdateRecBatchRec(id);
 }
        public void LoadData()
        {
            if (itemPanelName.SelectedItems.Count > 0)
            {
                btnDelete.Enabled = true;
                btnAD.Enabled     = true;
                SetSelectUpdateBatchID();
                //ButtonItem item = sender as ButtonItem;
                string id = BL.Get.UpdateBatchSelectID();

                // 取得所選名冊
                BL.StudUpdateRecBatchRec rec = DAL.DALTransfer.GetStudUpdateRecBatchRec(id);

                // 取得名冊內科別數
                List <string> DeptNameList = (from dept in rec.StudUpdateRecDocList orderby dept.Department ascending select dept.Department).Distinct().ToList();

                // 人數統計儲存
                Dictionary <string, int> TotalCountDict  = new Dictionary <string, int>();
                Dictionary <string, int> BoyCountDict    = new Dictionary <string, int>();
                Dictionary <string, int> GirlCountDict   = new Dictionary <string, int>();
                Dictionary <string, int> UnKnowCountDict = new Dictionary <string, int>();

                // 計算人數
                foreach (string str in DeptNameList)
                {
                    int total = 0, boy = 0, girl = 0, UnKnow = 0;

                    foreach (BL.StudUpdateRecDoc val in rec.StudUpdateRecDocList.Where(x => x.Department == str))
                    {
                        if (val.Gender == "男")
                        {
                            boy++;
                        }
                        else if (val.Gender == "女")
                        {
                            girl++;
                        }
                        else
                        {
                            UnKnow++;
                        }

                        total++;
                    }
                    if (string.IsNullOrEmpty(str))
                    {
                        TotalCountDict.Add("未分科別", total);
                        GirlCountDict.Add("未分科別", girl);
                        BoyCountDict.Add("未分科別", boy);
                        UnKnowCountDict.Add("未分科別", UnKnow);
                    }
                    else
                    {
                        TotalCountDict.Add(str, total);
                        GirlCountDict.Add(str, girl);
                        BoyCountDict.Add(str, boy);
                        UnKnowCountDict.Add(str, UnKnow);
                    }
                }

                if (DeptNameList.Count > 0)
                {
                    listView.SuspendLayout();

                    lblADCounter.Text = "【" + rec.Name + "】 各科人數統計";

                    //lblADInfo.Text = "【" + rec.ADNumber + "】 核准文號";
                    lblADInfo.Text      = "【" + rec.Name + "】 核准文號";
                    btnEReport1.Visible = true;
                    btnEReport2.Visible = true;

                    //處理看板資訊
                    StringBuilder builder = new StringBuilder("");
                    foreach (string deptN in DeptNameList)
                    {
                        string deptName = "";
                        if (string.IsNullOrEmpty(deptN))
                        {
                            deptName = "未分科別";
                        }
                        else
                        {
                            deptName = deptN;
                        }

                        if (GirlCountDict.ContainsKey(deptName) && TotalCountDict.ContainsKey(deptName) && BoyCountDict.ContainsKey(deptName))
                        {
                            builder = builder.Append("◎").Append(deptName).Append(" ")
                                      .Append("男生 <font color='blue'>").Append(BoyCountDict[deptName]).Append("</font> 人 ")
                                      .Append("女生 <font color='blue'>").Append(GirlCountDict[deptName]).Append("</font> 人 ")
                                      .Append("(合計 <font color='blue'>").Append(TotalCountDict[deptName]).Append("</font> 人)");
                        }

                        if (UnKnowCountDict.ContainsKey(deptName))
                        {
                            if (UnKnowCountDict[deptName] > 0)
                            {
                                builder = builder.Append("<font color='red'>").Append(UnKnowCountDict[deptName])
                                          .Append("</font>人未填性別");
                            }
                        }
                        builder = builder.Append("<br/>");
                    }
                    lblListContent.Text = builder.ToString();
                    lblADName1.Text     = rec.Name;
                    lblADName2.Text     = rec.Name;
                    lblADName3.Text     = rec.Name;

                    // 處理核准日期與文號
                    string adString = "";
                    if (!string.IsNullOrEmpty(rec.ADNumber))
                    {
                        adString += "核准文號 <font color='red'>" + rec.ADNumber + "</font> ";
                        if (rec.ADDate.HasValue)
                        {
                            adString += "核准日期 <font color='red'>" + rec.ADDate.Value.ToShortDateString() + "</font>";
                        }
                    }
                    else
                    {
                        adString = "<font color='red'>未登錄</font>";
                    }
                    lblAD.Text = adString;

                    //處理ListView呈現資料
                    listView.Clear();

                    // 欄位名稱
                    Dictionary <string, int> _ColumnWidthDict = new Dictionary <string, int>();
                    _ColumnWidthDict.Add("學號", 100);
                    _ColumnWidthDict.Add("姓名", 100);
                    _ColumnWidthDict.Add("年級", 100);
                    _ColumnWidthDict.Add("科別", 100);
                    _ColumnWidthDict.Add("異動原因及事項", 100);
                    _ColumnWidthDict.Add("異動日期", 100);

                    foreach (string strDeptName in DeptNameList)
                    {
                        // 若無群組則先加上群組
                        // 因為沒有科別先註掉
                        if (listView.Groups[strDeptName] == null)
                        {
                            listView.Groups.Add(strDeptName, strDeptName);
                        }

                        // 若沒有欄名則先加上欄名
                        if (listView.Columns.Count == 0)
                        {
                            foreach (string column in _ColumnWidthDict.Keys)
                            {
                                listView.Columns.Add(column, _ColumnWidthDict[column]);
                            }
                        }

                        ListViewItem rowItem = null;
                        foreach (BL.StudUpdateRecDoc val in rec.StudUpdateRecDocList.Where(x => x.Department == strDeptName))
                        {
                            //string strNum = val.StudentNumber;
                            //// 當異動代碼211讀取目前學生學號
                            //if (val.UpdateCode == "211")
                            //{
                            //    List<string> ids= new List<string> ();
                            //    ids.Add(val.StudentID);
                            //    SHStudent.RemoveByIDs(ids);
                            //    SHStudentRecord stud = SHStudent.SelectByID(val.StudentID);
                            //    strNum = stud.StudentNumber;
                            //}

                            //rowItem = new ListViewItem(strNum);
                            rowItem = new ListViewItem(val.StudentNumber);
                            rowItem.SubItems.Add(val.StudentName);
                            rowItem.SubItems.Add(val.GradeYear);
                            rowItem.SubItems.Add(val.Department);
                            rowItem.SubItems.Add(val.UpdateDescription);
                            rowItem.SubItems.Add(val.UpdateDate);
                            rowItem.Group = listView.Groups[strDeptName];
                            listView.Items.Add(rowItem);
                        }
                    }
                }
                listView.ResumeLayout();
            }
            else
            {
                btnDelete.Enabled = false;
                btnAD.Enabled     = false;
            }

            this.itemPanel1.RecalcLayout();
        }
 /// <summary>
 /// 登入文號
 /// </summary>
 public UpdateRecordADN(string id)
 {
     InitializeComponent();
     // 取得名冊
     GovDoc = DAL.DALTransfer.GetStudUpdateRecBatchRec(id);
 }