コード例 #1
0
    protected void btnEdit_Click(object sender, EventArgs e)
    {
        string result = "";

        if (Session["save_student_data"] != null)
        {
            string dupAdvisor = checkDup();

            if (ddlADVISOR.SelectedValue == "0")
            {
                divShow.Visible = false;
                MsgValidate("กรุณาระบุ อาจารย์ที่ปรึกษาหลัก");
            }
            else if (dupAdvisor != "")
            {
                divShow.Visible = false;
                MsgValidate("ตรวจพบความซ้ำซ้อนของอาจารย์: " + dupAdvisor);
            }
            else
            {
                Student updateStudent = new Student();
                updateStudent = (Student)Session["save_student_data"];

                GradAdvisorData grad_advisor_data = new GradAdvisorData();
                grad_advisor_data.Student_ID    = updateStudent.Student_ID;
                grad_advisor_data.Nation_ID     = updateStudent.Nation_ID;
                grad_advisor_data.Passport_ID   = updateStudent.Passport_ID;
                grad_advisor_data.Advisor_ID    = ddlADVISOR.SelectedValue;
                grad_advisor_data.CoAdvisor_ID1 = ddlCO_ADVISOR_1.SelectedValue;
                grad_advisor_data.CoAdvisor_ID2 = ddlCO_ADVISOR_2.SelectedValue;
                grad_advisor_data.CoAdvisor_ID3 = ddlCO_ADVISOR_3.SelectedValue;
                grad_advisor_data.CoAdvisor_ID4 = ddlCO_ADVISOR_4.SelectedValue;
                grad_advisor_data.CoAdvisor_ID5 = ddlCO_ADVISOR_5.SelectedValue;

                result = new Student().updateGradAdvisor(grad_advisor_data);

                if (result == "OK")
                {
                    Session.Remove("save_student_data");
                    divShow.Visible    = false;
                    divSuccess.Visible = true;
                }
                else
                {
                    divShow.Visible = false;
                    MsgValidate(result);
                }
            }
        }
        else
        {
            divShow.Visible = false;
            MsgValidate("ข้อมูลผิดพลาด โปรดกดค้นหาข้อมูลอีกครั้ง");
        }
    }
コード例 #2
0
    private void chkApprove_CheckedChanged(object sender, EventArgs e)
    {
        // lblAdvisor.Text = "";

        CheckBox check = (CheckBox)sender;

        if (check.Checked == true)
        {
            List <RegistrationData> ApproveRegisData = new List <RegistrationData>();
            int course_index = Convert.ToInt16(check.ID.Substring(7));
            RegistrationData Select_Course = studentRegisData[course_index - 1];
            int  dup = 0;
            uint chknum;

            if ((Select_Course.Course_Type == "4") || (Select_Course.Course_Type == "5") || (Select_Course.Course_Type == "7"))
            {
                if (!uint.TryParse(txtCredit[course_index - 1].Text, out chknum))
                {
                    txtCredit[course_index - 1].Text = Select_Course.Credit.ToString();
                }
                else
                {
                    Select_Course.Credit = Convert.ToUInt16(txtCredit[course_index - 1].Text);
                }
            }

            if (Session["ApproveRegis"] == null)
            {
                ApproveRegisData.Add(Select_Course);
            }
            else
            {
                ApproveRegisData = (List <RegistrationData>)Session["ApproveRegis"];

                foreach (RegistrationData data in ApproveRegisData)
                {
                    if (Select_Course.Academic_Year == data.Academic_Year && Select_Course.Semester == data.Semester && Select_Course.Course_Code == data.Course_Code && Select_Course.Sec_No == data.Sec_No && Select_Course.SubSec_No == data.SubSec_No)
                    {
                        dup++;
                    }
                }

                if (dup == 0)
                {
                    ApproveRegisData.Add(Select_Course);
                }
            }


            Session["ApproveRegis"] = ApproveRegisData;

            if (Session["ApproveRegis"] != null)
            {
                string          Lecturer_ID  = (string)Session["Lecturer_ID"];
                GradAdvisorData advisor_data = new GradAdvisorData();
                advisor_data = new Student().getAdvisorCoAdvisor(Select_Course.Student_ID);

                //lblFaculty.Text = Select_Course.Student_ID;

                if (advisor_data.Advisor_ID == null)
                {
                    lblAlertAdvisor.Text = "";
                    if (Session["ApproveRegis"] != null)
                    {
                        btnApprove.Enabled = true;
                    }
                    else
                    {
                        btnApprove.Enabled = false;
                    }
                }
                else if (advisor_data.Advisor_ID == "0")
                {
                    lblAlertAdvisor.Text = "";
                    if (Session["ApproveRegis"] != null)
                    {
                        btnApprove.Enabled = true;
                    }
                    else
                    {
                        btnApprove.Enabled = false;
                    }
                }
                else
                {
                    if (Lecturer_ID == advisor_data.Advisor_ID)
                    {
                        lblAlertAdvisor.Text = "";
                        if (Session["ApproveRegis"] != null)
                        {
                            btnApprove.Enabled = true;
                        }
                        else
                        {
                            btnApprove.Enabled = false;
                        }
                    }
                    else
                    {
                        lblAlertAdvisor.Text = "นักศึกษาได้แต่งตั้งอาจารย์ที่ปรึกษาแล้ว";
                        btnApprove.Enabled   = false;
                    }
                }
            }
            else
            {
                btnApprove.Enabled = false;
            }
        }

        else if (check.Checked == false)
        {
            if (Session["ApproveRegis"] != null)
            {
                List <RegistrationData> ApproveRegisData    = new List <RegistrationData>();
                List <RegistrationData> OldApproveRegisData = new List <RegistrationData>();
                int course_index = Convert.ToInt16(check.ID.Substring(7));
                RegistrationData Select_Course = studentRegisData[course_index - 1];

                OldApproveRegisData = (List <RegistrationData>)Session["ApproveRegis"];
                foreach (RegistrationData data in OldApproveRegisData)
                {
                    if (Select_Course.Academic_Year != data.Academic_Year || Select_Course.Semester != data.Semester || Select_Course.Course_Code != data.Course_Code || Select_Course.Sec_No != data.Sec_No || Select_Course.SubSec_No != data.SubSec_No)
                    {
                        ApproveRegisData.Add(data);
                    }
                }

                if (ApproveRegisData.Count > 0)
                {
                    Session["ApproveRegis"] = ApproveRegisData;
                }
                else
                {
                    Session.Remove("ApproveRegis");
                }
            }

            if (Session["ApproveRegis"] != null)
            {
                btnApprove.Enabled = true;
            }
            else
            {
                btnApprove.Enabled = false;
            }
        }
    }
コード例 #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        config_data   = new SystemConfig().getConfig();
        academic_year = config_data.AcademicYear;
        semester      = config_data.Semester;


        Student student_data = new Student();

        row1 = Request.QueryString["show_row"];

        if (Session["showRegCourse" + row1] == null)
        {
            Response.Redirect("List_StudentRegis_SecAdvisor.aspx");
        }
        else
        {
            student_data = (Student)Session["showRegCourse" + row1];

            lblStudentName.Text = student_data.Student_ID + " " + student_data.First_ThaiName + " " + student_data.Family_ThaiName;

            if (!Page.IsPostBack)
            {
                Session.Remove("ApproveRegis");
            }

            try
            {
                string          Lecturer_ID  = (string)Session["Lecturer_ID"];
                GradAdvisorData advisor_data = new GradAdvisorData();
                advisor_data = new Student().getAdvisorCoAdvisor(student_data.Student_ID);

                if (advisor_data.Advisor_ID == null)
                {
                    lblAlertAdvisor.Text = "";
                    if (Session["ApproveRegis"] != null)
                    {
                        btnApprove.Enabled = true;
                    }
                    else
                    {
                        btnApprove.Enabled = false;
                    }
                }
                else if (advisor_data.Advisor_ID == "0")
                {
                    lblAlertAdvisor.Text = "";
                    if (Session["ApproveRegis"] != null)
                    {
                        btnApprove.Enabled = true;
                    }
                    else
                    {
                        btnApprove.Enabled = false;
                    }
                }
                else
                {
                    if (Lecturer_ID == advisor_data.Advisor_ID)
                    {
                        lblAlertAdvisor.Text = "";
                        if (Session["ApproveRegis"] != null)
                        {
                            btnApprove.Enabled = true;
                        }
                        else
                        {
                            btnApprove.Enabled = false;
                        }
                    }
                    else
                    {
                        lblAlertAdvisor.Text = "นักศึกษาได้แต่งตั้งอาจารย์ที่ปรึกษาแล้ว";
                        btnApprove.Enabled   = false;
                    }
                }


                LectuereInformationData lecturer_data = new LectuereInformationData();
                lecturer_data = new Lecturer().getLecturer(student_data.Advisor_ID);

                degree_char = student_data.Degree_Char;

                studentRegisData = new Student_Registration().getRegistration(academic_year, semester, student_data.Student_ID, degree_char);

                int        numrow = 1;
                CheckBox[] chk    = new CheckBox[studentRegisData.Count];
                txtCredit = new TextBox[studentRegisData.Count];
                int i = 0;

                // Head Table
                //string[] ar = { "ตอนที่", "รหัสวิชา", "ชื่อวิชา", "ผู้สอน", "ห้องเรียน", "เวลาเรียน", "สอบกลางภาค", "สอบปลายภาค", "อนุมัติ" };
                string[] ar  = { "ตอนที่", "รหัสวิชา", "ชื่อวิชา", "ผู้สอน", "ห้องเรียน", "เวลาเรียน", "ประเภทการลงทะเบียน", "สถานะการลงทะเบียน", "สถานะการชำระเงิน", "จำนวนหน่วยกิต", "อนุมัติ" };
                Table    tb1 = new Table();
                tb1.Attributes.Add("class", "table table-bordered table-hover table-striped");
                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.Text = ar[cellCtr - 1];
                    cellHead.Attributes.Add("class", "text-align-center");
                    tRowHead.Cells.Add(cellHead);
                }

                tb1.Rows.Add(tRowHead);

                List <RegistrationData> ApproveRegisData = new List <RegistrationData>();
                if (Session["ApproveRegis"] != null)
                {
                    ApproveRegisData = (List <RegistrationData>)Session["ApproveRegis"];
                }

                foreach (RegistrationData data in studentRegisData)
                {
                    teachingData = new TeachingTable().getSubTeachingTable(academic_year, semester, data.Course_Code, data.Sec_No, data.SubSec_No, degree_char);

                    lec_table = degree_char;

                    // กรณีวิชาที่เพิ่มโดยอาจารย์ผู้สอน เป็นวิชาที่อยู่คนละระดับการศึกษา
                    if (teachingData.Count <= 0)
                    {
                        if (degree_char == "U" || degree_char == "B")
                        {
                            teachingData = new TeachingTable().getSubTeachingTable(academic_year, semester, data.Course_Code, data.Sec_No, data.SubSec_No, "M");
                            lec_table    = "M";
                        }
                        else
                        {
                            teachingData = new TeachingTable().getSubTeachingTable(academic_year, semester, data.Course_Code, data.Sec_No, data.SubSec_No, "B");
                            lec_table    = "B";
                        }
                    }
                    //=======================

                    CourseData course_reg = new CourseData();
                    course_reg = new Course().getCourse(data.Course_Code);

                    TableRow tRowBody = new TableRow();
                    tRowBody.TableSection = TableRowSection.TableBody;

                    string course_type = "";
                    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_type += data.SubSec_No;
                    }
                    else
                    {
                        course_type += data.Sec_No;
                    }

                    TableCell cellSec = new TableCell();
                    cellSec.Text = course_type;
                    cellSec.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellSec);

                    TableCell cellCourseCode = new TableCell();
                    cellCourseCode.Text = course_reg.Course_Code;
                    cellCourseCode.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellCourseCode);

                    TableCell cellCourse = new TableCell();
                    cellCourse.Text = course_reg.Course_Thainame;
                    tRowBody.Cells.Add(cellCourse);

                    TableCell cellLecturer = new TableCell();
                    string    lec_name     = "";
                    foreach (TeachingTableData teach in teachingData)
                    {
                        lecturerData = new LecturerTable().getLecturerTable(teach, lec_table);
                        foreach (LecturerTableData lec in lecturerData)
                        {
                            lec_name += new Lecturer().getLecturer(lec.Lecturer).Lecturer_ShortName + ",";
                        }

                        lec_name = lec_name.Substring(0, lec_name.Length - 1);

                        lec_name += "<br>";
                    }

                    cellLecturer.Text = lec_name;
                    tRowBody.Cells.Add(cellLecturer);
                    TableCell cellRoom = new TableCell();

                    foreach (TeachingTableData teach in teachingData)
                    {
                        cellRoom.Text += teach.Building_Code + "-" + teach.Room_Code;
                        if (teach.Campus_Code == "2")
                        {
                            cellRoom.Text += "*";
                        }
                        else if (teach.Campus_Code == "3")
                        {
                            cellRoom.Text += "**";
                        }

                        cellRoom.Text += "<br/>";
                    }
                    cellRoom.Attributes.Add("class", "text-align-center");

                    tRowBody.Cells.Add(cellRoom);

                    TableCell cellTeaching = new TableCell();
                    foreach (TeachingTableData teach in teachingData)
                    {
                        string day = "";

                        if (teach.Teaching_Day == "1")
                        {
                            day = "Mon";
                        }
                        else if (teach.Teaching_Day == "2")
                        {
                            day = "Tue";
                        }
                        if (teach.Teaching_Day == "3")
                        {
                            day = "Wed";
                        }
                        if (teach.Teaching_Day == "4")
                        {
                            day = "Thu";
                        }
                        if (teach.Teaching_Day == "5")
                        {
                            day = "Fri";
                        }
                        if (teach.Teaching_Day == "6")
                        {
                            day = "Sat";
                        }
                        if (teach.Teaching_Day == "7")
                        {
                            day = "Sun";
                        }

                        cellTeaching.Text += day + " " + teach.Teaching_Start_Time + " - " + teach.Teaching_End_Time + "<br>";
                        cellTeaching.Attributes.Add("class", "text-align-center");
                    }
                    tRowBody.Cells.Add(cellTeaching);

                    //TableCell cellMid = new TableCell();
                    //cellMid.Text = new utility().getThaiBirthDay(exam_data.ExamMid_Day) + " เวลา:" + exam_data.ExamMid_StartTime + "-" + exam_data.ExamMid_EndTime;
                    //tRowBody.Cells.Add(cellMid);

                    //TableCell cellFinal = new TableCell();
                    //cellFinal.Text = new utility().getThaiBirthDay(exam_data.ExamFinal_Day) + " เวลา:" + exam_data.ExamFinal_StartTime + "-" + exam_data.ExamFinal_EndTime;
                    //tRowBody.Cells.Add(cellFinal);

                    TableCell cellRegType = new TableCell();
                    cellRegType.Text = data.Reg_Type;
                    cellRegType.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellRegType);

                    TableCell cellRegStatus = new TableCell();
                    cellRegStatus.Text = statusObj.getStatus(data.Status).Status_Thai;
                    cellRegStatus.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellRegStatus);

                    TableCell cellPaymentStatus = new TableCell();
                    cellPaymentStatus.Text = statusObj.getStatus(new Student_Payment().getPaymentStatus(data.Payment_ID, degree_char)).Status_Thai;
                    cellPaymentStatus.Attributes.Add("class", "text-align-center");
                    tRowBody.Cells.Add(cellPaymentStatus);

                    TableCell cellCredit = new TableCell();
                    cellCredit.Attributes.Add("class", "text-align-center");

                    if ((data.Course_Type == "4") || (data.Course_Type == "5") || (data.Course_Type == "7"))
                    {
                        txtCredit[i]           = new TextBox();
                        txtCredit[i].ID        = "credit" + numrow.ToString();
                        txtCredit[i].MaxLength = 2;
                        txtCredit[i].Width     = 30;
                        txtCredit[i].Attributes.Add("class", "text-center");
                        txtCredit[i].Text = data.Credit.ToString();
                        if (data.Approve_Status == "y")
                        {
                            txtCredit[i].ReadOnly  = true;
                            txtCredit[i].BackColor = System.Drawing.ColorTranslator.FromHtml("#CCCCCC");
                        }
                        else
                        {
                            txtCredit[i].ReadOnly     = false;
                            txtCredit[i].AutoPostBack = true;
                            txtCredit[i].TextChanged += new EventHandler(txtCredit_TextChanged);
                        }
                        cellCredit.Controls.Add(txtCredit[i]);
                    }
                    else
                    {
                        cellCredit.Text = data.Credit.ToString();
                    }
                    tRowBody.Cells.Add(cellCredit);

                    TableCell cellchkApprove = new TableCell();

                    if (data.Approve_Status == "n")
                    {
                        chk[i] = new CheckBox();
                        chk[i].AutoPostBack = true;
                        chk[i].ID           = "approve" + numrow.ToString();

                        foreach (RegistrationData chkdata in ApproveRegisData)
                        {
                            if (data.Academic_Year == chkdata.Academic_Year && data.Semester == chkdata.Semester && data.Course_Code == chkdata.Course_Code && data.Sec_No == chkdata.Sec_No && data.SubSec_No == chkdata.SubSec_No)
                            {
                                chk[i].Checked = true;
                            }
                        }

                        chk[i].CheckedChanged += new EventHandler(chkApprove_CheckedChanged);
                        cellchkApprove.Controls.Add(chk[i]);
                        cellchkApprove.Attributes.Add("class", "text-align-center");
                    }
                    else
                    {
                        if (data.Approve_Status == "y")
                        {
                            cellchkApprove.Text = "อนุมัติ";
                            cellchkApprove.Attributes.Add("class", "txt-green-bold text-align-center");
                        }
                    }


                    tRowBody.Cells.Add(cellchkApprove);

                    numrow++;
                    i++;

                    tb1.Rows.Add(tRowBody);
                }



                TableRow  row  = new TableRow();
                TableCell cell = new TableCell();
                cell.Controls.Add(tb1);
                row.Cells.Add(cell);
                tblStudentAdvisor.Rows.Add(row);
            }
            catch (Exception err)
            {
                HttpContext.Current.Session["response"] = "ไม่สามารถดำเนินการได้" + err.ToString();
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }