Ejemplo n.º 1
0
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        try
        {
            lecturer      = Request.QueryString["lecturer"];
            academic_year = Request.QueryString["year"];
            semester      = Request.QueryString["semester"];

            string          result;
            AddWorkLoadData dataInsert = new AddWorkLoadData();
            dataInsert.AcademicYear = academic_year;
            dataInsert.Semester     = semester;
            dataInsert.Lecturer     = lecturer;
            dataInsert.HourRefer    = float.Parse(txthourRef.Text);
            dataInsert.TotalCredit  = float.Parse(txtTotalCredit.Text);

            result = new AddWorkLoad().insertAddWorkLoad(dataInsert);

            if (result == "OK")
            {
                divSuccess.Visible = true;
                divAdd.Visible     = false;
            }
            else
            {
                MsgValidate("ไม่สามารถเพิ่มตำแหน่งงานบริหาร กรุณาทำใหม่อีกครั้ง");
            }
        }
        catch (Exception err)
        {
            MsgValidate(err.ToString());
        }
    }
Ejemplo n.º 2
0
    public string updateAddWorkLoad(AddWorkLoadData updateData)
    {
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";


        sql = "Update AddWorkLoad SET HOUR_REFER=" + updateData.HourRefer + ", TOTAL_CREDIT=" + updateData.TotalCredit + " Where ACADEMIC_YEAR='" + updateData.AcademicYear + "' And SEMESTER='" + updateData.Semester + "' And LECTURER='" + updateData.Lecturer + "' ";

        try
        {
            oracleObj.UpdateCommand = sql;

            if (oracleObj.Update() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:AddWorkLoad:updateAddWorkLoad" + " ไม่สามารถดำเนินการได้" + sql;
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(response);
    }
Ejemplo n.º 3
0
    public AddWorkLoadData getAddWorkLoad(string academic_year, string semester, string lecturer_id)
    {
        AddWorkLoadData addwork_data = new AddWorkLoadData();

        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();
        string        sql       = "Select * From AddWorkLoad Where ACADEMIC_YEAR='" + academic_year + "' And SEMESTER='" + semester + "' And LECTURER='" + lecturer_id + "' ";

        try
        {
            oracleObj.SelectCommand = sql;
            DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty);
            foreach (DataRowView rowData in allData)
            {
                addwork_data.AcademicYear = rowData["ACADEMIC_YEAR"].ToString();
                addwork_data.Semester     = rowData["SEMESTER"].ToString();
                addwork_data.Lecturer     = rowData["LECTURER"].ToString();
                addwork_data.HourRefer    = float.Parse(rowData["HOUR_REFER"].ToString());
                addwork_data.TotalCredit  = float.Parse(rowData["TOTAL_CREDIT"].ToString());
            }
        }
        catch (Exception e)
        {
            HttpContext.Current.Session["response"] = "Unit Test:AddWorkLoad:getAddWorkLoad" + " ไม่สามารถดำเนินการได้";
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(addwork_data);
    }
Ejemplo n.º 4
0
    public string insertAddWorkLoad(AddWorkLoadData dataInsert)
    {
        string        response  = "";
        ConnectDB     db        = new ConnectDB();
        SqlDataSource oracleObj = db.ConnectionOracle();

        string sql = "";

        sql = "Insert Into AddWorkLoad(ACADEMIC_YEAR, SEMESTER, LECTURER, HOUR_REFER, TOTAL_CREDIT) Values('" + dataInsert.AcademicYear + "','" + dataInsert.Semester + "','" + dataInsert.Lecturer + "'," + dataInsert.HourRefer + "," + dataInsert.TotalCredit + ")";

        try
        {
            oracleObj.InsertCommand = sql;

            if (oracleObj.Insert() == 1)
            {
                response = "OK";
            }
        }
        catch (Exception e)
        {
            response = e.Message.ToString();
            HttpContext.Current.Session["response"] = "Unit Test:AddWorkLoad:insertAddWorkLoad" + " ไม่สามารถดำเนินการได้";
            HttpContext.Current.Response.Redirect("err_response.aspx");
        }

        return(response);
    }
Ejemplo n.º 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_department) || autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
            {
                /*=============================*/
                if (!Page.IsPostBack)
                {
                    fail.Visible       = false;
                    divSuccess.Visible = false;

                    try
                    {
                        lecturer      = Request.QueryString["lecturer"];
                        academic_year = Request.QueryString["year"];
                        semester      = Request.QueryString["semester"];

                        AddWorkLoadData addWorkData = new AddWorkLoadData();
                        addWorkData = new AddWorkLoad().getAddWorkLoad(academic_year, semester, lecturer);

                        txthourRef.Text     = addWorkData.HourRefer.ToString();
                        txtTotalCredit.Text = addWorkData.TotalCredit.ToString();
                    }
                    catch (Exception err)
                    {
                        MsgValidate(err.ToString());
                    }
                }
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Ejemplo n.º 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_department) || autro_obj.CheckGroupUser(login_data, group_var.officer_faculty) || autro_obj.CheckGroupUser(login_data, group_var.lecturer))
            {
                /*=============================*/
                try
                {
                    string  lec_code = Request.QueryString["lecturer"];
                    SysUser lec      = new SysUser().getSysUser(lec_code);

                    bool authorized = false;

                    if (autro_obj.CheckGroupUser(login_data, group_var.lecturer))
                    {
                        if (lec_code == login_data.Nation_ID)
                        {
                            authorized = true;
                        }
                        else
                        {
                            authorized = false;
                        }
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_faculty))
                    {
                        authorized = true;
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.officer_department))
                    {
                        List <string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.officer_department);

                        foreach (string dep in department_authorized)
                        {
                            if (dep == lec.DepartmentCode)
                            {
                                authorized = true;
                                break;
                            }
                        }
                    }

                    if (authorized == true)
                    {
                        string academic_year = Request.QueryString["year"];
                        string semester      = Request.QueryString["semester"];

                        string prev_course = "";
                        int    prev_sec    = 0;
                        int    prev_subsec = 0;

                        List <LecturerTableData> lecturerData = new List <LecturerTableData>();
                        lecturerData = new LecturerTable().getAllDegreeLecturerTable(academic_year, semester, lec_code);



                        headLecturer.Text = new AcademicPosition().getAcademicPosition(lec.AcademicPositionCode).AcademicPositionThName + " " + lec.ThName + " " + lec.ThSurName;

                        // Head Table
                        string[] ar  = { "ลำดับ", "ชื่อวิชา", "ตอนเรียน", "วัน", "เวลา", "ตัวคูณ", "หน่วยกิต", "ชั่วโมงอ้างอิง" };
                        Table    tb1 = new Table();
                        tb1.Attributes.Add("class", "table table-bordered table-striped table-hover");
                        tb1.Attributes.Add("id", "dt_basic");
                        TableHeaderRow tRowHead = new TableHeaderRow();
                        tRowHead.TableSection = TableRowSection.TableHeader;

                        for (int cellCtr = 1; cellCtr <= ar.Length; cellCtr++)
                        {
                            TableHeaderCell cellHead = new TableHeaderCell();
                            cellHead.Text = ar[cellCtr - 1];
                            cellHead.Attributes.Add("class", "text-center");
                            tRowHead.Cells.Add(cellHead);
                        }
                        tb1.Rows.Add(tRowHead);

                        int num = 1;

                        float         totalCredit  = 0;
                        float         totalHourRef = 0;
                        SubCreditData subcredit    = new SubCreditData();

                        TableCell cellDay  = new TableCell();
                        TableCell cellTime = new TableCell();

                        foreach (LecturerTableData data in lecturerData)
                        {
                            //if ((prev_course == "") || (prev_course != data.Course_Code) || (prev_sec != data.Sec_No) || (prev_subsec != data.SubSec_No))
                            //    {

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

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

                            TableCell cellNum = new TableCell();
                            cellNum.Attributes.Add("class", "text-center");
                            cellNum.Attributes.Add("style", "vertical-align:middle");
                            cellNum.Text = num.ToString();
                            tRowBody.Cells.Add(cellNum);

                            TableCell cellCourseName = new TableCell();
                            cellCourseName.Attributes.Add("style", "vertical-align:middle");
                            cellCourseName.Text = course_data.Course_Code + " " + course_data.Course_Engname;
                            tRowBody.Cells.Add(cellCourseName);

                            string course_type = "";
                            string course_sec  = "";

                            if (data.Course_Type == "1")
                            {
                                course_type = "S.";
                            }
                            else if (data.Course_Type == "2")
                            {
                                course_type = "L.";
                            }
                            else if (data.Course_Type == "4")
                            {
                                course_type = "T.";
                            }
                            else if (data.Course_Type == "5")
                            {
                                course_type = "M.";
                            }
                            else if (data.Course_Type == "6")
                            {
                                course_type = "SP.";
                            }
                            else if (data.Course_Type == "7")
                            {
                                course_type = "D.";
                            }

                            if (data.SubSec_No != 0)
                            {
                                course_sec = data.SubSec_No.ToString();
                            }
                            else
                            {
                                course_sec = data.Sec_No.ToString();
                            }

                            TableCell cellSec = new TableCell();
                            cellSec.Attributes.Add("class", "text-center");
                            cellSec.Attributes.Add("style", "vertical-align:middle");
                            cellSec.Text = course_type + course_sec;
                            tRowBody.Cells.Add(cellSec);

                            string day = "";

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

                            cellDay = new TableCell();
                            cellDay.Attributes.Add("class", "text-center");
                            cellDay.Attributes.Add("style", "vertical-align:middle");
                            cellDay.Text = day;
                            tRowBody.Cells.Add(cellDay);

                            string teach_time = data.Teaching_Start_Time + " - " + data.Teaching_End_Time;

                            cellTime = new TableCell();
                            cellTime.Attributes.Add("class", "text-center");
                            cellTime.Attributes.Add("style", "vertical-align:middle");
                            cellTime.Text = teach_time;
                            tRowBody.Cells.Add(cellTime);


                            subcredit = new SubCredit().getSubCredit(data.AcademicYear, data.Semester, data.Course_Code, data.Sec_No, data.SubSec_No, data.Lecturer, data.Teaching_Day, data.Teaching_Start_Time, data.Teaching_End_Time, data.Course_Degree_Char);

                            float credit = subcredit.SubCredit;
                            totalCredit += subcredit.SubCredit;



                            HourReferData hour_data = new HourReferData();
                            float         hour_ref  = 0;

                            if (course_data.Course_DegreeLevel == "01")// ปวช.
                            {
                                hour_data = new HourRefer().getHourRefer("U", data.Course_Type);
                                hour_ref  = hour_data.HourRefer * credit;
                            }
                            else if (course_data.Course_DegreeLevel == "02") //ป.ตรี
                            {
                                hour_data = new HourRefer().getHourRefer("B", data.Course_Type);
                                hour_ref  = hour_data.HourRefer * credit;
                            }
                            else
                            { // บัณฑิต
                                hour_data = new HourRefer().getHourRefer("M", data.Course_Type);
                                hour_ref  = hour_data.HourRefer * credit;
                            }

                            totalHourRef += hour_ref;

                            TableCell cellMultiply = new TableCell();
                            cellMultiply.Attributes.Add("class", "text-center");
                            cellMultiply.Attributes.Add("style", "vertical-align:middle");
                            cellMultiply.Text = hour_data.HourRefer.ToString();
                            tRowBody.Cells.Add(cellMultiply);

                            TableCell cellCredit = new TableCell();
                            cellCredit.Attributes.Add("class", "text-center");
                            cellCredit.Attributes.Add("style", "vertical-align:middle");
                            cellCredit.Text = credit.ToString();
                            tRowBody.Cells.Add(cellCredit);

                            TableCell cellHourRef = new TableCell();
                            cellHourRef.Attributes.Add("class", "text-center");
                            cellHourRef.Attributes.Add("style", "vertical-align:middle");
                            cellHourRef.Text = hour_ref.ToString();
                            tRowBody.Cells.Add(cellHourRef);

                            tb1.Rows.Add(tRowBody);

                            num++;

                            prev_course = data.Course_Code;
                            prev_sec    = data.Sec_No;
                            prev_subsec = data.SubSec_No;
                        }

                        AddWorkLoadData AddWork_data = new AddWorkLoadData();
                        AddWork_data = new AddWorkLoad().getAddWorkLoad(academic_year, semester, lec_code);

                        if (AddWork_data.Lecturer != null)
                        {
                            totalCredit  += AddWork_data.TotalCredit;
                            totalHourRef += AddWork_data.HourRefer;

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

                            TableCell cellAddNum = new TableCell();
                            cellAddNum.Attributes.Add("class", "text-center");
                            cellAddNum.Attributes.Add("style", "vertical-align:middle");
                            cellAddNum.Text = num.ToString();
                            tRowBody1.Cells.Add(cellAddNum);

                            TableCell cellAddTitle = new TableCell();
                            cellAddTitle.Attributes.Add("class", "text-left");
                            cellAddTitle.Attributes.Add("style", "vertical-align:middle");
                            cellAddTitle.ColumnSpan = 5;
                            cellAddTitle.Text       = "ภาระงานต้นสังกัด";
                            tRowBody1.Cells.Add(cellAddTitle);

                            TableCell cellAddCredit = new TableCell();
                            cellAddCredit.Attributes.Add("class", "text-center");
                            cellAddCredit.Attributes.Add("style", "vertical-align:middle");
                            cellAddCredit.Text = AddWork_data.TotalCredit.ToString();
                            tRowBody1.Cells.Add(cellAddCredit);

                            TableCell cellAddHourRef = new TableCell();
                            cellAddHourRef.Attributes.Add("class", "text-center");
                            cellAddHourRef.Attributes.Add("style", "vertical-align:middle");
                            cellAddHourRef.Text = AddWork_data.HourRefer.ToString();
                            tRowBody1.Cells.Add(cellAddHourRef);

                            tb1.Rows.Add(tRowBody1);
                        }

                        //====================

                        TableFooterRow footRow = new TableFooterRow();
                        footRow.TableSection = TableRowSection.TableFooter;

                        TableCell cellSumTitle = new TableCell();
                        cellSumTitle.Attributes.Add("class", "text-right txt-blue-bold");
                        cellSumTitle.ColumnSpan = 6;
                        cellSumTitle.Text       = "รวม";
                        footRow.Cells.Add(cellSumTitle);

                        TableCell cell1 = new TableCell();
                        cell1.Attributes.Add("class", "text-center txt-blue-bold");
                        cell1.Text = totalCredit.ToString();
                        footRow.Cells.Add(cell1);

                        TableCell cell3 = new TableCell();
                        cell3.Attributes.Add("class", "text-center txt-blue-bold");
                        cell3.Text = totalHourRef.ToString();
                        footRow.Cells.Add(cell3);
                        tb1.Rows.Add(footRow);

                        TableRow  row  = new TableRow();
                        TableCell cell = new TableCell();
                        cell.Controls.Add(tb1);
                        row.Cells.Add(cell);
                        tblWorkLoad.Rows.Add(row);
                    }
                    else
                    {
                        HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                        HttpContext.Current.Response.Redirect("err_response.aspx");
                    }
                }
                catch (Exception err)
                {
                }
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }