public DataTable MakingFinanceStat(string templateName, string grade, string className, DateTime date, out ArrayList list) { list = new ArrayList(); try { using (DataTable dtStudentPresents = new FinanInfoDataAccess().GetStudentPresents(date, className)) { if (dtStudentPresents != null && dtStudentPresents.Rows.Count > 0) { DataTable dtFilterTemplateContents = FilterTemplateContents(templateName, grade, className); DataTable dtBuilded = BuildingFinanceStat(dtFilterTemplateContents); foreach (DataRow dr in dtStudentPresents.Rows) { DataRow newRow = dtBuilded.NewRow(); int index = 3; foreach(DataRow drContents in dtFilterTemplateContents.Rows) { TemplateContentsRecordSet contents = new TemplateContentsRecordSet(drContents["name"].ToString(), drContents["fullDays"].ToString(), drContents["fullDaysSpend"].ToString(), drContents["halfDaysSpend"].ToString(), drContents["perDaySpend"].ToString(), drContents["noSpendMonth"].ToString(), drContents["halfSpendMonth"].ToString(), drContents["grade"].ToString(), drContents["class"].ToString()); newRow[0] = dr["学号"]; newRow[1] = dr["姓名"]; newRow[2] = dr["班级"]; if (contents.Grade == "不选择" || Regex.Match(contents.Grade + contents.ClassName, string.Format("^{2}{0}|{2}{1}$", className, "不选择", grade)).Success) { if (!contents.FullDays.Equals("-")) { if (!contents.FullDaysSpend.Equals("-")) { int fullDays = Convert.ToInt32(contents.FullDays); int presentDays = Convert.ToInt32(dr["times"]); if (presentDays >= fullDays) { newRow[index] = contents.FullDaysSpend; } else { if (!contents.HalfDaysSpend.Equals("-")) { newRow[index] = contents.HalfDaysSpend; } else { if (!contents.PerDaySpend.Equals("-")) { double perDaySpend = Convert.ToDouble(contents.PerDaySpend); newRow[index] = Convert.ToInt32(dr["times"]) * perDaySpend; } else { newRow[index] = 0; } } } } else { if (!contents.PerDaySpend.Equals("-")) { double perDaySpend = Convert.ToDouble(contents.PerDaySpend); newRow[index] = Convert.ToInt32(dr["times"]) * perDaySpend; } else { newRow[index] = 0; } } } else { if (!contents.PerDaySpend.Equals("-")) { double perDaySpend = Convert.ToDouble(contents.PerDaySpend); newRow[index] = Convert.ToInt32(dr["times"]) * perDaySpend; } else { newRow[index] = 0; } } if (!contents.NoSpendMonth.Equals("-")) { string month = date.Month.ToString(); string pattern = string.Format(@"^{0}$", contents.NoSpendMonth.Replace(",", "|")); if (Convert.ToInt32(dr["times"]) == 0) { newRow[index] = Regex.Match(month, pattern).Success ? 0 : newRow[index]; } } if (!contents.HalfSpendMonth.Equals("-")) { string month = date.Month.ToString(); string pattern = string.Format(@"^{0}$", contents.HalfSpendMonth.Replace(",", "|")); newRow[index] = Regex.Match(month, pattern).Success ? Convert.ToDouble(newRow[index]) / 2 : newRow[index]; } } else { if (!list.Contains(contents.ColumnName)) { list.Add(contents.ColumnName); } newRow[index] = 0; } index++; } dtBuilded.Rows.Add(newRow); } return dtBuilded; } else { return null; } } } catch(Exception ex) { Util.WriteLog(ex.Message, Util.EXCEPTION_LOG_TITLE); return null; } }
public DataTable MakingFinanceStat(string templateName, string grade, string className, DateTime date, out ArrayList list) { list = new ArrayList(); try { using (DataTable dtStudentPresents = new FinanInfoDataAccess().GetStudentPresents(date, className)) { if (dtStudentPresents != null && dtStudentPresents.Rows.Count > 0) { DataTable dtFilterTemplateContents = FilterTemplateContents(templateName, grade, className); DataTable dtBuilded = BuildingFinanceStat(dtFilterTemplateContents); foreach (DataRow dr in dtStudentPresents.Rows) { DataRow newRow = dtBuilded.NewRow(); int index = 3; foreach (DataRow drContents in dtFilterTemplateContents.Rows) { TemplateContentsRecordSet contents = new TemplateContentsRecordSet(drContents["name"].ToString(), drContents["fullDays"].ToString(), drContents["fullDaysSpend"].ToString(), drContents["halfDaysSpend"].ToString(), drContents["perDaySpend"].ToString(), drContents["noSpendMonth"].ToString(), drContents["halfSpendMonth"].ToString(), drContents["grade"].ToString(), drContents["class"].ToString()); newRow[0] = dr["学号"]; newRow[1] = dr["姓名"]; newRow[2] = dr["班级"]; if (contents.Grade == "不选择" || Regex.Match(contents.Grade + contents.ClassName, string.Format("^{2}{0}|{2}{1}$", className, "不选择", grade)).Success) { if (!contents.FullDays.Equals("-")) { if (!contents.FullDaysSpend.Equals("-")) { int fullDays = Convert.ToInt32(contents.FullDays); int presentDays = Convert.ToInt32(dr["times"]); if (presentDays >= fullDays) { newRow[index] = contents.FullDaysSpend; } else { if (!contents.HalfDaysSpend.Equals("-")) { newRow[index] = contents.HalfDaysSpend; } else { if (!contents.PerDaySpend.Equals("-")) { double perDaySpend = Convert.ToDouble(contents.PerDaySpend); newRow[index] = Convert.ToInt32(dr["times"]) * perDaySpend; } else { newRow[index] = 0; } } } } else { if (!contents.PerDaySpend.Equals("-")) { double perDaySpend = Convert.ToDouble(contents.PerDaySpend); newRow[index] = Convert.ToInt32(dr["times"]) * perDaySpend; } else { newRow[index] = 0; } } } else { if (!contents.PerDaySpend.Equals("-")) { double perDaySpend = Convert.ToDouble(contents.PerDaySpend); newRow[index] = Convert.ToInt32(dr["times"]) * perDaySpend; } else { newRow[index] = 0; } } if (!contents.NoSpendMonth.Equals("-")) { string month = date.Month.ToString(); string pattern = string.Format(@"^{0}$", contents.NoSpendMonth.Replace(",", "|")); if (Convert.ToInt32(dr["times"]) == 0) { newRow[index] = Regex.Match(month, pattern).Success ? 0 : newRow[index]; } } if (!contents.HalfSpendMonth.Equals("-")) { string month = date.Month.ToString(); string pattern = string.Format(@"^{0}$", contents.HalfSpendMonth.Replace(",", "|")); newRow[index] = Regex.Match(month, pattern).Success ? Convert.ToDouble(newRow[index]) / 2 : newRow[index]; } } else { if (!list.Contains(contents.ColumnName)) { list.Add(contents.ColumnName); } newRow[index] = 0; } index++; } dtBuilded.Rows.Add(newRow); } return(dtBuilded); } else { return(null); } } } catch (Exception ex) { Util.WriteLog(ex.Message, Util.EXCEPTION_LOG_TITLE); return(null); } }