예제 #1
0
파일: RoleDAL.cs 프로젝트: weiliji/NFMT
        public override IModel CreateModel(SqlDataReader dr)
        {
            Role role = new Role();

            int indexRoleId = dr.GetOrdinal("RoleId");
            role.RoleId = Convert.ToInt32(dr[indexRoleId]);

            int indexRoleName = dr.GetOrdinal("RoleName");
            role.RoleName = Convert.ToString(dr[indexRoleName]);

            int indexRoleStatus = dr.GetOrdinal("RoleStatus");
            if (dr["RoleStatus"] != DBNull.Value)
            {
                role.RoleStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexRoleStatus]);
            }

            int indexCreatorId = dr.GetOrdinal("CreatorId");
            role.CreatorId = Convert.ToInt32(dr[indexCreatorId]);

            int indexCreateTime = dr.GetOrdinal("CreateTime");
            role.CreateTime = Convert.ToDateTime(dr[indexCreateTime]);

            int indexLastModifyId = dr.GetOrdinal("LastModifyId");
            if (dr["LastModifyId"] != DBNull.Value)
            {
                role.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]);
            }

            int indexLastModifyTime = dr.GetOrdinal("LastModifyTime");
            if (dr["LastModifyTime"] != DBNull.Value)
            {
                role.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]);
            }

            return role;
        }
예제 #2
0
파일: RoleDAL.cs 프로젝트: weiliji/NFMT
        public ResultModel Load(UserModel user, int empId)
        {
            ResultModel result = new ResultModel();
            try
            {
                string cmdText = "select r.* from dbo.Role r inner join dbo.EmpRole er on er.RoleId = r.RoleId where er.EmpId=@empId";
                SqlParameter[] paras = new SqlParameter[1];
                paras[0] = new SqlParameter("@empId", empId);

                DataTable dt = SqlHelper.ExecuteDataTable(SqlHelper.ConnectionStringUser, cmdText, paras, CommandType.Text);

                List<Role> roles = new List<Role>();

                foreach (DataRow dr in dt.Rows)
                {
                    Role role = new Role();
                    role.RoleId = Convert.ToInt32(dr["RoleId"]);

                    role.RoleName = Convert.ToString(dr["RoleName"]);

                    if (dr["RoleStatus"] != DBNull.Value)
                    {
                        role.RoleStatus = (Common.StatusEnum)Convert.ToInt32(dr["RoleStatus"]);
                    }
                    role.CreatorId = Convert.ToInt32(dr["CreatorId"]);

                    role.CreateTime = Convert.ToDateTime(dr["CreateTime"]);

                    if (dr["LastModifyId"] != DBNull.Value)
                    {
                        role.LastModifyId = Convert.ToInt32(dr["LastModifyId"]);
                    }
                    if (dr["LastModifyTime"] != DBNull.Value)
                    {
                        role.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]);
                    }
                    roles.Add(role);
                }
                result.AffectCount = dt.Rows.Count;
                result.Message = "获取列表成功";
                result.ResultStatus = 0;
                result.ReturnValue = roles;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }

            return result;
        }