Exemple #1
0
        private void buttonX2_Click(object sender, EventArgs e)
        {
            List <string> AttendList = new List <string>();

            this.UseWaitCursor = true;
            int         changedCount = 0;
            DSXmlHelper helper       = new DSXmlHelper("UpdateSCAttend");

            foreach (AttInfo each in _AttendInfoList)
            {
                if (each.HasChanged)
                {
                    changedCount++;
                    XmlElement attend = helper.AddElement("Attend");
                    DSXmlHelper.AppendChild(attend, "<ID>" + each.AttendID + "</ID>");
                    DSXmlHelper.AppendChild(attend, "<RefCourseID>" + each.CourseID + "</RefCourseID>");
                    helper.AddElement(".", attend);
                    AttendList.Add(each.AttendID);
                }
            }
            if (changedCount > 0)
            {
                EditCourse.UpdateAttend(helper);
            }
            //更新課程List資料
            //SCAttend.Instance.SyncDataBackground(AttendList);
            FISCA.Presentation.MotherForm.SetStatusBarMessage("調整修課學生完成。");


            //Customization.PlugIn.Global.SetStatusBarMessage("調整修課學生完成。");
            this.UseWaitCursor = false;
            this.Close();
        }
Exemple #2
0
        public void UpdateToServer()
        {
            int  progress       = 0;
            bool updateRequired = false;

            foreach (List <Course> each in _packings)
            {
                DSXmlHelper request = new DSXmlHelper("Request");

                foreach (Course course in each)
                {
                    if (course.ExamTemplate == null)
                    {
                        continue;
                    }

                    if (!course.ExamRequired)
                    {
                        continue;
                    }

                    //AllowUpload 為 True 時,略過成績計算,因為成績是由老師提供。
                    if (course.ExamTemplate.AllowUpload)
                    {
                        continue;
                    }

                    foreach (SCAttend attend in course.SCAttends.Values)
                    {
                        XmlElement  xmlAttend = request.AddElement("Attend");
                        DSXmlHelper hlpAttend = new DSXmlHelper(xmlAttend);
                        hlpAttend.AddElement(".", "ID", attend.Identity);

                        if (_clear_data)
                        {
                            hlpAttend.AddElement(".", "Score", "");
                            attend.PreviousScore = string.Empty;
                        }
                        else
                        {
                            hlpAttend.AddElement(".", "Score", attend.Score);
                            attend.SaveScore();
                        }

                        updateRequired = true; //指示是否要執行呼叫 Service 的動作。

                        progress++;
                    }
                }

                if (updateRequired)
                {
                    EditCourse.UpdateAttend(request);
                }

                Progress.ReportProgress("", progress);
            }
        }
Exemple #3
0
        public override void Save()
        {
            List <AttendInfo> insertList = new List <AttendInfo>();  //新增清單
            List <AttendInfo> updateList = new List <AttendInfo>();  //更新清單
            List <AttendInfo> deleteList = new List <AttendInfo>();  //刪除清單

            GetList(insertList, updateList, deleteList);

            try
            {
                List <string> synclist = new List <string>();
                DSXmlHelper   helper   = new DSXmlHelper("InsertSCAttend");
                foreach (AttendInfo each in insertList)
                {
                    XmlElement attend = helper.AddElement("Attend");
                    DSXmlHelper.AppendChild(attend, "<RefStudentID>" + each.RefStudentID.ToString() + "</RefStudentID>");
                    DSXmlHelper.AppendChild(attend, "<RefCourseID>" + RunningID + "</RefCourseID>");
                    DSXmlHelper.AppendChild(attend, "<IsRequired>" + each.IsRequired + "</IsRequired>");
                    DSXmlHelper.AppendChild(attend, "<RequiredBy>" + each.RequiredBy + "</RequiredBy>");
                    //DSXmlHelper.AppendChild(attend, "<GradeYear>" + each.GradeYear + "</GradeYear>");
                    helper.AddElement(".", attend);
                }
                if (insertList.Count > 0)
                {
                    DSXmlHelper insertResult = AddCourse.AttendCourse(helper).GetContent();
                    foreach (XmlElement each in insertResult.GetElements("NewID"))
                    {
                        synclist.Add(each.InnerText);
                    }
                }

                helper = new DSXmlHelper("UpdateSCAttend");
                foreach (AttendInfo each in updateList)
                {
                    XmlElement attend = helper.AddElement("Attend");
                    DSXmlHelper.AppendChild(attend, "<ID>" + each.Identity + "</ID>");
                    DSXmlHelper.AppendChild(attend, "<IsRequired>" + each.IsRequired + "</IsRequired>");
                    DSXmlHelper.AppendChild(attend, "<RequiredBy>" + each.RequiredBy + "</RequiredBy>");
                    synclist.Add(each.Identity.ToString());

                    helper.AddElement(".", attend);
                }
                if (updateList.Count > 0)
                {
                    EditCourse.UpdateAttend(helper);
                }

                helper = new DSXmlHelper("DeleteSCAttendRequest");
                foreach (AttendInfo each in deleteList)
                {
                    XmlElement attend = helper.AddElement("Attend");
                    DSXmlHelper.AppendChild(attend, "<ID>" + each.Identity + "</ID>");
                    synclist.Add(each.Identity.ToString());

                    helper.AddElement(".", attend);
                }
                if (deleteList.Count > 0)
                {
                    EditCourse.DeleteAttend(helper);
                }

                #region Log

                StringBuilder desc = new StringBuilder("");
                desc.AppendLine("課程名稱:" + Course.Instance.Items[RunningID].Name);
                if (insertList.Count > 0)
                {
                    desc.AppendLine("加入修課學生:");
                }
                foreach (AttendInfo info in insertList)
                {
                    desc.AppendLine("- " + info.Class + " " + info.StudentNumber + " " + info.StudentName + " ");
                }
                if (deleteList.Count > 0)
                {
                    desc.AppendLine("移除課程修課學生:");
                }
                foreach (AttendInfo info in deleteList)
                {
                    desc.AppendLine("- " + info.Class + " " + info.StudentNumber + " " + info.StudentName + " ");
                }
                if (updateList.Count > 0)
                {
                    desc.AppendLine("課程修課學生修課資訊調整:");
                }
                foreach (AttendInfo info in updateList)
                {
                    desc.AppendLine("- " + info.Class + " " + info.StudentNumber + " " + info.StudentName + " ");
                }

                //CurrentUser.Instance.AppLog.Write(EntityType.Course, "修改課程修課學生", RunningID, desc.ToString(), "課程", "");
                FISCA.LogAgent.ApplicationLog.Log("課程基本資料", "修改課程修課學生", desc.ToString());

                #endregion

                //SCAttend.Instance.SyncDataBackground(synclist);
                LoadContent(RunningID);
            }
            catch (Exception ex)
            {
                MsgBox.Show("儲存失敗:" + ex.Message);
            }
        }
Exemple #4
0
        public override void Save()
        {
            // 產生新增成績 Request
            int insertStudentCount = 0;
            int updateStudentCount = 0;
            int deleteStudentCount = 0;
            int usCount            = 0;

            DSXmlHelper insertHelper = new DSXmlHelper("Request");
            DSXmlHelper updateHelper = new DSXmlHelper("Request");
            DSXmlHelper deleteHelper = new DSXmlHelper("Request");
            DSXmlHelper usHelper     = new DSXmlHelper("Request");

            insertHelper.AddElement("ScoreSheetList");
            updateHelper.AddElement("ScoreSheetList");
            deleteHelper.AddElement("ScoreSheet");

            foreach (DataGridViewRow row in dataGridView1.Rows)
            {
                string attendid = row.Tag.ToString();

                foreach (DataGridViewCell cell in row.Cells)
                {
                    IExamCell ic = cell.Tag as IExamCell;
                    if (ic == null)
                    {
                        continue;
                    }
                    ColumnSetting setting = dataGridView1.Columns[cell.ColumnIndex].Tag as ColumnSetting;
                    string        examid  = setting.Key;
                    if (ic is ScoreExamCell && ic.IsDirty)
                    {
                        usCount++;
                        usHelper.AddElement("Attend");
                        usHelper.AddElement("Attend", "Score", ic.GetValue());
                        usHelper.AddElement("Attend", "ID", attendid);
                    }
                    else if (string.IsNullOrEmpty(ic.Key) && ic.IsDirty)
                    {
                        insertStudentCount++;
                        insertHelper.AddElement("ScoreSheetList", "ScoreSheet");
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "ExamID", examid);
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "AttendID", attendid);
                        insertHelper.AddElement("ScoreSheetList/ScoreSheet", "Score", ic.GetValue());
                    }
                    else if (!string.IsNullOrEmpty(ic.Key) && ic.IsDirty && !string.IsNullOrEmpty(ic.GetValue()))
                    {
                        updateStudentCount++;
                        updateHelper.AddElement("ScoreSheetList", "ScoreSheet");
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "Score", ic.GetValue());
                        updateHelper.AddElement("ScoreSheetList/ScoreSheet", "ID", ic.Key);
                    }
                    else if (!string.IsNullOrEmpty(ic.Key) && ic.IsDirty && string.IsNullOrEmpty(ic.GetValue()))
                    {
                        deleteStudentCount++;
                        deleteHelper.AddElement("ScoreSheet", "ID", ic.Key);
                    }
                }
            }

            if (insertStudentCount > 0)
            {
                EditCourse.InsertSCEScore(new DSRequest(insertHelper));
            }
            if (updateStudentCount > 0)
            {
                EditCourse.UpdateSCEScore(new DSRequest(updateHelper));
            }
            if (deleteStudentCount > 0)
            {
                EditCourse.DeleteSCEScore(new DSRequest(deleteHelper));
            }
            if (usCount > 0)
            {
                EditCourse.UpdateAttend(usHelper);
            }

            SaveButtonVisible = false;
            LoadContent(RunningID);
        }