Exemple #1
0
        public TransferStudentForm(string studentid)
        {
            CurrentStudentID = studentid;

            InitializeComponent();
            _steps = new List <IStep>();

            this.TransferStudentData = TransferStudentDAL.GetStudentTransferData(studentid);

            _steps.Add(new Step1(this));
            _steps.Add(new Step2(this));
            _steps.Add(new Step3(this));

            _currentStepIndex   = 0;
            btnPrevious.Enabled = false;
            btnSave.Enabled     = false;
            LoadCurrentStep();
        }
        public static TransferStudentData GetStudentTransferData(string studentid)
        {
            string targetService = "SmartSchool.Score.GetSemesterMoralScore";

            DSXmlHelper helper = new DSXmlHelper("Request");

            helper.AddElement("Field");
            helper.AddElement("Field", "SchoolYear");
            helper.AddElement("Field", "Semester");
            helper.AddElement("Field", "TextScore");
            helper.AddElement("Field", "InitialSummary");
            helper.AddElement("Field", "Summary");
            helper.AddElement("Condition");
            helper.AddElement("Condition", "RefStudentID", studentid);

            DSRequest  req = new DSRequest(helper.BaseElement);
            DSResponse rsp = FISCA.Authentication.DSAServices.CallService(targetService, req);

            TransferStudentData data = new TransferStudentData(rsp.GetContent().BaseElement);

            return(data);
        }
        public static void Save(TransferStudentData transferStudentData, string studentid)
        {
            List <SemesterHistoryData> history = GetSemesterHistory(studentid);

            DSXmlHelper insertHelper = new DSXmlHelper("Request");
            DSXmlHelper updateHelper = new DSXmlHelper("Request");
            int         insertIndex = 1, updateIndex = 1;

            foreach (SemesterHistoryData sh in history)
            {
                //預設用 insert 來儲存此學期資料
                string modifyType = "insert";

                //預設存在 Summary 欄位中
                Flag target = Flag.Summary;

                foreach (SourceFlag flag in transferStudentData.SourceFlags)
                {
                    // 如果學習歷程中的學年度學期包含在此學生的資料當中, 表示要用 Update 來儲存此學期資料
                    if (flag.SchoolYear == sh.SchoolYear && flag.Semester == sh.Semester)
                    {
                        modifyType = "update";
                        target     = flag.Flag;
                        break;
                    }
                }

                // 如果為本學年度學期的話, 則一律存在 InitialSummary 欄位中
                if (sh.SchoolYear == School.DefaultSchoolYear && sh.Semester == School.DefaultSemester)
                {
                    target = Flag.IntialSummary;
                }

                XmlElement statisticElement = transferStudentData.GetStatisticsElement(sh.SchoolYear, sh.Semester);
                XmlElement textScoreElement = transferStudentData.GetTextScoreElement(sh.SchoolYear, sh.Semester);

                if (modifyType == "insert")
                {
                    insertHelper.AddElement("SemesterMoralScore");
                    insertHelper.AddElement("SemesterMoralScore[" + insertIndex + "]", "RefStudentID", studentid);
                    insertHelper.AddElement("SemesterMoralScore[" + insertIndex + "]", "SchoolYear", sh.SchoolYear);
                    insertHelper.AddElement("SemesterMoralScore[" + insertIndex + "]", "Semester", sh.Semester);
                    insertHelper.AddElement("SemesterMoralScore[" + insertIndex + "]", "TextScore", textScoreElement.OuterXml, true);

                    if (target == Flag.IntialSummary)
                    {
                        insertHelper.AddElement("SemesterMoralScore[" + insertIndex + "]", "InitialSummary", statisticElement.OuterXml, true);
                    }
                    else
                    {
                        insertHelper.AddElement("SemesterMoralScore[" + insertIndex + "]", "Summary", statisticElement.OuterXml, true);
                    }

                    insertIndex++;
                }
                else
                {
                    updateHelper.AddElement("SemesterMoralScore");
                    updateHelper.AddElement("SemesterMoralScore[" + updateIndex + "]", "Condition");
                    updateHelper.AddElement("SemesterMoralScore[" + updateIndex + "]/Condition", "RefStudentID", studentid);
                    updateHelper.AddElement("SemesterMoralScore[" + updateIndex + "]/Condition", "SchoolYear", sh.SchoolYear);
                    updateHelper.AddElement("SemesterMoralScore[" + updateIndex + "]/Condition", "Semester", sh.Semester);
                    updateHelper.AddElement("SemesterMoralScore[" + updateIndex + "]", "TextScore", textScoreElement.OuterXml, true);

                    if (target == Flag.IntialSummary)
                    {
                        updateHelper.AddElement("SemesterMoralScore[" + updateIndex + "]", "InitialSummary", statisticElement.OuterXml, true);
                    }
                    else
                    {
                        updateHelper.AddElement("SemesterMoralScore[" + updateIndex + "]", "Summary", statisticElement.OuterXml, true);
                    }

                    updateIndex++;
                }
            }

            if (insertIndex > 1)
            {
                FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.InsertSemesterMoralScore", new DSRequest(insertHelper.BaseElement));
            }
            if (updateIndex > 1)
            {
                FISCA.Authentication.DSAServices.CallService("SmartSchool.Score.UpdateSemesterMoralScore", new DSRequest(updateHelper.BaseElement));
            }
        }