Example #1
0
        public static bool CanUserAccessThisApplication(User_cu user, DB_Application application)
        {
            if (user == null)
            {
                return(false);
            }

            User_Application_cu userApplcaition =
                User_Application_cu.ItemsList.Find(
                    item =>
                    Convert.ToInt32(item.User_CU_ID).Equals(Convert.ToInt32(user.ID)) &&
                    item.Application_P_ID.Equals((int)application));

            if (userApplcaition != null)
            {
                return(true);
            }

            List <User_UserGroup_cu> userAttachedGroups =
                User_UserGroup_cu.ItemsList.FindAll(item => Convert.ToInt32(item.User_CU_ID).Equals(Convert.ToInt32(user.ID)));

            if (userAttachedGroups.Count == 0)
            {
                return(false);
            }

            foreach (User_UserGroup_cu userAttachedGroup in userAttachedGroups)
            {
                UserGroup_cu userGroup =
                    UserGroup_cu.ItemsList.Find(
                        item => Convert.ToInt32(item.ID).Equals(Convert.ToInt32(userAttachedGroup.UserGroup_CU_ID)));
                if (userGroup == null)
                {
                    continue;
                }

                UserGroup_Application_cu userGroupApplication =
                    UserGroup_Application_cu.ItemsList.Find(
                        item =>
                        Convert.ToInt32(item.UserGroup_CU_ID).Equals(Convert.ToInt32(userGroup.ID)) &&
                        Convert.ToInt32(item.Application_P_ID).Equals((int)application));
                if (userGroupApplication != null)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #2
0
        public static bool IsLoginCredentialsCorrect(string loginName, string password)
        {
            if (string.IsNullOrEmpty(loginName) || string.IsNullOrWhiteSpace(loginName) || string.IsNullOrEmpty(password) ||
                string.IsNullOrWhiteSpace(password))
            {
                return(false);
            }

            User_cu user = GetUser(loginName);

            if (user == null)
            {
                return(false);
            }

            return(Convert.ToString(user.Password).Equals(password));
        }
        public static bool RemoveUser(List <User_UserGroup_cu> list, User_cu user)
        {
            if (list.Count == 0 || user == null)
            {
                return(false);
            }

            User_UserGroup_cu userBridge =
                list.Find(item => Convert.ToInt32(item.User_CU_ID).Equals(Convert.ToInt32(user.Person_CU_ID)));

            if (userBridge == null)
            {
                return(false);
            }

            list.Remove(userBridge);

            return(true);
        }
        public static List <User_cu> GetUsers(List <User_UserGroup_cu> list)
        {
            if (list.Count == 0)
            {
                return(null);
            }

            List <User_cu> usersList = new List <User_cu>();

            foreach (User_UserGroup_cu userBridge in list)
            {
                User_cu user =
                    User_cu.ItemsList.Find(item => Convert.ToInt32(item.Person_CU_ID).Equals(Convert.ToInt32(userBridge.User_CU_ID)));
                if (user != null)
                {
                    usersList.Add(user);
                }
            }

            return(usersList);
        }
Example #5
0
        public static bool UserCanAccess(string loginName, string password)
        {
            if (IsPrivateLoginCredentialsUser(loginName, password))
            {
                UserName = "******";
                return(true);
            }

            if (!IsLoginCredentialsCorrect(loginName, password))
            {
                return(false);
            }

            User_cu user = GetUser(loginName);

            if (user == null)
            {
                return(false);
            }

            ActiveLoginUser = user;
            UserName        = user.FullName.ToString();

            PEMRSavingMode_User_cu pemrSavingMode = PEMRSavingMode_User_cu.ItemsList.Find(item =>
                                                                                          Convert.ToInt32(item.User_CU_ID).Equals(Convert.ToInt32(user.Person_CU_ID)));

            if (pemrSavingMode == null)
            {
                PEMRSavingMode = DB_PEMRSavingMode.SaveImmediately;
            }
            else
            {
                PEMRSavingMode = (DB_PEMRSavingMode)pemrSavingMode.PEMRSavingMode_P_ID;
            }

            return(CanAccessApplication);
        }
 private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     SelectedUserFromGrid = GetSelectedRow <User_cu>((GridView)sender);
 }
 private void gridView1_MouseUp(object sender, MouseEventArgs e)
 {
     SelectedUserFromGrid = GetSelectedRow <User_cu>((GridView)sender);
 }
 private void gridView1_GotFocus(object sender, EventArgs e)
 {
     SelectedUserFromGrid = GetSelectedRow <User_cu>((GridView)sender);
 }
 private void gridView1_MouseUp(object sender, MouseEventArgs e)
 {
     SelectedUserFromGrid = CommonViewsActions.GetSelectedRowObject <User_cu>((GridView)sender);
 }