/// <summary> /// Kết nối đến NTS để lấy dữ liệu ngày tháng /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainWindow_Loaded(object sender, RoutedEventArgs e) { //Get the time System.ComponentModel.BackgroundWorker GetTimeWorker = new System.ComponentModel.BackgroundWorker(); GetTimeWorker.DoWork += GetTimeWorker_DoWork; GetTimeWorker.RunWorkerCompleted += GetTimeWorker_RunWorkerCompleted; GetTimeWorker.RunWorkerAsync(); //Show the login dialog if (!debug) { Login.Login Lg = new Login.Login(); Lg.LoginCompleted += Lg_LoginCompleted; this.ShowCustomDialog(Lg); } }
private void Lg_LoginCompleted(object sender, EventArgs e) { //Login dialog instance Login.Login lg = (Login.Login)sender; //Disable the blocking border this.BlockingBackground.Visibility = Visibility.Collapsed; Grid G = (Grid)this.BlockingBackground.Parent; G.Children.Remove(BlockingBackground); //Close the dialog host this.DialogHost.Visibility = Visibility.Collapsed; this.DialogHost.IsOpen = false; //Create model this.DataConn = new Data.ConnectContainer(); //Logged in staff this.LoggedInStaff = lg.LoggedInStaff; this.StaffKey = this.LoggedInStaff.Key; //Get permission of current user this.Permission = this.DataConn.Permissions.Where(p => p.StaffKey == this.StaffKey).FirstOrDefault(); if (this.Permission != null) { this.CanManageUser = this.Permission.CanManageStaff; } //Enable the windows command button this.WindowsCommandCollection.IsHitTestVisible = true; //Create the view this.ProjectViewer.LoadTreeView(); this.ProjectViewer.LoadProjects(); }