/// <summary> /// Table FACULTY_AUTHORIZED_SYSTEM /// </summary> /// <param name="dataInsert"></param> /// <returns></returns> public string insertFacultyAuthorizedSystem(UserAuthorizedSystemData dataInsert) { string response = ""; UserLoginData loginData = new UserLoginData(); loginData = (UserLoginData)HttpContext.Current.Session["login_data"]; LogData log_data = new LogData(); log_data.ModuleCode = new LogData().Module_Setting; log_data.Username = loginData.User_ID; log_data.Message = "Insert FacultyAuthorizedSystem with: " + dataInsert.Faculty_Users_Group_Id + ", " + dataInsert.Faculty_User_Id + ", " + dataInsert.Faculty_Authorized_Code; ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); string sql = ""; sql = "Insert Into FACULTY_AUTHORIZED_SYSTEM (USERS_GROUP_ID, USER_ID, FACULTY_AUTHORIZED_CODE) Values ('" + dataInsert.Faculty_Users_Group_Id + "','" + dataInsert.Faculty_User_Id + "','" + dataInsert.Faculty_Authorized_Code + "')"; oracleObj.InsertCommand = sql; try { if (oracleObj.Insert() == 1) { response = "OK"; log_data.StatusCode = log_data.LogStatus_SUCCESS; } else { log_data.StatusCode = log_data.LogStatus_FAILED; } } catch (Exception e) { response = e.Message.ToString() + " "; log_data.StatusCode = log_data.LogStatus_ERROR; log_data.Message += " [" + e.ToString() + "]"; } new Log().WriteLog(log_data); return(response); }
/// <summary> /// Table OTHER_AUTHORIZED_SYSTEM /// </summary> /// <param name="User_Id"></param> /// <returns></returns> public UserAuthorizedSystemData getOtherAuthorizedSystem(string User_Id) { UserAuthorizedSystemData data = new UserAuthorizedSystemData(); ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); oracleObj.SelectCommand = "Select * From OTHER_AUTHORIZED_SYSTEM Where USER_ID='" + User_Id + "'"; DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty); foreach (DataRowView rowData in allData) { data.Other_Users_Group_Id = rowData["USERS_GROUP_ID"].ToString(); data.Other_User_Id = rowData["USER_ID"].ToString(); data.Other_Authorized_Code = rowData["OTHER_AUTHORIZED_CODE"].ToString(); } return(data); }
/// <summary> /// Table OTHER_AUTHORIZED_SYSTEM /// </summary> /// <returns></returns> public List <UserAuthorizedSystemData> getOtherAuthorizedSystem() { List <UserAuthorizedSystemData> data = new List <UserAuthorizedSystemData>(); ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); oracleObj.SelectCommand = "Select * From OTHER_AUTHORIZED_SYSTEM Order By USER_ID"; DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty); foreach (DataRowView rowData in allData) { UserAuthorizedSystemData users = new UserAuthorizedSystemData(); users.Other_Users_Group_Id = rowData["USERS_GROUP_ID"].ToString(); users.Other_User_Id = rowData["USER_ID"].ToString(); users.Other_Authorized_Code = rowData["OTHER_AUTHORIZED_CODE"].ToString(); data.Add(users); } return(data); }
/// <summary> /// Table DEPARTMENT_AUTHORIZED_SYSTEM /// </summary> /// <param name="sql"></param> /// <returns></returns> public List <UserAuthorizedSystemData> getDepartmentAuthorizedSystemManual(string sql) { List <UserAuthorizedSystemData> data = new List <UserAuthorizedSystemData>(); ConnectDB db = new ConnectDB(); SqlDataSource oracleObj = db.ConnectionOracle(); oracleObj.SelectCommand = sql; DataView allData = (DataView)oracleObj.Select(DataSourceSelectArguments.Empty); foreach (DataRowView rowData in allData) { UserAuthorizedSystemData users = new UserAuthorizedSystemData(); users.Department_Users_Group_Id = rowData["USERS_GROUP_ID"].ToString(); users.Department_User_Id = rowData["USER_ID"].ToString(); users.Department_Aathorized_Code = rowData["DEPARTMENT_AUTHORIZED_CODE"].ToString(); data.Add(users); } return(data); }
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); }