public MoralWriter() { _types = new Dictionary <string, List <string> >(); _rc = new ReportConfiguration(Global.ReportName); if (_rc.Contains("假別設定")) { XmlElement config = K12.Data.XmlHelper.LoadXml(_rc.GetString("假別設定", "<假別設定/>")); foreach (XmlElement type in config.SelectNodes("Type")) { string typeName = type.GetAttribute("Text"); foreach (XmlElement absence in type.SelectNodes("Absence")) { string absenceName = absence.GetAttribute("Text"); if (!_types.ContainsKey(typeName)) { _types.Add(typeName, new List <string>()); } _types[typeName].Add(absenceName); } } } }
private void _BGWAbsenceAndPeriodList_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) { pictureBox.Visible = false; 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.dgv.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.dgv.Columns.Add(newCol); } foreach (string type in typeList) { DataGridViewRow row = new DataGridViewRow(); row.CreateCells(dgv, type); row.Tag = type; dgv.Rows.Add(row); } #region 讀取列印設定 Preference if (rc.Contains("假別設定")) { XmlElement config = K12.Data.XmlHelper.LoadXml(rc.GetString("假別設定", "<假別設定/>")); #region 已有設定檔則將設定檔內容填回畫面上 foreach (XmlElement type in config.SelectNodes("Type")) { string typeName = type.GetAttribute("Text"); foreach (DataGridViewRow row in dgv.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 } #endregion }