Example #1
0
        private void OpenFormHome(object sender, RoutedEventArgs e)
        {
            this.Hide();
            var homeWindow = new HomeWindow(IdUsuario, _tarefaService, _loginService, _usuarioService);

            homeWindow.Show();
        }
 private void button1_Click(object sender, RoutedEventArgs e)
 {
     //Submit
     if (oldPasswordBox.Password == password)
     {
         label4.Visibility = Visibility.Hidden;
         if (newPasswordBox.Password == confirmNewPassword.Password)
         {
             label5.Visibility = Visibility.Hidden;
             UserOperations operations = new UserOperations();
             operations.changePassword(userName, oldPasswordBox.Password, newPasswordBox.Password);
             HomeWindow hm = new HomeWindow(userName, password, emp);
             hm.Show();
             this.Close();
         }
         else
         {
             label5.Visibility = Visibility.Visible;
         }
     }
     else
     {
         label4.Visibility = Visibility.Visible;
     }
 }
Example #3
0
        private void Login(object sender, RoutedEventArgs e)
        {
            try
            {
                var findUser = _unitOfWork.User.ExistUser(txtUserName.Text.ToString().Trim(), txtPassword.Password.Trim().ToString());
                if (findUser == null)
                {
                    status.Text   = $"ইউসার নাম এবং পাসওয়ার্ড ভুল প্রদান করা হয়েছে।";
                    Dialog.IsOpen = true;
                    return;
                }
                if (findUser.Role.Name == "Admin")
                {
                    ApplicationState.SetValue("IsAdmin", true);
                }
                else
                {
                    ApplicationState.SetValue("IsAdmin", false);
                }

                ApplicationState.SetValue("UserInfo", findUser);

                HomeWindow homeWindow = new HomeWindow();
                homeWindow.Show();
                this.Close();
                return;
            }
            catch (System.Exception ex)
            {
                status.Text   = $"প্রোগ্রাম সম্পর্কিত সমস্যা: { ex.Message}";
                Dialog.IsOpen = true;
            }
        }
Example #4
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection sqlCon = new SqlConnection(Util.CONNECTION_STRING);

            try
            {
                if (sqlCon.State == ConnectionState.Closed)
                {
                    sqlCon.Open();
                }
                String     query  = "SELECT COUNT(1) FROM pacijenti WHERE jmbg=@jmbg AND lozinka=@lozinka and aktivan=1";
                SqlCommand sqlCmd = new SqlCommand(query, sqlCon);
                sqlCmd.CommandType = CommandType.Text;
                sqlCmd.Parameters.AddWithValue("@jmbg", txtUsername.Text);
                sqlCmd.Parameters.AddWithValue("@lozinka", txtPassword.Password);
                int count = Convert.ToInt32(sqlCmd.ExecuteScalar());
                if (count == 1)
                {
                    PacijentGlavna dashboard = new PacijentGlavna(txtUsername.Text);
                    dashboard.Show();
                    this.Close();
                }
                if (count != 1)
                {
                    String     query1  = "SELECT COUNT(1) FROM doktori WHERE jmbg=@jmbg AND lozinka=@lozinka and aktivan=1";
                    SqlCommand sqlCmd1 = new SqlCommand(query1, sqlCon);
                    sqlCmd1.CommandType = CommandType.Text;
                    sqlCmd1.Parameters.AddWithValue("@jmbg", txtUsername.Text);
                    sqlCmd1.Parameters.AddWithValue("@lozinka", txtPassword.Password);
                    int count1 = Convert.ToInt32(sqlCmd1.ExecuteScalar());
                    if (count1 == 1)
                    {
                        LekarGlavna dashboard = new LekarGlavna(txtUsername.Text);
                        dashboard.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Username or password is incorrect.");
                    }
                }

                if (txtUsername.Text.Equals("admin") && txtPassword.Password.Equals("admin"))
                {
                    HomeWindow dashboard = new HomeWindow();
                    dashboard.Show();
                    this.Close();
                }
            }


            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                sqlCon.Close();
            }
        }
Example #5
0
        private void mainBtn_Click(object sender, RoutedEventArgs e)
        {
            HomeWindow window = new HomeWindow();

            window.Show();
            Close();
        }
Example #6
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            UserOperations operations = new UserOperations();
            LoginStatus    status     = operations.isValidUser(textBox1.Text, passwordBox1.Password);

            if (status.ValidUser)
            {
                label3.Visibility = Visibility.Hidden;
                if (status.FirstLogin)
                {
                    if (System.Windows.MessageBox.Show("You need to change your password.", "Change Password", MessageBoxButton.OK, MessageBoxImage.Information) == MessageBoxResult.OK)
                    {
                        ChangePassword change = new ChangePassword(textBox1.Text, passwordBox1.Password, status.Employee);
                        change.Show();
                        this.Close();
                    }
                }
                else
                {
                    HomeWindow hm = new HomeWindow(textBox1.Text, passwordBox1.Password, status.Employee);
                    hm.Show();
                    this.Close();
                }
            }
            else
            {
                label3.Visibility = Visibility.Visible;
            }
        }
Example #7
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            HomeWindow window = new HomeWindow();
            UserVM     VM     = new UserVM();

            window.DataContext = VM;
            window.Show();
        }
        public void ResumeGame(object param)
        {
            HomeWindow    window = new HomeWindow();
            HomeViewModel homeVM = new HomeViewModel(user, true);

            window.DataContext = homeVM;
            App.Current.MainWindow.Close();
            App.Current.MainWindow = window;
            window.Show();
        }
Example #9
0
        /// <summary>
        /// Method to Load Main Model after Login Successful.
        /// </summary>
        private async void LoadMainModel(string userRole)
        {
            await Application.Current.Dispatcher.BeginInvoke(new Action(() =>
            {
                CommonSettings.logger.LogInfo(typeof(string),
                                              string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgStart,
                                                            DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(),
                                                            MethodBase.GetCurrentMethod().Name));
                try
                {
                    if (!string.IsNullOrEmpty(userRole))
                    {
                        Application.Current.Properties["LoggedInUserRole"] = userRole;

                        HomeWindow homeWindow = new HomeWindow();

                        // close the login window and show home window
                        foreach (Window window in Application.Current.Windows)
                        {
                            if (window.Title.Equals("login", StringComparison.OrdinalIgnoreCase))
                            {
                                window.Close();
                                homeWindow.Show();
                            }
                        }
                    }
                    else
                    {
                        clsValidationPopUp.ErrMsgPassword = Resources.ErrorNoRoleAsign;
                    }
                }
                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));
                }
            }));

            IsLogining = false;
        }
        public void LoginButtonIsPressed(string SSN, string Password)
        {
            if (_validateLogin.CheckSSN(SSN))
            {
                if (_loadDatabase.ValidateLogin(SSN, Password))
                {
                    //ALT HERFRA TIL _HOMEWINDOW TÆNKER VI ER GODT
                    //Spørgsmålet er, hvorvidt det skal placeres her, eller i homewindow eller et andet sted, så det kommer
                    //med videre rundt i forløbet i programmet. :)

                    _patient = _loadDatabase.LoadPatientInfo(SSN);
                    //foreach (var item in _patient.PackageList)
                    //{
                    //    _exercisePackage = _loadDatabase.LoadPackageInfo(item.ExercisePackageID);
                    //    _packageList.Add(_exercisePackage);
                    //}


                    //foreach (var item in _packageList)
                    //{
                    //    foreach (var exercise in item.ExerciseList)
                    //    {
                    //        _exercise = _loadDatabase.LoadExerciseInfo(exercise.ExerciseID);
                    //        _exerciseList.Add(_exercise);
                    //    }
                    //}



                    _homeWindow = new HomeWindow(_patient);
                    _homeWindow.Show();
                    _loginWindow.Close();
                }
                else
                {
                    _loginWindow.LoginErrorMessage();
                    _loginWindow.cprTB.Clear();
                    _loginWindow.pwTB.Clear();
                    _loginWindow.cprTB.Focus();
                }
            }
            else
            {
                _loginWindow.SSNErrorMessage();
                _loginWindow.cprTB.Clear();
                _loginWindow.pwTB.Clear();
                _loginWindow.cprTB.Focus();
            }
        }
Example #11
0
        public void CategorySelected(Category category)
        {
            user.GameProperty.CategoryProperty = category;
            user.GameProperty.LevelProperty    = 1;
            user.GameProperty.MistakesProperty = 0;
            user.GameProperty.WordOnDisplay    = "";
            user.GameProperty.WordToGuess      = "";
            HomeWindow    window = new HomeWindow();
            HomeViewModel homeVM = new HomeViewModel(user);

            window.DataContext = homeVM;
            App.Current.MainWindow.Close();
            App.Current.MainWindow = window;
            window.Show();
        }
Example #12
0
        public void CheckResult()
        {
            model.checkLogin(view.txtEmail.Text, view.txtPassword.Password);
            bool result = model.getResult();

            if (result)
            {
                HomeWindow home = new HomeWindow();
                home.Show();
                view.Close();
            }
            else
            {
                MessageBox.Show("Username / Password Invalid!");
                view.txtEmail.Focus();
            }
        }
Example #13
0
        /// <summary>
        /// 打开主页
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tsbMain_Click(object sender, EventArgs e)
        {
            if (null == homeWindow || homeWindow.IsDisposed)
            {
                homeWindow            = new HomeWindow();
                homeWindow.MdiParent  = this;
                homeWindow.StartLoad += (obj, ev) =>
                {
                    StartLoad(obj);
                };
                homeWindow.StopLoad += (obj, ev) =>
                {
                    StopLoad(obj);
                };


                homeWindow.Show();
            }

            SetSelect(tsbMain, tsmiMain);
            homeWindow.Activate();
        }
Example #14
0
        void App_Startup(object sender, StartupEventArgs e)
        {
            var login   = new Login();
            var loginVM = new LoginViewModel();

            loginVM.LoginCompleted += (sender1, e1) =>
            {
                if (loginVM.Theme == 1)
                {
                    HomeWindow main = new HomeWindow();
                    main.Show();
                }
                else
                {
                    MainWindow main = new MainWindow();
                    main.Show();
                }
                login.Close();
            };
            login.DataContext = loginVM;
            login.ShowDialog();
        }
Example #15
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            AppDomain.CurrentDomain.UnhandledException += (sender, args) => CurrentDomainOnUnhandledException(args);

            TaskScheduler.UnobservedTaskException += (sender, args) => TaskSchedulerOnUnobservedTaskException(args);

            var bootstrap = new StartUp.Bootstrap();

            var container = bootstrap.Bootstraper();

            using (var scope = container.BeginLifetimeScope())
            {
                HomeWindow main = container.Resolve <HomeWindow>();
                try
                {
                    main.Show();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }

            var vCulture = new CultureInfo("sr-SP-Latin");//odavde do dole za defaultni jezik bez obzira na windows podesavanja

            Thread.CurrentThread.CurrentCulture       = vCulture;
            Thread.CurrentThread.CurrentUICulture     = vCulture;
            CultureInfo.DefaultThreadCurrentCulture   = vCulture;
            CultureInfo.DefaultThreadCurrentUICulture = vCulture;

            FrameworkElement.LanguageProperty.OverrideMetadata(
                typeof(FrameworkElement),
                new FrameworkPropertyMetadata(
                    System.Windows.Markup.XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            base.OnStartup(e);
        }
Example #16
0
        public void login(string Username, string Password)
        {
            HomeWindow home       = new HomeWindow();
            MainWindow mainWindow = new MainWindow();

            try
            {
                Register register           = Register.GetInstance();
                string   encryptingPassword = register.Encrypting(Password);
                using (var dbEntities = new ToDoListEntities())
                {
                    var _username = (from x in dbEntities.Users
                                     where x.Username == Username
                                     select x).FirstOrDefault <Users>();

                    var _password = (from x in dbEntities.Users
                                     where x.Password == encryptingPassword
                                     select x).FirstOrDefault <Users>();



                    if (_username != null && _password != null)
                    {
                        CloseAllWindows();
                        home.Show();
                    }
                    else
                    {
                        MessageBox.Show("Username or Password incorrect!", "Error Message", MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error Message", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #17
0
        private void Login()
        {
            WarehouseDbContext ctx = new WarehouseDbContext();
            var user = ctx.Users.SingleOrDefault(u => u.Email == CurrentUser.Email);

            if (user != null && CurrentUser.Password == user.Password)
            {
                user.LastLoginDate = DateTime.Now;
                ctx.SaveChanges();

                HomeWindow myWindow = new HomeWindow();
                myWindow.Show();

                this.CurrentWindows.Close();

                //keep current user id in the application
                App.Current.Properties["CurrentUserID"] = user.ID;
            }
            else
            {
                MessageBox.Show(CurrentWindows, "Invalid email or password !");
                return;
            }
        }
Example #18
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            _homeWnd = new HomeWindow();

            _homeWnd.Show();
        }
 public static void ShowTutorials()
 {
     HomeWindow.Show(HomeWindow.HomeMode.Tutorial);
 }
 public void ReturnToHome(Window window)
 {
     window.Close();
     _homeWindow.Show();
 }
Example #21
0
        private void Add_Closed(object sender, EventArgs e)
        {
            HomeWindow window = new HomeWindow();

            window.Show();
        }
Example #22
0
        /// <summary>
        /// Login actions. Retrieve info from SQL server
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void BtLogin_Click(object sender, RoutedEventArgs e)
        {
            username = tbUsername.Text;
            password = tbPassword.Password;

            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "好的!",
                NegativeButtonText    = "谢谢,不用",
                ColorScheme           = MetroDialogOptions.ColorScheme,
                AnimateShow           = true,
                AnimateHide           = true
            };

            var myProcessSettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "好的!",
                ColorScheme           = MetroDialogOptions.ColorScheme,
                AnimateShow           = true,
                AnimateHide           = true
            };

            if (exSQL != null)
            {
                await this.ShowMessageAsync("运维提醒(可忽略)",
                                            "这条消息会出现是因为代码内部检测到了上一个操作发生了错误。" +
                                            "\n如果您是一位用户并恰巧看到了这个消息,您可以忽略该消息,但是仍然建议您将此问题报告给系统管理员。",
                                            settings : mySettings);
            }

            //Check
            //TO-DOs: Password should not contain any special character.
            var beValid = password.Length != 0 && _viewModel.bValidUsernameInput;

            //----------Validate input
            if (!beValid)
            {
                MessageDialogResult result = await this.ShowMessageAsync("格式有误", "检查一下你输入的账号信息哦~d=====( ̄▽ ̄*)b",
                                                                         MessageDialogStyle.Affirmative, mySettings);
            }
            //----------Validate information
            else
            {
                //Last unhandled exception
                if (db_helper.bConnectionAlive)
                {
                    await this.ShowMessageAsync("运维提醒(可忽略)",
                                                "数据库连接仍然处于活跃状态,这可能会导致程序接下来的运行不稳定。" +
                                                "这条消息会出现是因为代码内部检测到了上一个操作的连接没有被成功关闭。" +
                                                "\n如果您是一位用户并恰巧看到了这个消息,您可以忽略该消息,但是仍然建议您将此问题报告给系统管理员。",
                                                settings : mySettings);
                }

                var controller = await this.ShowProgressAsync("请稍等......", "我们正在连接到数据库以获取您的账号信息", settings : myProcessSettings);

                controller.SetIndeterminate();
                controller.SetCancelable(true);

                //Stage 1 - Connect
                exSQL = await Task.Run(() => db_helper.Connect());

                controller.SetCancelable(false);

                if (exSQL != null)
                {
                    ErrorCount++;
                    controller.SetProgress(1.0d);
                    controller.SetTitle("很抱歉~");
                    controller.SetMessage("与数据库的连接出现了问题...建议您尝试重新连接...\n\nMySQL说道:\n\"" + exSQL.Message + "\"");

                    if (ErrorCount < 2)
                    {
                        await Task.Delay(3000);
                    }
                    else
                    {
                        await this.ShowMessageAsync("检测到连续的错误",
                                                    "程序内部检测到数据库连接阶段发生了多次错误。\n您可以忽略该消息,但是仍然建议您将此问题报告给系统管理员。",
                                                    settings : mySettings);
                    }

                    await controller.CloseAsync();

                    exSQL = null;

                    return;
                }
                ErrorCount = 0;

                //Cancel the action
                if (controller.IsCanceled)
                {
                    controller.SetProgress(1.0d);

                    controller.SetTitle("结束");
                    controller.SetMessage("用户取消了下一步操作。");

                    await Task.Run(() => db_helper.Disconnect());

                    await Task.Delay(1000);

                    await controller.CloseAsync();

                    return;
                }

                //Stage 2 - Retrieve info
                controller.SetMessage("正在从服务端获取加密信息...");
                var query_result = await Task.Run(
                    ()
                    =>
                    studentInfo = db_helper.RetrieveStudentInfo(username, HITwhCMS.Backend.DataTemplate.DataFormat.Login)
                    );

                exSQL = studentInfo.exSQL;

                //Stage 3 - Check account state
                if (studentInfo.CurrentFormat == HITwhCMS.Backend.DataTemplate.DataFormat.NULL)
                {
                    string msg = "";
                    if (exSQL == null)
                    {
                        msg = "数据库里面还没有您的学号信息,请检查输入哦~”";
                    }
                    else
                    {
                        msg = exSQL.Message;
                    }

                    ErrorCount++;

                    controller.SetProgress(1.0d);
                    controller.SetTitle("很抱歉~");

                    //No user info
                    if (exSQL == null)
                    {
                        controller.SetMessage(msg);
                    }
                    //Exception
                    else if (ErrorCount < 2)
                    {
                        controller.SetMessage("数据库在读取您的数据的时候出现了问题...建议您尝试重新连接...\n\nMySQL说道:\n\"" + msg + "\"");
                    }
                    //Repeated exception
                    else
                    {
                        controller.SetMessage("数据库在读取您的数据的时候出现了问题...建议您尝试重新连接...\n\nMySQL说道:\n\"" + msg + "\"");
                        await this.ShowMessageAsync("检测到连续的错误",
                                                    "程序内部检测到同一个任务阶段发生了多个错误。\n您可以忽略该消息,但是仍然建议您将此问题报告给系统管理员。",
                                                    settings : mySettings);
                    }

                    exSQL = await Task.Run(() => db_helper.Disconnect());

                    await Task.Delay(3000);

                    await controller.CloseAsync();

                    return;
                }
                ErrorCount = 0;

                if (!studentInfo.bRegistered)
                {
                    controller.SetProgress(1.0d);
                    controller.SetTitle("很抱歉~");
                    controller.SetMessage("您还没有入驻本系统,先在登陆界面点击“新用户入驻哦~”");

                    exSQL = await Task.Run(() => db_helper.Disconnect());

                    await Task.Delay(3000);

                    await controller.CloseAsync();

                    return;
                }

                //We wiped the SQL connection because there's no need to keep it up.
                exSQL = await Task.Run(() => db_helper.Disconnect());

                //Stage 4 - Decrypt data
                controller.SetMessage("正在解密从服务端传输的信息...");
                var correct_pwd = await Task.Run(() => AESHelper.Decrypt(studentInfo.sPasswd, AES_Static.AES256Key));

                //Stage 5 - Validate data
                controller.SetMessage("正在验证您输入的账户信息...");
                if (tbPassword.Password != correct_pwd)
                {
                    controller.SetProgress(1.0d);
                    controller.SetTitle("很抱歉~");
                    controller.SetMessage("您输入了错误的密码呢(+_+)?请检查以下输入哦~如果想找回密码请点击右上角“更多功能”~");
                    await Task.Delay(3000);

                    await controller.CloseAsync();
                }
                else
                {
                    controller.SetProgress(1.0d);
                    controller.SetTitle("欢迎回来!");
                    controller.SetMessage(studentInfo.sName + ",咱们很长时间没有见过了!");
                    await Task.Delay(3000);

                    await controller.CloseAsync();

                    var s = new HomeWindow();
                    s.Closing += (o, args) =>
                    {
                        Application.Current.Shutdown();
                    };
                    s.Show();
                    this.Hide();
                }
                return;
            }
        }
Example #23
0
 public void IntervalSet(int interval)
 {
     _saveDatabase.SaveInterval(interval);
     _homeWindow.Show();
     _intervalWindow.Close();
 }
Example #24
0
        private void StartupHome()
        {
            var HomeWindow = new HomeWindow();

            HomeWindow.Show();
        }