public float getTotalCreditforEdit(string academic_year, string semester, string lectuere_id, SubCreditData oldData) { string prev_course = ""; int prev_sec = 0; int prev_subsec = 0; float totalCredit = new AddWorkLoad().getAddWorkLoad(academic_year, semester, lectuere_id).TotalCredit; List <LecturerTableData> lecturerData = new List <LecturerTableData>(); lecturerData = new LecturerTable().getAllDegreeLecturerTable(academic_year, semester, lectuere_id); SubCreditData subcredit = new SubCreditData(); foreach (LecturerTableData data in lecturerData) { if (!(data.AcademicYear == oldData.AcademicYear && data.Semester == oldData.Semester && data.Course_Code == oldData.Course_Code && data.Sec_No == oldData.Sec_No && data.SubSec_No == oldData.SubSec_No && data.Lecturer == oldData.Lecturer)) { subcredit = new SubCredit().getSubCredit(data.AcademicYear, data.Semester, data.Course_Code, data.Sec_No, data.SubSec_No, data.Lecturer, data.Teaching_Day, data.Teaching_Start_Time, data.Teaching_End_Time, data.Course_Degree_Char); totalCredit += subcredit.SubCredit; // prev_course = data.Course_Code; // prev_sec = data.Sec_No; // prev_subsec = data.SubSec_No; } } return(totalCredit); }
public float getTotalCredit(string academic_year, string semester, string lectuere_id) { string prev_course = ""; int prev_sec = 0; int prev_subsec = 0; float totalCredit = new AddWorkLoad().getAddWorkLoad(academic_year, semester, lectuere_id).TotalCredit; List <LecturerTableData> lecturerData = new List <LecturerTableData>(); lecturerData = new LecturerTable().getAllDegreeLecturerTable(academic_year, semester, lectuere_id); foreach (LecturerTableData data in lecturerData) { //if ((prev_course == "") || (prev_course != data.Course_Code) || (prev_sec != data.Sec_No) || (prev_subsec != data.SubSec_No)) // { SubCreditData subcredit = new SubCreditData(); subcredit = new SubCredit().getSubCredit(data.AcademicYear, data.Semester, data.Course_Code, data.Sec_No, data.SubSec_No, data.Lecturer, data.Teaching_Day, data.Teaching_Start_Time, data.Teaching_End_Time, data.Course_Degree_Char); totalCredit += subcredit.SubCredit; prev_course = data.Course_Code; prev_sec = data.Sec_No; prev_subsec = data.SubSec_No; // } } return(totalCredit); }
public float getInTimeHourRef(string academic_year, string semester, string lectuere_id) { string prev_course = ""; int prev_sec = 0; int prev_subsec = 0; //float hour_ref = new AddWorkLoad().getAddWorkLoad(academic_year, semester, lectuere_id).HourRefer; float hour_ref = 0; List <LecturerTableData> lecturerData = new List <LecturerTableData>(); lecturerData = new LecturerTable().getAllDegreeLecturerTable(academic_year, semester, lectuere_id); foreach (LecturerTableData data in lecturerData) { int end_time = (int)Convert.ToDouble(data.Teaching_End_Time.Replace(':', '.')); if ((data.Teaching_Day == "1" || data.Teaching_Day == "2" || data.Teaching_Day == "3" || data.Teaching_Day == "4" || data.Teaching_Day == "5") && (end_time <= 16)) { HourReferData hour_data = new HourReferData(); CourseData course_data = new CourseData(); course_data = new Course().getCourse(data.Course_Code); float credit = 0; SubCreditData subcredit = new SubCreditData(); subcredit = new SubCredit().getSubCredit(data.AcademicYear, data.Semester, data.Course_Code, data.Sec_No, data.SubSec_No, data.Lecturer, data.Teaching_Day, data.Teaching_Start_Time, data.Teaching_End_Time, data.Course_Degree_Char); credit = subcredit.SubCredit; if (course_data.Course_DegreeLevel == "01")// ปวช. { hour_data = new HourRefer().getHourRefer("U", data.Course_Type); hour_ref += hour_data.HourRefer * credit; } else if (course_data.Course_DegreeLevel == "02") //ป.ตรี { hour_data = new HourRefer().getHourRefer("B", data.Course_Type); hour_ref += hour_data.HourRefer * credit; } else { // บัณฑิต hour_data = new HourRefer().getHourRefer("M", data.Course_Type); hour_ref += hour_data.HourRefer * credit; } prev_course = data.Course_Code; prev_sec = data.Sec_No; prev_subsec = data.SubSec_No; } } return(hour_ref); }
public float getHourRef(string academic_year, string semester, string lectuere_id) { string prev_course = ""; int prev_sec = 0; int prev_subsec = 0; float hour_ref = new AddWorkLoad().getAddWorkLoad(academic_year, semester, lectuere_id).HourRefer; List <LecturerTableData> lecturerData = new List <LecturerTableData>(); lecturerData = new LecturerTable().getAllDegreeLecturerTable(academic_year, semester, lectuere_id); foreach (LecturerTableData data in lecturerData) { //if ((prev_course == "") || (prev_course != data.Course_Code) || (prev_sec != data.Sec_No) || (prev_subsec != data.SubSec_No)) // { HourReferData hour_data = new HourReferData(); CourseData course_data = new CourseData(); course_data = new Course().getCourse(data.Course_Code); float credit = 0; SubCreditData subcredit = new SubCreditData(); subcredit = new SubCredit().getSubCredit(data.AcademicYear, data.Semester, data.Course_Code, data.Sec_No, data.SubSec_No, data.Lecturer, data.Teaching_Day, data.Teaching_Start_Time, data.Teaching_End_Time, data.Course_Degree_Char); credit = subcredit.SubCredit; if (course_data.Course_DegreeLevel == "01") // ปวช. { hour_data = new HourRefer().getHourRefer("U", data.Course_Type); hour_ref += hour_data.HourRefer * credit; } else if (course_data.Course_DegreeLevel == "02") //ป.ตรี { hour_data = new HourRefer().getHourRefer("B", data.Course_Type); hour_ref += hour_data.HourRefer * credit; } else { // บัณฑิต hour_data = new HourRefer().getHourRefer("M", data.Course_Type); hour_ref += hour_data.HourRefer * credit; } prev_course = data.Course_Code; prev_sec = data.Sec_No; prev_subsec = data.SubSec_No; // } } return(hour_ref); }
protected void Page_Load(object sender, EventArgs e) { if (Session["login_data"] == null) { Response.Redirect("../index.aspx"); } else { //ตรวจสอบสิทธิ์ login_data = (UserLoginData)Session["login_data"]; if (autro_obj.CheckGroupUser(login_data, group_var.officer_department) || autro_obj.CheckGroupUser(login_data, group_var.officer_faculty) || autro_obj.CheckGroupUser(login_data, group_var.lecturer)) { /*=============================*/ try { string lec_code = Request.QueryString["lecturer"]; SysUser lec = new SysUser().getSysUser(lec_code); bool authorized = false; if (autro_obj.CheckGroupUser(login_data, group_var.lecturer)) { if (lec_code == login_data.Nation_ID) { authorized = true; } else { authorized = false; } } else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) { authorized = true; } else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) { List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department); foreach (string dep in department_authorized) { if (dep == lec.DepartmentCode) { authorized = true; break; } } } if (authorized == true) { string academic_year = Request.QueryString["year"]; string semester = Request.QueryString["semester"]; string prev_course = ""; int prev_sec = 0; int prev_subsec = 0; List <LecturerTableData> lecturerData = new List <LecturerTableData>(); lecturerData = new LecturerTable().getAllDegreeLecturerTable(academic_year, semester, lec_code); headLecturer.Text = new AcademicPosition().getAcademicPosition(lec.AcademicPositionCode).AcademicPositionThName + " " + lec.ThName + " " + lec.ThSurName; // Head Table string[] ar = { "ลำดับ", "ชื่อวิชา", "ตอนเรียน", "วัน", "เวลา", "ตัวคูณ", "หน่วยกิต", "ชั่วโมงอ้างอิง" }; Table tb1 = new Table(); tb1.Attributes.Add("class", "table table-bordered table-striped table-hover"); tb1.Attributes.Add("id", "dt_basic"); TableHeaderRow tRowHead = new TableHeaderRow(); tRowHead.TableSection = TableRowSection.TableHeader; for (int cellCtr = 1; cellCtr <= ar.Length; cellCtr++) { TableHeaderCell cellHead = new TableHeaderCell(); cellHead.Text = ar[cellCtr - 1]; cellHead.Attributes.Add("class", "text-center"); tRowHead.Cells.Add(cellHead); } tb1.Rows.Add(tRowHead); int num = 1; float totalCredit = 0; float totalHourRef = 0; SubCreditData subcredit = new SubCreditData(); TableCell cellDay = new TableCell(); TableCell cellTime = new TableCell(); foreach (LecturerTableData data in lecturerData) { //if ((prev_course == "") || (prev_course != data.Course_Code) || (prev_sec != data.Sec_No) || (prev_subsec != data.SubSec_No)) // { CourseData course_data = new CourseData(); course_data = new Course().getCourse(data.Course_Code); TableRow tRowBody = new TableRow(); tRowBody.TableSection = TableRowSection.TableBody; TableCell cellNum = new TableCell(); cellNum.Attributes.Add("class", "text-center"); cellNum.Attributes.Add("style", "vertical-align:middle"); cellNum.Text = num.ToString(); tRowBody.Cells.Add(cellNum); TableCell cellCourseName = new TableCell(); cellCourseName.Attributes.Add("style", "vertical-align:middle"); cellCourseName.Text = course_data.Course_Code + " " + course_data.Course_Engname; tRowBody.Cells.Add(cellCourseName); string course_type = ""; string course_sec = ""; if (data.Course_Type == "1") { course_type = "S."; } else if (data.Course_Type == "2") { course_type = "L."; } else if (data.Course_Type == "4") { course_type = "T."; } else if (data.Course_Type == "5") { course_type = "M."; } else if (data.Course_Type == "6") { course_type = "SP."; } else if (data.Course_Type == "7") { course_type = "D."; } if (data.SubSec_No != 0) { course_sec = data.SubSec_No.ToString(); } else { course_sec = data.Sec_No.ToString(); } TableCell cellSec = new TableCell(); cellSec.Attributes.Add("class", "text-center"); cellSec.Attributes.Add("style", "vertical-align:middle"); cellSec.Text = course_type + course_sec; tRowBody.Cells.Add(cellSec); string day = ""; if (data.Teaching_Day == "1") { day = "Mon"; } else if (data.Teaching_Day == "2") { day = "Tue"; } if (data.Teaching_Day == "3") { day = "Wed"; } if (data.Teaching_Day == "4") { day = "Thu"; } if (data.Teaching_Day == "5") { day = "Fri"; } if (data.Teaching_Day == "6") { day = "Sat"; } if (data.Teaching_Day == "7") { day = "Sun"; } cellDay = new TableCell(); cellDay.Attributes.Add("class", "text-center"); cellDay.Attributes.Add("style", "vertical-align:middle"); cellDay.Text = day; tRowBody.Cells.Add(cellDay); string teach_time = data.Teaching_Start_Time + " - " + data.Teaching_End_Time; cellTime = new TableCell(); cellTime.Attributes.Add("class", "text-center"); cellTime.Attributes.Add("style", "vertical-align:middle"); cellTime.Text = teach_time; tRowBody.Cells.Add(cellTime); subcredit = new SubCredit().getSubCredit(data.AcademicYear, data.Semester, data.Course_Code, data.Sec_No, data.SubSec_No, data.Lecturer, data.Teaching_Day, data.Teaching_Start_Time, data.Teaching_End_Time, data.Course_Degree_Char); float credit = subcredit.SubCredit; totalCredit += subcredit.SubCredit; HourReferData hour_data = new HourReferData(); float hour_ref = 0; if (course_data.Course_DegreeLevel == "01")// ปวช. { hour_data = new HourRefer().getHourRefer("U", data.Course_Type); hour_ref = hour_data.HourRefer * credit; } else if (course_data.Course_DegreeLevel == "02") //ป.ตรี { hour_data = new HourRefer().getHourRefer("B", data.Course_Type); hour_ref = hour_data.HourRefer * credit; } else { // บัณฑิต hour_data = new HourRefer().getHourRefer("M", data.Course_Type); hour_ref = hour_data.HourRefer * credit; } totalHourRef += hour_ref; TableCell cellMultiply = new TableCell(); cellMultiply.Attributes.Add("class", "text-center"); cellMultiply.Attributes.Add("style", "vertical-align:middle"); cellMultiply.Text = hour_data.HourRefer.ToString(); tRowBody.Cells.Add(cellMultiply); TableCell cellCredit = new TableCell(); cellCredit.Attributes.Add("class", "text-center"); cellCredit.Attributes.Add("style", "vertical-align:middle"); cellCredit.Text = credit.ToString(); tRowBody.Cells.Add(cellCredit); TableCell cellHourRef = new TableCell(); cellHourRef.Attributes.Add("class", "text-center"); cellHourRef.Attributes.Add("style", "vertical-align:middle"); cellHourRef.Text = hour_ref.ToString(); tRowBody.Cells.Add(cellHourRef); tb1.Rows.Add(tRowBody); num++; prev_course = data.Course_Code; prev_sec = data.Sec_No; prev_subsec = data.SubSec_No; } AddWorkLoadData AddWork_data = new AddWorkLoadData(); AddWork_data = new AddWorkLoad().getAddWorkLoad(academic_year, semester, lec_code); if (AddWork_data.Lecturer != null) { totalCredit += AddWork_data.TotalCredit; totalHourRef += AddWork_data.HourRefer; TableRow tRowBody1 = new TableRow(); tRowBody1.TableSection = TableRowSection.TableBody; TableCell cellAddNum = new TableCell(); cellAddNum.Attributes.Add("class", "text-center"); cellAddNum.Attributes.Add("style", "vertical-align:middle"); cellAddNum.Text = num.ToString(); tRowBody1.Cells.Add(cellAddNum); TableCell cellAddTitle = new TableCell(); cellAddTitle.Attributes.Add("class", "text-left"); cellAddTitle.Attributes.Add("style", "vertical-align:middle"); cellAddTitle.ColumnSpan = 5; cellAddTitle.Text = "ภาระงานต้นสังกัด"; tRowBody1.Cells.Add(cellAddTitle); TableCell cellAddCredit = new TableCell(); cellAddCredit.Attributes.Add("class", "text-center"); cellAddCredit.Attributes.Add("style", "vertical-align:middle"); cellAddCredit.Text = AddWork_data.TotalCredit.ToString(); tRowBody1.Cells.Add(cellAddCredit); TableCell cellAddHourRef = new TableCell(); cellAddHourRef.Attributes.Add("class", "text-center"); cellAddHourRef.Attributes.Add("style", "vertical-align:middle"); cellAddHourRef.Text = AddWork_data.HourRefer.ToString(); tRowBody1.Cells.Add(cellAddHourRef); tb1.Rows.Add(tRowBody1); } //==================== TableFooterRow footRow = new TableFooterRow(); footRow.TableSection = TableRowSection.TableFooter; TableCell cellSumTitle = new TableCell(); cellSumTitle.Attributes.Add("class", "text-right txt-blue-bold"); cellSumTitle.ColumnSpan = 6; cellSumTitle.Text = "รวม"; footRow.Cells.Add(cellSumTitle); TableCell cell1 = new TableCell(); cell1.Attributes.Add("class", "text-center txt-blue-bold"); cell1.Text = totalCredit.ToString(); footRow.Cells.Add(cell1); TableCell cell3 = new TableCell(); cell3.Attributes.Add("class", "text-center txt-blue-bold"); cell3.Text = totalHourRef.ToString(); footRow.Cells.Add(cell3); tb1.Rows.Add(footRow); TableRow row = new TableRow(); TableCell cell = new TableCell(); cell.Controls.Add(tb1); row.Cells.Add(cell); tblWorkLoad.Rows.Add(row); } else { HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน"; HttpContext.Current.Response.Redirect("err_response.aspx"); } } catch (Exception err) { } /*=============================*/ } else { HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน"; HttpContext.Current.Response.Redirect("err_response.aspx"); } } }
protected void onclick_section_finish(object sender, EventArgs e) { try { bool check = (bool)Session["isOK"]; if (check) { result.Text = new AvailableCourse().updateAvailableCourse(available_data, old_available_data, degree_char); string[] res = new AvailableStudent().updateAvailableStudent(available_student, old_available_student, degree_char); string[] res2 = new TeachingTable().updateTeachingTable(teachtable, old_teaching, degree_char); string[] res3 = new LecturerTable().updateLecturerTable(lecturertable, old_lecturer, degree_char); string[] res4 = new SubCredit().updateSubCredit(subcreditData, degree_char); divBody.Visible = false; divSuccess.Visible = true; } else { float totalCredit = 0; CourseData course_data = new Course().getCourse(available_data.Course_Code); int credit = course_data.Credit; if (lecturertable[0].Course_Type == "1") { if (course_data.Practice != 0) { credit = course_data.Theory; } else { credit = course_data.Credit; } } else if (lecturertable[0].Course_Type == "2") { if (course_data.Theory != 0) { credit = course_data.Practice / 2; } else { credit = course_data.Credit; } } string credit_err = ""; foreach (SubCreditData subcredit in subcreditData) { totalCredit += subcredit.SubCredit; float remain_credit = new WorkLoadCalculate().checkEditLecturerCredit2(subcredit.AcademicYear, subcredit.Semester, subcredit.Lecturer, subcredit.SubCredit, subcredit); if (remain_credit != -1) { credit_err += subcredit.Lecturer + "," + remain_credit; break; } } if (credit_err.Length > 0) { string[] arr = credit_err.Split(','); lblSubDreditErr.Visible = true; LectuereInformationData lec = new LectuereInformationData(); lec = new Lecturer().getLecturer(arr[0]); lblSubDreditErr.Text = "อาจารย์ " + lec.First_ThaiName + " " + lec.Family_ThaiName + " ไม่สามารถสอนได้เกิน " + arr[1] + " เครดิต"; btnSubmit.Focus(); } else if (totalCredit != credit) { lblSubDreditErr.Visible = true; lblSubDreditErr.Text = "จำนวนหน่วยกิตรวมต้องเท่ากับ " + credit; btnSubmit.Focus(); } else { result.Text = new AvailableCourse().updateAvailableCourse(available_data, old_available_data, degree_char); string[] res = new AvailableStudent().updateAvailableStudent(available_student, old_available_student, degree_char); string[] res2 = new TeachingTable().updateTeachingTable(teachtable, old_teaching, degree_char); string[] res3 = new LecturerTable().updateLecturerTable(lecturertable, old_lecturer, degree_char); string[] res4 = new SubCredit().updateSubCredit(subcreditData, degree_char); divBody.Visible = false; divSuccess.Visible = true; } } } catch { divFail.Visible = true; } }