Beispiel #1
0
        //**************************************************************************
        ///    <Description>
        ///       This method uses to get all role of user
        ///    </Description>
        ///    <Inputs>
        ///        user id
        ///    </Inputs>
        ///    <Outputs>
        ///        array list
        ///    </Outputs>
        ///    <Returns>
        ///       ArrayList
        ///    </Returns>
        ///    <Authors>
        ///       DungLA
        ///    </Authors>
        ///    <History>
        ///       06-Apr-2005
        ///    </History>
        ///    <Notes>
        ///    </Notes>
        //**************************************************************************

        public ArrayList GetRoles(string pstrUserName)
        {
            int intUserID = new Sys_UserDS().GetUserIDByUserName(pstrUserName);
            Sys_UserToRoleDS dsUserRole = new Sys_UserToRoleDS();

            return(dsUserRole.ListRoleByUser(intUserID));
        }
Beispiel #2
0
        /// <summary>
        /// Save a list of selected role into database
        /// Get a list of current role granted to this user from database in dataset
        /// and then use this dataset to input a new role
        /// call the DS method to update this dataset
        /// </summary>
        /// <param name="pintUserID"></param>
        /// <param name="pdtListOfRole"></param>
        /// <Author> Thien HD, Jan 11, 2005</Author>

        public void SaveRoleToUser(int pintUserID, DataTable pdtListOfRole)
        {
            try
            {
                //Get the list of current granted role of this user.
                Sys_UserToRoleDS objSys_UserToRoleDS = new Sys_UserToRoleDS();
                DataSet          dstCurrentRole      = objSys_UserToRoleDS.ListRoleToUser(pintUserID);
                dstCurrentRole.Tables[0].Columns[Sys_UserToRoleTable.ID_FLD].AutoIncrement = true;

                //Get the highest value for this column
                dstCurrentRole.Tables[0].Columns[Sys_UserToRoleTable.ID_FLD].AutoIncrementSeed = objSys_UserToRoleDS.GetMaxID() + 1;
                dstCurrentRole.Tables[0].Columns[Sys_UserToRoleTable.ID_FLD].AutoIncrementStep = 1;


                for (int i = 0; i < dstCurrentRole.Tables[0].Rows.Count; i++)
                {
                    dstCurrentRole.Tables[0].Rows[i].Delete();
                }
                pdtListOfRole.AcceptChanges();
                foreach (DataRow dr in pdtListOfRole.Rows)
                {
                    DataRow drNewRow = dstCurrentRole.Tables[0].NewRow();
                    drNewRow[Sys_UserToRoleTable.ROLEID_FLD] = dr[Sys_RoleTable.ROLEID_FLD];
                    drNewRow[Sys_UserToRoleTable.USERID_FLD] = pintUserID;
                    dstCurrentRole.Tables[0].Rows.Add(drNewRow);
                }

                //Update this data set into database
                objSys_UserToRoleDS.UpdateDataSet(dstCurrentRole);
            }
            catch (PCSDBException ex)
            {
                throw ex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }