Example #1
0
        private void Save()
        {
            CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

            bool isSucceed = false;

            try
            {
                if (string.IsNullOrEmpty(ValueKey))
                {
                    MessageBox.Show("Enter Value Key");
                    return;
                }

                if (string.IsNullOrEmpty(ValueDescription))
                {
                    MessageBox.Show("Enter Value Description");
                    return;
                }

                var list   = _serviceInstance.GetSystemSettings();
                var exists = list.Where(x => x.ValueKey.Equals(ValueKey, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                if (exists != null)
                {
                    MessageBox.Show("Value Key Already Exists");
                    return;
                }

                AdminUserProp setting = new AdminUserProp();
                setting.ValueDescription = ValueDescription;
                setting.ValueKey         = ValueKey;
                _serviceInstance.InsertSystemSettings(setting);
                SystemSettingsList.Add(setting);
                isSucceed = true;
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                if (isSucceed)
                {
                    MessageBox.Show(Resources.msgInsertedSuccessfully);
                    FindMode();
                }
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
Example #2
0
        private void Update()
        {
            CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

            bool isSucceed = false;

            try
            {
                if (string.IsNullOrEmpty(ValueKey))
                {
                    MessageBox.Show("Enter Value Key");
                    return;
                }

                if (string.IsNullOrEmpty(ValueDescription))
                {
                    MessageBox.Show("Enter Value Description");
                    return;
                }

                if (SelectedGridItem != null)
                {
                    var           existingSettings = _serviceInstance.GetSystemSettings();
                    AdminUserProp setting          = new AdminUserProp();
                    setting.ValueKey         = SelectedGridItem.ValueKey;
                    setting.ValueDescription = ValueDescription;
                    _serviceInstance.UpdateSystemSettings(setting);
                    var item = SystemSettingsList.Where(x => x.ValueKey == setting.ValueKey).FirstOrDefault();
                    SystemSettingsList.Remove(item);
                    systemSettingsList.Add(setting);
                    isSucceed = true;
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                if (isSucceed)
                {
                    MessageBox.Show(Resources.msgUpdatedSuccessfully);
                    ModifyMode();
                }
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }
Example #3
0
        private void Delete()
        {
            CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

            bool isSucceed = false;

            try
            {
                if (SelectedGridItem != null)
                {
                    MessageBoxResult result = MessageBox.Show("Are You Sure to Delete?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Cancel || result == MessageBoxResult.No)
                    {
                        return;
                    }
                    AdminUserProp setting = new AdminUserProp();
                    setting.ValueDescription = SelectedGridItem.ValueDescription;
                    setting.ValueKey         = SelectedGridItem.ValueKey;
                    _serviceInstance.DeleteSystemSettings(setting);
                    SystemSettingsList.Remove(SelectedGridItem);
                    isSucceed = true;
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                if (isSucceed)
                {
                    MessageBox.Show(Resources.msgDeleteSuccessfully);
                    ModifyMode();
                }
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));
            }
        }