private void radioButton5_CheckedChanged(object sender, EventArgs e) { if (radioButton5.Checked) { _mode = DateRangeModeNew.Custom; } }
private void radioButton4_CheckedChanged(object sender, EventArgs e) { if (radioButton4.Checked) { _mode = DateRangeModeNew.Week; } }
private void radioButton3_CheckedChanged(object sender, EventArgs e) { if (radioButton3.Checked) { _mode = DateRangeModeNew.Month; } }
public DemeritConfigForm(string defaultTemplate, DateRangeModeNew mode, byte[] buffer, string name, string address, bool printStudentList) { InitializeComponent(); //如果系統的Renderer是Office2007Renderer //同化_ClassTeacherView,_CategoryView的顏色 if (GlobalManager.Renderer is Office2007Renderer) { ((Office2007Renderer)GlobalManager.Renderer).ColorTableChanged += new EventHandler(ScoreCalcRuleEditor_ColorTableChanged); SetForeColor(this); } _defaultTemplate = defaultTemplate; _mode = mode; _printStudentList = printStudentList; if (buffer != null) { _buffer = buffer; } if (defaultTemplate == "預設範本2") //如果是2才設為2 { rbDEF_2.Checked = true; } else if (defaultTemplate == "自訂範本") //如果是自訂 { radioButton2.Checked = true; } else { rbDEF_1.Checked = true; //如果都不是就進入預設1 } checkBoxX2.Checked = printStudentList; switch (mode) { case DateRangeModeNew.Month: radioButton3.Checked = true; break; case DateRangeModeNew.Week: radioButton4.Checked = true; break; case DateRangeModeNew.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); 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; } } } }
private void LoadPreference() { #region 讀取 Preference //XmlElement config = CurrentUser.Instance.Preference["懲戒通知單"]; ConfigData cd = K12.Data.School.Configuration["留察通知單_ForSH"]; XmlElement config = cd.GetXml("XmlData", null); if (config != null) { _useDefaultTemplate = 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 (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 (customize != null) { string templateBase64 = customize.InnerText; _buffer = Convert.FromBase64String(templateBase64); _template = new MemoryStream(_buffer); } 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); } 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); } if (dateRangeMode != null) { _mode = (DateRangeModeNew)int.Parse(dateRangeMode.InnerText); if (_mode != DateRangeModeNew.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); } } else { #region 產生空白設定檔 config = new XmlDocument().CreateElement("懲戒通知單"); config.SetAttribute("Default", "預設範本1"); 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 = "預設範本1"; //_printHasRecordOnly = true; _PrintStudentList = false; #endregion } cd.Save(); //儲存組態資料。 #endregion //_preferenceLoaded = true; }