//1':14" public DataTable GetAllTimeOfEachClass(DataTable sortedDT, int Leniency) { DataTable DT3 = new DataTable(); DT3.Columns.Add("LOGIN", typeof(string)); DT3.Columns.Add("TeacherName", typeof(string)); // DT3.Columns.Add("code", typeof(string)); DT3.Columns.Add("code", typeof(int)); DT3.Columns.Add("LessonName", typeof(string)); DT3.Columns.Add("SumOfTime", typeof(string)); DT3.Columns.Add("TimeClass", typeof(string)); DT3.Columns.Add("SessionCount", typeof(string)); DT3.Columns.Add("Hozoor", typeof(string)); DT3.Columns.Add("Leniency", typeof(string)); DT3.Columns.Add("tterm", typeof(string)); DT3.Columns.Add("namedanesh", typeof(string)); DT3.Columns.Add("v_nazari", typeof(string)); DT3.Columns.Add("mahal_klas", typeof(string)); TimeOfEachClass TimeOfEachClass_ = new TimeOfEachClass(); TimeOfEachClass_.SumOfTime = 0; string Code = ""; string ScoID = ""; long TotalTime = 0; long TotalClassTime = 0; for (int i = 0; i < sortedDT.Rows.Count; i++) { //if (sortedDT.Rows[i]["code"].ToString() == "1610") //{ if (Code != sortedDT.Rows[i]["code"].ToString()) { if (i > 0) { DataRow row = DT3.NewRow(); row["LOGIN"] = TimeOfEachClass_.LOGIN; row["TeacherName"] = TimeOfEachClass_.TeacherName; row["code"] = TimeOfEachClass_.codeInt; row["LessonName"] = TimeOfEachClass_.LessonName; row["SumOfTime"] = TotalTime.ToString(); row["TimeClass"] = TotalClassTime.ToString(); row["SessionCount"] = TimeOfEachClass_.SessionCount.ToString(); row["Hozoor"] = TimeOfEachClass_.Hozoor.ToString(); row["Leniency"] = Leniency.ToString(); row["tterm"] = TimeOfEachClass_.tterm; row["namedanesh"] = TimeOfEachClass_.Department; row["mahal_klas"] = TimeOfEachClass_.mahalKlas; DT3.Rows.Add(row); TotalTime = 0; TotalClassTime = 0; } TimeOfEachClass_.LOGIN = sortedDT.Rows[i]["LOGIN"].ToString(); TimeOfEachClass_.TeacherName = sortedDT.Rows[i]["TeacherName"].ToString(); // TimeOfEachClass_.code = sortedDT.Rows[i]["code"].ToString(); TimeOfEachClass_.codeInt = int.Parse(sortedDT.Rows[i]["code"].ToString()); TimeOfEachClass_.LessonName = sortedDT.Rows[i]["LessonName"].ToString(); TimeOfEachClass_.mahalKlas = sortedDT.Rows[i]["mahal_klas"].ToString(); if (sortedDT.Rows[i]["SumOfTime"].ToString() != "") { TimeOfEachClass_.SumOfTime = int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); } else { TimeOfEachClass_.SumOfTime = 0; } if (sortedDT.Rows[i]["TimeClass"].ToString() == "") { TimeOfEachClass_.TimeClass = 0; } else { TimeOfEachClass_.TimeClass = int.Parse(sortedDT.Rows[i]["TimeClass"].ToString()); } TimeOfEachClass_.tterm = sortedDT.Rows[i]["tterm"].ToString(); TimeOfEachClass_.Department = sortedDT.Rows[i]["namedanesh"].ToString(); TimeOfEachClass_.SessionCount = 1; if ((TimeOfEachClass_.SumOfTime + (Leniency * int.Parse(sortedDT.Rows[i]["v_nazari"].ToString()))) - TimeOfEachClass_.TimeClass >= 0) { TimeOfEachClass_.Hozoor = 1; } else { TimeOfEachClass_.Hozoor = 0; } TotalTime = TotalTime + TimeOfEachClass_.SumOfTime; TotalClassTime = TotalClassTime + TimeOfEachClass_.TimeClass; Code = TimeOfEachClass_.codeInt.ToString(); ScoID = TimeOfEachClass_.SCO_ID; } //-------------------- else if ( !(sortedDT.Rows[i]["code"].ToString() == sortedDT.Rows[i - 1]["code"].ToString() && sortedDT.Rows[i]["PersianDate"].ToString() == sortedDT.Rows[i - 1]["PersianDate"].ToString() && sortedDT.Rows[i]["FirstLogin"].ToString() == sortedDT.Rows[i - 1]["FirstLogin"].ToString() && sortedDT.Rows[i]["LastLogOut"].ToString() == sortedDT.Rows[i - 1]["LastLogOut"].ToString() ) || (sortedDT.Rows[i]["code"].ToString() == sortedDT.Rows[i - 1]["code"].ToString() && sortedDT.Rows[i]["SCO_ID"].ToString() != sortedDT.Rows[i - 1]["SCO_ID"].ToString() && sortedDT.Rows[i]["PersianDate"].ToString() == sortedDT.Rows[i - 1]["PersianDate"].ToString() ) ) { if (sortedDT.Rows[i]["SumOfTime"].ToString() == "") { TimeOfEachClass_.SumOfTime = 0; } else { TimeOfEachClass_.SumOfTime = int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); } if (sortedDT.Rows[i]["TimeClass"].ToString() == "") { TimeOfEachClass_.TimeClass = 0; } else { TimeOfEachClass_.TimeClass = int.Parse(sortedDT.Rows[i]["TimeClass"].ToString()); } TimeOfEachClass_.SessionCount = TimeOfEachClass_.SessionCount + 1; if ((TimeOfEachClass_.SumOfTime + (Leniency * int.Parse(sortedDT.Rows[i]["v_nazari"].ToString()))) - TimeOfEachClass_.TimeClass >= 0) { TimeOfEachClass_.Hozoor = TimeOfEachClass_.Hozoor + 1; } // اضافه کرن مجموع زمان حضور TotalTime = TotalTime + TimeOfEachClass_.SumOfTime; // اضافه کردن مجموع زمان کلاس TotalClassTime = TotalClassTime + TimeOfEachClass_.TimeClass; TimeOfEachClass_.SumOfTime = int.Parse(TotalTime.ToString()); TimeOfEachClass_.TimeClass = int.Parse(TotalClassTime.ToString()); } //} } return(DT3); }
public DataTable TotalTimeResult(string Stcode, DateTime TermTimeStart, DateTime TermTimeEnd, string tterm) { DataTable DT1=new DataTable(); DataTable DT2 = new DataTable(); if (tterm == "93-94-1") { DT1 = GetTotalTime_Old(Stcode, TermTimeStart, TermTimeEnd); DT2 = GetTotalTime(Stcode, TermTimeStart, TermTimeEnd); foreach (DataRow item in DT2.Rows) DT1.Rows.Add(item.ItemArray); } if (tterm == "93-94-2") { DateTime Start = new DateTime(2015, 02, 01); DateTime End = new DateTime(2015, 08, 22); DT1 = spDAO.GetTotalTime(Stcode, Start, End, tterm); } if (tterm == "93-94-3") { DateTime Start = new DateTime(2015, 07, 01); DateTime End = new DateTime(2015, 09, 22); DT1 = spDAO.GetTotalTime(Stcode, Start, End, tterm); } if (tterm == "94-95-1") { DT1 = spDAO.GetTotalTime(Stcode, TermTimeStart, TermTimeEnd, tterm); } if (tterm == "94-95-2") { DT1 = spDAO.GetTotalTime(Stcode, TermTimeStart, TermTimeEnd, tterm); } //else // DT1 = GetTotalTime93942(Stcode); //DataTable DT10 = GetStudentClassInfoByTerm(tterm,Stcode); DataTable DT11 = new DataTable(); DT11.Columns.Add("LOGIN", typeof(string)); DT11.Columns.Add("StudentName", typeof(string)); DT11.Columns.Add("LessonName", typeof(string)); // DT11.Columns.Add("PersianDate", typeof(string)); DT11.Columns.Add("SumOfTime", typeof(string)); // DT11.Columns.Add("PRINCIPAL_ID", typeof(string)); DT11.Columns.Add("code", typeof(int)); DT11.Columns.Add("TeacherName", typeof(string)); DT11.Columns.Add("tterm", typeof(string)); //for (int i = 0; i < DT10.Rows.Count; i++) //{ for (int j = 0; j < DT1.Rows.Count; j++) { //if (DT10.Rows[i]["Code"].ToString() == DT1.Rows[j]["code"].ToString()) //{ DataTable dtClassInfo = spDAO.GetClassInfoByClassCode(DT1.Rows[j]["code"].ToString(), tterm); if (dtClassInfo.Rows.Count>0) { DataRow row = DT11.NewRow(); row["LOGIN"] = DT1.Rows[j]["stcode"].ToString(); row["StudentName"] = DT1.Rows[j]["StudentName"].ToString(); row["LessonName"] = dtClassInfo.Rows[0]["namedars"].ToString(); // row["LessonName"] = DT10.Rows[i]["namedars"].ToString(); // row["PersianDate"] = DT1.Rows[j]["PersianDate"].ToString(); row["SumOfTime"] = DT1.Rows[j]["SumOfTime"].ToString(); // row["PRINCIPAL_ID"] = DT1.Rows[j]["PRINCIPAL_ID"].ToString(); row["code"] = DT1.Rows[j]["code"].ToString(); row["TeacherName"] = dtClassInfo.Rows[0]["Ost_Name"].ToString(); row["tterm"] = tterm.ToString(); DT11.Rows.Add(row); //} // } } } if (DT11.Rows.Count > 0) { DataView dv = DT11.DefaultView; dv.Sort = "code"; DataTable sortedDT = dv.ToTable(); DataTable DT3 = new DataTable(); DT3.Columns.Add("ClassCode", typeof(string)); DT3.Columns.Add("LessonName", typeof(string)); DT3.Columns.Add("TeacherName", typeof(string)); DT3.Columns.Add("SumOfTime", typeof(string)); DT3.Columns.Add("Stcode", typeof(string)); DT3.Columns.Add("StName", typeof(string)); DT3.Columns.Add("tterm", typeof(string)); TimeOfEachClass TimeOfEachClass_ = new TimeOfEachClass(); string Code = ""; long TotalTime = 0; for (int i = 0; i <= sortedDT.Rows.Count; i++) { if (i == sortedDT.Rows.Count) { DataRow row = DT3.NewRow(); row["ClassCode"] = TimeOfEachClass_.code; row["LessonName"] = TimeOfEachClass_.LessonName; row["TeacherName"] = TimeOfEachClass_.TeacherName; row["Stcode"] = TimeOfEachClass_.Stcode; row["StName"] = TimeOfEachClass_.StName; row["SumOfTime"] = TotalTime.ToString(); row["tterm"] = tterm.ToString(); DT3.Rows.Add(row); TotalTime = 0; } else if (Code != sortedDT.Rows[i]["code"].ToString()) { if (i > 0) { DataRow row = DT3.NewRow(); row["ClassCode"] = TimeOfEachClass_.code; row["LessonName"] = TimeOfEachClass_.LessonName; row["TeacherName"] = TimeOfEachClass_.TeacherName; row["Stcode"] = TimeOfEachClass_.Stcode; row["StName"] = TimeOfEachClass_.StName; row["SumOfTime"] = TotalTime.ToString(); row["tterm"] = tterm.ToString(); DT3.Rows.Add(row); TotalTime = 0; } TimeOfEachClass_.code = sortedDT.Rows[i]["code"].ToString(); TimeOfEachClass_.LessonName = sortedDT.Rows[i]["LessonName"].ToString(); TimeOfEachClass_.TeacherName = sortedDT.Rows[i]["TeacherName"].ToString(); TimeOfEachClass_.Stcode = sortedDT.Rows[i]["LOGIN"].ToString(); TimeOfEachClass_.StName = sortedDT.Rows[i]["StudentName"].ToString(); TotalTime = TotalTime + int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); TimeOfEachClass_.tterm = tterm.ToString(); Code = TimeOfEachClass_.code; } else TotalTime = TotalTime + int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); } return DT3; } else return DT1; }
public DataTable GetAllTimeOfEachClass(int Leniency, string Nimsal, string Department) { DataTable sortedDT = SortedDataTableBothServer(Nimsal, Department); DataTable DT3 = new DataTable(); DT3.Columns.Add("Department", typeof(string)); DT3.Columns.Add("GroupName", typeof(string)); DT3.Columns.Add("LOGIN", typeof(string)); DT3.Columns.Add("TeacherName", typeof(string)); DT3.Columns.Add("code", typeof(int)); DT3.Columns.Add("LessonName", typeof(string)); DT3.Columns.Add("SumOfTime", typeof(string)); DT3.Columns.Add("TimeClass", typeof(string)); DT3.Columns.Add("SessionCount", typeof(string)); DT3.Columns.Add("Hozoor", typeof(string)); DT3.Columns.Add("Leniency", typeof(string)); DT3.Columns.Add("tterm", typeof(string)); TimeOfEachClass TimeOfEachClass_ = new TimeOfEachClass(); TimeOfEachClass_.SumOfTime = 0; string Code = ""; long TotalTime = 0; long TotalClassTime = 0; for (int i = 0; i < sortedDT.Rows.Count; i++) { if (Code != sortedDT.Rows[i]["code"].ToString()) { if (i > 0) { DataRow row = DT3.NewRow(); row["Department"] = TimeOfEachClass_.Department; row["GroupName"] = TimeOfEachClass_.GroupName; row["LOGIN"] = TimeOfEachClass_.LOGIN; row["TeacherName"] = TimeOfEachClass_.TeacherName; row["code"] = TimeOfEachClass_.codeInt; row["LessonName"] = TimeOfEachClass_.LessonName; row["SumOfTime"] = TotalTime.ToString(); row["TimeClass"] = TotalClassTime.ToString(); row["SessionCount"] = TimeOfEachClass_.SessionCount.ToString(); row["Hozoor"] = TimeOfEachClass_.Hozoor.ToString(); row["Leniency"] = Leniency.ToString(); row["tterm"] = TimeOfEachClass_.tterm.ToString(); DT3.Rows.Add(row); TotalTime = 0; TotalClassTime = 0; } TimeOfEachClass_.Department = sortedDT.Rows[i]["Department"].ToString(); TimeOfEachClass_.GroupName = sortedDT.Rows[i]["GroupName"].ToString(); TimeOfEachClass_.LOGIN = sortedDT.Rows[i]["LOGIN"].ToString(); TimeOfEachClass_.TeacherName = sortedDT.Rows[i]["TeacherName"].ToString(); TimeOfEachClass_.codeInt = int.Parse(sortedDT.Rows[i]["code"].ToString()); TimeOfEachClass_.LessonName = sortedDT.Rows[i]["LessonName"].ToString(); TimeOfEachClass_.SumOfTime = int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); TimeOfEachClass_.TimeClass = int.Parse(sortedDT.Rows[i]["TimeClass"].ToString()); TimeOfEachClass_.tterm = sortedDT.Rows[i]["tterm"].ToString(); TimeOfEachClass_.SessionCount = 1; if ((TimeOfEachClass_.SumOfTime + Leniency) - TimeOfEachClass_.TimeClass >= 0) { TimeOfEachClass_.Hozoor = 1; } else { TimeOfEachClass_.Hozoor = 0; } TotalTime = TotalTime + TimeOfEachClass_.SumOfTime; TotalClassTime = TotalClassTime + TimeOfEachClass_.TimeClass; Code = TimeOfEachClass_.codeInt.ToString(); } else if (!(sortedDT.Rows[i]["code"].ToString() == sortedDT.Rows[i - 1]["code"].ToString() && sortedDT.Rows[i]["PersianDate"].ToString() == sortedDT.Rows[i - 1]["PersianDate"].ToString() && sortedDT.Rows[i]["FirstLogin"].ToString() == sortedDT.Rows[i - 1]["FirstLogin"].ToString() && sortedDT.Rows[i]["LastLogOut"].ToString() == sortedDT.Rows[i - 1]["LastLogOut"].ToString() )) { if (sortedDT.Rows[i]["SumOfTime"].ToString() == "") { TimeOfEachClass_.SumOfTime = 0; } else { TimeOfEachClass_.SumOfTime = int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); } TimeOfEachClass_.TimeClass = int.Parse(sortedDT.Rows[i]["TimeClass"].ToString()); TimeOfEachClass_.SessionCount = TimeOfEachClass_.SessionCount + 1; if ((TimeOfEachClass_.SumOfTime + Leniency) - TimeOfEachClass_.TimeClass >= 0) { TimeOfEachClass_.Hozoor = TimeOfEachClass_.Hozoor + 1; } // اضافه کرن مجموع زمان حضور TotalTime = TotalTime + TimeOfEachClass_.SumOfTime; // اضافه کردن مجموع زمان کلاس TotalClassTime = TotalClassTime + TimeOfEachClass_.TimeClass; TimeOfEachClass_.SumOfTime = int.Parse(TotalTime.ToString()); TimeOfEachClass_.TimeClass = int.Parse(TotalClassTime.ToString()); } } return(DT3); }
public DataTable GetClassTimeResult(string ClassCode, DateTime TermTimeStart, DateTime TermTimeEnd, string tterm) { // اگر دانشجو در یک روز چند زمان داشته باشد // همه زمان ها را با هم جمع کرده و درآخر یکی می کند DataTable DT1 = new DataTable(); DataTable DT2 = new DataTable(); if (tterm == "93-94-1") { DT1 = GetClassTime_Old(ClassCode, TermTimeStart, TermTimeEnd); DT2 = GetClassTime( ClassCode, TermTimeStart, TermTimeEnd); foreach (DataRow item in DT2.Rows) DT1.Rows.Add(item.ItemArray); } else DT1 = GetClassTime93942(ClassCode); DataTable DT10 = GetStudentClassInfo(ClassCode,tterm); DataTable DT11 = new DataTable(); DT11.Columns.Add("LOGIN", typeof(string)); DT11.Columns.Add("StudentName", typeof(string)); DT11.Columns.Add("LessonName", typeof(string)); DT11.Columns.Add("PersianDate", typeof(string)); DT11.Columns.Add("SumOfTime", typeof(string)); DT11.Columns.Add("SCO_ID", typeof(string)); DT11.Columns.Add("PRINCIPAL_ID", typeof(string)); DT11.Columns.Add("TeacherName", typeof(string)); DT11.Columns.Add("code", typeof(int)); DT11.Columns.Add("TimeStart", typeof(string)); DT11.Columns.Add("TimeEND", typeof(string)); DT11.Columns.Add("TimeClass", typeof(string)); for (int i = 0; i < DT10.Rows.Count; i++) { for (int j = 0; j < DT1.Rows.Count; j++) { if (DT10.Rows[i]["Code"].ToString() == DT1.Rows[j]["Code"].ToString()) { DataRow row = DT11.NewRow(); row["LOGIN"] = DT1.Rows[j]["LOGIN"].ToString(); row["StudentName"] = DT1.Rows[j]["StudentName"].ToString(); row["LessonName"] = DT10.Rows[i]["namedars"].ToString(); row["PersianDate"] = DT1.Rows[j]["PersianDate"].ToString(); row["SumOfTime"] = DT1.Rows[j]["SumOfTime"].ToString(); row["SCO_ID"] = DT1.Rows[j]["SCO_ID"].ToString(); row["PRINCIPAL_ID"] = DT1.Rows[j]["PRINCIPAL_ID"].ToString(); row["TeacherName"] = DT1.Rows[j]["TeacherName"].ToString(); row["code"] = DT10.Rows[i]["did"].ToString(); row["TimeStart"] = DT10.Rows[i]["saatstart"].ToString(); row["TimeEND"] = DT10.Rows[i]["saatend"].ToString(); row["TimeClass"] = DT10.Rows[i]["TimeClass"].ToString(); DT11.Rows.Add(row); } } } if (DT11.Rows.Count > 0) { DataView dv = DT11.DefaultView; dv.Sort = "PersianDate"; dv.Sort = "LOGIN"; DataTable sortedDT = dv.ToTable(); DataTable DT3 = new DataTable(); DT3.Columns.Add("LOGIN", typeof(string)); DT3.Columns.Add("StudentName", typeof(string)); DT3.Columns.Add("LessonName", typeof(string)); DT3.Columns.Add("PersianDate", typeof(string)); DT3.Columns.Add("SumOfTime", typeof(string)); DT3.Columns.Add("SCO_ID", typeof(string)); DT3.Columns.Add("PRINCIPAL_ID", typeof(string)); DT3.Columns.Add("TeacherName", typeof(string)); DT3.Columns.Add("code", typeof(int)); DT3.Columns.Add("TimeStart", typeof(string)); DT3.Columns.Add("TimeEND", typeof(string)); DT3.Columns.Add("TimeClass", typeof(string)); TimeOfEachClass TimeOfEachClass_ = new TimeOfEachClass(); for (int i = 0; i < sortedDT.Rows.Count; i++) { if( i==0) { // First Row - ADD To Class TimeOfEachClass_.LOGIN = sortedDT.Rows[i]["LOGIN"].ToString(); TimeOfEachClass_.StudentName = sortedDT.Rows[i]["StudentName"].ToString(); TimeOfEachClass_.LessonName = sortedDT.Rows[i]["LessonName"].ToString(); TimeOfEachClass_.PersianDate = sortedDT.Rows[i]["PersianDate"].ToString(); TimeOfEachClass_.SCO_ID = sortedDT.Rows[i]["SCO_ID"].ToString(); TimeOfEachClass_.PRINCIPAL_ID = sortedDT.Rows[i]["PRINCIPAL_ID"].ToString(); TimeOfEachClass_.TeacherName = sortedDT.Rows[i]["TeacherName"].ToString(); TimeOfEachClass_.code = sortedDT.Rows[i]["code"].ToString(); TimeOfEachClass_.TimeStart = sortedDT.Rows[i]["TimeStart"].ToString(); TimeOfEachClass_.TimeEND = sortedDT.Rows[i]["TimeEND"].ToString(); ; TimeOfEachClass_.TimeClass = int.Parse(sortedDT.Rows[i]["TimeClass"].ToString()); TimeOfEachClass_.SumOfTime = int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); } else if (i==sortedDT.Rows.Count-1) { //Last Row if (sortedDT.Rows[i]["LOGIN"].ToString() == sortedDT.Rows[i - 1]["LOGIN"].ToString() && sortedDT.Rows[i]["PersianDate"].ToString() == sortedDT.Rows[i - 1]["PersianDate"].ToString()) { // اگر باقبلی یکی بود // مجموع ساعت حضور // DataTable سپس اضافه شود به TimeOfEachClass_.SumOfTime = TimeOfEachClass_.SumOfTime + int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); DataRow row = DT3.NewRow(); row["LOGIN"] = TimeOfEachClass_.LOGIN; row["StudentName"] = TimeOfEachClass_.StudentName; row["LessonName"] = TimeOfEachClass_.LessonName; row["PersianDate"] = TimeOfEachClass_.PersianDate; row["SCO_ID"] = TimeOfEachClass_.SCO_ID; row["PRINCIPAL_ID"] = TimeOfEachClass_.PRINCIPAL_ID; row["TeacherName"] = TimeOfEachClass_.TeacherName; row["code"] = TimeOfEachClass_.code; row["TimeStart"] = TimeOfEachClass_.TimeStart; row["TimeEND"] = TimeOfEachClass_.TimeEND; row["TimeClass"] = TimeOfEachClass_.TimeClass; row["SumOfTime"] = TimeOfEachClass_.SumOfTime; DT3.Rows.Add(row); } else { // اگر باقبلی یکی نبود // ابتدا تابع قبلی اضافه شود DataRow row = DT3.NewRow(); row["LOGIN"] = TimeOfEachClass_.LOGIN; row["StudentName"] = TimeOfEachClass_.StudentName; row["LessonName"] = TimeOfEachClass_.LessonName; row["PersianDate"] = TimeOfEachClass_.PersianDate; row["SCO_ID"] = TimeOfEachClass_.SCO_ID; row["PRINCIPAL_ID"] = TimeOfEachClass_.PRINCIPAL_ID; row["TeacherName"] = TimeOfEachClass_.TeacherName; row["code"] = TimeOfEachClass_.code; row["TimeStart"] = TimeOfEachClass_.TimeStart; row["TimeEND"] = TimeOfEachClass_.TimeEND; row["TimeClass"] = TimeOfEachClass_.TimeClass; row["SumOfTime"] = TimeOfEachClass_.SumOfTime; DT3.Rows.Add(row); // سپس آخرین ردیف اضافه شود DataRow row1 = DT3.NewRow(); row1["LOGIN"] = sortedDT.Rows[i]["LOGIN"].ToString(); row1["StudentName"] = sortedDT.Rows[i]["StudentName"].ToString(); row1["LessonName"] = sortedDT.Rows[i]["LessonName"].ToString(); row1["PersianDate"] = sortedDT.Rows[i]["PersianDate"].ToString(); row1["SCO_ID"] = sortedDT.Rows[i]["SCO_ID"].ToString(); row1["PRINCIPAL_ID"] = sortedDT.Rows[i]["PRINCIPAL_ID"].ToString(); row1["TeacherName"] = sortedDT.Rows[i]["TeacherName"].ToString(); row1["code"] = sortedDT.Rows[i]["code"].ToString(); row1["TimeStart"] = sortedDT.Rows[i]["TimeStart"].ToString(); row1["TimeEND"] = sortedDT.Rows[i]["TimeEND"].ToString(); row1["TimeClass"] = sortedDT.Rows[i]["TimeClass"].ToString(); row1["SumOfTime"] = sortedDT.Rows[i]["SumOfTime"].ToString(); DT3.Rows.Add(row1); } } else if (sortedDT.Rows[i]["LOGIN"].ToString() == sortedDT.Rows[i - 1]["LOGIN"].ToString() && sortedDT.Rows[i]["PersianDate"].ToString() == sortedDT.Rows[i - 1]["PersianDate"].ToString()) { // اگر باقبلی یکی نبود TimeOfEachClass_.SumOfTime = TimeOfEachClass_.SumOfTime + int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); } else { // اضافه شود DataTable ابتدا ردیف قبل به DataRow row = DT3.NewRow(); row["LOGIN"] = TimeOfEachClass_.LOGIN; row["StudentName"] = TimeOfEachClass_.StudentName; row["LessonName"] = TimeOfEachClass_.LessonName; row["PersianDate"] = TimeOfEachClass_.PersianDate; row["SCO_ID"] = TimeOfEachClass_.SCO_ID; row["PRINCIPAL_ID"] = TimeOfEachClass_.PRINCIPAL_ID; row["TeacherName"] = TimeOfEachClass_.TeacherName; row["code"] = TimeOfEachClass_.code; row["TimeStart"] = TimeOfEachClass_.TimeStart; row["TimeEND"] = TimeOfEachClass_.TimeEND; row["TimeClass"] = TimeOfEachClass_.TimeClass; row["SumOfTime"] = TimeOfEachClass_.SumOfTime; DT3.Rows.Add(row); // سپس ردیف جدید در کلاس قرار گیرد TimeOfEachClass_.LOGIN = sortedDT.Rows[i]["LOGIN"].ToString(); TimeOfEachClass_.StudentName = sortedDT.Rows[i]["StudentName"].ToString(); TimeOfEachClass_.LessonName = sortedDT.Rows[i]["LessonName"].ToString(); TimeOfEachClass_.PersianDate = sortedDT.Rows[i]["PersianDate"].ToString(); TimeOfEachClass_.SCO_ID = sortedDT.Rows[i]["SCO_ID"].ToString(); TimeOfEachClass_.PRINCIPAL_ID = sortedDT.Rows[i]["PRINCIPAL_ID"].ToString(); TimeOfEachClass_.TeacherName = sortedDT.Rows[i]["TeacherName"].ToString(); TimeOfEachClass_.code = sortedDT.Rows[i]["code"].ToString(); TimeOfEachClass_.TimeStart = sortedDT.Rows[i]["TimeStart"].ToString(); TimeOfEachClass_.TimeEND = sortedDT.Rows[i]["TimeEND"].ToString(); ; TimeOfEachClass_.TimeClass = int.Parse(sortedDT.Rows[i]["TimeClass"].ToString()); TimeOfEachClass_.SumOfTime = int.Parse(sortedDT.Rows[i]["SumOfTime"].ToString()); } } // Final Sort DataView dv2 = DT3.DefaultView; dv2.Sort = "PersianDate"; DataTable sortedDT2 = dv2.ToTable(); return sortedDT2; } else return DT1; }