Exemplo n.º 1
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            //คณะ
            if (Flag == "1")
            {
                string sql        = "Delete From FACULTY_AUTHORIZED_SYSTEM Where USERS_GROUP_ID = '" + Group + "' And USER_ID ='" + LoginName + "' And FACULTY_AUTHORIZED_CODE = '" + Token + "'";
                string delUserFac = new UserAuthorizedSystem().deleteFacultyAuthorizeSystemManual(sql);
                Response.Redirect("role_User.aspx?Uid=" + LoginName);
            }

            //ภาควิชา
            if (Flag == "2")
            {
                string sql        = "Delete From DEPARTMENT_AUTHORIZED_SYSTEM Where USERS_GROUP_ID = '" + Group + "' And USER_ID ='" + LoginName + "' And DEPARTMENT_AUTHORIZED_CODE = '" + Token + "'";
                string delUserFac = new UserAuthorized().deleteDepartmentAuthorizedManual(sql);
                Response.Redirect("role_User.aspx?Uid=" + LoginName);
            }

            //หน่วยงานอื่นๆ
            if (Flag == "3")
            {
                string sql        = "Delete From OTHER_AUTHORIZED_SYSTEM Where USERS_GROUP_ID = '" + Group + "' And USER_ID ='" + LoginName + "' And OTHER_AUTHORIZED_CODE = '" + Token + "'";
                string delUserFac = new UserAuthorized().deleteOtherAuthorizedManual(sql);
                Response.Redirect("role_User.aspx?Uid=" + LoginName);
            }
        }
        catch
        {
            //Response.Redirect("role_User.aspx?Uid=" + LoginName);

            Response.Redirect("role_User.aspx?Uid=" + LoginName + "&flag=" + Flag + "&token=" + Token);
        }
    }
Exemplo n.º 2
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        try
        {
            //คณะ
            if (Flag == "1")
            {
                string sql        = "Delete From USERS_FACULTY_AUTHORIZED Where USER_ID ='" + LoginName + "' And FACULTY_CODE = '" + Token + "'";
                string delUserFac = new UserAuthorized().deleteFacultyAuthorizeManual(sql);

                string sqlSystem        = "Delete From FACULTY_AUTHORIZED_SYSTEM Where USER_ID ='" + LoginName + "' And FACULTY_AUTHORIZED_CODE = '" + Token + "'";
                string delUserFacSystem = new UserAuthorizedSystem().deleteFacultyAuthorizeSystemManual(sqlSystem);

                Response.Redirect("list_User.aspx");
            }

            //ภาควิชา
            if (Flag == "2")
            {
                string sql        = "Delete From USERS_DEPARTMENT_AUTHORIZED Where USER_ID ='" + LoginName + "' And DEPARTMENT_CODE = '" + Token + "'";
                string delUserFac = new UserAuthorized().deleteDepartmentAuthorizedManual(sql);

                string sqlSystem        = "Delete From DEPARTMENT_AUTHORIZED_SYSTEM Where USER_ID ='" + LoginName + "' And DEPARTMENT_AUTHORIZED_CODE = '" + Token + "'";
                string delUserFacSystem = new UserAuthorized().deleteDepartmentAuthorizedManual(sqlSystem);

                Response.Redirect("list_User.aspx");
            }

            //หน่วยงานอื่นๆ
            if (Flag == "3")
            {
                string sql        = "Delete From USERS_OTHER_AUTHORIZED Where USER_ID ='" + LoginName + "' And OTHEROFFICE_CODE = '" + Token + "'";
                string delUserFac = new UserAuthorized().deleteOtherAuthorizedManual(sql);

                string sqlSystem        = "Delete From OTHER_AUTHORIZED_SYSTEM Where USER_ID ='" + LoginName + "' And OTHER_AUTHORIZED_CODE = '" + Token + "'";
                string delUserFacSystem = new UserAuthorized().deleteOtherAuthorizedManual(sqlSystem);

                Response.Redirect("list_User.aspx");
            }
        }
        catch
        {
            Response.Redirect("list_User.aspx");
        }
    }
Exemplo n.º 3
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);
        }
    }
Exemplo n.º 4
0
    protected void btnADD_Click(object sender, EventArgs e)
    {
        UsersInfo userInfo = new UsersInfo().getUsers(userId);


        //User คณะ
        if (ddlDivision.SelectedValue == "1" && ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue == "0000")
        {
            UserAuthorizedSystemData userFaculty = new UserAuthorizedSystemData();
            userFaculty.Faculty_Users_Group_Id  = ddlGroup.SelectedValue;
            userFaculty.Faculty_User_Id         = userInfo.USERS_INFO_USER_ID;
            userFaculty.Faculty_Authorized_Code = ddlFaculty.SelectedValue;

            //Check Duplicate
            string sqlUserFaculty = "Select * From FACULTY_AUTHORIZED_SYSTEM Where USERS_GROUP_ID='" + userFaculty.Faculty_Users_Group_Id + "' And USER_ID='" + userFaculty.Faculty_User_Id + "' And FACULTY_AUTHORIZED_CODE='" + userFaculty.Faculty_Authorized_Code + "'";
            List <UserAuthorizedSystemData> chkuserFaculty = new UserAuthorizedSystem().getFacultyAuthorizedSystemManual(sqlUserFaculty);



            if (chkuserFaculty.Count > 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่คณะ ซ้ำ!');", true);
            }
            else
            {
                //Insert ระดับคณะ
                string insertUserFaculty = new UserAuthorizedSystem().insertFacultyAuthorizedSystem(userFaculty);
            }
        }
        //User ภาควิชา
        else if (ddlDivision.SelectedValue == "1" && ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue != "0000")
        {
            UserAuthorizedSystemData userDepartment = new UserAuthorizedSystemData();
            userDepartment.Department_Users_Group_Id  = ddlGroup.SelectedValue;
            userDepartment.Department_User_Id         = userInfo.USERS_INFO_USER_ID;
            userDepartment.Department_Aathorized_Code = ddlDepartment.SelectedValue;

            //Check Duplicate
            string sqlUserDepartment = "Select * From DEPARTMENT_AUTHORIZED_SYSTEM Where USERS_GROUP_ID='" + userDepartment.Department_Users_Group_Id + "' And USER_ID='" + userDepartment.Department_User_Id + "' And DEPARTMENT_AUTHORIZED_CODE='" + userDepartment.Department_Aathorized_Code + "'";
            List <UserAuthorizedSystemData> chkuserDepartment = new UserAuthorizedSystem().getDepartmentAuthorizedSystemManual(sqlUserDepartment);

            if (chkuserDepartment.Count > 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่ภาควิชา ซ้ำ!');", true);
            }
            else
            {
                //Insert ระดับภาควิชา
                string insertUserDepartment = new UserAuthorizedSystem().insertDepartmentAuthorizedSystem(userDepartment);
            }
        }
        //User สำนักงาน
        //else if (ddlDivision.SelectedValue == "2" && ddlFaculty.SelectedValue == "00" && ddlDepartment.SelectedValue == "0000" && ddlOffice.SelectedValue != "0000")
        //{
        //    UserAuthorizedSystemData userOtherOffice = new UserAuthorizedSystemData();
        //    userOtherOffice.Other_Users_Group_Id = ddlGroup.SelectedValue;
        //    userOtherOffice.Other_User_Id = userInfo.USERS_INFO_USER_ID;
        //    userOtherOffice.Other_Authorized_Code = ddlOffice.SelectedValue;

        //    //Check Duplicate
        //    string sqlUserOffice = "Select * From OTHER_AUTHORIZED_SYSTEM Where USERS_GROUP_ID='" + userOtherOffice.Other_Users_Group_Id + "' And USER_ID='" + userOtherOffice.Other_User_Id + "' And OTHER_AUTHORIZED_CODE='" + userOtherOffice.Other_Authorized_Code + "'";
        //    List<UserAuthorizedSystemData> chkuserOffice = new UserAuthorizedSystem().getOtherAuthorizedSystemManual(sqlUserOffice);

        //    if (chkuserOffice.Count > 0)
        //    {
        //        Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่สำนักงาน ซ้ำ!');", true);
        //    }
        //    else
        //    {
        //        //Insert ระดับสำนักงาน
        //        string insertUserOffice = new UserAuthorizedSystem().insertOtherAuthorizedSystem(userOtherOffice);
        //    }

        //}
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('ไม่สามารถเพิ่มข้อมูลได้ในตอนนี้!');", true);
        }



        Response.Redirect("role_User.aspx?Uid=" + userId + "&flag=" + flag + "&token=" + token);
    }
Exemplo n.º 5
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);
                }
            }
        }
    }