コード例 #1
0
        private void cmdSave_Click(object sender, EventArgs e)
        {
            if (txtUserRole.Text.Length > 0)
            {
                UserRole UserRole = new UserRole();

                if (UserRoleID != null)
                {
                    UserRole.UserRoleID = int.Parse(UserRoleID);
                }
                UserRole.Name = txtUserRole.Text.ToString();
                UserRole.IsActive = Convert.ToBoolean(chkIsActive.EditValue);
                UserRole.CreatedOn = DateTime.Now;
                UserRole.UpdatedOn = DateTime.Now;

                UserService.SaveUserRole(UserRole);

                grdUserRole.DataSource = UserService.GetAllUserRoles(false);
            }
            else
            {
                MessageBox.Show("Please, fill the member id up!", "Invalid", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtUserRole.Focus();
            }
        }
コード例 #2
0
        private void cmdDelete_Click(object sender, EventArgs e)
        {
            if (UserRoleID != null)
            {
                UserRole UserRole = new UserRole();

                UserRole.UserRoleID = int.Parse(UserRoleID);
               // UserRole.Deleted = true;

                UserService.SaveUserRole(UserRole);

                grdUserRole.DataSource = UserService.GetAllUserRoles(false);
            }
        }
コード例 #3
0
        private UserRole GetInfo()
        {
            try
            {

                UserRole userRole = new UserRole();
                var userRoletest = grdUserRoleView.GetDataRow(grdUserRoleView.FocusedRowHandle);

                return userRole;
                //string CurUserID = grdUserRole.h

                //if (dsUser.Tables[0].Rows.Count > 0)
                //{
                //    EnableDisable(true);
                //    txtUserRole.Tag = dsUser.Tables[0].Rows[0]["LogInID"].ToString();
                //    txtUserRole.Text = dsUser.Tables[0].Rows[0]["LogInName"].ToString();
                //    chkIsActive.Checked = (bool)dsUser.Tables[0].Rows[0]["LogInIsActive"];
                //}
            }
            catch (Exception)
            {
                return null;
            }
        }
コード例 #4
0
        public void SaveUserRole(UserRole userRole)
        {
            UserRole existingData = GetUserRoleByID(userRole.UserRoleID);

            if (existingData == null)
                _context.UserRoles.AddObject(userRole);
            else
            {
                existingData.Name = userRole.Name;
                existingData.IsActive = userRole.IsActive;
                existingData.UpdatedOn = System.DateTime.Now;

                if (!_context.IsAttached(existingData))
                    _context.UserRoles.Attach(existingData);
            }

            _context.SaveChanges();
        }
コード例 #5
0
        /// <summary>
        /// Save user role 
        /// </summary>
        /// <param name="user">User</param>
        public bool SaveUserRole(UserRole userRole)
        {
            UserRole existingData = new UserRole();

            if (existingData != null && existingData.UserRoleID != userRole.UserRoleID)
            {
                if (existingData.UserRoleID != 0)
                    return false;
            }

            existingData = GetUserRoleByID(userRole.UserRoleID);

            if (existingData == null)
            {
                userRole.CreatedOn = System.DateTime.Now;
                userRole.UpdatedOn = System.DateTime.Now;
                _context.UserRoles.AddObject(userRole);
            }
            else
            {
                existingData.Name = userRole.Name;
                existingData.IsActive = userRole.IsActive;
                existingData.CreatedOn = userRole.CreatedOn;
                existingData.UpdatedOn = System.DateTime.Now;

                if (!_context.IsAttached(existingData))
                    _context.UserRoles.Attach(existingData);
            }
            _context.SaveChanges();

            return true;
        }
コード例 #6
0
        private void FixupnpUserRole(UserRole previousValue, bool skipKeys = false)
        {
            if (IsDeserializing)
            {
                return;
            }

            if (previousValue != null && previousValue.npUsers.Contains(this))
            {
                previousValue.npUsers.Remove(this);
            }

            if (npUserRole != null)
            {
                if (!npUserRole.npUsers.Contains(this))
                {
                    npUserRole.npUsers.Add(this);
                }

                UserRoleID = npUserRole.UserRoleID;
            }
            else if (!skipKeys)
            {
                UserRoleID = null;
            }

            if (ChangeTracker.ChangeTrackingEnabled)
            {
                if (ChangeTracker.OriginalValues.ContainsKey("npUserRole")
                    && (ChangeTracker.OriginalValues["npUserRole"] == npUserRole))
                {
                    ChangeTracker.OriginalValues.Remove("npUserRole");
                }
                else
                {
                    ChangeTracker.RecordOriginalValue("npUserRole", previousValue);
                }
                if (npUserRole != null && !npUserRole.ChangeTracker.ChangeTrackingEnabled)
                {
                    npUserRole.StartTracking();
                }
            }
        }