예제 #1
0
        /// <summary>
        /// Function to Delete record for user.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns>void</returns>
        /// <createdBy></createdBy>

        public void DeleteRecord(object obj)
        {
            try
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
                MessageBoxResult messageBoxResult = MessageBox.Show(Resources.MsgDeleteConfirm, Resources.msgTitleMessageBoxDelete, MessageBoxButton.YesNo);
                if (messageBoxResult == MessageBoxResult.Yes)
                {
                    string       errMsg          = string.Empty;
                    FindUserProp objFindUserProp = new FindUserProp();
                    objFindUserProp.UserID       = obj.GetType().GetProperty("UdUserID").GetValue(obj).ToString();
                    objFindUserProp.RecordStatus = "Inactive";
                    objFindUserProp.FirstName    = obj.GetType().GetProperty("UdUserFirstName").GetValue(obj).ToString();;
                    objFindUserProp.LastName     = obj.GetType().GetProperty("UdUserLastName").GetValue(obj).ToString();;
                    objFindUserProp.UserCode     = obj.GetType().GetProperty("UdUserCode").GetValue(obj).ToString();;
                    objFindUserProp.SelectedRole = SelectedRole;
                    string currentUserName = Application.Current.Properties["LoggedInUserName"].ToString().ToUpper();
                    string deleteUserName  = objFindUserProp.UserCode.ToUpper();
                    if (deleteUserName != currentUserName)
                    {
                        int value = _serviceInstance.RemoveUserDetails(objFindUserProp);
                        if (SelectedStatus != null && !SelectedStatus.Equals("All"))
                        {
                            objFindUserProp.selectedStatusRole = SelectedStatus;
                        }
                        if (obj.GetType().GetProperty("UdUserStatus").GetValue(obj) != null && !obj.GetType().GetProperty("UdUserStatus").GetValue(obj).ToString().Equals("All"))
                        {
                            objFindUserProp.selectedStatusRole = obj.GetType().GetProperty("UdUserStatus").GetValue(obj).ToString();;
                        }
                        FindUserDeligate.SetValueMethodCmdReferesh(string.Empty);
                        MessageBox.Show(Resources.msgDeleteSuccessfully);
                        UsersRecordList(null);
                    }
                    else
                    {
                        MessageBox.Show(Resources.WarnDeleteCurrentUser);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
예제 #2
0
        /// <summary>
        /// Method To Show All Record
        /// </summary>
        public void UsersRecordList(object obj)
        {
            try
            {
                Count = 0;
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                if (obj == null)
                {
                    CurrentPageIndex = 0;
                }
                if (CurrentPageIndex == 0)
                {
                    Application.Current.Properties["FindUserGridLastScrollOffset"] = 0;
                    Application.Current.Properties["FindUserGridCurrentPageIndex"] = 0;
                }

                FindUserProp objFindUserProp = new FindUserProp();
                objFindUserProp.CurrentPageIndex = CurrentPageIndex;
                objFindUserProp.PageSize         = CurrentPageIndex > 0 ? _GridPageSizeOnScroll : _GridPageSize;;
                objFindUserProp.DefaultPageSize  = _GridPageSize;
                objFindUserProp.FirstName        = FirstName;
                objFindUserProp.LastName         = LastName;
                objFindUserProp.UserCode         = UserCode;
                objFindUserProp.SelectedRole     = RoleName;

                if (SelectedStatus != null && !SelectedStatus.Equals("All"))
                {
                    objFindUserProp.selectedStatusRole = SelectedStatus;
                }

                var list = _serviceInstance.GetUserRecord(objFindUserProp).Select(d => new UserDetails
                {
                    UdUserCode      = d.UserCode,
                    UdUserFirstName = d.FirstName,
                    UdUserLastName  = d.LastName,
                    UdUserStatus    = d.UserStatus,
                    UdUserID        = d.UserID,
                    TotalPageCount  = d.TotalPageCount
                });

                if (CurrentPageIndex == 0)
                {
                    UserDetailList = null;
                    UserDetailList = new ObservableCollection <UserDetails>(list);
                }
                else
                {
                    if (UserDetailList != null && UserDetailList.Count > 0)
                    {
                        foreach (UserDetails ud in new ObservableCollection <UserDetails>(list))
                        {
                            UserDetailList.Add(ud);
                        }
                    }
                }
                Count = userDetailList.ToList().Where(x => x.TotalPageCount > 0).FirstOrDefault().TotalPageCount;
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                if (_searchTimer != null)
                {
                    _searchTimer.Dispose();
                }
            }
        }