Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNumber.Text))
            {
                MsgBox.Show("請輸入核準文號。");
                return;
            }

            DateTime date;

            if (!DateTime.TryParse(dtpDate.DateString, out date))
            {
                MsgBox.Show("日期格式不正確。");
                return;
            }

            // 修改名冊本身的日期與文號
            DSXmlHelper helper = new DSXmlHelper("AuthorizeBatchRequest");

            helper.AddElement("AuthorizeBatch");
            helper.AddElement("AuthorizeBatch", "Field");
            helper.AddElement("AuthorizeBatch/Field", "ADNumber", txtNumber.Text);
            helper.AddElement("AuthorizeBatch/Field", "ADDate", dtpDate.DateString);
            helper.AddElement("AuthorizeBatch", "Condition");
            helper.AddElement("AuthorizeBatch/Condition", "ID", _provider.ID);

            try
            {
                EditStudent.ModifyUpdateRecordBatch(new DSRequest(helper));
            }
            catch (Exception ex)
            {
                MsgBox.Show("編輯核准文號失敗:" + ex);
            }

            // 修改其包含的異動紀錄文號
            helper = new DSXmlHelper("UpdateRequest");
            helper.AddElement("UpdateRecord");
            helper.AddElement("UpdateRecord", "Field");
            helper.AddElement("UpdateRecord/Field", "ADNumber", txtNumber.Text);
            helper.AddElement("UpdateRecord/Field", "ADDate", dtpDate.DateString);
            helper.AddElement("UpdateRecord", "Condition");

            if (_provider.GetEntities().Length <= 0) //名冊中沒有任何學生,就不更新學生的核準文號了。
            {
                return;
            }

            foreach (IEntryFormat entity in _provider.GetEntities())
            {
                helper.AddElement("UpdateRecord/Condition", "ID", entity.ID);
            }

            try
            {
                EditStudent.ModifyUpdateRecord(new DSRequest(helper));
                if (DataSaved != null)
                {
                    DataSaved(this, null);
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show("編輯核准文號失敗:" + ex);
            }


            string batchName  = "";
            string schoolYear = "";
            string semester   = "";

            if (_provider.ID != "")
            {
                DSResponse dsrsp = QueryStudent.GetUpdateRecordBatch(_provider.ID);

                DSXmlHelper helper_ = dsrsp.GetContent();

                //填上名冊的 學年、學期、名稱
                foreach (XmlNode node in helper_.GetElements("UpdateRecordBatch"))
                {
                    schoolYear = node.SelectSingleNode("SchoolYear").InnerText;
                    semester   = node.SelectSingleNode("Semester").InnerText;
                    batchName  = node.SelectSingleNode("Name").InnerText;
                }
                // log,2018/3/1 穎驊新增,因應高雄 [10-03][01] 整個學年度核准過的文號的異動名冊全部不見了 項目
                // 本異動名冊 原只有新增會有系統紀錄,現在調整刪除、登打文號都會有紀錄
                JHSchool.PermRecLogProcess prlp = new JHSchool.PermRecLogProcess();
                string desc = "登錄文號" + schoolYear + "學年度,第" + semester + "學期," + batchName + "名冊,日期:" + dtpDate.DateString + ",文號:" + txtNumber.Text;
                prlp.SaveLog("教務.名冊", "登錄文號", desc);
            }



            this.Close();
        }
Пример #2
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtNumber.Text))
            {
                MsgBox.Show("請輸入核准文號。");
                return;
            }

            DateTime date;

            if (!DateTime.TryParse(dtpDate.DateString, out date))
            {
                MsgBox.Show("日期格式不正確。");
                return;
            }

            // 修改名冊本身的日期與文號
            DSXmlHelper helper = new DSXmlHelper("AuthorizeBatchRequest");

            helper.AddElement("AuthorizeBatch");
            helper.AddElement("AuthorizeBatch", "Field");
            helper.AddElement("AuthorizeBatch/Field", "ADNumber", txtNumber.Text);
            helper.AddElement("AuthorizeBatch/Field", "ADDate", dtpDate.DateString);
            helper.AddElement("AuthorizeBatch", "Condition");
            helper.AddElement("AuthorizeBatch/Condition", "ID", _provider.ID);

            try
            {
                EditStudent.ModifyUpdateRecordBatch(new DSRequest(helper));
            }
            catch (Exception ex)
            {
                MsgBox.Show("編輯核准文號失敗:" + ex);
            }

            // 修改其包含的異動紀錄文號
            helper = new DSXmlHelper("UpdateRequest");
            helper.AddElement("UpdateRecord");
            helper.AddElement("UpdateRecord", "Field");
            helper.AddElement("UpdateRecord/Field", "ADNumber", txtNumber.Text);
            helper.AddElement("UpdateRecord/Field", "ADDate", dtpDate.DateString);
            helper.AddElement("UpdateRecord", "Condition");

            if (_provider.GetEntities().Length <= 0) //名冊中沒有任何學生,就不更新學生的核准文號了。
            {
                return;
            }

            foreach (IEntryFormat entity in _provider.GetEntities())
            {
                helper.AddElement("UpdateRecord/Condition", "ID", entity.ID);
            }

            try
            {
                EditStudent.ModifyUpdateRecord(new DSRequest(helper));
                if (DataSaved != null)
                {
                    DataSaved(this, null);
                }
            }
            catch (Exception ex)
            {
                MsgBox.Show("編輯核准文號失敗:" + ex);
            }
            this.Close();
        }
Пример #3
0
        public bool Save()
        {
            if (_Action == UpdateRecordAction.None)
            {
                return(false);
            }

            bool _saved = false;

            DSXmlHelper helper = new DSXmlHelper("InsertRequest");

            helper.AddElement("UpdateRecord");
            helper.AddElement("UpdateRecord", "Field");
            if (_Action != UpdateRecordAction.Update)
            {
                helper.AddElement("UpdateRecord/Field", "RefStudentID", _StudentID);
            }
            helper.AddElement("UpdateRecord/Field", "ContextInfo");

            XmlDocument contextInfo = new XmlDocument();
            XmlElement  root        = contextInfo.CreateElement("ContextInfo");

            contextInfo.AppendChild(root);

            foreach (XmlNode node in GetElement().ChildNodes)
            {
                //Log,紀錄修改後的資料
                if (afterData.ContainsKey(node.Name))
                {
                    afterData.Remove(node.Name);
                }
                afterData.Add(node.Name, node.InnerText);

                // 如果是 Previous 開頭的全丟到 ContextInfo 中

                if (node.Name.StartsWith("Previous") ||
                    node.Name.StartsWith("Graduate") ||
                    node.Name == "NewStudentNumber" ||
                    node.Name == "LastUpdateCode" ||
                    node.Name == "NewData")
                {
                    XmlNode importNode = node.Clone();
                    importNode = contextInfo.ImportNode(importNode, true);
                    root.AppendChild(importNode);
                }
                else
                {
                    helper.AddElement("UpdateRecord/Field", node.Name, node.InnerText);
                }
            }

            //將 contextInfo 這個 document 的資料塞進 ContextInfo 的 CdataSection 裡
            helper.AddXmlString("UpdateRecord/Field/ContextInfo", root.OuterXml);

            if (_Action == UpdateRecordAction.Update)
            {
                // 補上條件
                helper.AddElement("UpdateRecord", "Condition");
                helper.AddElement("UpdateRecord/Condition", "ID", _UpdateRecordID);
            }

            try
            {
                if (IsValid())
                {
                    if (_Action == UpdateRecordAction.Update)
                    {
                        EditStudent.ModifyUpdateRecord(new DSRequest(helper));
                    }
                    else
                    {
                        EditStudent.InsertUpdateRecord(new DSRequest(helper));
                    }

                    _saved = true;
                }
            }
            catch (Exception ex)
            {
                if (_Action == UpdateRecordAction.Update)
                {
                    MsgBox.Show("修改異動資料失敗:" + ex.Message);
                }
                else
                {
                    MsgBox.Show("新增異動資料失敗:" + ex.Message);
                }
            }

            //#region 處理 Log,寫入 Log
            ////--- 這段用到 AccessHelp 先註解,之後再寫
            //StringBuilder desc = new StringBuilder("");
            //desc.AppendLine("學生姓名:" + ((_AccessHelper.StudentHelper.GetStudents(_StudentID).Count > 0) ? _AccessHelper.StudentHelper.GetStudents(_StudentID)[0].StudentName + " " : "未知 "));

            //if (_Action == UpdateRecordAction.Update)
            //    desc.AppendLine("修改異動紀錄: " + beforeData["UpdateDate"] + " " + beforeData["UpdateDescription"] + " ");
            //else
            //    desc.AppendLine("新增異動紀錄: " + afterData["UpdateDate"] + " " + afterData["UpdateDescription"] + " ");

            //foreach (string var in afterData.Keys)
            //{
            //    if (beforeData[var] != afterData[var])
            //    {
            //        if (_Action == UpdateRecordAction.Update)
            //            desc.AppendLine("欄位「" + _EnChDict[var] + "」由「" + beforeData[var] + "」變更為「" + afterData[var] + "」");
            //        else
            //            desc.AppendLine("新增欄位「" + _EnChDict[var] + "」為「" + afterData[var] + "」");
            //    }
            //}

            //EntityAction entityAction = EntityAction.Insert;
            //if (_Action == UpdateRecordAction.Update)
            //    entityAction = EntityAction.Update;

            //CurrentUser.Instance.AppLog.Write(EntityType.Student, entityAction, _StudentID, desc.ToString(), "異動資料", "");
            // ///---
            //#endregion


            #region 之前的儲存做法
            //if (_Action == UpdateRecordAction.Insert)
            //{
            //    DSXmlHelper helper = new DSXmlHelper("InsertRequest");
            //    helper.AddElement("UpdateRecord");
            //    helper.AddElement("UpdateRecord", "Field");
            //    helper.AddElement("UpdateRecord/Field", "RefStudentID", _StudentID);
            //    helper.AddElement("UpdateRecord/Field", "ContextInfo");

            //    XmlDocument contextInfo = new XmlDocument();
            //    XmlElement root = contextInfo.CreateElement("ContextInfo");
            //    contextInfo.AppendChild(root);

            //    foreach (XmlNode node in GetElement().ChildNodes)
            //    {
            //        afterData.Add(node.Name, node.InnerText);

            //        // 如果是 Previous 開頭的全丟到 ContextInfo 中

            //        if (node.Name.StartsWith("Previous") || node.Name.StartsWith("Graduate") || node.Name == "NewStudentNumber" || node.Name == "LastUpdateCode")
            //        {
            //            XmlNode importNode = node.Clone();
            //            importNode = contextInfo.ImportNode(importNode, true);
            //            root.AppendChild(importNode);
            //        }
            //        else
            //        {
            //            helper.AddElement("UpdateRecord/Field", node.Name, node.InnerText);
            //        }
            //    }

            //    // 將 contextInfo 這個 document 的資料塞進 ContextInfo 的 CdataSection 裡
            //    helper.AddXmlString("UpdateRecord/Field/ContextInfo", root.OuterXml);
            //    DSRequest dsreq = new DSRequest(helper);
            //    try
            //    {
            //        if (IsValid())
            //        {
            //            EditStudent.InsertUpdateRecord(dsreq);
            //            _saved = true;
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        MsgBox.Show("新增異動資料失敗:" + ex.Message);
            //    }
            //}
            //else
            //{
            //    DSXmlHelper helper = new DSXmlHelper("UpdateRequest");
            //    helper.AddElement("UpdateRecord");
            //    helper.AddElement("UpdateRecord", "Field");
            //    helper.AddElement("UpdateRecord/Field", "RefStudentID", _StudentID);
            //    helper.AddElement("UpdateRecord/Field", "ContextInfo");

            //    XmlDocument contextInfo = new XmlDocument();
            //    XmlElement root = contextInfo.CreateElement("ContextInfo");
            //    contextInfo.AppendChild(root);

            //    foreach (XmlNode node in GetElement().ChildNodes)
            //    {
            //        afterData.Add(node.Name, node.InnerText);

            //        if (node.Name.StartsWith("Previous") || node.Name.StartsWith("Graduate") || node.Name == "NewStudentNumber" || node.Name == "LastUpdateCode")
            //        {
            //            XmlNode importNode = node.Clone();
            //            importNode = contextInfo.ImportNode(importNode, true);
            //            root.AppendChild(importNode);
            //        }
            //        else
            //        {
            //            helper.AddElement("UpdateRecord/Field", node.Name, node.InnerText);
            //        }
            //    }

            //    // 將 contextInfo 這個 document 的資料塞進 ContextInfo 的 CdataSection 裡
            //    helper.AddXmlString("UpdateRecord/Field/ContextInfo", root.OuterXml);

            //    // 補上條件
            //    helper.AddElement("UpdateRecord", "Condition");
            //    helper.AddElement("UpdateRecord/Condition", "ID", _UpdateRecordID);

            //    try
            //    {
            //        if (IsValid())
            //        {
            //            EditStudent.ModifyUpdateRecord(new DSRequest(helper));
            //            _saved = true;
            //        }
            //    }
            //    catch (Exception ex)
            //    {
            //        MsgBox.Show("修改異動資料失敗:" + ex.Message);
            //    }
            //}
            #endregion

            return(_saved);
        }