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); } }
protected void ddlDepartment_SelectedIndexChanged(object sender, EventArgs e) { //Check lblErr1.Text = ""; if (ddlDepartment.SelectedValue != "0000") { userId = Request.QueryString["Uid"]; List <UserAuthorizedData> userAuthorizedData = new List <UserAuthorizedData>(); string sqlUserDepartment = "Select * From USERS_DEPARTMENT_AUTHORIZED Where USER_ID='" + userId + "' And DEPARTMENT_CODE='" + ddlDepartment.SelectedValue + "'"; userAuthorizedData = new UserAuthorized().getDepartmentAuthorizedManual(sqlUserDepartment); if (userAuthorizedData.Count <= 0) { lblErr1.Text = lblName.Text + " ยังไม่มีสิทธิ์เข้าใช้งานภาควิชา " + ddlDepartment.SelectedItem.Text; } else { //โหลดระดับสิทธิ์ระดับภาควิชา userGroupData = userGroup.getUserGroup(); ddlGroup.Items.Clear(); foreach (UserGroupData data in userGroupData) { if (data.Users_Group_Id == "0400" || data.Users_Group_Id == "0800") { ddlGroup.Items.Insert(ddlGroup.Items.Count, new ListItem(data.Users_Group_Name, data.Users_Group_Id)); } } btnSave.Focus(); } } }
private void ViewModel_AuthenticationStatusIndication (object sender, Library.Model.AuthorizeDetailEventArgs e) { if (e.IsAuthenticated) { //unsubscribe from form closing event since there is not need to exit the application on form closing FormClosing -= OnClosingSignIn; //Raise an event indicating that the user is authorized. UserAuthorized?.Invoke(this, e); //close the authentication form this.Close(); } else { //show a message that auth failed if (e.Message != null) { XtraMessageBox.Show(e.Message); } else { XtraMessageBox.Show("Invalid username or password! Please try again."); } //hide authenticating animation SetNormalUiState(); //Clear out the textedits and get focus to username ClearOutUiAndFocusUsername(); } }
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"); } }
public bool RequireUpdate(UserAuthorized auth) { if (auth.FSOVersion == null) { return(false); } var str = GlobalSettings.Default.ClientVersion; var authstr = auth.FSOBranch + "-" + auth.FSOVersion; return(str != authstr); /* * var split = str.LastIndexOf('-'); * int verNum = 0; * int.TryParse(split.) */ }
protected void btnOK_Click(object sender, EventArgs e) { try { string result = new UsersInfo().deleteUsers(LoginName); string delUserFac = new UserAuthorized().deleteFacultyAuthorize(LoginName); string delUserDep = new UserAuthorized().deleteDepartmentAuthorized(LoginName); string delUserOther = new UserAuthorized().deleteOtherAuthorized(LoginName); if (result == "OK") { Response.Redirect("list_User.aspx"); } else { Response.Redirect("list_User.aspx"); } } catch { Response.Redirect("list_User.aspx"); } }
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); } }
protected void btnSAVE_Click(object sender, EventArgs e) { string password = getMD5(txtPassword.Text); string confirm = getMD5(txtPasswordConfirm.Text); if (password == confirm) { UsersInfo userInfo = new UsersInfo(); userInfo.USERS_INFO_USER_ID = txtUserName.Text; userInfo.USERS_INFO_NATIONAL_ID = txtNationId.Text; userInfo.USERS_INFO_OFFICIAL_ID = txtOfficId.Text; userInfo.USERS_INFO_TITLE_THAINAME = ddlTitleThai.SelectedValue; userInfo.USERS_INFO_FIRST_THAINAME = txtNameThai.Text; userInfo.USERS_INFO_FAMILY_THAINAME = txtLnameThai.Text; userInfo.USERS_INFO_TITLE_ENGNAME = ddlTitleEng.SelectedValue; userInfo.USERS_INFO_FIRST_ENGNAME = txtNameEng.Text; userInfo.USERS_INFO_FAMILY_ENGNAME = txtLnameEng.Text; userInfo.USERS_INFO_FACULTY_ID = ddlFaculty.SelectedValue; userInfo.USERS_INFO_DEPARTMENT_ID = ddlDepartment.SelectedValue; userInfo.USERS_INFO_INTERNAL_PHONE = txtIntNumber.Text; userInfo.USERS_INFO_EXTERNAL_PHONE = txtExtNumber.Text; userInfo.OTHEROFFICE_CODE = ddlOffice.SelectedValue; userInfo.STATUS = "0001"; //0001 เปิดใช้งาน userInfo.PASSWORD = password; int userDup = new UsersInfo().getCountUsers(userInfo.USERS_INFO_USER_ID); if (userDup > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ซ้ำ!');", true); } else { string result = new UsersInfo().insertUsers(userInfo); //User คณะ if (userInfo.USERS_INFO_FACULTY_ID != "00" && userInfo.USERS_INFO_DEPARTMENT_ID == "0000" && userInfo.OTHEROFFICE_CODE == "0000") { UserAuthorizedData userFaculty = new UserAuthorizedData(); userFaculty.Faculty_Authorized_User_Id = userInfo.USERS_INFO_USER_ID; userFaculty.Faculty_Authorized_Faculty_Code = userInfo.USERS_INFO_FACULTY_ID; //0001 เปิดใช้งาน //0002 ไม่ใช้งาน userFaculty.Faculty_Authorized_Allow_Status = "0001"; //Check Duplicate string sqlUserFaculty = "Select * From USERS_FACULTY_AUTHORIZED Where USER_ID='" + userFaculty.Faculty_Authorized_User_Id + "' And FACULTY_CODE='" + userFaculty.Faculty_Authorized_Faculty_Code + "'"; List <UserAuthorizedData> chkuserFaculty = new UserAuthorized().getFacultyAuthorizedManual(sqlUserFaculty); if (chkuserFaculty.Count > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่คณะ ซ้ำ!');", true); } else { //Insert ระดับคณะ string insertUserFaculty = new UserAuthorized().insertFacultyAuthorized(userFaculty); } } //User ภาควิชา else if (userInfo.USERS_INFO_FACULTY_ID != "00" && userInfo.USERS_INFO_DEPARTMENT_ID != "0000" && userInfo.OTHEROFFICE_CODE == "0000") { UserAuthorizedData userFaculty = new UserAuthorizedData(); userFaculty.Faculty_Authorized_User_Id = userInfo.USERS_INFO_USER_ID; userFaculty.Faculty_Authorized_Faculty_Code = userInfo.USERS_INFO_FACULTY_ID; //0001 เปิดใช้งาน //0002 ไม่ใช้งาน userFaculty.Faculty_Authorized_Allow_Status = "0001"; //Check Duplicate string sqlUserFaculty = "Select * From USERS_FACULTY_AUTHORIZED Where USER_ID='" + userFaculty.Faculty_Authorized_User_Id + "' And FACULTY_CODE='" + userFaculty.Faculty_Authorized_Faculty_Code + "'"; List <UserAuthorizedData> chkuserFaculty = new UserAuthorized().getFacultyAuthorizedManual(sqlUserFaculty); if (chkuserFaculty.Count > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่คณะ ซ้ำ!');", true); } else { //Insert ระดับคณะ string insertUserFaculty = new UserAuthorized().insertFacultyAuthorized(userFaculty); } UserAuthorizedData userDepartment = new UserAuthorizedData(); userDepartment.Department_Authorized_User_Id = userInfo.USERS_INFO_USER_ID; userDepartment.Department_Authorized_Department_Code = userInfo.USERS_INFO_DEPARTMENT_ID; //0001 เปิดใช้งาน //0002 ไม่ใช้งาน userDepartment.Department_Authorized_Allow_Status = "0001"; //Check Duplicate string sqlUserDepartment = "Select * From USERS_DEPARTMENT_AUTHORIZED Where USER_ID='" + userDepartment.Department_Authorized_User_Id + "' And DEPARTMENT_CODE='" + userDepartment.Department_Authorized_Department_Code + "'"; List <UserAuthorizedData> chkuserDepartment = new UserAuthorized().getDepartmentAuthorizedManual(sqlUserDepartment); if (chkuserDepartment.Count > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่ภาควิชา ซ้ำ!');", true); } else { //Insert ระดับภาควิชา string insertUserDepartment = new UserAuthorized().insertDepartmentAuthorized(userDepartment); } } //User สำนักงาน else if (userInfo.USERS_INFO_FACULTY_ID == "00" && userInfo.USERS_INFO_DEPARTMENT_ID == "0000" && userInfo.OTHEROFFICE_CODE != "0000") { UserAuthorizedData userOtherOffice = new UserAuthorizedData(); userOtherOffice.Other_Authorized_User_Id = userInfo.USERS_INFO_USER_ID; userOtherOffice.Other_Authorized_Other_Code = userInfo.OTHEROFFICE_CODE; //0001 เปิดใช้งาน //0002 ไม่ใช้งาน userOtherOffice.Other_Authorized_Allow_Status = "0001"; //Check Duplicate string sqlUserOffice = "Select * From USERS_OTHER_AUTHORIZED Where USER_ID='" + userOtherOffice.Other_Authorized_User_Id + "' And OTHEROFFICE_CODE='" + userOtherOffice.Other_Authorized_Other_Code + "'"; List <UserAuthorizedData> chkuserOffice = new UserAuthorized().getOtherAuthorizedManual(sqlUserOffice); if (chkuserOffice.Count > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่สำนักงาน ซ้ำ!');", true); } else { //Insert ระดับสำนักงาน string insertUserOffice = new UserAuthorized().insertOtherAuthorized(userOtherOffice); } } Response.Redirect("list_User.aspx"); } } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('ตรวจสอบ Password อีกครั้ง!');", true); } }
protected void btnSave_Click(object sender, EventArgs e) { //if (autro_obj.CheckGroupUser(login_data, group_var.admin_university)) // { // //User คณะ // if (ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue == "0000" && ddlOffice.SelectedValue == "0000") // { // UserAuthorizedData userFaculty = new UserAuthorizedData(); // userFaculty.Faculty_Authorized_User_Id = userData.USERS_INFO_USER_ID; // userFaculty.Faculty_Authorized_Faculty_Code = ddlFaculty.SelectedValue; // //0001 เปิดใช้งาน // //0002 ไม่ใช้งาน // userFaculty.Faculty_Authorized_Allow_Status = "0001"; // //Check Duplicate // string sqlUserFaculty = "Select * From USERS_FACULTY_AUTHORIZED Where USER_ID='" + userFaculty.Faculty_Authorized_User_Id + "' And FACULTY_CODE='" + userFaculty.Faculty_Authorized_Faculty_Code + "'"; // List<UserAuthorizedData> chkuserFaculty = new UserAuthorized().getFacultyAuthorizedManual(sqlUserFaculty); // if (chkuserFaculty.Count > 0) // { // Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่คณะ ซ้ำ!');", true); // } // else // { // //Insert ระดับคณะ // string insertUserFaculty = new UserAuthorized().insertFacultyAuthorized(userFaculty); // } // } // //User ภาควิชา // else if (ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue != "0000" && ddlOffice.SelectedValue == "0000") // { // UserAuthorizedData userFaculty = new UserAuthorizedData(); // userFaculty.Faculty_Authorized_User_Id = userData.USERS_INFO_USER_ID; // userFaculty.Faculty_Authorized_Faculty_Code = ddlFaculty.SelectedValue; // //0001 เปิดใช้งาน // //0002 ไม่ใช้งาน // userFaculty.Faculty_Authorized_Allow_Status = "0001"; // //Check Duplicate // string sqlUserFaculty = "Select * From USERS_FACULTY_AUTHORIZED Where USER_ID='" + userFaculty.Faculty_Authorized_User_Id + "' And FACULTY_CODE='" + userFaculty.Faculty_Authorized_Faculty_Code + "'"; // List<UserAuthorizedData> chkuserFaculty = new UserAuthorized().getFacultyAuthorizedManual(sqlUserFaculty); // if (chkuserFaculty.Count > 0) // { // Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่คณะ ซ้ำ!');", true); // } // else // { // //Insert ระดับคณะ // string insertUserFaculty = new UserAuthorized().insertFacultyAuthorized(userFaculty); // } // UserAuthorizedData userDepartment = new UserAuthorizedData(); // userDepartment.Department_Authorized_User_Id = userData.USERS_INFO_USER_ID; // userDepartment.Department_Authorized_Department_Code = ddlDepartment.SelectedValue; // //0001 เปิดใช้งาน // //0002 ไม่ใช้งาน // userDepartment.Department_Authorized_Allow_Status = "0001"; // //Check Duplicate // string sqlUserDepartment = "Select * From USERS_DEPARTMENT_AUTHORIZED Where USER_ID='" + userDepartment.Department_Authorized_User_Id + "' And DEPARTMENT_CODE='" + userDepartment.Department_Authorized_Department_Code + "'"; // List<UserAuthorizedData> chkuserDepartment = new UserAuthorized().getDepartmentAuthorizedManual(sqlUserDepartment); // if (chkuserDepartment.Count > 0) // { // Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่ภาควิชา ซ้ำ!');", true); // } // else // { // //Insert ระดับภาควิชา // string insertUserDepartment = new UserAuthorized().insertDepartmentAuthorized(userDepartment); // } // } // // office // else if (ddlOffice.SelectedValue != "0000") // { // UserAuthorizedData userOtherOffice = new UserAuthorizedData(); // userOtherOffice.Other_Authorized_User_Id = userData.USERS_INFO_USER_ID; // userOtherOffice.Other_Authorized_Other_Code = ddlOffice.SelectedValue; // //0001 เปิดใช้งาน // //0002 ไม่ใช้งาน // userOtherOffice.Other_Authorized_Allow_Status = "0001"; // //Check Duplicate // string sqlUserOffice = "Select * From USERS_OTHER_AUTHORIZED Where USER_ID='" + userOtherOffice.Other_Authorized_User_Id + "' And OTHEROFFICE_CODE='" + userOtherOffice.Other_Authorized_Other_Code + "'"; // List<UserAuthorizedData> chkuserOffice = new UserAuthorized().getOtherAuthorizedManual(sqlUserOffice); // if (chkuserOffice.Count > 0) // { // Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่สำนักงาน ซ้ำ!');", true); // } // else // { // //Insert ระดับสำนักงาน // string insertUserOffice = new UserAuthorized().insertOtherAuthorized(userOtherOffice); // } // } // } if (autro_obj.CheckGroupUser(login_data, group_var.admin_faculty)) { //User คณะ if (ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue == "0000") { UserAuthorizedData userFaculty = new UserAuthorizedData(); userFaculty.Faculty_Authorized_User_Id = userData.USERS_INFO_USER_ID; userFaculty.Faculty_Authorized_Faculty_Code = ddlFaculty.SelectedValue; //0001 เปิดใช้งาน //0002 ไม่ใช้งาน userFaculty.Faculty_Authorized_Allow_Status = "0001"; //Check Duplicate string sqlUserFaculty = "Select * From USERS_FACULTY_AUTHORIZED Where USER_ID='" + userFaculty.Faculty_Authorized_User_Id + "' And FACULTY_CODE='" + userFaculty.Faculty_Authorized_Faculty_Code + "'"; List <UserAuthorizedData> chkuserFaculty = new UserAuthorized().getFacultyAuthorizedManual(sqlUserFaculty); if (chkuserFaculty.Count > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่คณะ ซ้ำ!');", true); } else { //Insert ระดับคณะ string insertUserFaculty = new UserAuthorized().insertFacultyAuthorized(userFaculty); } } //User ภาควิชา else if (ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue != "0000") { UserAuthorizedData userFaculty = new UserAuthorizedData(); userFaculty.Faculty_Authorized_User_Id = userData.USERS_INFO_USER_ID; userFaculty.Faculty_Authorized_Faculty_Code = ddlFaculty.SelectedValue; //0001 เปิดใช้งาน //0002 ไม่ใช้งาน userFaculty.Faculty_Authorized_Allow_Status = "0001"; //Check Duplicate string sqlUserFaculty = "Select * From USERS_FACULTY_AUTHORIZED Where USER_ID='" + userFaculty.Faculty_Authorized_User_Id + "' And FACULTY_CODE='" + userFaculty.Faculty_Authorized_Faculty_Code + "'"; List <UserAuthorizedData> chkuserFaculty = new UserAuthorized().getFacultyAuthorizedManual(sqlUserFaculty); if (chkuserFaculty.Count > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่คณะ ซ้ำ!');", true); } else { //Insert ระดับคณะ string insertUserFaculty = new UserAuthorized().insertFacultyAuthorized(userFaculty); } UserAuthorizedData userDepartment = new UserAuthorizedData(); userDepartment.Department_Authorized_User_Id = userData.USERS_INFO_USER_ID; userDepartment.Department_Authorized_Department_Code = ddlDepartment.SelectedValue; //0001 เปิดใช้งาน //0002 ไม่ใช้งาน userDepartment.Department_Authorized_Allow_Status = "0001"; //Check Duplicate string sqlUserDepartment = "Select * From USERS_DEPARTMENT_AUTHORIZED Where USER_ID='" + userDepartment.Department_Authorized_User_Id + "' And DEPARTMENT_CODE='" + userDepartment.Department_Authorized_Department_Code + "'"; List <UserAuthorizedData> chkuserDepartment = new UserAuthorized().getDepartmentAuthorizedManual(sqlUserDepartment); if (chkuserDepartment.Count > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่ภาควิชา ซ้ำ!');", true); } else { //Insert ระดับภาควิชา string insertUserDepartment = new UserAuthorized().insertDepartmentAuthorized(userDepartment); } } } //else if (autro_obj.CheckGroupUser(login_data, group_var.admin_department)) // { // //User ภาควิชา // if (ddlFaculty.SelectedValue != "00" && ddlDepartment.SelectedValue != "0000" ) // { // UserAuthorizedData userFaculty = new UserAuthorizedData(); // userFaculty.Faculty_Authorized_User_Id = userData.USERS_INFO_USER_ID; // userFaculty.Faculty_Authorized_Faculty_Code = ddlFaculty.SelectedValue; // //0001 เปิดใช้งาน // //0002 ไม่ใช้งาน // userFaculty.Faculty_Authorized_Allow_Status = "0001"; // //Check Duplicate // string sqlUserFaculty = "Select * From USERS_FACULTY_AUTHORIZED Where USER_ID='" + userFaculty.Faculty_Authorized_User_Id + "' And FACULTY_CODE='" + userFaculty.Faculty_Authorized_Faculty_Code + "'"; // List<UserAuthorizedData> chkuserFaculty = new UserAuthorized().getFacultyAuthorizedManual(sqlUserFaculty); // if (chkuserFaculty.Count > 0) // { // Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่คณะ ซ้ำ!');", true); // } // else // { // //Insert ระดับคณะ // string insertUserFaculty = new UserAuthorized().insertFacultyAuthorized(userFaculty); // } // UserAuthorizedData userDepartment = new UserAuthorizedData(); // userDepartment.Department_Authorized_User_Id = userData.USERS_INFO_USER_ID; // userDepartment.Department_Authorized_Department_Code = ddlDepartment.SelectedValue; // //0001 เปิดใช้งาน // //0002 ไม่ใช้งาน // userDepartment.Department_Authorized_Allow_Status = "0001"; // //Check Duplicate // string sqlUserDepartment = "Select * From USERS_DEPARTMENT_AUTHORIZED Where USER_ID='" + userDepartment.Department_Authorized_User_Id + "' And DEPARTMENT_CODE='" + userDepartment.Department_Authorized_Department_Code + "'"; // List<UserAuthorizedData> chkuserDepartment = new UserAuthorized().getDepartmentAuthorizedManual(sqlUserDepartment); // if (chkuserDepartment.Count > 0) // { // Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่ภาควิชา ซ้ำ!');", true); // } // else // { // //Insert ระดับภาควิชา // string insertUserDepartment = new UserAuthorized().insertDepartmentAuthorized(userDepartment); // } // } // } //else if (autro_obj.CheckGroupUser(login_data, group_var.admin_otherOffice)) // { // if (ddlOffice.SelectedValue != "0000") // { // UserAuthorizedData userOtherOffice = new UserAuthorizedData(); // userOtherOffice.Other_Authorized_User_Id = userData.USERS_INFO_USER_ID; // userOtherOffice.Other_Authorized_Other_Code = ddlOffice.SelectedValue; // //0001 เปิดใช้งาน // //0002 ไม่ใช้งาน // userOtherOffice.Other_Authorized_Allow_Status = "0001"; // //Check Duplicate // string sqlUserOffice = "Select * From USERS_OTHER_AUTHORIZED Where USER_ID='" + userOtherOffice.Other_Authorized_User_Id + "' And OTHEROFFICE_CODE='" + userOtherOffice.Other_Authorized_Other_Code + "'"; // List<UserAuthorizedData> chkuserOffice = new UserAuthorized().getOtherAuthorizedManual(sqlUserOffice); // if (chkuserOffice.Count > 0) // { // Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowBox", "alert('Username ที่สำนักงาน ซ้ำ!');", true); // } // else // { // //Insert ระดับสำนักงาน // string insertUserOffice = new UserAuthorized().insertOtherAuthorized(userOtherOffice); // } // } // } Response.Redirect("list_User.aspx"); }