コード例 #1
0
        public CopyClubRecord(CLUBRecordWithPhoto club)
        {
            _Club = club;
            //建立一個社團 / 社團學生的物件
            //並且傳入新社團的相關資料

            //本物件的功能
            //就是傳入新社團的ID
            //而本物件依據ID來建立學生記錄


        }
コード例 #2
0
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            //取得社團資料
            List<CLUBRecordWithPhoto> ClubPrimaryList = _AccessHelper.Select<CLUBRecordWithPhoto>(string.Format("UID = '{0}'", this.PrimaryKey));
            if (ClubPrimaryList.Count != 1)
            {
                //如果取得2門以上 或 沒取得社團時
                e.Cancel = true;
                return;
            }

            ClubPrimary = ClubPrimaryList[0];
        }
コード例 #3
0
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {

            //檢查目標學年期,是否有相同名稱之社團資料
            //如果有則移除該社團
            //並透過覆製功能進行新增動作
            removelist = CheckOldReMoveClub();
            Dictionary<string, List<SCJoin>> studentSCJDic = new Dictionary<string, List<SCJoin>>();

            if (StudentCopy)
            {
                //取得原有社團之學生社團記錄
                ScjStudentList = _AccessHelper.Select<SCJoin>(string.Format("ref_club_id in ('{0}')", string.Join("','", ClubAdmin.Instance.SelectedSource)));

                foreach (SCJoin each in ScjStudentList)
                {
                    if (!studentSCJDic.ContainsKey(each.RefClubID))
                    {
                        studentSCJDic.Add(each.RefClubID, new List<SCJoin>());
                    }
                    studentSCJDic[each.RefClubID].Add(each);
                }
            }

            Dictionary<string, List<CadresRecord>> studentCadreDic = new Dictionary<string, List<CadresRecord>>();
            if (CadresCopy)
            {
                //取得原有社團之學生社團記錄
                CadreStudentList = _AccessHelper.Select<CadresRecord>(string.Format("ref_club_id in ('{0}')", string.Join("','", ClubAdmin.Instance.SelectedSource)));

                foreach (CadresRecord each in CadreStudentList)
                {
                    if (!studentCadreDic.ContainsKey(each.RefClubID))
                    {
                        studentCadreDic.Add(each.RefClubID, new List<CadresRecord>());
                    }
                    studentCadreDic[each.RefClubID].Add(each);
                }
            }

            int LogSchoolYear = 90;
            int LogSemester = 1;

            if (Copylist.Count > 0)
            {
                LogSchoolYear = Copylist[0].SchoolYear;
                LogSemester = Copylist[0].Semester;
            }

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("已進行複製社團作業:");
            sb.AppendLine(string.Format("由學年度「{0}」學期「{1}」複製至學年度「{2}」學期「{3}」", LogSchoolYear.ToString(), LogSemester.ToString(), _SchoolYear.ToString(), _Semester.ToString()));
            if (StudentCopy)
            {
                sb.AppendLine("(已勾選複製學生選項)");
            }
            sb.AppendLine("");
            sb.AppendLine("新學期社團清單如下:");

            foreach (CLUBRecordWithPhoto each in Copylist)
            {
                #region 複製社團基本資料

                //如果是重覆社團則不處理
                if (removelist.Contains(each.ClubName))
                    continue;

                //是否複製學生
                if (StudentCopy)
                {
                    CopyClubRecord new_ccr = new CopyClubRecord(each);
                    if (studentSCJDic.ContainsKey(each.UID))
                    {
                        new_ccr.SetSCJ(studentSCJDic[each.UID]);
                    }
                }

                CLUBRecordWithPhoto cr = new CLUBRecordWithPhoto();
                cr.About = each.About;
                cr.ClubNumber = each.ClubNumber;
                cr.ClubCategory = each.ClubCategory;
                cr.ClubName = each.ClubName;
                cr.TotalNumberHours = each.TotalNumberHours;

                cr.Grade1Limit = each.Grade1Limit;
                cr.Grade2Limit = each.Grade2Limit;
                cr.Grade3Limit = each.Grade3Limit;
                cr.Grade4Limit = each.Grade4Limit;
                cr.Grade5Limit = each.Grade5Limit;

                cr.Grade1BoyLimit = each.Grade1BoyLimit;
                cr.Grade2BoyLimit = each.Grade2BoyLimit;
                cr.Grade3BoyLimit = each.Grade3BoyLimit;
                cr.Grade4BoyLimit = each.Grade4BoyLimit;
                cr.Grade5BoyLimit = each.Grade5BoyLimit;

                cr.Grade1GirlLimit = each.Grade1GirlLimit;
                cr.Grade2GirlLimit = each.Grade2GirlLimit;
                cr.Grade3GirlLimit = each.Grade3GirlLimit;
                cr.Grade4GirlLimit = each.Grade4GirlLimit;
                cr.Grade5GirlLimit = each.Grade5GirlLimit;

                cr.Location = each.Location;
                cr.Photo1 = each.Photo1;
                cr.Photo2 = each.Photo2;
                cr.RefTeacherID = each.RefTeacherID;
                cr.RefTeacherID2 = each.RefTeacherID2;
                cr.RefTeacherID3 = each.RefTeacherID3;

                cr.TotalNumberHours = each.TotalNumberHours;
                cr.FullPhase = each.FullPhase;
                cr.Domain = each.Domain;
                cr.Type = each.Type;
                cr.Formal = each.Formal;

                if (CadresCopy)
                {
                    //社長,副社長
                    cr.President = each.President;
                    cr.VicePresident = each.VicePresident;

                    //處理其它幹部

                    //newInsertCadresList
                }

                //使用者所設定之學年度學期
                cr.SchoolYear = _SchoolYear;
                cr.Semester = _Semester;
                newInsertList.Add(cr);

                sb.AppendLine(string.Format("學年度「{0}」學期「{1}」社團名稱「{2}」", cr.SchoolYear.ToString(), cr.Semester.ToString(), cr.ClubName));


                #endregion

            }

            if (newInsertList.Count > 0)
            {

                //新增之社團ID
                List<string> IDList = new List<string>();

                try
                {
                    IDList = _AccessHelper.InsertValues(newInsertList);
                }
                catch (Exception ex)
                {
                    SmartSchool.ErrorReporting.ReportingService.ReportException(ex);
                    e.Cancel = true;
                    return;
                }

                FISCA.LogAgent.ApplicationLog.Log("社團", "複製社團", sb.ToString());

                //取得社團
                List<CLUBRecordWithPhoto> ListInsertRecord = _AccessHelper.Select<CLUBRecordWithPhoto>(string.Format("UID in('{0}')", string.Join("','", IDList)));
                //如果有勾選複製社團
                //要把複製的社團取得ID,並且比隊其對應的原社團
                if (StudentCopy)
                {
                    #region 複製社團學生

                    if (IDList.Count != 0)
                    {

                        //建立學生的社團記錄Record
                        //所要複製的社團
                        List<CopyClubRecord> new_list = new List<CopyClubRecord>();
                        foreach (CLUBRecordWithPhoto each1 in Copylist)
                        {
                            CopyClubRecord new_ccr = new CopyClubRecord(each1);
                            if (studentSCJDic.ContainsKey(each1.UID))
                            {
                                new_ccr.SetSCJ(studentSCJDic[each1.UID]);
                                new_list.Add(new_ccr);
                            }
                        }

                        foreach (CLUBRecordWithPhoto each in ListInsertRecord)
                        {
                            foreach (CopyClubRecord each2 in new_list)
                            {
                                if (each.ClubName == each2._Club.ClubName)
                                {
                                    each2._new_Club = each;
                                    break;
                                }
                            }
                        }

                        //新增社團清單
                        insertSCJList = new List<SCJoin>();
                        foreach (CopyClubRecord each in new_list)
                        {
                            insertSCJList.AddRange(each.GetNewSCJoinList());
                        }

                        try
                        {
                            _AccessHelper.InsertValues(insertSCJList);
                        }
                        catch (Exception ex)
                        {
                            SmartSchool.ErrorReporting.ReportingService.ReportException(ex);
                            e.Cancel = true;
                            return;
                        }
                    }

                    #endregion
                }

                if (CadresCopy)
                {
                    #region 複製社團幹部 -2

                    if (IDList.Count != 0)
                    {
                        List<CopyClubRecord> new_list = new List<CopyClubRecord>();
                        foreach (CLUBRecordWithPhoto each1 in Copylist)
                        {
                            CopyClubRecord new_ccr = new CopyClubRecord(each1);
                            if (studentCadreDic.ContainsKey(each1.UID))
                            {
                                new_ccr.SetSCJ(studentCadreDic[each1.UID]);
                                new_list.Add(new_ccr);
                            }
                        }

                        foreach (CLUBRecordWithPhoto each in ListInsertRecord)
                        {
                            foreach (CopyClubRecord each2 in new_list)
                            {
                                if (each.ClubName == each2._Club.ClubName)
                                {
                                    each2._new_Club = each;
                                    break;
                                }
                            }
                        }

                        //新增社團清單
                        insertCadreList = new List<CadresRecord>();
                        foreach (CopyClubRecord each in new_list)
                        {
                            insertCadreList.AddRange(each.GetNewCadresList());
                        }

                        try
                        {
                            _AccessHelper.InsertValues(insertCadreList);
                        }
                        catch (Exception ex)
                        {
                            SmartSchool.ErrorReporting.ReportingService.ReportException(ex);
                            e.Cancel = true;
                            return;
                        }
                    }

                    #endregion
                }
            }
        }