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();
        }
Beispiel #2
0
        private void lstList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (lstList.SelectedItems.Count > 0)
            {
                btnDelete.Enabled = true;
                btnAD.Enabled     = true;

                ListViewItem item  = lstList.SelectedItems[0];
                string       id    = item.Tag.ToString();
                DSResponse   dsrsp = QueryStudent.GetUpdateRecordBatch(id);

                listView.SuspendLayout();
                if (dsrsp.HasContent)
                {
                    DSXmlHelper helper = dsrsp.GetContent();
                    provider = new SummaryProvider(helper);

                    lblADCounter.Text = "【" + provider.Title + "】 各科人數統計";
                    lblADInfo.Text    = "【" + provider.Title + "】 核准文號";
                    buttonX1.Visible  = true;
                    buttonX2.Visible  = true;

                    XmlNode contentNode = helper.GetElement("UpdateRecordBatch/Content");
                    if (contentNode == null)
                    {
                        return;
                    }
                    source = (XmlElement)contentNode.FirstChild;

                    //處理看板資訊
                    StringBuilder builder = new StringBuilder("");
                    foreach (Department dept in provider.GetDepartments())
                    {
                        builder = builder.Append("◎").Append(dept.Name).Append(" ")
                                  .Append("男生 <font color='blue'>").Append(dept.Male).Append("</font> 人 ")
                                  .Append("女生 <font color='blue'>").Append(dept.Female).Append("</font> 人 ")
                                  .Append("(合計 <font color='blue'>").Append(dept.Total).Append("</font> 人)");

                        if (dept.Unknow > 0)
                        {
                            builder = builder.Append("<font color='red'>").Append(dept.Unknow)
                                      .Append("</font>人未填性別");
                        }
                        builder = builder.Append("<br/>");
                    }
                    lblListContent.Text = builder.ToString();
                    lblADName1.Text     = provider.Title;
                    lblADName2.Text     = provider.Title;
                    lblADName3.Text     = provider.Title;

                    // 處理核准日期與文號
                    string adString = "";
                    if (!string.IsNullOrEmpty(provider.ADNumber))
                    {
                        adString += "核准文號 <font color='red'>" + provider.ADNumber + "</font> ";
                        adString += "核准日期 <font color='red'>" + provider.ADDate + "</font>";
                    }
                    else
                    {
                        adString = "<font color='red'>未登錄</font>";
                    }
                    lblAD.Text = adString;

                    //處理ListView呈現資料
                    listView.Clear();

                    foreach (IEntryFormat format in provider.GetEntities())
                    {
                        // 若無群組則先加上群組
                        if (listView.Groups[format.Group] == null)
                        {
                            listView.Groups.Add(format.Group, format.Group);
                        }

                        // 若沒有欄名則先加上欄名
                        if (listView.Columns.Count == 0)
                        {
                            foreach (string column in format.DisplayColumns.Keys)
                            {
                                listView.Columns.Add(column, format.DisplayColumns[column].Width);
                            }
                        }

                        // 欄位都有了則依據欄位填入其屬性值
                        ListViewItem rowItem = null;
                        for (int i = 0; i < listView.Columns.Count; i++)
                        {
                            string columnName = listView.Columns[i].Text;
                            string value      = format.DisplayColumns[columnName].Value;
                            if (i == 0)
                            {
                                rowItem = new ListViewItem(value);
                            }
                            else
                            {
                                rowItem.SubItems.Add(value);
                            }
                        }
                        rowItem.Tag   = format;
                        rowItem.Group = listView.Groups[format.Group];
                        listView.Items.Add(rowItem);
                    }
                }
                listView.ResumeLayout();
            }
            else
            {
                btnDelete.Enabled = false;
                btnAD.Enabled     = false;
            }

            this.itemPanel1.RecalcLayout();
            //this.itemPanel1.Refresh();
        }
        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();
        }