void Login(LoginWindow parameter) { if (parameter == null) { return; } //check username if (String.IsNullOrEmpty(parameter.txtUser.Text)) { MessageBox.Show("Vui lòng nhập tên đăng nhập!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning); parameter.txtUser.Focus(); return; } //check password if (String.IsNullOrEmpty(parameter.txtPassword.Text)) { MessageBox.Show("Vui lòng nhập mật khẩu!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning); parameter.txtPassword.Focus(); return; } string codedPassword = MD5Hash(parameter.txtPassword.Text); var checkACC = DataProvider.Instance.DB.Accounts.Where(x => x.Username == parameter.txtUser.Text && x.Password == codedPassword).Count(); if (checkACC > 0) { HomeWindow homeWindow = new HomeWindow(); CurrentAccount.Instance.ConvertAccToCurrentAcc(parameter.txtUser.Text); parameter.Hide(); ImageBrush imageBrush = new ImageBrush(); imageBrush.ImageSource = Converter.Instance.ConvertByteToBitmapImage(CurrentAccount.Image); homeWindow.grdAcc_Image.Background = imageBrush; homeWindow.menu_Acc_DisplayName.Header = CurrentAccount.DisplayName; if (homeWindow.grdAcc_Image.Children.Count != 0) { homeWindow.grdAcc_Image.Children.Remove(homeWindow.grdAcc_Image.Children[0]); } homeWindow.ShowDialog(); parameter.txtPassword.Text = ""; parameter.Show(); } else { MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu!", "Thông báo", MessageBoxButton.OK, MessageBoxImage.Warning); } }