Exemplo n.º 1
0
 private void radioButton5_CheckedChanged(object sender, EventArgs e)
 {
     if (radioButton5.Checked)
     {
         radioButton3.Checked = false;
         radioButton4.Checked = false;
         _mode = DateRangeMode.Custom;
     }
 }
        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;
        }
Exemplo n.º 3
0
        public AbsenceNotificationConfigForm(bool defaultTemplate, bool printHasRecordOnly, DateRangeMode mode, byte[] buffer, string name, string address, string conditionName, string conditionNumber, string conditionName2, string conditionNumber2, bool printStudentList)
        {
            InitializeComponent();
            #region 如果系統的Renderer是Office2007Renderer,同化_ClassTeacherView,_CategoryView的顏色
            if (GlobalManager.Renderer is Office2007Renderer)
            {
                ((Office2007Renderer)GlobalManager.Renderer).ColorTableChanged += new EventHandler(ScoreCalcRuleEditor_ColorTableChanged);
                SetForeColor(this);
            }
            #endregion
            _defaultTemplate    = defaultTemplate;
            _printHasRecordOnly = printHasRecordOnly;
            _mode             = mode;
            _printStudentList = printStudentList;

            if (buffer != null)
            {
                _buffer = buffer;
            }

            if (defaultTemplate)
            {
                radioButton1.Checked = true;
            }
            else
            {
                radioButton2.Checked = true;
            }

            checkBoxX1.Checked = printHasRecordOnly;
            checkBoxX2.Checked = printStudentList;

            switch (mode)
            {
            case DateRangeMode.Month:
                radioButton3.Checked = true;
                break;

            case DateRangeMode.Week:
                radioButton4.Checked = true;
                break;

            case DateRangeMode.Custom:
                radioButton5.Checked = true;
                break;

            default:
                throw new Exception("Date Range Mode Error.");
            }

            comboBoxEx1.SelectedIndex = 0;
            comboBoxEx2.SelectedIndex = 0;

            foreach (DevComponents.Editors.ComboItem var in comboBoxEx1.Items)
            {
                if (var.Text == name)
                {
                    comboBoxEx1.SelectedIndex = comboBoxEx1.Items.IndexOf(var);
                    break;
                }
            }

            foreach (DevComponents.Editors.ComboItem var in comboBoxEx2.Items)
            {
                if (var.Text == address)
                {
                    comboBoxEx2.SelectedIndex = comboBoxEx2.Items.IndexOf(var);
                    break;
                }
            }
            decimal tryValue;
            numericUpDown1.Value = (decimal.TryParse(conditionNumber, out tryValue)) ? tryValue : 0;

            numericUpDown2.Value = (decimal.TryParse(conditionNumber2, out tryValue)) ? tryValue : 0;

            GetAbsenceConfig();                        //取得缺曠別

            foreach (string each in comboBoxEx3.Items) //將畫面設定為前次設定值
            {
                if (each == conditionName)
                {
                    comboBoxEx3.SelectedItem = each;
                }
            }
            foreach (string each in comboBoxEx4.Items) //將畫面設定為前次設定值
            {
                if (each == conditionName2)
                {
                    comboBoxEx4.SelectedItem = each;
                }
            }
        }
Exemplo n.º 4
0
        public DisciplineNotificationConfigForm(bool defaultTemplate, DateRangeMode mode, byte[] buffer, string name, string address, string condName, string condNumber, bool printStudentList)
        {
            InitializeComponent();
            #region 如果系統的Renderer是Office2007Renderer,同化_ClassTeacherView,_CategoryView的顏色
            if (GlobalManager.Renderer is Office2007Renderer)
            {
                ((Office2007Renderer)GlobalManager.Renderer).ColorTableChanged += new EventHandler(ScoreCalcRuleEditor_ColorTableChanged);
                SetForeColor(this);
            }
            #endregion
            _defaultTemplate  = defaultTemplate;
            _mode             = mode;
            _printStudentList = printStudentList;

            if (buffer != null)
            {
                _buffer = buffer;
            }

            if (defaultTemplate)
            {
                radioButton1.Checked = true;
            }
            else
            {
                radioButton2.Checked = true;
            }

            checkBoxX2.Checked = printStudentList;

            switch (mode)
            {
            case DateRangeMode.Month:
                radioButton3.Checked = true;
                break;

            case DateRangeMode.Week:
                radioButton4.Checked = true;
                break;

            case DateRangeMode.Custom:
                radioButton5.Checked = true;
                break;

            default:
                throw new Exception("Date Range Mode Error.");
            }

            //設定 ComboBox
            Dictionary <ComboBoxEx, string> cboBoxes = new Dictionary <ComboBoxEx, string>();
            cboBoxes.Add(comboBoxEx1, name);
            cboBoxes.Add(comboBoxEx2, address);
            cboBoxes.Add(comboBoxEx3, condName);

            foreach (ComboBoxEx var in cboBoxes.Keys)
            {
                var.SelectedIndex = 0;
                foreach (DevComponents.Editors.ComboItem item in var.Items)
                {
                    if (item.Text == cboBoxes[var])
                    {
                        var.SelectedIndex = var.Items.IndexOf(item);
                        break;
                    }
                }
            }

            //設定 NumericUpDown
            decimal tryValue = 1;
            if (condNumber == "0")
            {
                condNumber = "1";
            }
            numericUpDown1.Value = (decimal.TryParse(condNumber, out tryValue)) ? tryValue : 1;
        }