Exemple #1
0
        public static List <Role> Find(string roleName)
        {
            List <Role> ret      = new List <Role>();
            string      querySql = "SELECT ID, Name, Description, RightsID, Status,CreateID,CreateDate FROM HPMS_Role where Name=@name and  Status >=0";

            IDbDataParameter[] b = new IDbDataParameter[1];
            b[0] = Gloabal.GDatabase.CreatePara("name", roleName);
            DataTable table = Gloabal.GDatabase.GetDataTable(querySql, b);

            foreach (DataRow tempRow in table.Rows)
            {
                Role role = new Role
                {
                    RoleId       = int.Parse(tempRow["ID"].ToString()),
                    Name         = (string)tempRow["Name"],
                    Description  = (string)tempRow["Description"],
                    RightsId     = (string)tempRow["RightsID"],
                    Right        = RightDao.GetRightsById((string)tempRow["RightsID"]),
                    CreateDate   = ((DateTime)tempRow["CreateDate"]).ToString(),
                    CreateId     = (int)tempRow["CreateID"],
                    RecordStatus = (RecordStatus)(int)tempRow["Status"]
                };
                ret.Add(role);
            }

            return(ret);
        }
Exemple #2
0
        public static List <Role> FindAll()
        {
            List <Role> ret      = new List <Role>();
            string      querySql = "SELECT ID, Name, Description, RightsID, Status,CreateID,CreateDate FROM HPMS_Role where  Status =1 and isSuper is Null";

            DataTable table = Gloabal.GDatabase.GetDataTable(querySql);

            foreach (DataRow tempRow in table.Rows)
            {
                Role role = new Role
                {
                    RoleId       = int.Parse(tempRow["ID"].ToString()),
                    Name         = (string)tempRow["Name"],
                    Description  = (string)tempRow["Description"],
                    RightsId     = (string)tempRow["RightsID"],
                    Right        = RightDao.GetRightsById((string)tempRow["RightsID"]),
                    CreateDate   = ((DateTime)tempRow["CreateDate"]).ToString(),
                    CreateId     = (int)tempRow["CreateID"],
                    RecordStatus = (RecordStatus)(int)tempRow["Status"]
                };
                ret.Add(role);
            }

            return(ret);
        }
Exemple #3
0
        public static List <User> Find(string userName)
        {
            List <User> ret      = new List <User>();
            string      querySql = "SELECT ID, UserName, Password, Salt, RoleID, " +
                                   "isSuper, CreateID, CreateDate,RoleRights, UserStatus,RoleName,RoleStatus FROM v_HPMS_User" +
                                   " where UserName = @username";

            IDbDataParameter[] b = new IDbDataParameter[1];
            b[0] = Gloabal.GDatabase.CreatePara("username", userName);
            DataTable table = Gloabal.GDatabase.GetDataTable(querySql, b);


            foreach (DataRow tempRow in table.Rows)
            {
                var user = new User();

                user.UserId     = int.Parse(tempRow["ID"].ToString());
                user.Username   = (string)tempRow["UserName"];
                user.Psw        = (string)tempRow["Password"];
                user.Role       = (string)tempRow["RoleName"];
                user.RoleId     = int.Parse(tempRow["RoleID"].ToString());
                user.CreateDate = ((DateTime)tempRow["CreateDate"]).ToString();
                user.Rights     = RightDao.GetRightsById((string)tempRow["RoleRights"]);
                user.CreaterId  = (int)tempRow["CreateID"];
                user.UserStatus = (RecordStatus)(int)tempRow["UserStatus"];
                user.IsSuper    = tempRow["isSuper"] != null;
                user.RoleStatus = (RecordStatus)(int)tempRow["RoleStatus"];

                ret.Add(user);
            }

            return(ret);
        }