/// <summary> /// 刪除1筆角色對應資料 /// </summary> /// <param name="myRoleUserMappingVO">角色對應型別物件</param> /// <returns>刪除1筆角色對應資料</returns> public int DeleteRoleUserMapping(VO.RoleUserMappingVO myRoleUserMappingVO) { SqlParameter[] sqlParams = new SqlParameter[1]; sqlParams[0] = new SqlParameter("@id", SqlDbType.Int); sqlParams[0].Value = myRoleUserMappingVO.id; StringBuilder sb = new StringBuilder(); sb.AppendLine("DELETE RoleUserMapping WHERE id=@id;"); return(SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams)); }
//Insert GridView的Insert /// <summary> /// 新增1筆角色對應資料 /// </summary> /// <param name="myRoleUserMappingVO">角色對應型別物件</param> /// <returns>新增1筆角色對應資料</returns> public int InsertRoleUserMapping(VO.RoleUserMappingVO myRoleUserMappingVO) { SqlParameter[] sqlParams = new SqlParameter[3]; sqlParams[0] = new SqlParameter("@role_id", SqlDbType.Int); sqlParams[0].Value = myRoleUserMappingVO.role_id; sqlParams[1] = new SqlParameter("@unit_id", SqlDbType.Int); sqlParams[1].Value = myRoleUserMappingVO.unit_id; sqlParams[2] = new SqlParameter("@emp_id", SqlDbType.NVarChar, 100); sqlParams[2].Value = myRoleUserMappingVO.emp_id; StringBuilder sb = new StringBuilder(); sb.AppendLine("INSERT INTO RoleUserMapping SELECT @role_id,@unit_id,ID FROM V_ACSM_USER2 WHERE ID=@emp_id and status!=2 ; "); int Result = -1; try { Result = SqlHelper.ExecuteNonQuery(MyConn(), CommandType.Text, sb.ToString(), sqlParams); if (Result == 0) { clsMyObj.ShowMessage("無法新增此人員!該人員不存在或已離職。"); } } catch (Exception ex) { try { if ((ex as System.Data.SqlClient.SqlException).Number == 2627) { clsMyObj.ShowMessage("該角色人員已存在!"); } else { throw ex; } } catch { throw ex; } } return(Result); }
public int DeleteRoleUserMapping(VO.RoleUserMappingVO myRoleUserMappingVO) { DAO.RoleUserMappingDAO myRoleUserMappingDAO = new ACMS.DAO.RoleUserMappingDAO(); return(myRoleUserMappingDAO.DeleteRoleUserMapping(myRoleUserMappingVO)); }
public int InsertRoleUserMapping(VO.RoleUserMappingVO myRoleUserMappingVO) { DAO.RoleUserMappingDAO myRoleUserMappingDAO = new ACMS.DAO.RoleUserMappingDAO(); return(myRoleUserMappingDAO.InsertRoleUserMapping(myRoleUserMappingVO)); }