private void ShowData(DataTable dataTable, string period) { mTable = new DataTable(); mTable.Columns.Add(new DataColumn("일자", typeof(string))); mTable.Columns.Add(new DataColumn("체크박스", typeof(CheckBox))); mTable.Columns.Add(new DataColumn("학년", typeof(string))); mTable.Columns.Add(new DataColumn("반", typeof(string))); mTable.Columns.Add(new DataColumn("번호", typeof(string))); mTable.Columns.Add(new DataColumn("성명", typeof(string))); mTable.Columns.Add(new DataColumn("출석상태", typeof(string))); foreach (DataRow row in dataTable.Rows) { DataRow newRow = mTable.NewRow(); newRow["체크박스"] = new CheckBox(); newRow["학년"] = row["학년"].ToString(); newRow["반"] = row["반"].ToString(); newRow["번호"] = row["번호"].ToString(); newRow["성명"] = row["성명"].ToString(); AttEnum attendance = (AttEnum)row[$"{period}교시"]; newRow["출석상태"] = AttToStrDict[attendance]; newRow["일자"] = ((DateTime)row["일자"]).ToShortDateString(); mTable.Rows.Add(newRow); } MainDataGrid.DataContext = mTable; mOriginal = mTable.Copy(); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { try { string text = value.ToString(); AttEnum att = AttEnum.NoData; if (StrToAttDict.Keys.Contains(text)) { att = StrToAttDict[text]; } if (att != AttEnum.NoData && att != AttEnum.Attended) { return("Bold"); } else { return("Regular"); } } catch { return(DependencyProperty.UnsetValue); } }
public void Add(AttEnum att) { if (mAttEnums.Count >= 9) { throw new InvalidOperationException("AttOfDay에는 0교시부터 8교시 즉, 9개의 AttEnum만 추가할 수 있습니다."); } mAttEnums.Add(att); }
private void ProcessAndShowData(DataTable attData) { mTable = new DataTable(); mTable.Columns.Add(new DataColumn("일자", typeof(string))); mTable.Columns.Add(new DataColumn("체크박스", typeof(CheckBox))); mTable.Columns.Add(new DataColumn("학년", typeof(string))); mTable.Columns.Add(new DataColumn("반", typeof(string))); mTable.Columns.Add(new DataColumn("번호", typeof(string))); mTable.Columns.Add(new DataColumn("성명", typeof(string))); mTable.Columns.Add(new DataColumn("해당사항", typeof(string))); mTable.Columns.Add(new DataColumn("벌점", typeof(string))); if (attData != null) { foreach (DataRow row in attData.Rows) { AttOfDay attOfDay = new AttOfDay((DateTime)row["일자"]); for (int period = 0; period <= 8; ++period) { AttEnum attEnum = (AttEnum)row[$"{period}교시"]; attOfDay.Add(attEnum); } if (attOfDay.HasFaults) { DataRow newRow = mTable.NewRow(); newRow["일자"] = ((DateTime)row["일자"]).ToShortDateString(); newRow["체크박스"] = new CheckBox(); newRow["학년"] = row["학년"].ToString(); newRow["반"] = row["반"].ToString(); newRow["번호"] = row["번호"].ToString(); newRow["성명"] = row["성명"].ToString(); newRow["해당사항"] = attOfDay.Description; newRow["벌점"] = attOfDay.PenaltyPoints.ToString(); mTable.Rows.Add(newRow); } } } if (mTable.Rows.Count == 0) { DataRow newRow = mTable.NewRow(); newRow["해당사항"] = "근태 불량자 없음"; mTable.Rows.Add(newRow); } MainDataGrid.DataContext = mTable; mOriginal = mTable.Copy(); }
private void ShowFaultsList(DataTable attTable) { mFaultsTable = new DataTable(); mFaultsTable.Columns.Add(new DataColumn("구분", typeof(string))); mFaultsTable.Columns.Add(new DataColumn("일자", typeof(string))); mFaultsTable.Columns.Add(new DataColumn("해당사항", typeof(string))); mFaultsTable.Columns.Add(new DataColumn("벌점", typeof(int))); int penaltySum = 0; foreach (DataRow row in attTable.Rows) { AttOfDay attOfDay = new AttOfDay((DateTime)row["일자"]); for (int period = 0; period <= 8; ++period) { AttEnum attEnum = (AttEnum)row[$"{period}교시"]; attOfDay.Add(attEnum); } if (attOfDay.HasFaults) { DataRow newRow = mFaultsTable.NewRow(); int penalty = attOfDay.PenaltyPoints; newRow["구분"] = "벌점"; newRow["일자"] = ((DateTime)row["일자"]).ToShortDateString(); newRow["해당사항"] = attOfDay.Description; newRow["벌점"] = penalty; mFaultsTable.Rows.Add(newRow); penaltySum += penalty; } } if (penaltySum > 0) { DataRow sumRow = mFaultsTable.NewRow(); sumRow["구분"] = "합계"; sumRow["벌점"] = penaltySum; mFaultsTable.Rows.Add(sumRow); } else { DataRow row = mFaultsTable.NewRow(); row["해당사항"] = "근태 불량 사항 없음"; mFaultsTable.Rows.Add(row); } FaultsDataGrid.DataContext = mFaultsTable; }
private void ImportData(DataTable attdata) { if (mStudents == null) { mStudents = new ObservableCollection <StudentInfo>(); } else { mStudents.Clear(); } if (mFaultsDict == null) { mFaultsDict = new Dictionary <StudentInfo, List <AttOfDay> >(); } else { mFaultsDict.Clear(); } foreach (DataRow row in attdata.Rows) { AttOfDay attOfDay = new AttOfDay((DateTime)row["일자"]); StudentInfo si = new StudentInfo(row["학년"].ToString(), row["반"].ToString(), row["번호"].ToString(), row["성명"].ToString()); for (int period = 0; period <= 8; ++period) { AttEnum attEnum = (AttEnum)row[$"{period}교시"]; attOfDay.Add(attEnum); } if (mStudents.Contains(si)) { mFaultsDict[si].Add(attOfDay); } else { mStudents.Add(si); mFaultsDict.Add(si, new List <AttOfDay>() { attOfDay }); } } mStudents = new ObservableCollection <StudentInfo>(mStudents.OrderBy(k => k)); }
private void ProcessData(DataTable dataToProcess) { mStuPenaltyList = new List <StuAndPenalty>(); foreach (DataRow row in dataToProcess.Rows) { AttOfDay attOfDay = new AttOfDay((DateTime)row["일자"]); for (int period = 0; period <= 8; ++period) { AttEnum attEnum = (AttEnum)row[$"{period}교시"]; attOfDay.Add(attEnum); } if (attOfDay.HasFaults) { StuAndPenalty sap = null; for (int i = 0; i < mStuPenaltyList.Count; ++i) { if (mStuPenaltyList[i].Name == row["성명"].ToString()) { sap = mStuPenaltyList[i]; break; } } if (sap == null) { sap = new StuAndPenalty(row["학년"].ToString(), row["반"].ToString(), row["번호"].ToString(), row["성명"].ToString(), attOfDay.PenaltyPoints); mStuPenaltyList.Add(sap); } else { sap.Penalty += attOfDay.PenaltyPoints; } } } }