예제 #1
0
        public bool AssignScreenToRole(RoleBO obj)
        {
            bool isAdd = false;

            try
            {
                foreach (ScreenBO screen in obj.ScreenList)
                {
                    foreach (ScreenFunctionsBO screenFun in screen.ScreenFunctions)
                    {
                        AssignRoleScreenFuntion(obj.RoleId, screenFun.ScreenFunctionCode, screenFun.IsGranted, obj.User.UserName, obj.User.UserName);

                    }

                }

                isAdd = true;

                return isAdd;
            }

            catch
            {
                return isAdd;
                throw;

            }
        }
예제 #2
0
        private void SaveUser()
        {
            UserBO user = new UserBO();
            //if (!ValidateData(user)) return;

            try
            {
                //if (user.UserId == -1)
                //{
                    if (!Common.IsValidPassword(textBoxPassword.Text.ToString().Trim()))
                    {
                        MessageBoxClass.ShowMessage(ErrorMessagesClass.InvaliedPasswordLength, true);
                        return;
                    }
                    if (textBoxPassword.Text.Contains(' '))
                    {
                        MessageBoxClass.ShowMessage(ErrorMessagesClass.InvaliedPasswordCharacter, true);
                        return;
                    }
                //}

                user.UserId = userID;
                user.UserName = textBoxUserName.Text.ToString();
                user.UserPassword = textBoxPassword.Text.ToString();
                user.FirstName = textBoxFirstName.Text.ToString().ToUpper();
                user.LastName = textBoxLastName.Text.ToString().ToUpper();
                user.Initials = "A.B.C";
                user.Address = textBoxAddress.Text.ToString().ToUpper();
                user.Nic = "NIC";
                user.PassportNo = "Passport";
                user.EmpNo = "EmpNo";
                user.TelHome = "Telephone";
                user.TelMobile = "Mobile";
                user.Email = textBoxEmail.Text.ToString().ToUpper();
                user.UserDesignation = new DesignationBO();
                user.UserDesignation.DesignationId = 1;

                user.UserLevelPrimary = new UserLevelsBO();
                var level = new UserLevelsBO();
                level.UserLevelId = 1;//int.Parse(comboBoxUserLevel.SelectedValue.ToString());
                user.UserLevelPrimary = level;

                user.UserLevelDeatailList = new List<UserLevelsDetailsBO>();
                user.UserLevelDeatailList = LoadUserLevelDetailsList(-1);

                user.UserBranchDetailList = new List<UserBranchesDetailsBO>();
                user.UserBranchDetailList = LoadUserBranchesDetailsList(-1);

                user.UserGroup = new UserGroupBO();
                user.UserGroup.GroupId = 1;

                user.UserRoles = new List<RoleBO>();

                var role=new RoleBO();
                role.RoleId = int.Parse(comboBoxUserLevel.SelectedValue.ToString());
                role.IsActive = true;

                user.UserRoles.Add(role);

                /*User Type, Group Id , lock*/

                user.UserType = 0;
                user.IsLock = 0;

                user.IsClientManager = false;
                user.IsAccountManager = false;
                user.IsEnable = checkBoxStatus.Checked;
                user.CreatedUser = Common.User.UserId;
                user.PasswordExpirePeriod = 0;//Convert.ToInt32(txtPasswordExpirePeriod.Text);
                user.IsUserChangePasswordFirstLogin = false;//ChkUserPasswordChange.Checked;
                user.IsPasswordExpire = false;//ChkPasswordExpire.Checked;
                user.IsAllowConcurrentConnection = false;//ChkConcurrentConnection.Checked;

                user.CreatedUser = Common.User.UserId;
                user.CreatedDate = DateTime.Now;

                user.UserId = new UserDAL().AddUser(user);

                if (user.UserId > 0)
                {
                    MessageBoxClass.ShowMessage(ErrorMessagesClass.UserSaveSucess, false);
                    GetUserInfo(user);
                    //HidePassWordPannel();
                }
                else if (user.UserId == -1)
                {
                    MessageBoxClass.ShowMessage(ErrorMessagesClass.UserNameAlreadyExists , true);
                }
                else
                {
                    MessageBoxClass.ShowMessage(ErrorMessagesClass.UserSaveFail, true);
                }
            }
            catch
            {
                //lblErrorMsg.Text = Common.GerErrorMessage("UM-16");
            }
        }
예제 #3
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool isAdd = false;
                var roleBo = new RoleBO();
                roleBo.RoleName = textBoxRoleName.Text.ToString();

                if (checkBoxActive.Checked)
                {
                    roleBo.IsActive = true;
                }
                else
                {
                    roleBo.IsActive = false;
                }
                roleBo.User = new UserBO();
                roleBo.User.UserName = Common.User.UserName;

                if (RoleID == -1)
                {
                    isAdd = new RoleDAL().SaveRole(roleBo);
                    if (isAdd)
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("U_009"), false);
                        Clear();

                    }
                    else
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("U_008"), false);
                    }
                }
                else
                {
                    roleBo.RoleId = RoleID;
                    roleBo.IsActive = checkBoxActive.Checked;

                    isAdd = new RoleDAL().UpdateRole(roleBo);
                    if (isAdd)
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("U_010"), false);
                        Clear();

                    }
                    else
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("U_011"), false);
                    }
                }

            }
            catch
            {
                MessageBoxClass.ShowMessage(CommonMethods.GetError("U_008"), true);
            }
        }
예제 #4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            try
            {
                bool isAdd = false;
                if (treeViewScreens.Nodes.Count > 0)
                {
                    RoleBO roleBO = new RoleBO();
                    roleBO.RoleId = RoleID;
                    roleBO.User = new UserBO();

                    roleBO.User.UserName = Common.User.UserName;

                    TraverseTreeView(treeViewScreens);

                    roleBO.ScreenList = screenList;

                    isAdd = new RoleDAL().AssignScreenToRole(roleBO);
                    if (isAdd)
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("U_009"), false);

                    }
                    else
                    {
                        MessageBoxClass.ShowMessage(CommonMethods.GetError("U_008"), false);
                    }
                }
            }
            catch
            {
                MessageBoxClass.ShowMessage(CommonMethods.GetError("U_008"), true);
            }
        }
예제 #5
0
        private RoleBO FillRoleForMaintain(SqlDataReader drRoleList)
        {
            RoleBO objRole = new RoleBO();
            try
            {
                objRole.RoleId = drRoleList.GetInt32(drRoleList.GetOrdinal("RoleId"));
                objRole.RoleName = drRoleList.GetValue(drRoleList.GetOrdinal("RoleName")).ToString();
                objRole.IsActive = drRoleList.GetBoolean(drRoleList.GetOrdinal("IsActive"));
                objRole.CreatedUser = drRoleList.GetInt32(drRoleList.GetOrdinal("CreatedUser"));
                objRole.CreatedDate = drRoleList.GetDateTime(drRoleList.GetOrdinal("CreatedDate"));
                objRole.ModifiedUser = drRoleList.GetInt32(drRoleList.GetOrdinal("ModifiedUser"));
                objRole.ModifiedDate = drRoleList.GetDateTime(drRoleList.GetOrdinal("ModifiedDate"));

            }
            catch
            {
                throw;
            }

            return objRole;
        }
예제 #6
0
        private RoleBO FillRole(SqlDataReader drRoleList,bool isLight)
        {
            RoleBO objRole = new RoleBO();
               try
               {
               objRole.RoleId = drRoleList.GetInt32(drRoleList.GetOrdinal("RoleId"));
               objRole.RoleName = drRoleList.GetValue(drRoleList.GetOrdinal("RoleName")).ToString();
               objRole.IsActive = drRoleList.GetBoolean(drRoleList.GetOrdinal("IsActive"));
               objRole.CreatedUser = drRoleList.GetInt32(drRoleList.GetOrdinal("CreatedUser"));
               objRole.CreatedDate = drRoleList.GetDateTime(drRoleList.GetOrdinal("CreatedDate"));
               objRole.ModifiedUser = drRoleList.GetInt32(drRoleList.GetOrdinal("ModifiedUser"));
               objRole.ModifiedDate = drRoleList.GetDateTime(drRoleList.GetOrdinal("ModifiedDate"));

               if (objRole.IsActive)
               {
                   objRole.IsActiveStatus = "Yes";
               }
               else
               {
                   objRole.IsActiveStatus = "No";

               }

               if (!isLight)
               {
                   ScreenDAL screen = new ScreenDAL();

                   List<ScreenBO> listScreen = screen.LoadScreensByRoleID(objRole.RoleId);

                   if (listScreen.Count > 0)
                   {
                       objRole.ScreenList = new List<ScreenBO>();
                       objRole.ScreenList.AddRange(screen.LoadScreensByRoleID(objRole.RoleId));
                   }
               }

               }
               catch
               {
               throw;
               }

               return objRole;
        }
예제 #7
0
        public bool UpdateRole(RoleBO obj)
        {
            DBEgine dbEgine = new DBEgine();
            bool isValid = false;
            try
            {
                dbEgine.DBOpen();

                SqlParameter[] parms = new SqlParameter[4];

                SqlParameter p1 = new SqlParameter();
                p1.ParameterName = "@RoleId";
                p1.SqlDbType = SqlDbType.Int;
                p1.Direction = ParameterDirection.Input;
                p1.Value = obj.RoleId;
                parms[0] = p1;

                SqlParameter p2 = new SqlParameter();
                p2.ParameterName = "@RoleName";
                p2.SqlDbType = SqlDbType.VarChar;
                p2.Direction = ParameterDirection.Input;
                p2.Value = obj.RoleName;
                parms[1] = p2;

                SqlParameter p3 = new SqlParameter();
                p3.ParameterName = "@IsActive";
                p3.SqlDbType = SqlDbType.NVarChar;
                p3.Direction = ParameterDirection.Input;
                p3.Value = obj.IsActive;
                parms[2] = p3;

                SqlParameter p4 = new SqlParameter();
                p4.ParameterName = "ModifiedUserName";
                p4.SqlDbType = SqlDbType.NVarChar;
                p4.Direction = ParameterDirection.Input;
                p4.Value = obj.User.UserName;
                parms[3] = p4;

                dbEgine.ExecNonQueryStoredProc("UserManagement.UM_UpdateRole", parms);
                isValid = true;

                dbEgine.DBClose();

                return isValid;

            }
            catch
            {
                throw;
            }
            finally
            {
                dbEgine.DBClose();
            }
        }