Beispiel #1
0
    // V 1.0.0
    public List <RoundPaidData> getNotExpireRoundPaid(string academic_year, string semester, string faculty_code, string degree_char)
    {
        List <RoundPaidData> RoundData = new List <RoundPaidData>();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        oracleObj.SelectCommand = "Select * From Round_Paid Where ACADEMIC_YEAR='" + academic_year + "' AND SEMESTER='" + semester + "' AND Faculty_Code='" + faculty_code + "' AND DEGREE_CHAR='" + degree_char + "' Order By ROUND";

        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);

        foreach (DataRowView rowData in allData)
        {
            utility utlObj    = new utility();
            string  due_date  = rowData["DUE_DATE"].ToString();
            int     diff_date = utlObj.getDiffDate(due_date, utlObj.getToday());

            if (diff_date >= 0)
            {
                RoundPaidData round_data = new RoundPaidData();
                round_data.Academic_Year = rowData["ACADEMIC_YEAR"].ToString();
                round_data.Semester      = rowData["SEMESTER"].ToString();
                round_data.Faculty_Code  = rowData["FACULTY_CODE"].ToString();
                round_data.Degree_Char   = rowData["DEGREE_CHAR"].ToString();
                round_data.RoundPaid     = Convert.ToInt16(rowData["ROUND"].ToString());
                round_data.Start_Date    = rowData["START_DATE"].ToString();
                round_data.Due_Date      = rowData["DUE_DATE"].ToString();
                RoundData.Add(round_data);
            }
        }

        return(RoundData);
    }
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        DateTime dt;
        utility  utlObj = new utility();

        if (!DateTime.TryParseExact(txtStartDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
        {
            MsgValidate("รูปแบบวันเริ่มต้นการจัดตาราสอน/ตาราสอบ วัน/เดือน/ปี เช่น 01/10/2015");
        }
        else if (!DateTime.TryParseExact(txtStopDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
        {
            MsgValidate("รูปแบบวันสุดท้ายการจัดตาราสอน/ตาราสอบ วัน/เดือน/ปี เช่น 01/10/2015");
        }
        else if (utlObj.getDiffDate(txtStartDate.Text, txtStopDate.Text) > 0)
        {
            MsgValidate("วันเริ่มแรกและวันสุดท้ายของการขึ้นทะเบียน ไม่สอดคล้องกัน");
        }
        else
        {
            config_data.Date_Start = txtStartDate.Text;
            config_data.Date_Stop  = txtStopDate.Text;
            string result = new TeachExamConfig().updateDateConfig(config_data);
            if (result == "OK")
            {
                fail.Visible    = false;
                success.Visible = true;
            }
            else
            {
                fail.Visible    = true;
                success.Visible = false;
            }
        }
    }
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        utility  utlObj = new utility();
        DateTime dt;

        if (ddlDepartment.SelectedItem.Value == "0")
        {
            MsgValidate("โปรดระบุ ภาควิชา");
        }
        else if (!DateTime.TryParseExact(txtStartDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
        {
            MsgValidate("รูปแบบวันเริ่มต้นการจัดตาราสอน/ตาราสอบ วัน/เดือน/ปี เช่น 01/10/2015");
        }
        else if (!DateTime.TryParseExact(txtStopDate.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out dt))
        {
            MsgValidate("รูปแบบวันสุดท้ายการจัดตาราสอน/ตาราสอบ วัน/เดือน/ปี เช่น 01/10/2015");
        }
        else if (utlObj.getDiffDate(txtStartDate.Text, txtStopDate.Text) > 0)
        {
            MsgValidate("วันเริ่มแรกและวันสุดท้ายของการขึ้นทะเบียน ไม่สอดคล้องกัน");
        }
        else
        {
            string result = "";
            config_data.Faculty_Code    = ddlFACULTY.SelectedItem.Value;
            config_data.Department_Code = ddlDepartment.SelectedItem.Value;
            config_data.Date_Start      = txtStartDate.Text;
            config_data.Date_Stop       = txtStopDate.Text;

            configData = new TeachExamConfig().getExtendTeachExamConfig(ddlDepartment.SelectedItem.Value);

            if (configData.Department_Code == null)
            {
                result          = new TeachExamConfig().extendDateConfig(config_data);
                lblSuccess.Text = "เพิ่มข้อมูลสำเร็จ";
            }
            else
            {
                config_data.Department_Code = configData.Department_Code;
                result          = new TeachExamConfig().updateExtendDateConfig(config_data);
                lblSuccess.Text = "แก้ไขข้อมูลสำเร็จ";
            }

            if (result == "OK")
            {
                success.Visible = true;
                fail.Visible    = false;
            }
            else
            {
                success.Visible = false;
                fail.Visible    = true;
            }
        }
    }
Beispiel #4
0
    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_faculty) || autro_obj.CheckGroupUser(login_data, group_var.officer_department))
            {
                divFail.Visible = false;

                if ((Session["save_data"] != null) && (Session["service_course"] != null))
                {
                    ConnectDB     db        = new ConnectDB();
                    SqlDataSource oracleObj = db.ConnectionOracle_tqf2();


                    available_data = (AvailableCourseData)Session["save_data"];
                    service_code   = (bool)Session["service_course"];



                    if (service_code == true)
                    {
                        // ตรวจสอบกำหนดการ

                        int diffDate = -1;


                        config_data1 = new TeachExamConfig().getTeachExamConfig();

                        if (config_data1.Date_Stop != null)
                        {
                            diffDate = utlObj.getDiffDate(config_data1.Date_Stop, utlObj.getToday());
                        }



                        string sql = "";
                        curr_year       = available_data.Curr_Code.Substring(0, 4);
                        curr_code       = available_data.Curr_Code.Substring(4);
                        lblFaculty.Text = "วิชาบริการศึกษา";
                        //available_data.Faculty_Code = "xx";
                        //available_data.Department_Code = "xxxx";
                        available_data.Major_Code = "xxxxxx";
                        lblCurri.Text             = new Curriculum().getCurriculum(available_data.Curr_Code).Curr_ThaiName + " (" + curr_year + ")";


                        //วิชาการคณะ
                        if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                        {
                            List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty);

                            sql = "Select DISTINCT COURSECODE From TQF2SEC3PLANDETAIL Where CURRCODE='" + curr_code + "' AND YEARVERSION='" + curr_year + "' AND  COURSECODE NOT Like '%x' AND (";

                            int ii = 0;
                            foreach (string fac in faculty_authorized)
                            {
                                ii++;
                                sql += "COURSECODE Like '" + fac + "%'";

                                if (faculty_authorized.Count != ii)
                                {
                                    sql += " OR ";
                                }
                            }

                            sql += ") Order By COURSECODE";
                            // lblCurri.Text = sql;
                        }

                        //วิชาการภาค
                        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);

                            sql = "Select DISTINCT COURSECODE From TQF2SEC3PLANDETAIL Where CURRCODE='" + curr_code + "' AND YEARVERSION='" + curr_year + "' AND  COURSECODE NOT Like '%x' AND (";

                            int ii = 0;
                            foreach (string dep in department_authorized)
                            {
                                ii++;
                                sql += "COURSECODE Like '" + dep + "%'";

                                if (department_authorized.Count != ii)
                                {
                                    sql += " OR ";
                                }
                            }

                            sql += ") Order By COURSECODE";
                        }

                        oracleObj.SelectCommand = sql;
                        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
                        all_course.Clear();
                        foreach (DataRowView rowData in allData)
                        {
                            int diffExtDate = -1;
                            config_data2 = new TeachExamConfig().getExtendTeachExamConfig(rowData["COURSECODE"].ToString().Substring(0, 4));
                            if (config_data2.Date_Stop != null)
                            {
                                diffExtDate = utlObj.getDiffDate(config_data2.Date_Stop, utlObj.getToday());
                            }

                            if (diffDate >= 0)
                            {
                                if (course.checkStatus(rowData["COURSECODE"].ToString()))
                                {
                                    all_course.Add(rowData["COURSECODE"].ToString());
                                }
                            }
                            else if (diffExtDate >= 0)
                            {
                                if (course.checkStatus(rowData["COURSECODE"].ToString()))
                                {
                                    all_course.Add(rowData["COURSECODE"].ToString());
                                }
                            }
                        }
                    }
                    else if (service_code == false)
                    {
                        curr_year = available_data.Curr_Code.Substring(0, 4);
                        curr_code = available_data.Curr_Code.Substring(4);

                        lblFaculty.Text = new Faculty().getFaculty(available_data.Faculty_Code).Faculty_Thai;
                        lblCurri.Text   = curr_code + " " + new Curriculum().getCurriculum(available_data.Curr_Code).Curr_ThaiName + " (" + curr_year + ")";

                        string sql = "";

                        //วิชาการคณะ
                        if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                        {
                            List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty);

                            sql = "Select DISTINCT COURSECODE From TQF2SEC3PLANDETAIL Where CURRCODE='" + curr_code + "' AND YEARVERSION='" + curr_year + "' AND  COURSECODE NOT Like '%x' AND (";

                            int ii = 0;
                            foreach (string fac in faculty_authorized)
                            {
                                ii++;
                                sql += "COURSECODE Like '" + fac + "%'";

                                if (faculty_authorized.Count != ii)
                                {
                                    sql += " OR ";
                                }
                            }

                            sql += ") Order By COURSECODE";
                        }

                        //วิชาการภาค
                        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);

                            sql = "Select DISTINCT COURSECODE From TQF2SEC3PLANDETAIL Where CURRCODE='" + curr_code + "' AND YEARVERSION='" + curr_year + "' AND  COURSECODE NOT Like '%x' AND (";

                            int ii = 0;
                            foreach (string dep in department_authorized)
                            {
                                ii++;
                                sql += "COURSECODE Like '" + dep + "%'";

                                if (department_authorized.Count != ii)
                                {
                                    sql += " OR ";
                                }
                            }

                            sql += ") Order By COURSECODE";
                        }

                        oracleObj.SelectCommand = sql;

                        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
                        all_course.Clear();
                        foreach (DataRowView rowData in allData)
                        {
                            if (course.checkStatus(rowData["COURSECODE"].ToString()))
                            {
                                all_course.Add(rowData["COURSECODE"].ToString());
                            }
                        }
                    }


                    RadioButton[] radio = new RadioButton[all_course.Count];
                    int           i     = 0;

                    // Head Table
                    string[] ar  = { "รหัสวิชา", "ชื่อวิชา", "หน่วยกิต", "เลือก" };
                    Table    tb1 = new Table();
                    tb1.Attributes.Add("class", "table table-bordered table-hover");
                    tb1.Attributes.Add("id", "dt_basic");
                    TableHeaderRow tRowHead = new TableHeaderRow();
                    tRowHead.TableSection = TableRowSection.TableHeader;
                    for (int cellCtr = 1; cellCtr <= ar.Length; cellCtr++)
                    {
                        // Create a new cell and add it to the row.
                        TableHeaderCell cellHead = new TableHeaderCell();
                        cellHead.Attributes.Add("class", "text-center");
                        cellHead.Text = ar[cellCtr - 1];
                        tRowHead.Cells.Add(cellHead);
                    }

                    tb1.Rows.Add(tRowHead);

                    foreach (string course_code in all_course)
                    {
                        TableRow tRowBody = new TableRow();
                        tRowBody.TableSection = TableRowSection.TableBody;

                        course_data = course.getCourse(course_code);


                        TableCell cellCourse_Code = new TableCell();
                        cellCourse_Code.Text = course_data.Course_Code;
                        tRowBody.Cells.Add(cellCourse_Code);

                        TableCell cellCourse_Name = new TableCell();
                        cellCourse_Name.Text = course_data.Course_Thainame + "<br/>" + course_data.Course_Engname;
                        tRowBody.Cells.Add(cellCourse_Name);

                        TableCell cellCourse_Credit = new TableCell();
                        cellCourse_Credit.Text = Convert.ToString(course_data.Credit) + "(" + Convert.ToString(course_data.Theory) + "-" + Convert.ToString(course_data.Practice) + "-" + course_data.Self_Study.ToString() + ")";
                        cellCourse_Credit.Attributes.Add("class", "text-center");
                        tRowBody.Cells.Add(cellCourse_Credit);

                        TableCell cellCourse_Radio = new TableCell();

                        radio[i]    = new RadioButton();
                        radio[i].ID = course_data.Course_Code;
                        cellCourse_Radio.Attributes.Add("class", "text-center");
                        radio[i].AutoPostBack    = true;
                        radio[i].GroupName       = "course_group";
                        radio[i].CheckedChanged += new EventHandler(radioButtons_CheckedChanged);
                        cellCourse_Radio.Controls.Add(radio[i]);


                        tRowBody.Cells.Add(cellCourse_Radio);

                        tb1.Rows.Add(tRowBody);

                        i++;
                    }

                    TableRow  row  = new TableRow();
                    TableCell cell = new TableCell();
                    cell.Controls.Add(tb1);
                    row.Cells.Add(cell);
                    tblCourse.Rows.Add(row);

                    //Disable Next button when page load
                    btnNext.Disabled = true;
                }
                else
                {
                    divShow.Visible = false;
                    divFail.Visible = true;
                }
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Beispiel #5
0
    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_faculty) || autro_obj.CheckGroupUser(login_data, group_var.officer_department) || autro_obj.CheckGroupUser(login_data, group_var.board_reg_sta) || autro_obj.CheckGroupUser(login_data, group_var.officer_reg_sta))
            {
                divShow.Visible    = false;
                divSuccess.Visible = false;
                divFail.Visible    = false;
                divFail2.Visible   = false;

                try
                {
                    divShow.Visible = true;

                    academic_year = Request.QueryString["year"];
                    semester      = Request.QueryString["sem"];
                    course_code   = Request.QueryString["course"];
                    curr_code     = Request.QueryString["curr_code"];
                    fac_code      = Request.QueryString["fac_code"];
                    dep_code      = Request.QueryString["dep_code"];
                    degree_char   = Request.QueryString["degree_char"];

                    //course_type = "";

                    //if (Request.QueryString["type"] == "S")
                    //{
                    //    course_type = "1";
                    //}
                    //else if (Request.QueryString["type"] == "L")
                    //{
                    //    course_type = "2";
                    //}
                    //else if (Request.QueryString["type"] == "T")
                    //{
                    //    course_type = "4";
                    //}
                    //else if (Request.QueryString["type"] == "M")
                    //{
                    //    course_type = "5";
                    //}
                    //else if (Request.QueryString["type"] == "SP")
                    //{
                    //    course_type = "6";
                    //}
                    //else if (Request.QueryString["type"] == "D")
                    //{
                    //    course_type = "7";
                    //}

                    //sec_num = Convert.ToInt16(Request.QueryString["sec"]);
                    //subsec_num = Convert.ToInt16(Request.QueryString["subsec"]);
                    //getAvailableCourse(string academic_year, string semester, string faculty_code, string department_code, string curr_code, string course_code, string degree_char)

                    available_data = new AvailableCourse().getAvailableCourse(academic_year, semester, fac_code, dep_code, curr_code, course_code, degree_char);

                    // ตรวจสอบกำหนดการ
                    config_data1 = new TeachExamConfig().getTeachExamConfig();
                    config_data2 = new TeachExamConfig().getExtendTeachExamConfig(available_data[0].Department_Code);
                    int diffDate    = -1;
                    int diffExtDate = -1;

                    if (config_data1.Date_Stop != null)
                    {
                        diffDate = utlObj.getDiffDate(config_data1.Date_Stop, utlObj.getToday());
                    }

                    if (config_data2.Date_Stop != null)
                    {
                        diffExtDate = utlObj.getDiffDate(config_data2.Date_Stop, utlObj.getToday());
                    }

                    // งานทะเบียน บัญฑิต
                    if (autro_obj.CheckGroupUser(login_data, group_var.board_reg_sta) || autro_obj.CheckGroupUser(login_data, group_var.officer_reg_sta))
                    {
                    }
                    // วิชาการ คณะ
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                    {
                        int           i = 0;
                        List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty);
                        foreach (string fac in faculty_authorized)
                        {
                            if (available_data[0].Faculty_Code == fac)
                            {
                                i++;
                                break;
                            }
                        }

                        if (i == 0)
                        {
                            MsgValidate("ไม่มีสิทธิ์ในการแก้ไขข้อมูล");
                            btnSAVE.Enabled = false;
                        }
                        else if (diffDate < 0 && diffExtDate < 0)
                        {
                            MsgValidate("เกินกำหนดระยะเวลาแก้ไขข้อมูล");
                            btnSAVE.Enabled = false;
                        }
                    }
                    // วิชาการภาค
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department))
                    {
                        int           i = 0;
                        List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department);
                        foreach (string dep in department_authorized)
                        {
                            if (available_data[0].Department_Code == dep)
                            {
                                i++;
                                break;
                            }
                        }

                        if (i == 0)
                        {
                            MsgValidate("ไม่มีสิทธิ์ในการแก้ไขข้อมูล");
                            btnSAVE.Enabled = false;
                        }
                        else if (diffDate < 0 && diffExtDate < 0)
                        {
                            MsgValidate("เกินกำหนดระยะเวลาแก้ไขข้อมูล");
                            btnSAVE.Enabled = false;
                        }
                    }



                    exam_data = examObj.getExamTable(available_data[0].AcademicYear, available_data[0].Semester, available_data[0].Course_Code, available_data[0].Faculty_Code, available_data[0].Department_Code, available_data[0].Curr_Code, degree_char);

                    if (exam_data.Course_Code != null)
                    {
                        if (!IsPostBack)
                        {
                            txtMIDEXAM_DAY.Text        = exam_data.ExamMid_Day;
                            txtMIDTERM_START_TIME.Text = exam_data.ExamMid_StartTime;
                            txtMIDTERM_END_TIME.Text   = exam_data.ExamMid_EndTime;
                            txtFINALEXAM_DAY.Text      = exam_data.ExamFinal_Day;
                            txtFINAL_START_TIME.Text   = exam_data.ExamFinal_StartTime;
                            txtFINAL_END_TIME.Text     = exam_data.ExamFinal_EndTime;
                        }

                        save         = false;
                        btnSAVE.Text = "Update";
                    }
                    else
                    {
                        save         = true;
                        btnSAVE.Text = "Save";
                    }

                    lblSemesterYear.Text = semester + "/" + academic_year;
                    CourseData course_data = new CourseData();
                    course_data    = new Course().getCourse(available_data[0].Course_Code);
                    lblCourse.Text = available_data[0].Course_Code + ":" + course_data.Course_Engname + ", " + course_data.Credit + "(" + course_data.Theory + "-" + course_data.Practice + "-" + course_data.Self_Study + ")";

                    //if (course_type == "1")
                    //{
                    //    lblSec.Text = "S." + sec_num;
                    //}
                    //else if (course_type == "2")
                    //{
                    //    if (subsec_num != 0)
                    //    {
                    //        lblSec.Text = "L." + subsec_num;
                    //    }
                    //    else
                    //    {
                    //        lblSec.Text = "L." + sec_num;
                    //    }
                    //}
                    //else if (course_type == "4")
                    //{
                    //    lblSec.Text = "T." + sec_num;
                    //}
                    //else if (course_type == "5")
                    //{
                    //    lblSec.Text = "M." + sec_num;
                    //}
                    //else if (course_type == "6")
                    //{
                    //    lblSec.Text = "SP." + sec_num;
                    //}
                    //else if (course_type == "7")
                    //{
                    //    lblSec.Text = "D." + sec_num;
                    //}
                }
                catch
                {
                    divFail.Visible = true;
                }
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Beispiel #6
0
    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_faculty) || autro_obj.CheckGroupUser(login_data, group_var.officer_department))
            {
                divFail.Visible = false;

                if ((Session["save_data"] != null) && (Session["service_course"] != null))
                {
                    ConnectDB     db        = new ConnectDB();
                    SqlDataSource oracleObj = db.ConnectionOracle();

                    available_data = (AvailableCourseData)Session["save_data"];
                    service_code   = (bool)Session["service_course"];

                    CurriculumGeneralData curr = new Curriculum().getCurriculum(available_data.Curr_Code);
                    degree_char = curr.Degree_Char;


                    CourseData course_data = new CourseData();
                    Course     course      = new Course();

                    List <string> all_course = new List <string>();
                    string        TableName  = new AvailableCourse().getTableName(degree_char);

                    string sql = "";

                    if (service_code == true)
                    {
                        lblFaculty.Text = "วิชาบริการศึกษา";
                        lblCurri.Text   = curr.Curr_ThaiName + " (ปีหลักสูตร " + curr.Curr_Year + ")";

                        // ตรวจสอบกำหนดการ

                        int diffDate = -1;


                        config_data1 = new TeachExamConfig().getTeachExamConfig();

                        if (config_data1.Date_Stop != null)
                        {
                            diffDate = utlObj.getDiffDate(config_data1.Date_Stop, utlObj.getToday());
                        }

                        //วิชาการคณะ
                        if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                        {
                            List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty);

                            sql = "Select COURSE_CODE From " + TableName + " Where ACADEMIC_YEAR='" + available_data.AcademicYear + "' And SEMESTER='" + available_data.Semester + "' And CURR_CODE='" + available_data.Curr_Code + "' And (";

                            int ii = 0;
                            foreach (string fac in faculty_authorized)
                            {
                                ii++;
                                sql += "FACULTY_CODE= '" + fac + "'";

                                if (faculty_authorized.Count != ii)
                                {
                                    sql += " OR ";
                                }
                            }

                            sql += ") GROUP By COURSE_CODE Order By COURSE_CODE";
                        }
                        //วิชาการภาค
                        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);

                            sql = "Select COURSE_CODE From " + TableName + " Where ACADEMIC_YEAR='" + available_data.AcademicYear + "' And SEMESTER='" + available_data.Semester + "' And CURR_CODE='" + available_data.Curr_Code + "' And (";

                            int ii = 0;
                            foreach (string dep in department_authorized)
                            {
                                ii++;
                                sql += "DEPARTMENT_CODE= '" + dep + "'";

                                if (department_authorized.Count != ii)
                                {
                                    sql += " OR ";
                                }
                            }

                            sql += ") GROUP By COURSE_CODE Order By COURSE_CODE";
                        }

                        oracleObj.SelectCommand = sql;
                        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
                        all_course.Clear();
                        foreach (DataRowView rowData in allData)
                        {
                            int diffExtDate = -1;
                            config_data2 = new TeachExamConfig().getExtendTeachExamConfig(rowData["COURSE_CODE"].ToString().Substring(0, 4));
                            if (config_data2.Date_Stop != null)
                            {
                                diffExtDate = utlObj.getDiffDate(config_data2.Date_Stop, utlObj.getToday());
                            }

                            if (diffDate >= 0)
                            {
                                all_course.Add(rowData["COURSE_CODE"].ToString());
                            }
                            else if (diffExtDate >= 0)
                            {
                                all_course.Add(rowData["COURSE_CODE"].ToString());
                            }
                        }
                    }
                    else if (service_code == false)
                    {
                        lblFaculty.Text = new Faculty().getFaculty(available_data.Faculty_Code).Faculty_Thai;
                        lblCurri.Text   = curr.Curr_Code + " " + curr.Curr_ThaiName;

                        sql = "Select COURSE_CODE From " + TableName + " Where ACADEMIC_YEAR='" + available_data.AcademicYear + "' And SEMESTER='" + available_data.Semester + "' And FACULTY_CODE='" + available_data.Faculty_Code + "' And DEPARTMENT_CODE='" + available_data.Department_Code + "' And CURR_CODE='" + available_data.Curr_Code + "' GROUP By COURSE_CODE Order By COURSE_CODE";

                        oracleObj.SelectCommand = sql;
                        DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
                        foreach (DataRowView rowData in allData)
                        {
                            all_course.Add(rowData["COURSE_CODE"].ToString());
                        }
                    }



                    RadioButton[] radio = new RadioButton[all_course.Count];
                    int           i     = 0;

                    // Head Table
                    string[] ar  = { "รหัสวิชา", "ชื่อวิชา", "หน่วยกิต", "เลือก" };
                    Table    tb1 = new Table();
                    tb1.Attributes.Add("class", "table table-bordered table-hover");
                    tb1.Attributes.Add("id", "dt_basic");
                    TableHeaderRow tRowHead = new TableHeaderRow();
                    tRowHead.TableSection = TableRowSection.TableHeader;
                    for (int cellCtr = 1; cellCtr <= ar.Length; cellCtr++)
                    {
                        // Create a new cell and add it to the row.
                        TableHeaderCell cellHead = new TableHeaderCell();
                        cellHead.Attributes.Add("class", "text-center");
                        cellHead.Text = ar[cellCtr - 1];
                        tRowHead.Cells.Add(cellHead);
                    }

                    tb1.Rows.Add(tRowHead);

                    foreach (string course_code in all_course)
                    {
                        TableRow tRowBody = new TableRow();
                        tRowBody.TableSection = TableRowSection.TableBody;

                        course_data = course.getCourse(course_code);

                        if (course_data.Practice != 0 && course_data.Theory != 0)
                        {
                            TableCell cellCourse_Code = new TableCell();
                            cellCourse_Code.Text = course_data.Course_Code;
                            tRowBody.Cells.Add(cellCourse_Code);

                            TableCell cellCourse_Name = new TableCell();
                            cellCourse_Name.Text = course_data.Course_Thainame + "<br/>" + course_data.Course_Engname;
                            tRowBody.Cells.Add(cellCourse_Name);

                            TableCell cellCourse_Credit = new TableCell();
                            cellCourse_Credit.Attributes.Add("class", "text-center");
                            cellCourse_Credit.Text = Convert.ToString(course_data.Credit) + "(" + Convert.ToString(course_data.Theory) + "-" + Convert.ToString(course_data.Practice) + "-" + course_data.Self_Study.ToString() + ")";
                            tRowBody.Cells.Add(cellCourse_Credit);

                            TableCell cellCourse_Radio = new TableCell();
                            cellCourse_Radio.Attributes.Add("class", "text-center");
                            radio[i]              = new RadioButton();
                            radio[i].ID           = course_data.Course_Code;
                            radio[i].AutoPostBack = true;
                            radio[i].GroupName    = "course_group";
                            if (Session["selected_course"] != null)
                            {
                                if (radio[i].ID == (string)Session["selected_course"])
                                {
                                    radio[i].Checked = true;
                                }
                            }
                            radio[i].CheckedChanged += new EventHandler(radioButtons_CheckedChanged);
                            cellCourse_Radio.Controls.Add(radio[i]);
                            tRowBody.Cells.Add(cellCourse_Radio);

                            tb1.Rows.Add(tRowBody);

                            i++;
                        }
                    }

                    if (!Page.IsPostBack)
                    {
                        //A1.Disabled = true;
                    }

                    TableRow  row  = new TableRow();
                    TableCell cell = new TableCell();
                    cell.Controls.Add(tb1);
                    row.Cells.Add(cell);
                    tblCourse.Rows.Add(row);
                }
                else
                {
                    divShow.Visible = false;
                    divFail.Visible = true;
                }
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Beispiel #7
0
    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_faculty) || autro_obj.CheckGroupUser(login_data, group_var.officer_department))
            {
                divFail.Visible = false;
                if (rbt1.Checked == true)
                {
                    ddlServiceCURRICULUM.Enabled   = false;
                    ddlServiceCURRICULUM.BackColor = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");

                    ddlFACULTY.Enabled      = true;
                    ddlDepartment.Enabled   = true;
                    ddlCURRICULUM.Enabled   = true;
                    ddlFACULTY.BackColor    = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
                    ddlDepartment.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
                    ddlCURRICULUM.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
                }
                else if (rbt2.Checked == true)
                {
                    ddlFACULTY.Enabled      = false;
                    ddlDepartment.Enabled   = false;
                    ddlCURRICULUM.Enabled   = false;
                    ddlFACULTY.BackColor    = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
                    ddlDepartment.BackColor = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
                    ddlCURRICULUM.BackColor = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");

                    ddlServiceCURRICULUM.Enabled   = true;
                    ddlServiceCURRICULUM.BackColor = System.Drawing.ColorTranslator.FromHtml("#FFFFFF");
                }

                if (!Page.IsPostBack)
                {
                    Session.Remove("save_data");
                    Session.Remove("save_student");
                    Session.Remove("save_teaching");
                    Session.Remove("save_p_teaching");
                    Session.Remove("save_lecturer");
                    Session.Remove("selected_course");
                    Session.Remove("selected_t_course");
                    Session.Remove("Sec");
                    Session.Remove("number_student");
                    Session.Remove("service_course");

                    config_data           = new TeachExamConfig().getTeachExamConfig();
                    txtACADEMIC_YEAR.Text = config_data.AcademicYear;
                    academic_year         = config_data.AcademicYear;
                    ddlSEMESTER.Items.FindByValue(config_data.Semester).Selected = true;

                    string faculty_code    = "";
                    string department_code = "";

                    // ระดับการศึกษา
                    degreeLevel = new Degree().getDegreeChar();
                    foreach (DegreeData data in degreeLevel)
                    {
                        ddlDEGREE.Items.Insert(ddlDEGREE.Items.Count, new ListItem(data.Degree_Thai, data.Degree_Char));
                    }

                    string Curr_LevelCode = "";
                    if (ddlDEGREE.SelectedValue == "U")
                    {
                        Curr_LevelCode = "01";
                    }
                    else if (ddlDEGREE.SelectedValue == "B")
                    {
                        Curr_LevelCode = "02";
                    }
                    else if (ddlDEGREE.SelectedValue == "M")
                    {
                        Curr_LevelCode = "03";
                    }
                    else if (ddlDEGREE.SelectedValue == "P")
                    {
                        Curr_LevelCode = "05";
                    }
                    else if (ddlDEGREE.SelectedValue == "D")
                    {
                        Curr_LevelCode = "04";
                    }

                    // ตรวจสอบกำหนดการ
                    config_data1 = new TeachExamConfig().getTeachExamConfig();

                    int diffDate = -1;
                    if (config_data1.Date_Stop != null)
                    {
                        diffDate = utlObj.getDiffDate(config_data1.Date_Stop, utlObj.getToday());
                    }



                    //วิชาการคณะ
                    if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                    {
                        List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.officer_faculty);

                        facultyData = new Faculty().getFaculty(faculty_authorized);
                        foreach (FacultyData data in facultyData)
                        {
                            ddlFACULTY.Items.Insert(ddlFACULTY.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                        }

                        faculty_code = ddlFACULTY.SelectedValue;

                        departmentData = new Department().getDepartmentWithFaculty(faculty_code);
                        foreach (DepartmentData data in departmentData)
                        {
                            int diffExtDate = -1;
                            config_data2 = new TeachExamConfig().getExtendTeachExamConfig(data.Department_Code);

                            if (config_data2.Date_Stop != null)
                            {
                                diffExtDate = utlObj.getDiffDate(config_data2.Date_Stop, utlObj.getToday());
                            }

                            if (diffDate >= 0)
                            {
                                ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                            }
                            else if (diffExtDate >= 0)
                            {
                                ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                            }
                            else
                            {
                                ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem("<เกินกำหนด> " + data.Department_Thai, data.Department_Code.Substring(0, 2) + "xx"));
                                //ddlDepartment.Items[ddlDepartment.Items.Count - 1].Attributes.Add("style", "color:red;");
                            }
                        }

                        department_code = ddlDepartment.SelectedValue;

                        string curr_sql = "Select * From CURRICULUM Where FACULTYCODE='" + faculty_code + "' AND DEPARTMENTCODE='" + department_code + "' AND CURRCODE!='999999999' AND LEVELCODE='" + Curr_LevelCode + "' AND APPROVESTATUS='Y'";
                        currData = new Curriculum().getManualCurriculum(curr_sql);

                        ddlCURRICULUM.Items.Clear();
                        if (currData.Count.Equals(0))
                        {
                            ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem("--- เลือกหลักสูตร ---", "0"));
                        }
                        else
                        {
                            foreach (CurriculumGeneralData data in currData)
                            {
                                ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem(data.Curr_Code + " " + data.Curr_ThaiName + " (" + data.Curr_Year + ")", data.Curr_Year + data.Curr_Code));
                            }
                        }
                    }


                    //วิชาการภาค
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department))
                    {
                        ddlFACULTY.Enabled = false;
                        List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department);

                        // ตรวจสอบกำหนดการ
                        // config_data1 = new TeachExamConfig().getTeachExamConfig();



                        departmentData = new Department().getDepartment(department_authorized);
                        foreach (DepartmentData data in departmentData)
                        {
                            int diffExtDate = -1;
                            config_data2 = new TeachExamConfig().getExtendTeachExamConfig(data.Department_Code);

                            if (config_data2.Date_Stop != null)
                            {
                                diffExtDate = utlObj.getDiffDate(config_data2.Date_Stop, utlObj.getToday());
                            }

                            if (diffDate >= 0)
                            {
                                ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                            }
                            else if (diffExtDate >= 0)
                            {
                                ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                            }
                            else
                            {
                                ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem("<เกินกำหนด> " + data.Department_Thai, data.Department_Code.Substring(0, 2) + "xx"));
                                //ddlDepartment.Items[ddlDepartment.Items.Count - 1].Attributes.Add("style", "color:red;");
                            }
                        }

                        department_code = ddlDepartment.SelectedValue;

                        faculty_data = new Faculty().getFaculty(department_code.Substring(0, 2));
                        ddlFACULTY.Items.Insert(ddlFACULTY.Items.Count, new ListItem(faculty_data.Faculty_Thai, faculty_data.Faculty_Code));

                        faculty_code = ddlFACULTY.SelectedValue;



                        string curr_sql = "Select * From CURRICULUM Where FACULTYCODE='" + faculty_code + "' AND  DEPARTMENTCODE='" + department_code + "' AND CURRCODE!='999999999' AND LEVELCODE='" + Curr_LevelCode + "' AND APPROVESTATUS='Y'";
                        currData = new Curriculum().getManualCurriculum(curr_sql);

                        ddlCURRICULUM.Items.Clear();
                        if (currData.Count.Equals(0))
                        {
                            ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem("--- เลือกหลักสูตร ---", "0"));
                        }
                        else
                        {
                            foreach (CurriculumGeneralData data in currData)
                            {
                                ddlCURRICULUM.Items.Insert(ddlCURRICULUM.Items.Count, new ListItem(data.Curr_Code + " " + data.Curr_ThaiName, data.Curr_Year + data.Curr_Code));
                            }
                        }
                    }


                    // วิชาบริการ
                    string curr_sql2 = "Select * From CURRICULUM Where CURRCODE='999999999' AND LEVELCODE='" + Curr_LevelCode + "' AND APPROVESTATUS='Y'";
                    currData2 = new Curriculum().getManualCurriculum(curr_sql2);
                    ddlServiceCURRICULUM.Items.Clear();
                    if (currData2.Count.Equals(0))
                    {
                        ddlServiceCURRICULUM.Items.Insert(ddlServiceCURRICULUM.Items.Count, new ListItem("--- เลือกหลักสูตร ---", "0"));
                    }
                    else
                    {
                        foreach (CurriculumGeneralData data in currData2)
                        {
                            ddlServiceCURRICULUM.Items.Insert(ddlServiceCURRICULUM.Items.Count, new ListItem(data.Curr_ThaiName + " ( ปีหลักสูตร " + data.Curr_Year + " )", data.Curr_Year + data.Curr_Code));
                        }
                    }
                }

                academic_year = txtACADEMIC_YEAR.Text;
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }