private void DeleteUserClick(object sender, System.Windows.RoutedEventArgs e)
        {
            DAL.UnitOfWork oUnitOfWork = null;

            try
            {
                oUnitOfWork = new DAL.UnitOfWork();

                System.Windows.MessageBoxResult oResult =
                    Infrastructure.MessageBox.Show
                    (
                        caption: Infrastructure.MessageBox.Caption.Question,
                        text: "آیا مطمئن به حذف کاربر از سیستم هستید ؟"
                    );

                if (oResult == System.Windows.MessageBoxResult.Yes)
                {
                    oUnitOfWork.UserRepository.DeleteById(_currentId);

                    oUnitOfWork.Save();

                    Infrastructure.MessageBox.Show
                    (
                        caption: Infrastructure.MessageBox.Caption.Information,
                        text: "کاربر با موفقیت از سیستم حذف گردید."
                    );

                    if (_currentId == Utility.CurrentUser.Id)
                    {
                        UserLoginWindow oUserLoginWindow = new UserLoginWindow();

                        (Utility.MainWindow as MainRibbonWindow).Hide();

                        oUserLoginWindow.Show();
                    }
                }

                oUnitOfWork.Save();
            }
            catch (System.Exception ex)
            {
                Infrastructure.MessageBox.Show(ex.Message);;
            }
            finally
            {
                if (oUnitOfWork != null)
                {
                    oUnitOfWork.Dispose();
                    oUnitOfWork = null;
                }
            }

            RefreshGridControl();
        }
Exemple #2
0
        private void UserLogoutClick(object sender, System.Windows.RoutedEventArgs e)
        {
            Utility.CurrentUser = null;
            Utility.CurrentFund = null;

            SthPanel.Children.Clear();

            this.Hide();

            UserLoginWindow oUserLoginWindow = new UserLoginWindow();

            oUserLoginWindow.ShowWelcomeWindow = false;

            oUserLoginWindow.Show();

            ShowMessageBox = false;
        }
        static void Main()
        {
            App app = new App();

            Utility.FarsiLocalization();
            Utility.SetStimulsoftLicense();

            DAL.UnitOfWork oUnitOfWork = new DAL.UnitOfWork();

            int UsersCount = oUnitOfWork.UserRepository
                             .Get()
                             .Count();

            if (UsersCount == 0)
            {
                CreateAdminWindow oCreateAdminWindow = new CreateAdminWindow();
                app.Run(oCreateAdminWindow);
            }
            else
            {
                UserLoginWindow oUserLoginWindow = new UserLoginWindow();
                app.Run(oUserLoginWindow);
            }
        }
Exemple #4
0
        private void SimpleButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            #region Error Handling Messages

            if (string.IsNullOrWhiteSpace(UsernameTextBox.Text) == true)
            {
                Infrastructure.MessageBox.Show(caption: Infrastructure.MessageBox.Caption.Error, text: "تکمیل فیلد نام کاربری الزامی است.");

                return;
            }

            if (string.IsNullOrWhiteSpace(PasswordTextBox.Password) == true)
            {
                Infrastructure.MessageBox.Show(caption: Infrastructure.MessageBox.Caption.Error, text: "تکمیل فیلد رمز عبور الزامی است.");

                return;
            }

            if (string.IsNullOrWhiteSpace(EmailAddressTextBox.Text) == true)
            {
                Infrastructure.MessageBox.Show(caption: Infrastructure.MessageBox.Caption.Error, text: "تکمیل فیلد پست الکترونیکی الزامی است.");

                return;
            }

            if (string.IsNullOrWhiteSpace(ConfirmPasswordTextBox.Password) == true)
            {
                Infrastructure.MessageBox.Show(caption: Infrastructure.MessageBox.Caption.Error, text: "تکمیل فیلد تایید رمز عبور الزامی است.");

                return;
            }

            if (PasswordTextBox.Password.Trim() != ConfirmPasswordTextBox.Password.Trim())
            {
                Infrastructure.MessageBox.Show(caption: Infrastructure.MessageBox.Caption.Error, text: "رمزهای عبور درج شده با یکدیگر مطابقت ندارند.");

                return;
            }

            if (string.IsNullOrWhiteSpace(CaptchaValueTextBox.Text) == true)
            {
                Infrastructure.MessageBox.Show(caption: Infrastructure.MessageBox.Caption.Error, text: "تکمیل فیلد درج کد امنیتی الزامی است.");

                return;
            }

            if (CaptchaValueTextBox.Text.Trim().ToUpper() != Captcha.CaptchaValue.ToUpper())
            {
                Infrastructure.MessageBox.Show(caption: Infrastructure.MessageBox.Caption.Error, text: "کد امنیتی درج شده صحیح نمی‌باشد.");

                return;
            }

            #endregion

            #region Transaction

            DAL.UnitOfWork oUnitOfWork = null;

            try
            {
                oUnitOfWork = new DAL.UnitOfWork();

                Models.User oUser = new Models.User();

                oUser.FullName.FirstName = FirstNameTextBox.Text.Trim();
                oUser.FullName.LastName  = LastNameTextBox.Text.Trim();
                oUser.Username           = UsernameTextBox.Text.Trim();
                oUser.Password           = Dtx.Security.Hashing.GetMD5(PasswordTextBox.Password);
                oUser.EmailAddress       = EmailAddressTextBox.Text.Trim();
                oUser.LastLoginTime      = null;
                oUser.RegisterationDate  = System.DateTime.Now;
                oUser.IsAdmin            = true;
                oUser.CanBeDeleted       = false;

                Models.UserSetting oUserSetting = new Models.UserSetting();

                oUserSetting.CanChangeDatabaseBackupPath    = true;
                oUserSetting.DatabaseBackupPath             = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments) + @"\Fund\Backups\";
                oUserSetting.PersianCalendarHijriAdjustment = -1;

                oUser.UserSetting = oUserSetting;

                oUnitOfWork.UserRepository.Insert(oUser);

                oUnitOfWork.Save();

                Utility.AdminUserId = oUser.Id;

                UserLoginWindow oUserLoginWindow = new UserLoginWindow();

                this.Hide();

                oUserLoginWindow.Show();
            }
            catch (System.Exception ex)
            {
                Infrastructure.MessageBox.Show(ex.Message);;
            }
            finally
            {
                if (oUnitOfWork != null)
                {
                    oUnitOfWork.Dispose();
                    oUnitOfWork = null;
                }
            }

            #endregion
        }