/// <summary>
        /// Add the selected roles
        /// </summary>
        private void AddSelectedRoles()
        {
            SEC_USER_ROLES secuserroles;

            try
            {
                if (_selectedItemsRoleMaster != null)
                {
                    while (_selectedItemsRoleMaster.Count > 0)
                    {
                        SEC_ROLES_MASTER srm = (SEC_ROLES_MASTER)_selectedItemsRoleMaster[0];
                        secuserroles           = new SEC_USER_ROLES();
                        secuserroles.ROLE_NAME = srm.ROLE_NAME;
                        secuserroles.USER_NAME = _userName;
                        Sec_Roles_Master_List.Remove(srm);
                        Sec_User_Roles_List.Add(secuserroles);
                    }
                    NotifyPropertyChanged("Sec_User_Roles_List");
                    NotifyPropertyChanged("Sec_Roles_Master_List");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Process Designer");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="userInformation"></param>
        public RolesInfoViewModel(UserInformation userInformation, DataRowView selectedItem, string mode)
        {
            try
            {
                _userInformation = userInformation;
                _secRolesMaster  = new SEC_ROLES_MASTER();

                if (mode == "U")
                {
                    selecteditem              = selectedItem;
                    _secRolesMaster.ROWID     = Guid.Parse(selectedItem["ROWID"].ToString());
                    _secRolesMaster.ROLE_NAME = selectedItem["ROLE_NAME"].ToValueAsString();
                    Role_Name = _secRolesMaster.ROLE_NAME;
                    _mode     = OperationMode.Edit;
                }
                else
                {
                    _mode = OperationMode.AddNew;
                }
                _usrroledet = new UserRoleDet(_userInformation);
            }
            catch (Exception ex)
            {
                throw ex.LogException();
            }
        }
        /// <summary>
        /// Remove the selected roles
        /// </summary>
        private void RemoveSelectedRoles()
        {
            SEC_ROLES_MASTER secrolesmaster;

            try
            {
                if (_selectedItemsUserRole != null)
                {
                    while (_selectedItemsUserRole.Count > 0)
                    {
                        SEC_USER_ROLES srm = (SEC_USER_ROLES)_selectedItemsUserRole[0];
                        secrolesmaster           = new SEC_ROLES_MASTER();
                        secrolesmaster.ROLE_NAME = srm.ROLE_NAME;
                        Sec_Roles_Master_List.Add(secrolesmaster);
                        Sec_User_Roles_List.Remove(srm);
                    }
                    NotifyPropertyChanged("Sec_User_Roles_List");
                    NotifyPropertyChanged("Sec_Roles_Master_List");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Process Designer");
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Check  duplicate role name
        /// </summary>
        /// <param name="rolename"></param>
        /// <returns></returns>
        public bool CheckDuplicate(SEC_ROLES_MASTER secroleparam, OperationMode opermode)
        {
            SEC_ROLES_MASTER secrolemaster = null;

            try
            {
                if (opermode == OperationMode.Edit)
                {
                    secrolemaster = (from secrole in DB.SEC_ROLES_MASTER
                                     where secrole.ROLE_NAME.ToUpper() == secroleparam.ROLE_NAME.ToUpper().Trim() &&
                                     Convert.ToBoolean(Convert.ToInt16(secrole.DELETE_FLAG)) == false &&
                                     secrole.ROWID != secroleparam.ROWID
                                     select secrole).SingleOrDefault <SEC_ROLES_MASTER>();
                }
                else
                {
                    secrolemaster = (from secrole in DB.SEC_ROLES_MASTER
                                     where secrole.ROLE_NAME.ToUpper() == secroleparam.ROLE_NAME.ToUpper().Trim() &&
                                     Convert.ToBoolean(Convert.ToInt16(secrole.DELETE_FLAG)) == false
                                     select secrole).SingleOrDefault <SEC_ROLES_MASTER>();
                }
                if (secrolemaster == null)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            catch (Exception ex)
            {
                throw ex.LogException();
            }
        }
        /// <summary>
        /// Remove the selected roles
        /// </summary>
        private void RemoveSelectedRoles()
        {
            SEC_ROLES_MASTER secrolesmaster;

            try
            {
                if (_selectedItemsUserRole != null)
                {
                    while (_selectedItemsUserRole.Count > 0)
                    {
                        SEC_USER_ROLES srm = (SEC_USER_ROLES)_selectedItemsUserRole[0];
                        secrolesmaster           = new SEC_ROLES_MASTER();
                        secrolesmaster.ROLE_NAME = srm.ROLE_NAME;
                        Sec_Roles_Master_List.Add(secrolesmaster);
                        Sec_User_Roles_List.Remove(srm);
                    }
                    NotifyPropertyChanged("Sec_User_Roles_List");
                    NotifyPropertyChanged("Sec_Roles_Master_List");
                }
                SelectListItem();
                EnableOrDisableSelect();
            }
            catch (Exception ex)
            {
                throw ex.LogException();
            }
        }
        /// <summary>
        /// Add all the roles
        /// </summary>
        private void RemoveAllRoles()
        {
            SEC_ROLES_MASTER secrolesmaster;

            try
            {
                foreach (SEC_USER_ROLES srm in Sec_User_Roles_List)
                {
                    secrolesmaster           = new SEC_ROLES_MASTER();
                    secrolesmaster.ROLE_NAME = srm.ROLE_NAME;
                    Sec_Roles_Master_List.Add(secrolesmaster);
                }
                Sec_User_Roles_List.Clear();
                NotifyPropertyChanged("Sec_User_Roles_List");
                NotifyPropertyChanged("Sec_Roles_Master_List");
            }
            catch (Exception ex)
            {
                throw throw ex;
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="userInformation"></param>
 public RolesInfoViewModel(UserInformation userInformation)
 {
     _userInformation = userInformation;
     _secRolesMaster  = new SEC_ROLES_MASTER();
     _usrroledet      = new UserRoleDet(_userInformation);
 }
Esempio n. 8
0
        /// <summary>
        /// This function is used to save the roles
        /// </summary>
        /// <param name="secrolesmaster"></param>
        /// <returns></returns>
        public bool SaveRoles(SEC_ROLES_MASTER secrolesmaster, OperationMode mode)
        {
            string           oldRoleName                    = "";
            SEC_ROLES_MASTER editsecrolesmaster             = new SEC_ROLES_MASTER();
            bool             submit                         = false;
            bool             insert                         = false;
            bool             update                         = false;
            bool             insertpermission               = false;
            List <SEC_ROLE_OBJECT_PERMISSION> lstPermission = new List <SEC_ROLE_OBJECT_PERMISSION>();

            try
            {
                if (mode == OperationMode.AddNew)
                {
                    secrolesmaster.ROWID        = Guid.NewGuid();
                    secrolesmaster.ENTERED_BY   = this.userInformation.UserName;
                    secrolesmaster.ENTERED_DATE = DateTime.Now;
                    secrolesmaster.DELETE_FLAG  = false;
                    insert = true;
                    DB.SEC_ROLES_MASTER.InsertOnSubmit(secrolesmaster);
                    if (InsertDefaultPermissionForRole(secrolesmaster.ROLE_NAME, ref lstPermission))
                    {
                        submit           = true;
                        insertpermission = true;
                        DB.SEC_ROLE_OBJECT_PERMISSION.InsertAllOnSubmit(lstPermission);
                        DB.SubmitChanges();
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    editsecrolesmaster = (from c in DB.SEC_ROLES_MASTER
                                          where c.ROWID == secrolesmaster.ROWID
                                          select c).Single <SEC_ROLES_MASTER>();
                    oldRoleName = editsecrolesmaster.ROLE_NAME;
                    editsecrolesmaster.ROLE_NAME    = secrolesmaster.ROLE_NAME;
                    editsecrolesmaster.UPDATED_DATE = serverDateTime;
                    editsecrolesmaster.UPDATED_BY   = userInformation.UserName;
                    submit = true;
                    DB.SubmitChanges();
                    if (oldRoleName.Trim() != editsecrolesmaster.ROLE_NAME.Trim())
                    {
                        SaveRoleForPermission(oldRoleName, editsecrolesmaster.ROLE_NAME);
                        UpdateRolesForUser(oldRoleName, editsecrolesmaster.ROLE_NAME);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                ex.LogException();
                if (submit == true)
                {
                    if (insert == true)
                    {
                        DB.SEC_ROLES_MASTER.DeleteOnSubmit(secrolesmaster);
                    }
                    else if (update == true)
                    {
                        DB.SEC_ROLES_MASTER.Context.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, editsecrolesmaster);
                    }
                    if (insertpermission == true)
                    {
                        DB.SEC_ROLE_OBJECT_PERMISSION.DeleteAllOnSubmit(lstPermission);
                    }
                }
            }
            return(false);
        }