コード例 #1
0
        /// <summary>
        /// 背景模式
        /// </summary>
        void BGW_DoWork(object sender, DoWorkEventArgs e)
        {
            paperForStudent = new SmartSchool.ePaper.ElectronicPaper(School.DefaultSchoolYear + "學生日常表現總表", School.DefaultSchoolYear, School.DefaultSemester, SmartSchool.ePaper.ViewerType.Student);

            #region 設定檔

            cd = Campus.Configuration.Config.User[ConfigName];

            XmlElement config = cd.GetXml("XmlData", null);
            if (config == null)
            {
                e.Cancel = true;
                return;
            }

            absenceList = new List <string>();
            int absenceindex = 1;
            //集會,一般...
            foreach (XmlElement xml in config.SelectNodes("Type"))
            {
                //曠課,病假...
                foreach (XmlElement node in xml.SelectNodes("Absence"))
                {
                    string s1 = xml.GetAttribute("Text");
                    string s2 = node.GetAttribute("Text");
                    absenceList.Add(s2 + s1);

                    //記錄Index
                    DicSummaryIndex.Add(s2 + s1, absenceindex);
                    absenceindex++;
                }
            }

            #endregion

            #region 開頭處理

            BehaviorList  = GetBehaviorConfig();
            BehaviorList1 = new List <string>();
            BehaviorList2 = new List <string>();
            BehaviorList3 = new List <string>();

            //製作日常生活表現,標題的Index
            int BeIndex = 0;
            foreach (string each in BehaviorList)
            {
                BeIndex++;
                if (BeIndex > SuperBehaviorIndex1 && BeIndex <= SuperBehaviorIndex2)
                {
                    BehaviorList2.Add(each);
                    DicSummaryIndex.Add(each, BeIndex - SuperBehaviorIndex1);
                }
                else if (BeIndex > SuperBehaviorIndex2)
                {
                    BehaviorList3.Add(each);
                    DicSummaryIndex.Add(each, BeIndex - SuperBehaviorIndex2);
                }
                else if (BeIndex <= SuperBehaviorIndex1)
                {
                    BehaviorList1.Add(each);
                    DicSummaryIndex.Add(each, BeIndex);
                }
            }

            //依據日常生活表現欄位,讀取範本
            _template = new Document(new MemoryStream(Properties.Resources.日常生活記錄表_範本_1));

            if (BehaviorList.Count > SuperBehaviorIndex1)
            {
                _template = new Document(new MemoryStream(Properties.Resources.日常生活記錄表_範本_2));
            }

            if (BehaviorList.Count > SuperBehaviorIndex2)
            {
                _template = new Document(new MemoryStream(Properties.Resources.日常生活記錄表_範本_3));
            }

            //建立資料模型
            Data = new StudentInfo(BehaviorList);

            #endregion

            if (SingeFile) //如果是單檔儲存
            {
                #region 單一學生

                Dictionary <string, Document> DocDic = new Dictionary <string, Document>();

                foreach (string student in Data.DicStudent.Keys)
                {
                    Document PageOne = SetDocument(student);

                    //電子報表
                    MemoryStream stream = new MemoryStream();
                    PageOne.Save(stream, SaveFormat.Docx);
                    paperForStudent.Append(new PaperItem(PaperFormat.Office2003Doc, stream, student));

                    if (!DocDic.ContainsKey(student))
                    {
                        DocDic.Add(student, PageOne);
                    }
                }

                e.Result = DocDic;

                #endregion
            }
            else
            {
                #region 多名學生存單一檔案

                _doc = new Document();
                _doc.Sections.Clear(); //清空此Document

                foreach (string student in Data.DicStudent.Keys)
                {
                    Document PageOne = SetDocument(student);

                    //電子報表
                    MemoryStream stream = new MemoryStream();
                    PageOne.Save(stream, SaveFormat.Docx);
                    paperForStudent.Append(new PaperItem(PaperFormat.Office2003Doc, stream, student));

                    _doc.Sections.Add(_doc.ImportNode(PageOne.FirstSection, true));
                }

                e.Result = _doc;

                #endregion
            }

            //如果有打勾則上傳電子報表
            if (PrintUpdateStudentFile)
            {
                SmartSchool.ePaper.DispatcherProvider.Dispatch(paperForStudent);
            }
        }
        private void LoadPreference()
        {
            #region 讀取 Preference

            //XmlElement config = CurrentUser.Instance.Preference["獎懲通知單"];
            Campus.Configuration.ConfigData cd = Campus.Configuration.Config.User[ConfigName一般設定];
            XmlElement config = cd.GetXml("XmlData", null);

            if (config != null)
            {
                _useDefaultTemplate = bool.Parse(config.GetAttribute("Default"));

                XmlElement customize        = (XmlElement)config.SelectSingleNode("CustomizeTemplate");
                XmlElement dateRangeMode    = (XmlElement)config.SelectSingleNode("DateRangeMode");
                XmlElement receive          = (XmlElement)config.SelectSingleNode("Receive");
                XmlElement conditions       = (XmlElement)config.SelectSingleNode("Conditions");
                XmlElement PrintStudentList = (XmlElement)config.SelectSingleNode("PrintStudentList");

                if (customize != null)
                {
                    string templateBase64 = customize.InnerText;
                    _buffer   = Convert.FromBase64String(templateBase64);
                    _template = new MemoryStream(_buffer);
                }

                //列印學生清單
                if (PrintStudentList != null)
                {
                    if (PrintStudentList.HasAttribute("Checked"))
                    {
                        _PrintStudentList = bool.Parse(PrintStudentList.GetAttribute("Checked"));
                    }
                }
                else
                {
                    XmlElement newPrintStudentList = config.OwnerDocument.CreateElement("PrintStudentList");
                    newPrintStudentList.SetAttribute("Checked", "False");
                    config.AppendChild(newPrintStudentList);
                    cd.SetXml("XmlData", config);
                }

                if (receive != null)
                {
                    _receiveName    = receive.GetAttribute("Name");
                    _receiveAddress = receive.GetAttribute("Address");
                }
                else
                {
                    XmlElement newReceive = config.OwnerDocument.CreateElement("Receive");
                    newReceive.SetAttribute("Name", "");
                    newReceive.SetAttribute("Address", "");
                    config.AppendChild(newReceive);
                    cd.SetXml("XmlData", config);
                    //CurrentUser.Instance.Preference["獎懲通知單"] = config;
                }

                if (conditions != null)
                {
                    if (conditions.HasAttribute("ConditionName") && conditions.HasAttribute("ConditionNumber"))
                    {
                        _conditionName   = conditions.GetAttribute("ConditionName");
                        _conditionNumber = conditions.GetAttribute("ConditionNumber");
                    }
                    else
                    {
                        _conditionName   = "大功";
                        _conditionNumber = "1";
                    }
                }
                else
                {
                    XmlElement newConditions = config.OwnerDocument.CreateElement("Conditions");
                    newConditions.SetAttribute("ConditionName", "");
                    newConditions.SetAttribute("ConditionNumber", "1");
                    config.AppendChild(newConditions);
                    cd.SetXml("XmlData", config);
                    //CurrentUser.Instance.Preference["獎懲通知單"] = config;
                }

                if (dateRangeMode != null)
                {
                    _mode = (DateRangeMode)int.Parse(dateRangeMode.InnerText);
                    if (_mode != DateRangeMode.Custom)
                    {
                        dateTimeInput2.Enabled = false;
                    }
                    else
                    {
                        dateTimeInput2.Enabled = true;
                    }
                }
                else
                {
                    XmlElement newDateRangeMode = config.OwnerDocument.CreateElement("DateRangeMode");
                    newDateRangeMode.InnerText = ((int)_mode).ToString();
                    config.AppendChild(newDateRangeMode);
                    cd.SetXml("XmlData", config);
                    //CurrentUser.Instance.Preference["獎懲通知單"] = config;
                }
            }
            else
            {
                #region 產生空白設定檔
                config = new XmlDocument().CreateElement("XmlData");
                config.SetAttribute("Default", "true");
                XmlElement customize        = config.OwnerDocument.CreateElement("CustomizeTemplate");
                XmlElement dateRangeMode    = config.OwnerDocument.CreateElement("DateRangeMode");
                XmlElement receive          = config.OwnerDocument.CreateElement("Receive");
                XmlElement conditions       = config.OwnerDocument.CreateElement("Conditions");
                XmlElement printStudentList = config.OwnerDocument.CreateElement("PrintStudentList");

                dateRangeMode.InnerText = ((int)_mode).ToString();
                receive.SetAttribute("Name", "");
                receive.SetAttribute("Address", "");
                conditions.SetAttribute("ConditionName", "");
                conditions.SetAttribute("ConditionNumber", "1");
                printStudentList.SetAttribute("Checked", "false");

                config.AppendChild(customize);
                config.AppendChild(dateRangeMode);
                config.AppendChild(receive);
                config.AppendChild(conditions);
                config.AppendChild(printStudentList);
                cd.SetXml("XmlData", config);
                //CurrentUser.Instance.Preference["獎懲通知單"] = config;

                _useDefaultTemplate = true;

                #endregion
            }

            cd.Save(); //儲存組態資料。

            #endregion

            _preferenceLoaded = true;
        }
コード例 #3
0
        private void LeaveConfigSetting_Load(object sender, EventArgs e)
        {
            Campus.Configuration.ConfigData absence1 = Campus.Configuration.Config.App["ischool.leave.config"];
            XElement xmlabs1;

            if (absence1.PreviousData != null)
            {
                xmlabs1 = XElement.Parse(absence1.PreviousData.OuterXml);
            }
            else
            {
                xmlabs1 = XElement.Parse("<Config />");
            }

            foreach (XElement abs in xmlabs1.Elements("AllowAbsence"))
            {
                _AbsenceWasAllow.Add(abs.Value, true);
            }

            //顯示「假別對照表」於 ComboBox。
            Campus.Configuration.ConfigData absence2 = Campus.Configuration.Config.App["假別對照表"];
            XElement xmlabs2 = XElement.Parse(absence2.PreviousData.OuterXml);

            foreach (XElement abs in xmlabs2.Elements("Absence"))
            {
                var item = listViewEx1.Items.Add(abs.Attribute("Name").Value);

                if (_AbsenceWasAllow.ContainsKey(abs.Attribute("Name").Value))
                {
                    item.Checked = true;
                }
                else
                {
                    item.Checked = false;
                }

                comboBoxEx1.Items.Add(abs.Attribute("Name").Value);
            }

            foreach (XElement abs in xmlabs1.Elements("AnnualAbsence"))
            {
                comboBoxEx1.Text = abs.Value;
            }


            foreach (XElement abs in xmlabs1.Elements("RequestSignTitle"))
            {
                _RequestSignTitleList.Add(abs.Value);
            }

            foreach (XElement abs in xmlabs1.Elements("AnnualSignTitle"))
            {
                _AnnualSignTitleList.Add(abs.Value);
            }
            {
                int index = 0;
                foreach (var textBox in new DevComponents.DotNetBar.Controls.TextBoxX[] { textBoxX1, textBoxX2, textBoxX3, textBoxX4, textBoxX5, textBoxX6 })
                {
                    if (_RequestSignTitleList.Count > index)
                    {
                        textBox.Text = _RequestSignTitleList[index];
                    }
                    index++;
                }
            }
            {
                int index = 0;
                foreach (var textBox in new DevComponents.DotNetBar.Controls.TextBoxX[] { textBoxX7, textBoxX8, textBoxX9, textBoxX10, textBoxX11 })
                {
                    if (_AnnualSignTitleList.Count > index)
                    {
                        textBox.Text = _AnnualSignTitleList[index];
                    }
                    index++;
                }
            }
        }
コード例 #4
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            #region 儲存 Preference
            Campus.Configuration.ConfigData cd = Campus.Configuration.Config.User[ConfigName一般設定];
            XmlElement config = cd.GetXml("XmlData", null);

            //XmlElement config = CurrentUser.Instance.Preference["獎懲通知單"];

            if (config == null)
            {
                config = new XmlDocument().CreateElement("XmlData");
            }

            config.SetAttribute("Default", _defaultTemplate.ToString());

            XmlElement customize        = config.OwnerDocument.CreateElement("CustomizeTemplate");
            XmlElement mode             = config.OwnerDocument.CreateElement("DateRangeMode");
            XmlElement receive          = config.OwnerDocument.CreateElement("Receive");
            XmlElement conditions       = config.OwnerDocument.CreateElement("Conditions");
            XmlElement PrintStudentList = config.OwnerDocument.CreateElement("PrintStudentList");

            PrintStudentList.SetAttribute("Checked", _printStudentList.ToString());
            config.ReplaceChild(PrintStudentList, config.SelectSingleNode("PrintStudentList"));

            if (_isUpload)
            {
                customize.InnerText = base64;
                config.ReplaceChild(customize, config.SelectSingleNode("CustomizeTemplate"));
            }

            mode.InnerText = ((int)_mode).ToString();
            config.ReplaceChild(mode, config.SelectSingleNode("DateRangeMode"));

            receive.SetAttribute("Name", ((DevComponents.Editors.ComboItem)comboBoxEx1.SelectedItem).Text);
            receive.SetAttribute("Address", ((DevComponents.Editors.ComboItem)comboBoxEx2.SelectedItem).Text);
            if (config.SelectSingleNode("Receive") == null)
            {
                config.AppendChild(receive);
            }
            else
            {
                config.ReplaceChild(receive, config.SelectSingleNode("Receive"));
            }

            conditions.SetAttribute("ConditionName", ((DevComponents.Editors.ComboItem)comboBoxEx3.SelectedItem).Text);
            conditions.SetAttribute("ConditionNumber", numericUpDown1.Value.ToString());
            if (config.SelectSingleNode("Conditions") == null)
            {
                config.AppendChild(conditions);
            }
            else
            {
                config.ReplaceChild(conditions, config.SelectSingleNode("Conditions"));
            }

            cd.SetXml("XmlData", config);
            cd.Save();

            //CurrentUser.Instance.Preference["獎懲通知單"] = config;

            #endregion

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
コード例 #5
0
        //儲存
        private void buttonX1_Click(object sender, EventArgs e)
        {
            _RequestSignTitleList.Clear();
            foreach (var textBox in new DevComponents.DotNetBar.Controls.TextBoxX[] { textBoxX1, textBoxX2, textBoxX3, textBoxX4, textBoxX5, textBoxX6 })
            {
                _RequestSignTitleList.Add(textBox.Text);
            }


            _AnnualSignTitleList.Clear();
            foreach (var textBox in new DevComponents.DotNetBar.Controls.TextBoxX[] { textBoxX7, textBoxX8, textBoxX9, textBoxX10, textBoxX11 })
            {
                _AnnualSignTitleList.Add(textBox.Text);
            }


            XmlDocument doc  = new XmlDocument();
            XmlElement  root = doc.CreateElement("Config");

            doc.AppendChild(root);

            foreach (ListViewItem item in listViewEx1.Items)
            {
                if (item.Checked)
                {
                    XmlElement AllowAbsence = doc.CreateElement("AllowAbsence");

                    AllowAbsence.InnerText = item.Text;

                    root.AppendChild(AllowAbsence);
                }
            }

            if (comboBoxEx1.Text != "")
            {
                XmlElement AnnualAbsence = doc.CreateElement("AnnualAbsence");
                AnnualAbsence.InnerText = comboBoxEx1.Text;
                root.AppendChild(AnnualAbsence);
            }

            foreach (string title in _RequestSignTitleList)
            {
                XmlElement RequestSignTitle = doc.CreateElement("RequestSignTitle");
                RequestSignTitle.InnerText = title;
                root.AppendChild(RequestSignTitle);
            }

            foreach (string title in _AnnualSignTitleList)
            {
                XmlElement AnnualSignTitle = doc.CreateElement("AnnualSignTitle");

                AnnualSignTitle.InnerText = title;

                root.AppendChild(AnnualSignTitle);
            }


            Campus.Configuration.ConfigData absence1 = Campus.Configuration.Config.App["ischool.leave.config"];
            if (absence1.PreviousData == null)
            {
                absence1.Save();
            }

            DSXmlHelper helper = new DSXmlHelper("Lists");

            helper.AddElement("List");
            helper.AddElement("List", "Content", root.OuterXml, true);
            helper.AddElement("List", "Condition");
            helper.AddElement("List/Condition", "Name", "ischool.leave.config");

            //儲存
            try
            {
                Framework.Feature.Config.Update(new DSRequest(helper));
            }
            catch (Exception exception)
            {
                FISCA.Presentation.Controls.MsgBox.Show("更新失敗 :" + exception.Message, "錯誤", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            FISCA.Presentation.Controls.MsgBox.Show("儲存成功!", "完成", MessageBoxButtons.OK, MessageBoxIcon.Information);

            //更新
            try
            {
                Campus.Configuration.Config.App.Sync("ischool.leave.config");
            }
            catch
            {
                FISCA.Presentation.Controls.MsgBox.Show("資料重設失敗,新設定值將於下次啟動系統後生效!", "失敗", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.Close();
        }