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 (!Page.IsPostBack) { Session.Remove("CurrCode"); Session.Remove("YearVersion"); Session.Remove("NumTQF1"); List <FacultyData> faculty = new Faculty().getFaculty(); ddlCURR_FACULTY.Items.Clear(); ddlCURR_FACULTY.Items.Insert(ddlCURR_FACULTY.Items.Count, new ListItem("--- เลือกคณะ ---", "00")); foreach (FacultyData row in faculty) { ddlCURR_FACULTY.Items.Insert(ddlCURR_FACULTY.Items.Count, new ListItem(row.Faculty_Thai, row.Faculty_Code)); if (row.Faculty_Code == "11") { ddlCURR_FACULTY.Items.FindByValue(row.Faculty_Code).Selected = true; } } // Department string sql1 = "Select * From DEPARTMENT Where FACULTY_CODE='" + ddlCURR_FACULTY.SelectedValue + "' And DEPARTMENT_STATUS='0001' Order By DEPARTMENT_CODE"; List <DepartmentData> department = new Department().getDepartmentManual(sql1); ddlCURR_DEPARTMENT.Items.Clear(); ddlCURR_DEPARTMENT.Items.Insert(ddlCURR_DEPARTMENT.Items.Count, new ListItem("--- เลือกภาควิชา ---", "0000")); foreach (DepartmentData row in department) { ddlCURR_DEPARTMENT.Items.Insert(ddlCURR_DEPARTMENT.Items.Count, new ListItem(row.Department_Thai, row.Department_Code)); } //========== // Head Table tableHeader(tblCurriculum); //เลือก default เป็นคณะสถาปัตย์ string sql = "Select * From CURRICULUM Where FACULTYCODE = '11' Order By YEARVERSION"; List <TQF.Curriculum> CurriculumRow = new TQF.Curriculum().getCurriculumManual(sql); //.getCurriculum(); lblTITLE_CURR_FACULTY.Text = new Faculty().getFaculty("11").Faculty_Thai; foreach (TQF.Curriculum data in CurriculumRow) { TableRow tRowBody = new TableRow(); tRowBody.TableSection = TableRowSection.TableBody; TableCell cellCurrCode = new TableCell(); //cellCurrCode.Text = data.CurrCode; cellCurrCode.Text = "<a href=\"detailCurr.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"View\" target=\"_blank\">" + data.CurrCode + "</a>"; tRowBody.Cells.Add(cellCurrCode); TableCell cellYearVersion = new TableCell(); cellYearVersion.Text = data.YearVersion; tRowBody.Cells.Add(cellYearVersion); TableCell cellCurrThName = new TableCell(); cellCurrThName.Text = data.CurrThName + "<br>" + data.CurrEnName; tRowBody.Cells.Add(cellCurrThName); TableCell cellCurrStatus = new TableCell(); if (data.CurrStatus == "1") { cellCurrStatus.Text = "<span class='txt-color-red'><strong>ใหม่</strong></span>"; } if (data.CurrStatus == "2") { cellCurrStatus.Text = "<span class='txt-color-green'><strong>ปรับปรุง</strong></span>"; } tRowBody.Cells.Add(cellCurrStatus); TableCell cellApproveStatus = new TableCell(); // งานหลักสูตร if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) { string urlShow = "approveCURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; HyperLink hypShow = new HyperLink(); hypShow.Attributes.Add("data-target", "#editModal"); hypShow.Attributes.Add("data-toggle", "modal"); if (data.ApproveStatus == "Y") { hypShow.Text = "<h4 class='txt-color-green'><i class='fa fa-check'></i></h4>"; } if (data.ApproveStatus == "N") { hypShow.Text = "<h4 class='txt-color-red'><i class='fa fa-times'></i></h4>"; } hypShow.NavigateUrl = urlShow; hypShow.ToolTip = "คลิกเพื่อเปลี่ยนสถานะอนุญาตหลักสูตร"; cellApproveStatus.Controls.Add(hypShow); } // วิชาการคณะ //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) // { // bool editable = false; // List<string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty); // foreach (string fac in faculty_authorized) // { // if (fac == data.FacultyCode) // { // editable = true; // break; // } // } // if (editable == true) // { // string urlShow = "approveCURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; // HyperLink hypShow = new HyperLink(); // hypShow.Attributes.Add("data-target", "#editModal"); // hypShow.Attributes.Add("data-toggle", "modal"); // if (data.ApproveStatus == "Y") hypShow.Text = "<h4 class='txt-color-green'><i class='fa fa-check'></i></h4>"; // if (data.ApproveStatus == "N") hypShow.Text = "<h4 class='txt-color-red'><i class='fa fa-times'></i></h4>"; // hypShow.NavigateUrl = urlShow; // hypShow.ToolTip = "คลิกเพื่อเปลี่ยนสถานะอนุญาตหลักสูตร"; // cellApproveStatus.Controls.Add(hypShow); // } // else // { // string urlShow = "#"; // HyperLink hypShow = new HyperLink(); // hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; // hypShow.NavigateUrl = urlShow; // hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; // cellApproveStatus.Controls.Add(hypShow); // } // } // วิชาการภาค else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) { string urlShow = "#"; HyperLink hypShow = new HyperLink(); hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; hypShow.NavigateUrl = urlShow; hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; cellApproveStatus.Controls.Add(hypShow); } // วิชาการคณะ //else if(autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) //{ // string urlShow = "#"; // HyperLink hypShow = new HyperLink(); // hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; // hypShow.NavigateUrl = urlShow; // hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; // cellApproveStatus.Controls.Add(hypShow); //} //// วิชาการภาค //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) //{ // string urlShow = "#"; // HyperLink hypShow = new HyperLink(); // hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; // hypShow.NavigateUrl = urlShow; // hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; // cellApproveStatus.Controls.Add(hypShow); //} // ทุกกลุ่มผู้ใช้ else { string urlShow = "#"; HyperLink hypShow = new HyperLink(); hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; hypShow.NavigateUrl = urlShow; hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; cellApproveStatus.Controls.Add(hypShow); } cellApproveStatus.CssClass = "text-center"; tRowBody.Cells.Add(cellApproveStatus); TableCell cellDetail = new TableCell(); cellDetail.Text = "<h4><a href=\"detailCurr.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"View\" target=\"_blank\"><i class=\"fa fa-search\"></i></a></h4>"; cellDetail.CssClass = "text-center"; tRowBody.Cells.Add(cellDetail); TableCell cellEdit = new TableCell(); // งานหลักสูตร if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) { if (data.CurrCode == "999999999") { cellEdit.Text = "<h4><a href=\"editCURR_GEN_EDU1.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Edit\"><i class='fa fa-edit'></i></a></h4>"; } else { cellEdit.Text = "<h4><a href=\"Faculty_edit_CURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Edit\"><i class='fa fa-edit'></i></a></h4>"; } } // วิชาการคณะ //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) //{ // bool editable = false; // List<string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty); // foreach (string fac in faculty_authorized) // { // if (fac == data.FacultyCode) // { // editable = true; // break; // } // } // if (editable == true) // { // cellEdit.Text = "<h4><a href=\"Faculty_edit_CURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Edit\"><i class='fa fa-edit'></i></a></h4>"; // } // else // { // cellEdit.Text = "<h4><a href='#' title=\"ไม่สามารถแก้ไขหลักสูตรได้\"><i class='fa fa-lock'></i></a></h4>"; // } //} // วิชาการภาค else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) { bool editable = false; List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department); foreach (string dep in department_authorized) { if (dep == data.DepartmentCode) { editable = true; break; } } if (editable == true) { cellEdit.Text = "<h4><a href=\"Faculty_edit_CURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Edit\"><i class='fa fa-edit'></i></a></h4>"; } else { cellEdit.Text = "<h4><a href='#' title=\"ไม่สามารถแก้ไขหลักสูตรได้\"><i class='fa fa-lock'></i></a></h4>"; } } // ทุกกลุ่มผู้ใช้ else { cellEdit.Text = "<h4><a href='#' title=\"ไม่สามารถแก้ไขหลักสูตรได้\"><i class='fa fa-lock'></i></a></h4>"; } cellEdit.CssClass = "text-center"; tRowBody.Cells.Add(cellEdit); TableCell cellDel = new TableCell(); //เช็คว่าหลักสูตรมีการนำไปใช้แล้วหรือยัง ถ้ามีแล้วจะไม่สามารถลบข้อมูลได้ bool chkExistCurr = new Student().existCurriculum("STUDENT", data.YearVersion + data.CurrCode); //ระดับปริญญาตรี bool chkGradExistCurr = new Student().existCurriculum("GRAD_STUDENT", data.YearVersion + data.CurrCode); //ระดับบัณฑิตศึกษา // งานหลักสูตร if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty) && chkExistCurr == false && chkGradExistCurr == false) { //string urlDel = "deleteElective_COURSE.aspx?token=" + data.CourseElectiveCode + "&facultyId=" + data.FacultyCode; string urlDel = "delete_CURRICULUM.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; HyperLink hypDel = new HyperLink(); hypDel.Attributes.Add("data-target", "#deleteModal"); hypDel.Attributes.Add("data-toggle", "modal"); hypDel.Text = "<h4><i class='fa fa-trash-o'></i></h4>"; hypDel.NavigateUrl = urlDel; hypDel.ToolTip = "Delete"; cellDel.Controls.Add(hypDel); } // วิชาการคณะ //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) //{ // bool editable = false; // List<string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty); // foreach (string fac in faculty_authorized) // { // if (fac == data.FacultyCode) // { // editable = true; // break; // } // } // if (editable == true && chkExistCurr == false && chkGradExistCurr == false) // { // string urlDel = "delete_CURRICULUM.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; // HyperLink hypDel = new HyperLink(); // hypDel.Attributes.Add("data-target", "#deleteModal"); // hypDel.Attributes.Add("data-toggle", "modal"); // hypDel.Text = "<h4><i class='fa fa-trash-o'></i></h4>"; // hypDel.NavigateUrl = urlDel; // hypDel.ToolTip = "Delete"; // cellDel.Controls.Add(hypDel); // } // else // { // string urlDel = "#"; // HyperLink hypDel = new HyperLink(); // hypDel.Text = "<h4><i class='fa fa-lock'></i></h4>"; // hypDel.NavigateUrl = urlDel; // hypDel.ToolTip = "ไม่สามารถลบหลักสูตรได้"; // cellDel.Controls.Add(hypDel); // } //} // วิชาการภาค else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) { bool editable = false; List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department); foreach (string dep in department_authorized) { if (dep == data.DepartmentCode) { editable = true; break; } } if (editable == true && chkExistCurr == false && chkGradExistCurr == false) { string urlDel = "delete_CURRICULUM.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; HyperLink hypDel = new HyperLink(); hypDel.Attributes.Add("data-target", "#deleteModal"); hypDel.Attributes.Add("data-toggle", "modal"); hypDel.Text = "<h4><i class='fa fa-trash-o'></i></h4>"; hypDel.NavigateUrl = urlDel; hypDel.ToolTip = "Delete"; cellDel.Controls.Add(hypDel); } else { string urlDel = "#"; HyperLink hypDel = new HyperLink(); hypDel.Text = "<h4><i class='fa fa-lock'></i></h4>"; hypDel.NavigateUrl = urlDel; hypDel.ToolTip = "ไม่สามารถลบหลักสูตรได้"; cellDel.Controls.Add(hypDel); } } // ทุกกลุ่มผู้ใช้ else { string urlDel = "#"; HyperLink hypDel = new HyperLink(); hypDel.Text = "<h4><i class='fa fa-lock'></i></h4>"; hypDel.NavigateUrl = urlDel; hypDel.ToolTip = "ไม่สามารถลบหลักสูตรได้"; cellDel.Controls.Add(hypDel); } cellDel.CssClass = "text-center"; cellDel.Width = 50; tRowBody.Cells.Add(cellDel); TableCell cellPrint = new TableCell(); cellPrint.Text = "<a href=\"PrintCurr.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Save PDF\" target=\"_blank\"><img src=\"../img/icon_pdf.png\" style=\"padding-bottom:5px\"></a>"; cellPrint.Text += "<a href=\"PrintCurr2.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Save Doc\" target=\"_blank\"><img src=\"../img/icon_doc.png\"></a>"; cellPrint.CssClass = "text-center"; tRowBody.Cells.Add(cellPrint); tblCurriculum.Rows.Add(tRowBody); } } } }
protected void btnSEARCH_Click(object sender, EventArgs e) { lblTITLE_CURR_FACULTY.Text = ddlCURR_FACULTY.SelectedItem.Text; lblTITLE_CURR_DEPARTMENT.Text = "ภาควิชา" + ddlCURR_DEPARTMENT.SelectedItem.Text; // Head Table tableHeader(tblCurriculum); //tRowBody string sql = "Select * From CURRICULUM Where DEPARTMENTCODE = '" + ddlCURR_DEPARTMENT.SelectedValue + "'"; List <TQF.Curriculum> CurriculumRow = new TQF.Curriculum().getCurriculumManual(sql); foreach (TQF.Curriculum data in CurriculumRow) { TableRow tRowBody = new TableRow(); tRowBody.TableSection = TableRowSection.TableBody; TableCell cellCurrCode = new TableCell(); cellCurrCode.Text = "<a href=\"detailCurr.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"View\" target=\"_blank\">" + data.CurrCode + "</a>"; tRowBody.Cells.Add(cellCurrCode); TableCell cellYearVersion = new TableCell(); cellYearVersion.Text = data.YearVersion; tRowBody.Cells.Add(cellYearVersion); TableCell cellCurrThName = new TableCell(); cellCurrThName.Text = data.CurrThName + "<br>" + data.CurrEnName; tRowBody.Cells.Add(cellCurrThName); TableCell cellCurrStatus = new TableCell(); if (data.CurrStatus == "1") { cellCurrStatus.Text = "<span class='txt-color-red'><strong>ใหม่</strong></span>"; } if (data.CurrStatus == "2") { cellCurrStatus.Text = "<span class='txt-color-green'><strong>ปรับปรุง</strong></span>"; } tRowBody.Cells.Add(cellCurrStatus); TableCell cellApproveStatus = new TableCell(); // งานหลักสูตร if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) { string urlShow = "approveCURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; HyperLink hypShow = new HyperLink(); hypShow.Attributes.Add("data-target", "#editModal"); hypShow.Attributes.Add("data-toggle", "modal"); if (data.ApproveStatus == "Y") { hypShow.Text = "<h4 class='txt-color-green'><i class='fa fa-check'></i></h4>"; } if (data.ApproveStatus == "N") { hypShow.Text = "<h4 class='txt-color-red'><i class='fa fa-times'></i></h4>"; } hypShow.NavigateUrl = urlShow; hypShow.ToolTip = "คลิกเพื่อเปลี่ยนสถานะอนุญาตหลักสูตร"; cellApproveStatus.Controls.Add(hypShow); } // วิชาการคณะ //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) // { // bool editable = false; // List<string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty); // foreach (string fac in faculty_authorized) // { // if (fac == data.FacultyCode) // { // editable = true; // break; // } // } // if (editable == true) // { // string urlShow = "approveCURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; // HyperLink hypShow = new HyperLink(); // hypShow.Attributes.Add("data-target", "#editModal"); // hypShow.Attributes.Add("data-toggle", "modal"); // if (data.ApproveStatus == "Y") hypShow.Text = "<h4 class='txt-color-green'><i class='fa fa-check'></i></h4>"; // if (data.ApproveStatus == "N") hypShow.Text = "<h4 class='txt-color-red'><i class='fa fa-times'></i></h4>"; // hypShow.NavigateUrl = urlShow; // hypShow.ToolTip = "คลิกเพื่อเปลี่ยนสถานะอนุญาตหลักสูตร"; // cellApproveStatus.Controls.Add(hypShow); // } // else // { // string urlShow = "#"; // HyperLink hypShow = new HyperLink(); // hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; // hypShow.NavigateUrl = urlShow; // hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; // cellApproveStatus.Controls.Add(hypShow); // } // } // วิชาการภาค else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) { string urlShow = "#"; HyperLink hypShow = new HyperLink(); hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; hypShow.NavigateUrl = urlShow; hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; cellApproveStatus.Controls.Add(hypShow); } // วิชาการคณะ //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) //{ // string urlShow = "#"; // HyperLink hypShow = new HyperLink(); // hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; // hypShow.NavigateUrl = urlShow; // hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; // cellApproveStatus.Controls.Add(hypShow); //} //// วิชาการภาค //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) //{ // string urlShow = "#"; // HyperLink hypShow = new HyperLink(); // hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; // hypShow.NavigateUrl = urlShow; // hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; // cellApproveStatus.Controls.Add(hypShow); //} // ทุกกลุ่มผู้ใช้ else { string urlShow = "#"; HyperLink hypShow = new HyperLink(); hypShow.Text = "<h4><i class=\"fa fa-lock\"></i></h4>"; hypShow.NavigateUrl = urlShow; hypShow.ToolTip = "ไม่สามารถเปลี่ยนสถานะได้"; cellApproveStatus.Controls.Add(hypShow); } cellApproveStatus.CssClass = "text-center"; tRowBody.Cells.Add(cellApproveStatus); TableCell cellDetail = new TableCell(); cellDetail.Text = "<h4><a href=\"detailCurr.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"View\" target=\"_blank\"><i class=\"fa fa-search\"></i></a></h4>"; cellDetail.CssClass = "text-center"; tRowBody.Cells.Add(cellDetail); TableCell cellEdit = new TableCell(); // งานหลักสูตร if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) { if (data.CurrCode == "999999999") { cellEdit.Text = "<h4><a href=\"editCURR_GEN_EDU1.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Edit\"><i class='fa fa-edit'></i></a></h4>"; } else { cellEdit.Text = "<h4><a href=\"Faculty_edit_CURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Edit\"><i class='fa fa-edit'></i></a></h4>"; } } // วิชาการคณะ //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) //{ // bool editable = false; // List<string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty); // foreach (string fac in faculty_authorized) // { // if (fac == data.FacultyCode) // { // editable = true; // break; // } // } // if (editable == true) // { // cellEdit.Text = "<h4><a href=\"Faculty_edit_CURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Edit\"><i class='fa fa-edit'></i></a></h4>"; // } // else // { // cellEdit.Text = "<h4><a href='#' title=\"ไม่สามารถแก้ไขหลักสูตรได้\"><i class='fa fa-lock'></i></a></h4>"; // } //} // วิชาการภาค else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) { bool editable = false; List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department); foreach (string dep in department_authorized) { if (dep == data.DepartmentCode) { editable = true; break; } } if (editable == true) { cellEdit.Text = "<h4><a href=\"Faculty_edit_CURR.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Edit\"><i class='fa fa-edit'></i></a></h4>"; } else { cellEdit.Text = "<h4><a href='#' title=\"ไม่สามารถแก้ไขหลักสูตรได้\"><i class='fa fa-lock'></i></a></h4>"; } } // ทุกกลุ่มผู้ใช้ else { cellEdit.Text = "<h4><a href='#' title=\"ไม่สามารถแก้ไขหลักสูตรได้\"><i class='fa fa-lock'></i></a></h4>"; } cellEdit.CssClass = "text-center"; tRowBody.Cells.Add(cellEdit); TableCell cellDel = new TableCell(); //เช็คว่าหลักสูตรมีการนำไปใช้แล้วหรือยัง ถ้ามีแล้วจะไม่สามารถลบข้อมูลได้ bool chkExistCurr = new Student().existCurriculum("STUDENT", data.YearVersion + data.CurrCode); //ระดับปริญญาตรี bool chkGradExistCurr = new Student().existCurriculum("GRAD_STUDENT", data.YearVersion + data.CurrCode); //ระดับบัณฑิตศึกษา // งานหลักสูตร if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty) && chkExistCurr == false && chkGradExistCurr == false) { //string urlDel = "deleteElective_COURSE.aspx?token=" + data.CourseElectiveCode + "&facultyId=" + data.FacultyCode; string urlDel = "delete_CURRICULUM.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; HyperLink hypDel = new HyperLink(); hypDel.Attributes.Add("data-target", "#deleteModal"); hypDel.Attributes.Add("data-toggle", "modal"); hypDel.Text = "<h4><i class='fa fa-trash-o'></i></h4>"; hypDel.NavigateUrl = urlDel; hypDel.ToolTip = "Delete"; cellDel.Controls.Add(hypDel); } // วิชาการคณะ //else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty)) //{ // bool editable = false; // List<string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty); // foreach (string fac in faculty_authorized) // { // if (fac == data.FacultyCode) // { // editable = true; // break; // } // } // if (editable == true && chkExistCurr == false && chkGradExistCurr == false) // { // string urlDel = "delete_CURRICULUM.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; // HyperLink hypDel = new HyperLink(); // hypDel.Attributes.Add("data-target", "#deleteModal"); // hypDel.Attributes.Add("data-toggle", "modal"); // hypDel.Text = "<h4><i class='fa fa-trash-o'></i></h4>"; // hypDel.NavigateUrl = urlDel; // hypDel.ToolTip = "Delete"; // cellDel.Controls.Add(hypDel); // } // else // { // string urlDel = "#"; // HyperLink hypDel = new HyperLink(); // hypDel.Text = "<h4><i class='fa fa-lock'></i></h4>"; // hypDel.NavigateUrl = urlDel; // hypDel.ToolTip = "ไม่สามารถลบหลักสูตรได้"; // cellDel.Controls.Add(hypDel); // } //} // วิชาการภาค else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department)) { bool editable = false; List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department); foreach (string dep in department_authorized) { if (dep == data.DepartmentCode) { editable = true; break; } } if (editable == true && chkExistCurr == false && chkGradExistCurr == false) { string urlDel = "delete_CURRICULUM.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion; HyperLink hypDel = new HyperLink(); hypDel.Attributes.Add("data-target", "#deleteModal"); hypDel.Attributes.Add("data-toggle", "modal"); hypDel.Text = "<h4><i class='fa fa-trash-o'></i></h4>"; hypDel.NavigateUrl = urlDel; hypDel.ToolTip = "Delete"; cellDel.Controls.Add(hypDel); } else { string urlDel = "#"; HyperLink hypDel = new HyperLink(); hypDel.Text = "<h4><i class='fa fa-lock'></i></h4>"; hypDel.NavigateUrl = urlDel; hypDel.ToolTip = "ไม่สามารถลบหลักสูตรได้"; cellDel.Controls.Add(hypDel); } } // ทุกกลุ่มผู้ใช้ else { string urlDel = "#"; HyperLink hypDel = new HyperLink(); hypDel.Text = "<h4><i class='fa fa-lock'></i></h4>"; hypDel.NavigateUrl = urlDel; hypDel.ToolTip = "ไม่สามารถลบหลักสูตรได้"; cellDel.Controls.Add(hypDel); } cellDel.CssClass = "text-center"; cellDel.Width = 50; tRowBody.Cells.Add(cellDel); TableCell cellPrint = new TableCell(); cellPrint.Text = "<a href=\"PrintCurr.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Save PDF\" target=\"_blank\"><img src=\"../img/icon_pdf.png\" style=\"padding-bottom:5px\"></a>"; cellPrint.Text += "<a href=\"PrintCurr2.aspx?CurrCode=" + data.CurrCode + "&YearVersion=" + data.YearVersion + "\" title=\"Save Doc\" target=\"_blank\"><img src=\"../img/icon_doc.png\"></a>"; cellPrint.CssClass = "text-center"; tRowBody.Cells.Add(cellPrint); tblCurriculum.Rows.Add(tRowBody); } }
protected void Page_Load(object sender, EventArgs e) { //ทดสอบ ชั่วคราว ลบออกเมื่อใช้งานจริง //Session["CurrCode"] = "707012555"; //Session["YearVersion"] = "2555"; //Session["NumTQF1"] = "001"; CurrCode = Request.QueryString["CurrCode"]; YearVersion = Request.QueryString["YearVersion"]; TQF.Curriculum curriculum = new TQF.Curriculum().getCurriculum(CurrCode, YearVersion); StructurePlan structurePlan = new StructurePlan().getStructurePlan(CurrCode, YearVersion); Label1.Text = curriculum.CurrThName; //Label2.Text = curriculum.MajorName; if (curriculum.CurrStatus == "1") { //สถานะของหลักสูตร(1=ใหม่, 2=ปรับปรุง) curriculum.CurrStatus = "หลักสูตรใหม่"; } else { curriculum.CurrStatus = "หลักสูตรปรับปรุง"; } Label3.Text = "(" + curriculum.CurrStatus + " พ.ศ. " + curriculum.YearVersion + ")"; Label4.Text = "มหาวิทยาลัยเทคโนโลยีพระจอมเกล้าพระนครเหนือ"; Label5.Text = new Faculty().getFaculty(curriculum.FacultyCode).Faculty_Thai + " "; Label6.Text = new Department().getDepartment(curriculum.DepartmentCode).Department_Thai; //รหัสและชื่อหลักสูตร Label7.Text = curriculum.CurrCode; Label8.Text = curriculum.CurrThName; Label9.Text = curriculum.CurrShortThName; Label10.Text = curriculum.CurrEnName; Label11.Text = curriculum.CurrShortEnName; if (CurrCode != "999999999") { //ชื่อปริญญาและสาขาวิชา Label12.Text = new Diploma().getDiploma(curriculum.DiplomaCode).DomainThName; Label13.Text = new Diploma().getDiploma(curriculum.DiplomaCode).DomainThShortName; Label14.Text = new Diploma().getDiploma(curriculum.DiplomaCode).DomainEnName; Label15.Text = new Diploma().getDiploma(curriculum.DiplomaCode).DomainEnShortName; //วันที่อนุมัติหลักสูตร และภาคการศึกษาที่เริ่มใช้หลักสูตร Label16.Text = new utility().getThaiBirthDay(curriculum.ApprovedDate); Label17.Text = curriculum.BeginSemester + "/" + curriculum.YearVersion; //จำนวนหน่วยกิตที่เรียนตลอดหลักสูตร Label18.Text = structurePlan.TotalCredits + " หน่วยกิต"; } //รูปแบบของหลักสูตร string sqlStructurePlan = "Select * From STRUCTUREPLAN Where CURRCODE='" + CurrCode + "' And YEARVERSION='" + YearVersion + "'"; List <StructurePlan> dataStructurePlan = new StructurePlan().getStructurePlanManual(sqlStructurePlan); foreach (StructurePlan data in dataStructurePlan) { Label19.Text = new CurrFormat().getCurrFormat(data.CurrFormatCode).CurrFormatName; if (dataStructurePlan.Count > 1) { Label19.Text += "<br>"; } //Tab 2: โครงสร้างหลักสูตร htmlGenerateTab2(data.MajorCode, data.CurrFormatCode, data.TotalCredits, data.YearVersion, data.CurrTypeCode); //Tab 3: รายวิชาในหลักสูตร htmlGenerateTab3(data.MajorCode, data.CurrFormatCode, data.TotalCredits, data.YearVersion, data.CurrTypeCode); //Tab 4: แผนการศึกษา htmlGenerateTab4(data.MajorCode, data.CurrFormatCode, data.TotalCredits, data.YearVersion, data.CurrTypeCode); //Tab 5: คำอธิบายรายวิชา htmlGenerateTab5(data.MajorCode, data.CurrFormatCode, data.TotalCredits, data.YearVersion, data.CurrTypeCode); } Label20.Text = curriculum.NumYear + " ปี / " + curriculum.MaxNumYear + " ปี"; //อาจารย์ผู้รับผิดชอบหลักสูตร //ความหมาย LOADTYPECODE //1 อาจารย์ประจำหลักสูตร //4 อาจารย์ประจำแขนง string sqlLecturer = "Select * From ABOUTLECTURER Where CURRCODE='" + CurrCode + "' And YEARVERSION='" + YearVersion + "' And LOADTYPECODE='1' Order By LECTIDENTITY"; List <AboutLecturer> aboutLecturer = new AboutLecturer().getAboutLecturerManual(sqlLecturer); int i = 1; foreach (AboutLecturer data in aboutLecturer) { SysUser sysUser = new SysUser().getSysUser(data.LectIdentity); AcademicPosition position = new AcademicPosition().getAcademicPosition(sysUser.AcademicPositionCode); Label21.Text += "<span class=\"report-indent-1em\">" + i + ". " + position.AcademicPositionThName + sysUser.ThName + " " + sysUser.ThSurName + "</span><BR>"; i++; } //Export to PDF utility utname = new utility(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + CurrCode + ".pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); dvHtml.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A4, 50f, 50f, 50f, 50f); //Document pdfDoc = new Document(PageSize.A4.Rotate(), 50f, 50f, 10f, 10f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); StyleSheet styles = new StyleSheet(); FontFactory.Register(Server.MapPath("~/Fonts/") + "THSarabunNew.ttf"); styles.LoadTagStyle("body", HtmlTags.FACE, "THSarabunNew"); styles.LoadTagStyle("body", "size", "16pt"); styles.LoadTagStyle("body", "encoding", BaseFont.IDENTITY_H); styles.LoadTagStyle(HtmlTags.TABLE, "width", "100%"); styles.LoadTagStyle(HtmlTags.TABLE, "align", "center"); styles.LoadTagStyle(HtmlTags.TABLE, HtmlTags.BORDER, "0"); styles.LoadTagStyle(HtmlTags.TH, HtmlTags.BORDER, "0"); styles.LoadTagStyle(HtmlTags.TD, HtmlTags.BORDER, "0"); htmlparser.SetStyleSheet(styles); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); Response.End(); //End Export to PDF }