コード例 #1
0
        private void LoadConfiguration()
        {
            dgv.SuspendLayout();
            dgv.Rows.Clear();

            K12.Data.Configuration.ConfigData cd = K12.Data.School.Configuration[TitleName];
            if (cd.Contains("xml") && !string.IsNullOrEmpty(cd["xml"]))
            {
                XmlElement element = cd.GetXml("xml", XmlHelper.LoadXml("<SpecialEduDomainList/>"));
                foreach (XmlElement domainElement in element.SelectNodes("Domain"))
                {
                    DataGridViewRow row = new DataGridViewRow();
                    row.CreateCells(dgv, domainElement.InnerText);
                    dgv.Rows.Add(row);
                }
            }

            dgv.ResumeLayout();
        }
コード例 #2
0
        private void LoadPreference()
        {
            #region 讀取 Preference
            XmlElement config = SmartSchool.Customization.Data.SystemInformation.Preference[_ConfigValue2];
            if (config != null)
            {
                //列印資訊
                XmlElement print = (XmlElement)config.SelectSingleNode("Print");
                if (print != null)
                {
                    DSXmlHelper printHelper = new DSXmlHelper(print);
                    _print_cleared     = bool.Parse(printHelper.GetText("@IsPrintCleared"));
                    checkBoxX1.Checked = _print_cleared;
                }
                else
                {
                    XmlElement newPrint = config.OwnerDocument.CreateElement("Print");
                    newPrint.SetAttribute("IsPrintCleared", "False");
                    _print_cleared = false;
                    config.AppendChild(newPrint);
                    SmartSchool.Customization.Data.SystemInformation.Preference[_ConfigValue2] = config;
                }
            }
            else
            {
                #region 產生空白設定檔
                config = new XmlDocument().CreateElement(_ConfigValue2);
                SmartSchool.Customization.Data.SystemInformation.Preference[_ConfigValue2] = config;
                #endregion
            }

            //使用者設定的假別
            _print_types.Clear();

            K12.Data.Configuration.ConfigData Defconfig = K12.Data.School.Configuration[_ConfigValue2];

            XmlElement config_2;

            if (Defconfig.GetXml(_configDefName, null) == null)
            {
                config_2 = new XmlDocument().CreateElement(_configDefName);
                Defconfig[_configDefName] = config.OuterXml;
                Defconfig.Save();
            }
            else
            {
                config_2 = Defconfig.GetXml(_configDefName, null);

                foreach (XmlElement type in config_2.SelectNodes("Type"))
                {
                    string typeName = type.GetAttribute("Text");

                    if (!_print_types.ContainsKey(typeName))
                    {
                        _print_types.Add(typeName, new List <string>());
                    }

                    foreach (XmlElement absence in type.SelectNodes("Absence"))
                    {
                        string absenceName = absence.GetAttribute("Text");

                        if (!_print_types[typeName].Contains(absenceName))
                        {
                            _print_types[typeName].Add(absenceName);
                        }
                    }
                }
            }



            #endregion
        }
コード例 #3
0
        void _BGWAbsenceAndPeriodList_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            pictureBox1.Visible = false;

            System.Windows.Forms.DataGridViewTextBoxColumn colName = new DataGridViewTextBoxColumn();
            colName.HeaderText   = "節次分類";
            colName.MinimumWidth = 70;
            colName.Name         = "colName";
            colName.ReadOnly     = true;
            colName.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
            colName.Width        = 70;
            this.dataGridViewX1.Columns.Add(colName);

            foreach (string absence in absenceList)
            {
                System.Windows.Forms.DataGridViewCheckBoxColumn newCol = new DataGridViewCheckBoxColumn();
                newCol.HeaderText = absence;
                newCol.Width      = 55;
                newCol.ReadOnly   = false;
                newCol.SortMode   = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
                newCol.Tag        = absence;
                newCol.ValueType  = typeof(bool);
                this.dataGridViewX1.Columns.Add(newCol);
            }

            foreach (string type in typeList)
            {
                DataGridViewRow row = new DataGridViewRow();
                row.CreateCells(dataGridViewX1, type);
                row.Tag = type;
                dataGridViewX1.Rows.Add(row);
            }


            #region 讀取列印設定 Preference
            valueOnChange = true;

            K12.Data.Configuration.ConfigData Defconfig = K12.Data.School.Configuration[_preferenceElementName];

            XmlElement config;

            if (Defconfig.GetXml(_configDefName, null) == null)
            {
                config = new XmlDocument().CreateElement(_configDefName);
                Defconfig[_configDefName] = config.OuterXml;
                Defconfig.Save();
            }
            else
            {
                #region 已有設定檔則將設定檔內容填回畫面上

                config = Defconfig.GetXml(_configDefName, null);

                foreach (XmlElement type in config.SelectNodes("Type"))
                {
                    string typeName = type.GetAttribute("Text");
                    foreach (DataGridViewRow row in dataGridViewX1.Rows)
                    {
                        if (typeName == ("" + row.Tag))
                        {
                            foreach (XmlElement absence in type.SelectNodes("Absence"))
                            {
                                string absenceName = absence.GetAttribute("Text");
                                foreach (DataGridViewCell cell in row.Cells)
                                {
                                    if (cell.OwningColumn is DataGridViewCheckBoxColumn && ("" + cell.OwningColumn.Tag) == absenceName)
                                    {
                                        cell.Value = true;
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
                #endregion
            }

            valueOnChange = false;

            #endregion
        }
コード例 #4
0
        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (!CheckColumnNumber())
            {
                return;
            }

            #region 更新列印設定 Preference

            K12.Data.Configuration.ConfigData Defconfig = K12.Data.School.Configuration[_preferenceElementName];

            XmlElement config;

            if (Defconfig.GetXml(_configDefName, null) == null)
            {
                config = new XmlDocument().CreateElement(_configDefName);
            }
            else
            {
                config = Defconfig.GetXml(_configDefName, null);
            }

            config.RemoveAll();

            foreach (DataGridViewRow row in dataGridViewX1.Rows)
            {
                bool       needToAppend = false;
                XmlElement type         = config.OwnerDocument.CreateElement("Type");
                type.SetAttribute("Text", "" + row.Tag);
                foreach (DataGridViewCell cell in row.Cells)
                {
                    XmlElement absence = config.OwnerDocument.CreateElement("Absence");
                    absence.SetAttribute("Text", "" + cell.OwningColumn.Tag);
                    if (cell.Value is bool && ((bool)cell.Value))
                    {
                        needToAppend = true;
                        type.AppendChild(absence);
                    }
                }
                if (needToAppend)
                {
                    config.AppendChild(type);
                }
            }

            //foreach (TreeNode typeNode in treeView1.Nodes)
            //{
            //    XmlElement type = config.OwnerDocument.CreateElement("Type");
            //    type.SetAttribute("Text", typeNode.Text);
            //    type.SetAttribute("Checked", typeNode.Checked.ToString());

            //    foreach (TreeNode absenceNode in typeNode.Nodes)
            //    {
            //        if (absenceNode.Checked == true)
            //        {
            //            XmlElement absence = config.OwnerDocument.CreateElement("Absence");
            //            absence.SetAttribute("Text", absenceNode.Text);
            //            type.AppendChild(absence);
            //        }
            //    }
            //    config.AppendChild(type);
            //}

            Defconfig[_configDefName] = config.OuterXml;
            Defconfig.Save();

            #endregion

            this.DialogResult = DialogResult.OK;
        }