/// <summary> /// 載入節次列表 /// </summary> private void LoadPeriodList() { mSelectedCommonPeriods.Clear(); mSelectedOtherPeriods.Clear(); #region 取得所有節次清單,若是有儲存設定則加入儲存設定,否則加入所有節次到一般統計 Campus.Configuration.ConfigData configPeriod = Campus.Configuration.Config.User["請假代課統計表"]; string PeriodOption = configPeriod["PeriodOption"]; if (!string.IsNullOrWhiteSpace(PeriodOption)) { XElement Element = XElement.Load(new StringReader(PeriodOption)); foreach (XElement elmPeriodOption in Element.Elements("PeriodOption")) { PeriodOption vPeriodOption = new PeriodOption(elmPeriodOption); if (vPeriodOption.Checked) { if (vPeriodOption.Type.Equals("一般")) mSelectedCommonPeriods.Add(vPeriodOption.Period); else if (vPeriodOption.Type.Equals("其他")) mSelectedOtherPeriods.Add(vPeriodOption.Period); } } } else { List<string> PeriodList = Calendar.Instance.GetPeriodList(); mSelectedCommonPeriods.AddRange(PeriodList); } #endregion }
private void frmExchangeReplaceSatTemplateConfig_Load(object sender, EventArgs e) { //取得設定 Campus.Configuration.ConfigData config = Campus.Configuration.Config.User["請假代課統計表"]; if (config != null) { #region 取得樣版,及是否使用自訂樣版 int _useTemplateNumber = 0; int.TryParse(config["TemplateNumber"], out _useTemplateNumber); string customize = config["CustomizeTemplate"]; _buffer = Resources.請假代課統計表; if (!string.IsNullOrEmpty(customize)) _buffer = Convert.FromBase64String(customize); _base64string = Convert.ToBase64String(_buffer); switch (_useTemplateNumber) { case 0: chkDefault.Checked = true; break; case 1: chkCustom.Checked = true; break; default: break; } #endregion #region 取得節次設定 List<string> PeriodList = Calendar.Instance.GetPeriodList(); SortedDictionary<string, PeriodOption> PeriodOptions = new SortedDictionary<string, PeriodOption>(); string PeriodOption = config["PeriodOption"]; if (!string.IsNullOrWhiteSpace(PeriodOption)) { XElement Element = XElement.Load(new StringReader(PeriodOption)); foreach (XElement elmPeriodOption in Element.Elements("PeriodOption")) { PeriodOption vPeriodOption = new PeriodOption(elmPeriodOption); PeriodOptions.Add(vPeriodOption.Period, vPeriodOption); } } foreach (string Period in PeriodList) { if (!PeriodOptions.ContainsKey(Period)) { PeriodOption Option = new PeriodOption(); Option.Checked = false; Option.Period = Period; Option.Type = "一般"; PeriodOptions.Add(Option.Period, Option); } } foreach (PeriodOption vPeriodOption in PeriodOptions.Values) { int RowIndex = grdPeriod.Rows.Add(); grdPeriod.Rows[RowIndex].SetValues(vPeriodOption.Checked, vPeriodOption.Period, vPeriodOption.Type); } #endregion } }