Beispiel #1
0
        protected override void DoDelete(JHTagConfigRecord record)
        {
            int use_count = 0;

            foreach (JHClassTagRecord rec in JHClassTag.SelectAll())
            {
                if (rec.RefTagID == record.ID)
                {
                    use_count++;
                }
            }


            string msg;

            if (use_count > 0)
            {
                msg = string.Format("目前有「{0}」個班級使用此類別,您確定要刪除此類別嗎?", use_count);
            }
            else
            {
                msg = "您確定要刪除此類別嗎?";
            }

            if (FISCA.Presentation.Controls.MsgBox.Show(msg, MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                PermRecLogProcess prlp = new PermRecLogProcess();
                prlp.SaveLog("學籍.類別管理", "類別管理刪除類別", "刪除 " + record.Category + " 類別,名稱:" + record.FullName);
                JHTagConfig.Delete(record);
            }
        }
        public static void Main()
        {
            _bgLLoadUDT.DoWork             += _bgLLoadUDT_DoWork;
            _bgLLoadUDT.RunWorkerCompleted += _bgLLoadUDT_RunWorkerCompleted;
            _bgLLoadUDT.RunWorkerAsync();

            Dictionary <string, UDT_ClassLock> _UDT_ClassLockDict = UDTTransfer.GetClassLockNameIDDict();
            Dictionary <string, KH_HighConcernCalc.ClassStudent> _ClassStudentDict = KH_HighConcernCalc.Calc.GetClassStudentAllIDDict();

            Catalog catalog01 = RoleAclSource.Instance["班級"]["功能按鈕"];

            catalog01.Add(new RibbonFeature("KH_HighConcern_ClassLock", "班級鎖定/解鎖"));
            catalog01.Add(new RibbonFeature("KH_HighConcern_AllClassUnLock", "全部班級解鎖"));
            catalog01.Add(new RibbonFeature("KH_HighConcern_SendClassDataView", "檢視傳送局端備查紀錄"));

            ListPaneField ClassLockStudentCountField = new ListPaneField("編班人數");

            ClassLockStudentCountField.GetVariable += delegate(object sender, GetVariableEventArgs e)
            {
                if (_ClassStudentDict.ContainsKey(e.Key))
                {
                    if (_ClassStudentDict.ContainsKey(e.Key))
                    {
                        e.Value = _ClassStudentDict[e.Key].ClassStudentCountStr;
                    }
                }
            };
            K12.Presentation.NLDPanels.Class.AddListPaneField(ClassLockStudentCountField);


            ListPaneField ClassLockField = new ListPaneField("班級鎖定");

            ClassLockField.GetVariable += delegate(object sender, GetVariableEventArgs e)
            {
                if (_UDT_ClassLockDict.ContainsKey(e.Key))
                {
                    // 當有鎖定再顯示
                    if (_UDT_ClassLockDict[e.Key].isLock)
                    {
                        if (_UDT_ClassLockDict[e.Key].UnAutoUnlock)
                        {
                            e.Value = "鎖定(不自動解鎖)";
                        }
                        else
                        {
                            e.Value = "鎖定";
                        }
                    }
                }
            };
            K12.Presentation.NLDPanels.Class.AddListPaneField(ClassLockField);

            ListPaneField ClassLockCommentField = new ListPaneField("鎖定備註");

            ClassLockCommentField.GetVariable += delegate(object sender, GetVariableEventArgs e)
            {
                // 只要有資料就顯示
                if (_UDT_ClassLockDict.ContainsKey(e.Key))
                {
                    e.Value = _UDT_ClassLockDict[e.Key].Comment;
                }
            };
            K12.Presentation.NLDPanels.Class.AddListPaneField(ClassLockCommentField);


            ListPaneField ClassLockSStudentCountField = new ListPaneField("特殊生人數");

            ClassLockSStudentCountField.GetVariable += delegate(object sender, GetVariableEventArgs e)
            {
                if (_ClassStudentDict.ContainsKey(e.Key))
                {
                    if (_ClassStudentDict.ContainsKey(e.Key))
                    {
                        e.Value = _ClassStudentDict[e.Key].ClassHStudentCount;
                    }
                }
            };
            K12.Presentation.NLDPanels.Class.AddListPaneField(ClassLockSStudentCountField);


            K12.Presentation.NLDPanels.Class.SelectedSourceChanged += delegate {
                // 檢查當有權限並只選一個班才可以使用
                K12.Presentation.NLDPanels.Class.ListPaneContexMenu["班級鎖定/解鎖"].Enable = UserAcl.Current["KH_HighConcern_ClassLock"].Executable && (K12.Presentation.NLDPanels.Class.SelectedSource.Count == 1);
            };

            //RibbonBarItem rbSendClassDataView = K12.Presentation.NLDPanels.Class.RibbonBarItems["其它"];
            //rbSendClassDataView["檢視傳送局端備查紀錄"].Enable = UserAcl.Current["KH_HighConcern_SendClassDataView"].Executable;
            //rbSendClassDataView["檢視傳送局端備查紀錄"].Click += delegate
            //{
            //    SendDataView sdv = new SendDataView();
            //    sdv.ShowDialog();
            //};

            RibbonBarItem rbiDelAll = K12.Presentation.NLDPanels.Class.RibbonBarItems["其它"];

            rbiDelAll["全部班級解鎖"].Enable = UserAcl.Current["KH_HighConcern_AllClassUnLock"].Executable;
            rbiDelAll["全部班級解鎖"].Click += delegate
            {
                MsgForm mf2 = new MsgForm();
                mf2.Text = "全部班級解鎖";
                mf2.SetMsg("將全部班級解鎖,按下「是」確認後,局端會留解鎖紀錄。");
                //if (FISCA.Presentation.Controls.MsgBox.Show("將全部班級解鎖,按下「是」確認後,局端會留解鎖紀錄。", "全部班級解鎖", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                if (mf2.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                {
                    // 全部解鎖
                    UDTTransfer.UnlockAllClass();

                    // 紀錄班級名稱條件:不自動解鎖false,鎖定 true
                    List <string> ClassNameList = (from data in _UDT_ClassLockDict.Values where data.UnAutoUnlock == false && data.isLock == true select data.ClassName).ToList();

                    foreach (UDT_ClassLock data in _UDT_ClassLockDict.Values)
                    {
                        if (data.UnAutoUnlock == false && data.isLock == true)
                        {
                            Utility.SendData(data.ClassName, "", "", "解除鎖定班級", data.DateStr, data.Comment, data.DocNo, data.EDoc, data.ClassID, "", "");
                        }
                    }

                    FISCA.Presentation.Controls.MsgBox.Show("全部班級解鎖");

                    // 重新整理
                    _UDT_ClassLockDict = UDTTransfer.GetClassLockNameIDDict();
                    ClassLockField.Reload();
                    ClassLockCommentField.Reload();
                    ClassLockStudentCountField.Reload();
                    ClassLockSStudentCountField.Reload();
                }
            };

            #region  步更新

            // 當高關懷特殊身分有更新
            FISCA.InteractionService.SubscribeEvent("KH_HighConcern_HighConcernContent", (sender, args) =>
            {
                _ClassStudentDict = KH_HighConcernCalc.Calc.GetClassStudentAllIDDict();
                ClassLockStudentCountField.Reload();
                ClassLockSStudentCountField.Reload();
            });

            // 當變更學生狀態
            FISCA.InteractionService.SubscribeEvent("KH_StudentChangeStatus", (sender, args) =>
            {
                _ClassStudentDict = KH_HighConcernCalc.Calc.GetClassStudentAllIDDict();
                ClassLockStudentCountField.Reload();
                ClassLockSStudentCountField.Reload();
            });

            // 當變更學生班級
            FISCA.InteractionService.SubscribeEvent("KH_StudentClassItemContent", (sender, args) =>
            {
                _ClassStudentDict = KH_HighConcernCalc.Calc.GetClassStudentAllIDDict();
                ClassLockStudentCountField.Reload();
                ClassLockSStudentCountField.Reload();
            });

            // 當變更學生轉入
            FISCA.InteractionService.SubscribeEvent("KH_StudentTransferStudentBriefItem", (sender, args) =>
            {
                _ClassStudentDict = KH_HighConcernCalc.Calc.GetClassStudentAllIDDict();
                ClassLockStudentCountField.Reload();
                ClassLockSStudentCountField.Reload();
            });

            // 當變更學生匯入
            FISCA.InteractionService.SubscribeEvent("KH_StudentImportWizard", (sender, args) =>
            {
                _ClassStudentDict = KH_HighConcernCalc.Calc.GetClassStudentAllIDDict();
                ClassLockStudentCountField.Reload();
                ClassLockSStudentCountField.Reload();
            });

            // 當變更學生-轉入
            FISCA.InteractionService.SubscribeEvent("KH_StudentTransStudBase", (sender, args) =>
            {
                _ClassStudentDict = KH_HighConcernCalc.Calc.GetClassStudentAllIDDict();
                ClassLockStudentCountField.Reload();
                ClassLockSStudentCountField.Reload();
            });

            #endregion


            K12.Presentation.NLDPanels.Class.ListPaneContexMenu["班級鎖定/解鎖"].Click += delegate
            {
                string cid = K12.Presentation.NLDPanels.Class.SelectedSource[0];
                // 檢查並取得班級鎖定
                UDT_ClassLock        data     = UDTTransfer.GetClassLockByClassID(cid);
                K12.Data.ClassRecord classRec = K12.Data.Class.SelectByID(cid);

                List <JHClassTagRecord> recList = JHClassTag.SelectByClassID(cid);

                bool Class_Has_Standard_Category = false;


                string grYear = "";
                string SecondPriorityClassName = "", ThridPriorityClassName = "";
                if (classRec.GradeYear.HasValue)
                {
                    grYear = classRec.GradeYear.Value.ToString();
                }

                Dictionary <string, int> classCot = new Dictionary <string, int>();

                List <KH_HighConcernCalc.ClassStudent> ClassStudentList = KH_HighConcernCalc.Calc.GetClassStudentList(grYear);
                int idx = 1;
                foreach (KH_HighConcernCalc.ClassStudent cs in ClassStudentList)
                {
                    classCot.Add(cs.ClassName, cs.ClassStudentCount);
                    if (idx == 2)     // 第二順位
                    {
                        SecondPriorityClassName = cs.ClassName;
                    }

                    if (idx == 3)      // 第三順位
                    {
                        ThridPriorityClassName = cs.ClassName;
                    }
                    idx++;
                }

                //穎驊新增, 用來檢查,此班級 是否有高雄定義的標準班級分類, 其定義了十種標準子類別在 KH_HighConcern專案 Program 下面程式碼,
                // 定義了普通班、體育班、美術班、音樂班、舞蹈班、資優班、資源班、特教班、技藝專班、機構式非學校自學班,
                //2016/12 高雄局端,希望在所有班級鎖班之前,都必須要有標準"班級分類",以利作業。

                foreach (var rec in recList)
                {
                    if (rec.Prefix == "班級分類")
                    {
                        Class_Has_Standard_Category = true;
                    }
                }



                // 當已被鎖定,問是否解鎖
                if (data.isLock)
                {
                    MsgForm mf1 = new MsgForm();
                    mf1.Text = "班級解鎖";
                    mf1.SetMsg("「班級解鎖」,按下「是」確認後,局端會留解鎖紀錄。");
                    //if (FISCA.Presentation.Controls.MsgBox.Show("「班級解鎖」,按下「是」確認後,局端會留解鎖紀錄。", "班級解鎖", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                    if (mf1.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                    {
                        // 已被鎖定解鎖
                        data.isLock       = false;
                        data.UnAutoUnlock = false;
                        string errMsg = Utility.SendData(classRec.Name, grYear, "", "解除鎖定班級", data.DateStr, data.Comment, data.DocNo, data.EDoc, data.ClassID, "", "");
                        if (errMsg != "")
                        {
                            FISCA.Presentation.Controls.MsgBox.Show(errMsg);
                        }
                        else
                        {
                            FISCA.Presentation.Controls.MsgBox.Show("已解鎖");
                        }
                        // 解鎖清除鎖定備註
                        data.Comment = "";
                    }
                }
                else
                {
                    if (Class_Has_Standard_Category)
                    {
                        // 未鎖定,問是否要鎖定
                        // 編班委員會會議日期
                        string strDate    = "";
                        string strComment = "";
                        string strDocNo   = "";
                        string strEDoc    = "";

                        SendDataForm sdf = new SendDataForm();
                        if (sdf.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                        {
                            strDate    = sdf.GetSendDate();
                            strComment = sdf.GetComment();
                            strDocNo   = sdf.GetDocNo();
                            strEDoc    = sdf.GetEDoc();
                            MsgForm mf = new MsgForm();
                            mf.Text = "班級鎖定";
                            mf.SetMsg("「班級鎖定」,按下「是」確認後,除集中式特殊班級,餘需函報教育局並由局端線上審核。");
                            //if (FISCA.Presentation.Controls.MsgBox.Show("「班級鎖定」,按下「是」確認後,除集中式特殊班級,餘需函報教育局並由局端線上審核。", "班級鎖定", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Warning, System.Windows.Forms.MessageBoxDefaultButton.Button2) == System.Windows.Forms.DialogResult.Yes)
                            if (mf.ShowDialog() == System.Windows.Forms.DialogResult.Yes)
                            {
                                // 寫入相對班級學生變動
                                int icid = int.Parse(cid);
                                UDTTransfer.UpdateUDTClassSepcByClassID(icid, classRec.Name, data.Comment, strComment);

                                data.ClassID      = cid;
                                data.ClassName    = classRec.Name;
                                data.Comment      = strComment;
                                data.DocNo        = strDocNo;
                                data.DateStr      = strDate;
                                data.EDoc         = strEDoc;
                                data.UnAutoUnlock = sdf.GetNUnLock();
                                data.isLock       = true;

                                string errMsg = Utility.SendData(classRec.Name, grYear, "", "鎖定班級", strDate, strComment, strDocNo, strEDoc, data.ClassID, SecondPriorityClassName, ThridPriorityClassName);

                                // 傳送檔案到局端
                                Utility.UploadFile(data.ClassID, sdf.GetBase64DataString(), sdf.GetFileName());

                                if (errMsg != "")
                                {
                                    FISCA.Presentation.Controls.MsgBox.Show(errMsg);
                                }
                                else
                                {
                                    if (data.UnAutoUnlock)
                                    {
                                        FISCA.Presentation.Controls.MsgBox.Show("已鎖定(不自動解鎖)");
                                    }
                                    else
                                    {
                                        FISCA.Presentation.Controls.MsgBox.Show("已鎖定");
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        FISCA.Presentation.Controls.MsgBox.Show("鎖班前,請將本班級先加入'班級分類:'中任一類別", "警告", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);

                        return;
                    }
                }
                // 儲存 UDT
                if (data != null)
                {
                    data.Save();
                    _UDT_ClassLockDict = UDTTransfer.GetClassLockNameIDDict();
                    ClassLockField.Reload();
                    ClassLockCommentField.Reload();
                    ClassLockStudentCountField.Reload();
                    ClassLockSStudentCountField.Reload();
                }
            };
        }