Пример #1
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.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
            {
                /*=============================*/
                LoginName = Request.QueryString["UserId"];

                UsersInfo user = new UsersInfo().getUsers(LoginName);

                if (user.USERS_INFO_FACULTY_ID == "00")
                {
                    OtherOfficeData otherOffice = new OtherOffice().getOtherOffice(user.OTHEROFFICE_CODE);
                    lblStringToRemove.Text = LoginName + " สังกัด" + otherOffice.OtherOffice_ThaiName;
                }
                else
                {
                    lblStringToRemove.Text = LoginName + " สังกัด" + new Faculty().getFaculty(user.USERS_INFO_FACULTY_ID).Faculty_Thai;
                }
                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #2
0
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        OtherOfficeData officeSave = new OtherOfficeData();

        officeSave.OtherOffice_Code      = txtOfficeCode.Text;
        officeSave.OtherOffice_ThaiName  = txtOfficeNameThai.Text;
        officeSave.OtherOffice_EngName   = txtOfficeNameEng.Text;
        officeSave.OtherOffice_ShortName = txtOfficeShortName.Text;
        officeSave.OtherOffice_Status    = ddlOfficeStatus.SelectedValue;

        string result = new OtherOffice().updateOtherOffice(officeSave);

        Response.Redirect("list_Office.aspx");
    }
Пример #3
0
    protected void btnSAVE_Click(object sender, EventArgs e)
    {
        OtherOfficeData officeSave = new OtherOfficeData();

        officeSave.OtherOffice_Code      = txtOfficeCode.Text;
        officeSave.OtherOffice_ThaiName  = txtOfficeNameThai.Text;
        officeSave.OtherOffice_EngName   = txtOfficeNameEng.Text;
        officeSave.OtherOffice_ShortName = txtOfficeShortName.Text;
        officeSave.OtherOffice_Status    = ddlOfficeStatus.SelectedValue;

        int count = new OtherOffice().getCountOtherOffice(txtOfficeCode.Text.Trim());

        if (count > 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('รหัส ข้อมูลซ้ำ!');", true);
        }
        else
        {
            string result = new OtherOffice().insertOtherOffice(officeSave);
            Response.Redirect("list_Office.aspx");
        }
    }
Пример #4
0
    protected void btnSEARCH_Click(object sender, EventArgs e)
    {
        //โหลดข้อมูล Users
        string sql  = "";
        int    flag = 0;
        List <UserAuthorizedData> userAuthorizedData = new List <UserAuthorizedData>();

        if (ddlDivision.SelectedValue == "1")
        {
            if (ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue == "0000")
            {
                sql = "Select * From USERS_FACULTY_AUTHORIZED Where FACULTY_CODE='" + ddlFaculty.SelectedValue + "' Order by USER_ID";
                userAuthorizedData = new UserAuthorized().getFacultyAuthorizedManual(sql);
                flag = 1; //คณะ
            }
            else if (ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue != "0000")
            {
                sql = "Select * From USERS_DEPARTMENT_AUTHORIZED Where DEPARTMENT_CODE='" + ddlDepartment.SelectedValue + "' Order by USER_ID";
                userAuthorizedData = new UserAuthorized().getDepartmentAuthorizedManual(sql);
                flag = 2; //ภาควิชา
            }
        }
        else if (ddlDivision.SelectedValue == "2")
        {
            if (ddlOffice.SelectedValue == "0000")
            {
                sql = "Select * From USERS_OTHER_AUTHORIZED Order by USER_ID";
                userAuthorizedData = new UserAuthorized().getOtherAuthorizedManual(sql);
                flag = 3; //หน่วยงานอื่นๆ
            }
            else
            {
                sql = "Select * From USERS_OTHER_AUTHORIZED Where OTHEROFFICE_CODE='" + ddlOffice.SelectedValue + "' Order by USER_ID";
                userAuthorizedData = new UserAuthorized().getOtherAuthorizedManual(sql);
                flag = 3; //หน่วยงานอื่นๆ
            }
        }

        // กำหนด Header
        if (autro_obj.CheckGroupUser(login_data, group_var.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
        {
            // Head Table
            string[] ar = { "รหัสผู้ใช้งาน", "ชื่อ-นามสกุล", "ภาควิชา (ต้นสังกัด)", "คณะ/วิทยาลัย/สำนักงาน (ต้นสังกัด)", "สถานะ", "กำหนดสิทธิ์", "เปลี่ยนรหัสผ่าน", "แก้ไข", "ลบ (หน่วยงาน)", "ลบ (ระบบ)" };
            tblUsers.Attributes.Add("class", "table table-bordered table-striped table-hover");
            tblUsers.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];
                tRowHead.Cells.Add(cellHead);
            }
            tblUsers.Rows.Add(tRowHead);
        }
        else
        {
            // Head Table
            string[] ar = { "รหัสผู้ใช้งาน", "ชื่อ-นามสกุล", "ภาควิชา (ต้นสังกัด)", "คณะ/วิทยาลัย/สำนักงาน (ต้นสังกัด)", "สถานะ", "กำหนดสิทธิ์", "ลบ (หน่วยงาน)" };
            tblUsers.Attributes.Add("class", "table table-bordered table-striped table-hover");
            tblUsers.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];
                tRowHead.Cells.Add(cellHead);
            }
            tblUsers.Rows.Add(tRowHead);
        }



        foreach (UserAuthorizedData data in userAuthorizedData)
        {
            string urlDel        = "";
            string urlPermission = "";
            if (flag == 1) //คณะ
            {
                userData = userObj.getUsers(data.Faculty_Authorized_User_Id);
                urlDel   = "delete_Member_OU.aspx?UserId=" + userData.USERS_INFO_USER_ID + "&flag=1&token=" + data.Faculty_Authorized_Faculty_Code;

                urlPermission = "role_User.aspx?Uid=" + userData.USERS_INFO_USER_ID + "&flag=1&token=" + data.Faculty_Authorized_Faculty_Code;
            }
            else if (flag == 2) //ภาควิชา
            {
                userData = userObj.getUsers(data.Department_Authorized_User_Id);
                urlDel   = "delete_Member_OU.aspx?UserId=" + userData.USERS_INFO_USER_ID + "&flag=2&token=" + data.Department_Authorized_Department_Code;

                urlPermission = "role_User.aspx?Uid=" + userData.USERS_INFO_USER_ID + "&flag=2&token=" + data.Department_Authorized_Department_Code;
            }
            else if (flag == 3) //หน่วยงานอื่นๆ
            {
                userData = userObj.getUsers(data.Other_Authorized_User_Id);
                urlDel   = "delete_Member_OU.aspx?UserId=" + userData.USERS_INFO_USER_ID + "&flag=3&token=" + data.Other_Authorized_Other_Code;

                urlPermission = "role_User.aspx?Uid=" + userData.USERS_INFO_USER_ID + "&flag=3&token=" + data.Other_Authorized_Other_Code;
            }

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

            TableCell cellUserId = new TableCell();
            cellUserId.Text = userData.USERS_INFO_USER_ID;
            tRowBody.Cells.Add(cellUserId);

            TableCell cellUserNameThai = new TableCell();
            Prefix    prefixObj        = new Prefix();
            if (userData.USERS_INFO_FIRST_THAINAME == "")
            {
                cellUserNameThai.Text = prefixObj.getPrefix(userData.USERS_INFO_TITLE_THAINAME).Prefix_Eng + userData.USERS_INFO_FIRST_ENGNAME + " " + userData.USERS_INFO_FAMILY_ENGNAME;
            }
            else
            {
                cellUserNameThai.Text = prefixObj.getPrefix(userData.USERS_INFO_TITLE_THAINAME).Prefix_Thai + userData.USERS_INFO_FIRST_THAINAME + " " + userData.USERS_INFO_FAMILY_THAINAME;
            }

            tRowBody.Cells.Add(cellUserNameThai);

            TableCell cellDepartment = new TableCell();
            if (userData.USERS_INFO_DEPARTMENT_ID == "0000")
            {
                cellDepartment.Text = "หน่วยงาน/สำนักงานคณะ";
            }
            else
            {
                Department departmentObj = new Department();
                cellDepartment.Text = departmentObj.getDepartment(userData.USERS_INFO_DEPARTMENT_ID).Department_Thai;
            }
            tRowBody.Cells.Add(cellDepartment);

            TableCell cellFaculty = new TableCell();
            if (userData.USERS_INFO_FACULTY_ID == "00")
            {
                OtherOfficeData otherOffice = new OtherOffice().getOtherOffice(userData.OTHEROFFICE_CODE);
                cellFaculty.Text = otherOffice.OtherOffice_ThaiName;
            }
            else
            {
                cellFaculty.Text = facultyObj.getFaculty(userData.USERS_INFO_FACULTY_ID).Faculty_Thai;
            }

            tRowBody.Cells.Add(cellFaculty);

            TableCell cellStatus = new TableCell();
            string    urlShow    = "update_UserInfo_Status.aspx?userId=" + userData.USERS_INFO_USER_ID;
            HyperLink hypShow    = new HyperLink();
            hypShow.Attributes.Add("data-target", "#updateStatus");
            hypShow.Attributes.Add("data-toggle", "modal");
            //0001 = ใช้งาน
            if (userData.STATUS == "0001")
            {
                hypShow.Text    = "<h4 class='txt-color-green'><i class='fa fa-user'></i></h4>";
                hypShow.ToolTip = "ใช้งาน";
            }
            //0002 = ระงับการใช้งาน
            if (userData.STATUS == "0002")
            {
                hypShow.Text    = "<h4 class='txt-color-red'><i class='fa fa-user'></i></h4>";
                hypShow.ToolTip = "ระงับการใช้งาน";
            }
            //0003 = ระงับการใช้งานชั่วคราว
            if (userData.STATUS == "0003")
            {
                hypShow.Text    = "<h4 class='txt-color-yellow'><i class='fa fa-user'></i></h4>";
                hypShow.ToolTip = "ระงับการใช้งานชั่วคราว";
            }
            hypShow.NavigateUrl = urlShow;
            cellStatus.CssClass = "text-center";
            cellStatus.Controls.Add(hypShow);
            tRowBody.Cells.Add(cellStatus);

            TableCell cellPermission = new TableCell();
            //string urlPermission = "role_User.aspx?Uid=" + userData.USERS_INFO_USER_ID;
            HyperLink hypPermission = new HyperLink();
            hypPermission.Text        = "<h4><i class='fa fa-gear'></i></h4>";
            hypPermission.NavigateUrl = urlPermission;
            hypPermission.ToolTip     = "กำหนดสิทธิ์";
            cellPermission.Controls.Add(hypPermission);
            cellPermission.CssClass = "text-center";
            tRowBody.Cells.Add(cellPermission);

            if (autro_obj.CheckGroupUser(login_data, group_var.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
            {
                TableCell cellPassword = new TableCell();
                string    urlPassword  = "******" + userData.USERS_INFO_USER_ID;
                HyperLink hypPassword  = new HyperLink();
                hypPassword.Attributes.Add("data-target", "#updatePassword");
                hypPassword.Attributes.Add("data-toggle", "modal");
                hypPassword.Text        = "<h4 class='txt-color-green'><i class='fa fa-key'></i></h4>";
                hypPassword.ToolTip     = "เปลี่ยนรหัสผ่าน";
                hypPassword.NavigateUrl = urlPassword;
                cellPassword.CssClass   = "text-center";
                cellPassword.Controls.Add(hypPassword);
                tRowBody.Cells.Add(cellPassword);

                TableCell cellEdit = new TableCell();
                string    urlEdit  = "edit_User2.aspx?Uid=" + userData.USERS_INFO_USER_ID;
                HyperLink hypEdit  = new HyperLink();
                hypEdit.Text        = "<h4><i class='fa fa-edit'></i></h4>";
                hypEdit.NavigateUrl = urlEdit;
                hypEdit.ToolTip     = "แก้ไข";
                cellEdit.Controls.Add(hypEdit);
                cellEdit.CssClass = "text-center";
                tRowBody.Cells.Add(cellEdit);
            }


            TableCell cellDel = new TableCell();
            HyperLink hypDel  = new HyperLink();
            hypDel.Attributes.Add("data-target", "#deleteUser");
            hypDel.Attributes.Add("data-toggle", "modal");
            hypDel.Text        = "<h4><i class='fa fa-trash-o'></i></h4>";
            hypDel.NavigateUrl = urlDel;
            hypDel.ToolTip     = "ลบผู้ใช้งานออกจากหน่วยงาน";
            cellDel.Controls.Add(hypDel);
            cellDel.CssClass = "text-center";
            tRowBody.Cells.Add(cellDel);

            if (autro_obj.CheckGroupUser(login_data, group_var.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
            {
                string FacultyAuthorizedGroup = new UserAuthorizedSystem().getFacultyAuthorizedSystem(userData.USERS_INFO_USER_ID).Faculty_Users_Group_Id;
                string DepartAuthorizedGroup  = new UserAuthorizedSystem().getDepartmentAuthorizedSystem(userData.USERS_INFO_USER_ID).Department_Users_Group_Id;
                string OtherAuthorizedGroup   = new UserAuthorizedSystem().getOtherAuthorizedSystem(userData.USERS_INFO_USER_ID).Other_Users_Group_Id;

                //if (FacultyAuthorizedGroup == group_var.admin_faculty || DepartAuthorizedGroup == group_var.admin_department || OtherAuthorizedGroup == group_var.admin_otherOffice)
                //{
                if (DepartAuthorizedGroup == group_var.admin_department || OtherAuthorizedGroup == group_var.admin_otherOffice)
                {
                    TableCell cellRemoveSystem = new TableCell();
                    string    urlRemoveSystem  = "";
                    HyperLink hypRemoveSystem  = new HyperLink();
                    hypRemoveSystem.Text        = "<h4 class='txt-color-red'><i class='fa fa-lock'></i></h4>";
                    hypRemoveSystem.NavigateUrl = urlRemoveSystem;
                    hypRemoveSystem.ToolTip     = "ระดับสิทธิ์ \"ผู้ดูแลระบบ\" ไม่สามารถลบได้";
                    cellRemoveSystem.Controls.Add(hypRemoveSystem);
                    cellRemoveSystem.CssClass = "text-center";
                    tRowBody.Cells.Add(cellRemoveSystem);
                }
                else
                {
                    TableCell cellRemoveSystem = new TableCell();
                    string    urlRemoveSystem  = "delete_User.aspx?UserId=" + userData.USERS_INFO_USER_ID;
                    HyperLink hypRemoveSystem  = new HyperLink();
                    hypRemoveSystem.Attributes.Add("data-target", "#deleteUser");
                    hypRemoveSystem.Attributes.Add("data-toggle", "modal");
                    hypRemoveSystem.Text        = "<h4 class='txt-color-red'><i class='fa fa-times'></i></h4>";
                    hypRemoveSystem.NavigateUrl = urlRemoveSystem;
                    hypRemoveSystem.ToolTip     = "ลบผู้ใช้งานออกจากระบบ";
                    cellRemoveSystem.Controls.Add(hypRemoveSystem);
                    cellRemoveSystem.CssClass = "text-center";
                    tRowBody.Cells.Add(cellRemoveSystem);
                }
            }


            tblUsers.Rows.Add(tRowBody);
        }
    }
Пример #5
0
    protected void btnSEARCH_Click(object sender, EventArgs e)
    {
        //โหลดข้อมูล Users
        string sql = "Select * From USERS_INFO Where USER_ID Like '%" + txtKeyWord.Text.Trim() + "%' Or FIRST_THAINAME Like '%" + txtKeyWord.Text.Trim() + "%' Or FAMILY_THAINAME Like '%" + txtKeyWord.Text.Trim() + "%' Or FIRST_ENGNAME Like '%" + txtKeyWord.Text.Trim() + "%' Or FAMILY_ENGNAME  Like '%" + txtKeyWord.Text.Trim() + "%' Order by FIRST_THAINAME";

        userData = userObj.getUsersFromCommand(sql);

        foreach (UsersInfo data in userData)
        {
            TableRow tRowBody = new TableRow();
            tRowBody.TableSection = TableRowSection.TableBody;

            TableCell cellUserId = new TableCell();
            cellUserId.Text = data.USERS_INFO_USER_ID;
            tRowBody.Cells.Add(cellUserId);

            TableCell cellUserNameThai = new TableCell();
            Prefix    prefixObj        = new Prefix();
            if (data.USERS_INFO_FIRST_THAINAME == "")
            {
                cellUserNameThai.Text = prefixObj.getPrefix(data.USERS_INFO_TITLE_THAINAME).Prefix_Eng + data.USERS_INFO_FIRST_ENGNAME + " " + data.USERS_INFO_FAMILY_ENGNAME;
            }
            else
            {
                cellUserNameThai.Text = prefixObj.getPrefix(data.USERS_INFO_TITLE_THAINAME).Prefix_Thai + data.USERS_INFO_FIRST_THAINAME + " " + data.USERS_INFO_FAMILY_THAINAME;
            }
            tRowBody.Cells.Add(cellUserNameThai);

            TableCell cellDepartment = new TableCell();
            if (data.USERS_INFO_DEPARTMENT_ID == "0000")
            {
                cellDepartment.Text = "หน่วยงาน/สำนักงานคณะ";
            }
            else
            {
                Department departmentObj = new Department();
                cellDepartment.Text = departmentObj.getDepartment(data.USERS_INFO_DEPARTMENT_ID).Department_Thai;
            }
            tRowBody.Cells.Add(cellDepartment);

            TableCell cellFaculty = new TableCell();
            if (data.USERS_INFO_FACULTY_ID == "00")
            {
                OtherOfficeData otherOffice = new OtherOffice().getOtherOffice(data.OTHEROFFICE_CODE);
                cellFaculty.Text = otherOffice.OtherOffice_ThaiName;
            }
            else
            {
                cellFaculty.Text = facultyObj.getFaculty(data.USERS_INFO_FACULTY_ID).Faculty_Thai;
            }

            tRowBody.Cells.Add(cellFaculty);

            TableCell cellPermission = new TableCell();
            string    urlPermission  = "add_Member_OU.aspx?Uid=" + data.USERS_INFO_USER_ID;
            HyperLink hypPermission  = new HyperLink();
            hypPermission.Text        = "<h4><i class='fa fa-male'></i><i class='fa fa-female'></i></h4>";
            hypPermission.NavigateUrl = urlPermission;
            hypPermission.ToolTip     = "Permission";
            cellPermission.Controls.Add(hypPermission);
            cellPermission.CssClass = "text-center";
            tRowBody.Cells.Add(cellPermission);

            tblUsers.Rows.Add(tRowBody);
        }
    }
Пример #6
0
 protected void btnOK_Click(object sender, EventArgs e)
 {
     string result = new OtherOffice().deleteOtherOffice(officeId);
     Response.Redirect("list_Office.aspx");
 }
Пример #7
0
    public void TableBody(string permissionObject, string userId)
    {
        string sql;
        List <UserAuthorizedSystemData> o;

        if (permissionObject == "Faculty")
        {
            sql = "Select * From FACULTY_AUTHORIZED_SYSTEM Where USER_ID='" + userId + "' Order by USERS_GROUP_ID";
            o   = new UserAuthorizedSystem().getFacultyAuthorizedSystemManual(sql);

            foreach (UserAuthorizedSystemData data in o)
            {
                TableRow tRowBody = new TableRow();
                tRowBody.TableSection = TableRowSection.TableBody;

                TableCell cellUserPermission = new TableCell();
                cellUserPermission.Text = new UserGroup().getUserGroup(data.Faculty_Users_Group_Id).Users_Group_Name + " (คณะ)";
                cellUserPermission.Attributes.Add("class", "txt-color-red");
                tRowBody.Cells.Add(cellUserPermission);

                TableCell cellDepartment = new TableCell();
                if (data.Department_Aathorized_Code == null)
                {
                    cellDepartment.Text = "คณะ/สำนักงาน";
                }
                else
                {
                    Department departmentObj = new Department();
                    cellDepartment.Text = departmentObj.getDepartment(data.Department_Aathorized_Code).Department_Thai;
                }
                cellDepartment.Attributes.Add("class", "txt-color-red");
                tRowBody.Cells.Add(cellDepartment);

                TableCell cellFaculty = new TableCell();
                Faculty   facultyObj  = new Faculty();
                cellFaculty.Text = facultyObj.getFaculty(data.Faculty_Authorized_Code).Faculty_Thai;
                cellFaculty.Attributes.Add("class", "txt-color-red");
                tRowBody.Cells.Add(cellFaculty);

                TableCell cellDel = new TableCell();
                //string urlDel = "#";
                string    urlDel = "delete_Role.aspx?UserId=" + data.Faculty_User_Id + "&Token=" + data.Faculty_Authorized_Code + "&Flage=1&Group=" + data.Faculty_Users_Group_Id;
                HyperLink hypDel = new HyperLink();
                hypDel.Attributes.Add("data-target", "#delete");
                hypDel.Attributes.Add("data-toggle", "modal");
                hypDel.Text        = "<h4 class='txt-color-red'><i class='fa fa-trash-o'></i></h4>";
                hypDel.NavigateUrl = urlDel;
                hypDel.ToolTip     = "Delete";
                cellDel.Controls.Add(hypDel);
                cellDel.CssClass = "text-center";
                tRowBody.Cells.Add(cellDel);

                tblUsers.Rows.Add(tRowBody);
            }
        }
        else if (permissionObject == "Department")
        {
            sql = "Select * From DEPARTMENT_AUTHORIZED_SYSTEM Where USER_ID='" + userId + "' Order by USERS_GROUP_ID";
            o   = new UserAuthorizedSystem().getDepartmentAuthorizedSystemManual(sql);

            if (o.Count > 0)
            {
                foreach (UserAuthorizedSystemData data in o)
                {
                    TableRow tRowBody = new TableRow();
                    tRowBody.TableSection = TableRowSection.TableBody;

                    TableCell cellUserPermission = new TableCell();
                    cellUserPermission.Text = new UserGroup().getUserGroup(data.Department_Users_Group_Id).Users_Group_Name + " (ภาควิชา)";
                    cellUserPermission.Attributes.Add("class", "txt-color-green");
                    tRowBody.Cells.Add(cellUserPermission);

                    TableCell cellDepartment = new TableCell();
                    if (data.Department_Aathorized_Code == null)
                    {
                        cellDepartment.Text = "คณะ/สำนักงาน";
                    }
                    else
                    {
                        Department departmentObj = new Department();
                        cellDepartment.Text = departmentObj.getDepartment(data.Department_Aathorized_Code).Department_Thai;
                    }
                    cellDepartment.Attributes.Add("class", "txt-color-green");
                    tRowBody.Cells.Add(cellDepartment);

                    TableCell      cellFaculty    = new TableCell();
                    Faculty        facultyObj     = new Faculty();
                    DepartmentData departmentObj2 = new Department().getDepartment(data.Department_Aathorized_Code);
                    cellFaculty.Text = facultyObj.getFaculty(departmentObj2.Department_FacultyCode).Faculty_Thai;
                    cellFaculty.Attributes.Add("class", "txt-color-green");
                    tRowBody.Cells.Add(cellFaculty);

                    TableCell cellDel = new TableCell();
                    //string urlDel = "#";
                    string    urlDel = "delete_Role.aspx?UserId=" + data.Department_User_Id + "&Token=" + data.Department_Aathorized_Code + "&Flage=2&Group=" + data.Department_Users_Group_Id;
                    HyperLink hypDel = new HyperLink();
                    hypDel.Attributes.Add("data-target", "#delete");
                    hypDel.Attributes.Add("data-toggle", "modal");
                    hypDel.Text        = "<h4 class='txt-color-green'><i class='fa fa-trash-o'></i></h4>";
                    hypDel.NavigateUrl = urlDel;
                    hypDel.ToolTip     = "Delete";
                    cellDel.Controls.Add(hypDel);
                    cellDel.CssClass = "text-center";
                    tRowBody.Cells.Add(cellDel);

                    tblUsers.Rows.Add(tRowBody);
                }
            }
        }
        else if (permissionObject == "Office")
        {
            sql = "Select * From OTHER_AUTHORIZED_SYSTEM Where USER_ID='" + userId + "' Order by USERS_GROUP_ID";
            o   = new UserAuthorizedSystem().getOtherAuthorizedSystemManual(sql);

            if (o.Count > 0)
            {
                foreach (UserAuthorizedSystemData data in o)
                {
                    TableRow tRowBody = new TableRow();
                    tRowBody.TableSection = TableRowSection.TableBody;

                    TableCell cellUserPermission = new TableCell();
                    cellUserPermission.Text = new UserGroup().getUserGroup(data.Other_Users_Group_Id).Users_Group_Name + " (หน่วยงาน)";
                    cellUserPermission.Attributes.Add("class", "txt-color-blue");
                    tRowBody.Cells.Add(cellUserPermission);

                    TableCell cellDepartment = new TableCell();
                    cellDepartment.Text = "คณะ/สำนักงาน";
                    cellDepartment.Attributes.Add("class", "txt-color-blue");
                    tRowBody.Cells.Add(cellDepartment);

                    TableCell       cellFaculty = new TableCell();
                    OtherOfficeData otherOffice = new OtherOffice().getOtherOffice(data.Other_Authorized_Code);
                    cellFaculty.Attributes.Add("class", "txt-color-blue");
                    cellFaculty.Text = otherOffice.OtherOffice_ThaiName;

                    tRowBody.Cells.Add(cellFaculty);

                    TableCell cellDel = new TableCell();
                    //string urlDel = "#";
                    string    urlDel = "delete_Role.aspx?UserId=" + data.Other_User_Id + "&Token=" + data.Other_Authorized_Code + "&Flage=3&Group=" + data.Other_Users_Group_Id;
                    HyperLink hypDel = new HyperLink();
                    hypDel.Attributes.Add("data-target", "#delete");
                    hypDel.Attributes.Add("data-toggle", "modal");
                    hypDel.Text        = "<h4 class='txt-color-blue'><i class='fa fa-trash-o'></i></h4>";
                    hypDel.NavigateUrl = urlDel;
                    hypDel.ToolTip     = "Delete";
                    cellDel.Controls.Add(hypDel);
                    cellDel.CssClass = "text-center";
                    tRowBody.Cells.Add(cellDel);

                    tblUsers.Rows.Add(tRowBody);
                }
            }
        }
    }
Пример #8
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.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty) || autro_obj.CheckGroupUser(login_data, group_var.admin_department) || autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice))
            {
                /*=============================*/

                userId = Request.QueryString["Uid"];
                flag   = Request.QueryString["flag"];
                token  = Request.QueryString["token"];

                bool haverole = false;

                //if (autro_obj.CheckGroupUser(login_data, group_var.admin_university))
                //    {
                //    haverole = true;
                //    }
                if (autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
                {
                    List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.admin_faculty);
                    foreach (string fac in faculty_authorized)
                    {
                        if (fac == token.Substring(0, 2))
                        {
                            haverole = true;
                            break;
                        }
                    }
                }
                //else if (autro_obj.CheckGroupUser(login_data, group_var.admin_department))
                //    {

                //    List<string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.admin_department);
                //    foreach(string dep in department_authorized)
                //        {
                //        if(dep == token)
                //            {
                //            haverole = true;
                //            break;
                //            }
                //        }

                //    }
                //else if (autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice))
                //    {
                //    List<string> otheroffice_authorized = autro_obj.getOtherOffice_Authorized(login_data, group_var.admin_otherOffice);
                //    foreach(string office in otheroffice_authorized)
                //        {
                //        if (office == token)
                //            {
                //            haverole = true;
                //            break;
                //            }
                //        }
                //    }
                else
                {
                    haverole = false;
                }


                if (haverole == true)
                {
                    userData       = userObj.getUsers(userId);
                    lblUserId.Text = userData.USERS_INFO_USER_ID;
                    lblName.Text   = new Prefix().getPrefix(userData.USERS_INFO_TITLE_THAINAME).Prefix_Thai;
                    lblName.Text  += userData.USERS_INFO_FIRST_THAINAME + " " + userData.USERS_INFO_FAMILY_THAINAME;

                    if (userData.USERS_INFO_DEPARTMENT_ID == "0000")
                    {
                        lblDepartment.Text = "-";
                    }
                    else
                    {
                        Department departmentObj = new Department();
                        lblDepartment.Text = departmentObj.getDepartment(userData.USERS_INFO_DEPARTMENT_ID).Department_Thai;
                    }

                    if (userData.USERS_INFO_FACULTY_ID == "00")
                    {
                        OtherOfficeData otherOffice = new OtherOffice().getOtherOffice(userData.OTHEROFFICE_CODE);
                        lblFaculty.Text = otherOffice.OtherOffice_ThaiName;
                    }
                    else
                    {
                        Faculty facultyObj2 = new Faculty();
                        lblFaculty.Text = facultyObj2.getFaculty(userData.USERS_INFO_FACULTY_ID).Faculty_Thai;
                    }

                    // Head Table
                    string[] ar = { "ระดับสิทธิ์", "ภาควิชา", "คณะ/วิทยาลัย/สำนักงาน", "ลบ" };
                    //Table tb1 = new Table();
                    tblUsers.Attributes.Add("class", "table table-bordered table-striped table-hover");
                    tblUsers.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];

                        if (cellCtr == 1)
                        {
                            cellHead.Width = 250;
                        }
                        else if (cellCtr == 4)
                        {
                            cellHead.Width = 80;
                        }
                        tRowHead.Cells.Add(cellHead);
                    }
                    tblUsers.Rows.Add(tRowHead);

                    TableBody("Faculty", userId);
                    TableBody("Department", userId);
                    TableBody("Office", userId);


                    if (!Page.IsPostBack)
                    {
                        //ซ่อน ddl สังกัดไว้ตอน page load
                        if (flag == "1" || flag == "2")
                        {
                            ddlDivision.Items.FindByValue("1").Selected = true;
                            //ddlFaculty.Items.FindByValue(token).Selected = true;

                            // คณะ
                            //List<string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.admin_faculty);
                            ddlFaculty.Items.Clear();
                            FacultyData fac_data = new FacultyData();
                            fac_data = facultyObj.getFaculty(token.Substring(0, 2));
                            ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(fac_data.Faculty_Thai, fac_data.Faculty_Code));

                            //โหลดภาควิชา
                            List <DepartmentData> departmentData = new List <DepartmentData>();
                            departmentData = new Department().getDepartmentWithFaculty(fac_data.Faculty_Code);
                            ddlDepartment.Items.Clear();
                            ddlDepartment.Items.Insert(0, new ListItem("-- ไม่ได้สังกัดภาควิชา --", "0000"));
                            foreach (DepartmentData data in departmentData)
                            {
                                ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                            }

                            //โหลดระดับสิทธิ์ระดับคณะ
                            userGroupData = userGroup.getUserGroup();
                            ddlGroup.Items.Clear();
                            foreach (UserGroupData data in userGroupData)
                            {
                                if (data.Users_Group_Id == "0300" || data.Users_Group_Id == "1101")
                                {
                                    ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id));
                                }
                            }



                            divOffice.Visible = false;
                        }
                        //if (flag == "2")
                        //    {
                        //    //โหลดภาควิชา
                        //    Department department = new Department();
                        //    List<DepartmentData> departmentData = new List<DepartmentData>();

                        //    //departmentData = department.getDepartmentWithFaculty(ddlFaculty.SelectedValue);
                        //    departmentData = department.getDepartment();
                        //    ddlDepartment.Items.Clear();
                        //    ddlDepartment.Items.Insert(0, new ListItem("-- ไม่ได้สังกัดภาควิชา --", "0000"));
                        //    foreach (DepartmentData data in departmentData)
                        //        {
                        //        ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                        //        }

                        //    string fac = new Department().getDepartment(token).Department_FacultyCode;

                        //    ddlDivision.Items.FindByValue("1").Selected = true;
                        //    ddlFaculty.Items.FindByValue(fac).Selected = true;
                        //    ddlDepartment.Items.FindByValue(token).Selected = true;

                        //    //โหลดระดับสิทธิ์ระดับภาควิชา
                        //    userGroupData = userGroup.getUserGroup();
                        //    ddlGroup.Items.Clear();
                        //    foreach (UserGroupData data in userGroupData)
                        //        {
                        //        if (data.Users_Group_Id == "0400" || data.Users_Group_Id == "1102" || data.Users_Group_Id == "0800")
                        //            {
                        //            ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id));
                        //            }
                        //        }

                        //    divOffice.Visible = false;
                        //    }
                        if (flag == "3")
                        {
                            /////รหัสสิทธิ์ Users_Group_Id
                            //0300	วิชาการคณะ
                            //0200	เจ้าหน้าที่ทะเบียน สถิติ บณฑิต
                            //0100	ผู้บริหารงานทะเบียน สถิติ บัณฑิต
                            //0400	วิชาการภาค
                            //0500	งานการเงิน
                            //0800	อาจารย์ที่ปรึกษา/ผู้สอน
                            //5000	งานธนาคาร
                            //1103	ผู้ดูแลหน่วยงาน
                            //0900	งานหลักสูตร
                            //0700	งานทุนนักศึกษา
                            //1000	ผู้บริหารมหาวิทยาลัย
                            //1101	ผู้ดูแลระบบคณะ
                            //1102	ผู้ดูแลลระบบภาควิชา
                            //1100	ผู้ดูแลระบบหลัก
                            //0600	งานกองแผนงาน

                            divFaculty.Visible = false;
                            ddlDivision.Items.FindByValue("2").Selected = true;
                            ddlOffice.Items.FindByValue(token).Selected = true;

                            //0500	กองแผนงาน
                            if (ddlOffice.SelectedValue == "0500")
                            {
                                //โหลดระดับสิทธิ์ระดับสำนักงาน
                                userGroupData = userGroup.getUserGroup();
                                ddlGroup.Items.Clear();
                                foreach (UserGroupData data in userGroupData)
                                {
                                    if (data.Users_Group_Id == "0600" || data.Users_Group_Id == "1103")
                                    {
                                        ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id));
                                    }
                                }
                            }

                            //2200	สำนักคอมพิวเตอร์และเทคโนโลยีสารสนเทศ
                            if (ddlOffice.SelectedValue == "2200")
                            {
                                //โหลดระดับสิทธิ์ระดับสำนักงาน
                                userGroupData = userGroup.getUserGroup();
                                ddlGroup.Items.Clear();
                                foreach (UserGroupData data in userGroupData)
                                {
                                    if (data.Users_Group_Id == "1100" || data.Users_Group_Id == "1000" || data.Users_Group_Id == "5000")
                                    {
                                        ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id));
                                    }
                                }
                            }

                            //0601	กองบริการการศึกษา
                            if (ddlOffice.SelectedValue == "0601")
                            {
                                //โหลดระดับสิทธิ์ระดับสำนักงาน
                                userGroupData = userGroup.getUserGroup();
                                ddlGroup.Items.Clear();
                                foreach (UserGroupData data in userGroupData)
                                {
                                    if (data.Users_Group_Id == "0900" || data.Users_Group_Id == "0100" || data.Users_Group_Id == "0200" || data.Users_Group_Id == "1103")
                                    {
                                        ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id));
                                    }
                                }
                            }

                            //1001	กองคลัง
                            if (ddlOffice.SelectedValue == "1001")
                            {
                                //โหลดระดับสิทธิ์ระดับสำนักงาน
                                userGroupData = userGroup.getUserGroup();
                                ddlGroup.Items.Clear();
                                foreach (UserGroupData data in userGroupData)
                                {
                                    if (data.Users_Group_Id == "0500" || data.Users_Group_Id == "1103")
                                    {
                                        ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id));
                                    }
                                }
                            }

                            //5001	ธนาคารกรุงเทพ
                            if (ddlOffice.SelectedValue == "5001")
                            {
                                //โหลดระดับสิทธิ์ระดับสำนักงาน
                                userGroupData = userGroup.getUserGroup();
                                ddlGroup.Items.Clear();
                                foreach (UserGroupData data in userGroupData)
                                {
                                    if (data.Users_Group_Id == "5000")
                                    {
                                        ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id));
                                    }
                                }
                            }

                            //0700	กองกิจการนักศึกษา
                            if (ddlOffice.SelectedValue == "0700")
                            {
                                //โหลดระดับสิทธิ์ระดับสำนักงาน
                                userGroupData = userGroup.getUserGroup();
                                ddlGroup.Items.Clear();
                                foreach (UserGroupData data in userGroupData)
                                {
                                    if (data.Users_Group_Id == "0700" || data.Users_Group_Id == "1103")
                                    {
                                        ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id));
                                    }
                                }
                            }
                        }
                    }
                }
                else
                {
                    HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                    HttpContext.Current.Response.Redirect("err_response.aspx");
                }


                /*=============================*/
            }
            else
            {
                HttpContext.Current.Session["response"] = "ตรวจสอบไม่พบสิทธิ์การเข้าใช้งาน";
                HttpContext.Current.Response.Redirect("err_response.aspx");
            }
        }
    }
Пример #9
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.admin_university) || autro_obj.CheckGroupUser(login_data, group_var.admin_faculty) || autro_obj.CheckGroupUser(login_data, group_var.admin_department) || autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice))
            {
                /*=============================*/
                userId = Request.QueryString["Uid"];

                userData = userObj.getUsers(userId);

                lblUserId.Text = userData.USERS_INFO_USER_ID;
                lblName.Text   = new Prefix().getPrefix(userData.USERS_INFO_TITLE_THAINAME).Prefix_Thai;
                lblName.Text  += userData.USERS_INFO_FIRST_THAINAME + " " + userData.USERS_INFO_FAMILY_THAINAME;

                if (userData.USERS_INFO_DEPARTMENT_ID == "0000")
                {
                    lblDepartment.Text = "-";
                }
                else
                {
                    Department departmentObj = new Department();
                    lblDepartment.Text = departmentObj.getDepartment(userData.USERS_INFO_DEPARTMENT_ID).Department_Thai;
                }

                if (userData.USERS_INFO_FACULTY_ID == "00")
                {
                    OtherOfficeData otherOffice = new OtherOffice().getOtherOffice(userData.OTHEROFFICE_CODE);
                    lblFaculty.Text = otherOffice.OtherOffice_ThaiName;
                }
                else
                {
                    Faculty facultyObj2 = new Faculty();
                    lblFaculty.Text = facultyObj2.getFaculty(userData.USERS_INFO_FACULTY_ID).Faculty_Thai;
                }



                //ซ่อน ddl สังกัดไว้ตอน page load
                //divFaculty.Visible = false;
                // divOffice.Visible = false;

                if (!Page.IsPostBack)
                {
                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_university))
                    {
                        divFaculty.Visible = false;
                        divOffice.Visible  = false;
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
                    {
                        divFaculty.Visible = true;
                        divOffice.Visible  = false;
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.admin_department))
                    {
                        divFaculty.Visible = true;
                        divOffice.Visible  = false;
                    }
                    else if (autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice))
                    {
                        divFaculty.Visible = false;
                        divOffice.Visible  = true;
                    }

                    // admin มหาวิทยาลัย
                    //if (autro_obj.CheckGroupUser(login_data, group_var.admin_university))
                    //    {

                    //    // เลือกสังกัด
                    //    ddlDivision.Enabled = true;

                    //    // คณะ
                    //    ddlFaculty.Items.Clear();
                    //    facultyData = facultyObj.getFaculty();
                    //    ddlFaculty.Items.Insert(0, new ListItem("--- เลือกคณะ ---", "00"));
                    //    foreach (FacultyData data in facultyData)
                    //        {
                    //        ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                    //        }

                    //    }
                    // admin คณะ
                    if (autro_obj.CheckGroupUser(login_data, group_var.admin_faculty))
                    {
                        // เลือกสังกัด
                        ddlDivision.Enabled = false;
                        ddlDivision.Items.Clear();
                        ddlDivision.Items.Insert(ddlDivision.Items.Count, new ListItem("คณะ/วิทยาลัย", "1"));

                        List <string> faculty_authorized = autro_obj.getFaculty_Authorized(login_data, group_var.admin_faculty);

                        // คณะ
                        ddlFaculty.Items.Clear();
                        facultyData = facultyObj.getFaculty(faculty_authorized);
                        ddlFaculty.Items.Insert(0, new ListItem("--- เลือกคณะ ---", "00"));
                        foreach (FacultyData data in facultyData)
                        {
                            ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(data.Faculty_Thai, data.Faculty_Code));
                        }
                    }
                    // admin ภาควิชา
                    //if (autro_obj.CheckGroupUser(login_data, group_var.admin_department))
                    //  {
                    //  // เลือกสังกัด
                    //  ddlDivision.Enabled = false;
                    //  ddlDivision.Items.Clear();
                    //  ddlDivision.Items.Insert(ddlDivision.Items.Count, new ListItem("คณะ/วิทยาลัย", "1"));

                    //  List<string> department_authorized = autro_obj.getDepartment_Authorized(login_data, group_var.admin_department);
                    //  // ภาควิชา
                    //  ddlDepartment.Items.Clear();
                    //  departmentData = new Department().getDepartment(department_authorized);
                    //  foreach (DepartmentData data in departmentData)
                    //      {
                    //      ddlDepartment.Items.Insert(ddlDepartment.Items.Count, new ListItem(data.Department_Thai, data.Department_Code));
                    //      }

                    //  // คณะ
                    //  ddlFaculty.Enabled = false;
                    //  FacultyData faculty_data = new FacultyData();
                    //  faculty_data = new Faculty().getFaculty(ddlDepartment.SelectedValue.Substring(0, 2));
                    //  ddlFaculty.Items.Insert(ddlFaculty.Items.Count, new ListItem(faculty_data.Faculty_Thai, faculty_data.Faculty_Code));


                    //  }
                    // admin สำนักงาน
                    //if (autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice))
                    //    {
                    //    // เลือกสังกัด
                    //    ddlDivision.Enabled = false;
                    //    ddlDivision.Items.Clear();
                    //    ddlDivision.Items.Insert(ddlDivision.Items.Count, new ListItem("สำนักงาน", "2"));

                    //    //สำนักงาน
                    //    List<string> otheroffice_authorized = autro_obj.getOtherOffice_Authorized(login_data, group_var.admin_otherOffice);
                    //    otherOfficeData = otherOfficeObj.getOtherOffice(otheroffice_authorized);
                    //    ddlOffice.Items.Clear();
                    //    ddlOffice.Items.Insert(0, new ListItem("--- เลือกสำนักงาน ---", "0000"));
                    //    foreach (OtherOfficeData data in otherOfficeData)
                    //        {
                    //        ddlOffice.Items.Insert(ddlOffice.Items.Count, new ListItem(data.OtherOffice_ThaiName, data.OtherOffice_Code));
                    //        }



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