public Ctrl_Bug(Bug pBug, Win_Home pHomeWin) { InitializeComponent(); MyBug = pBug; MyHomeWindow = pHomeWin; UpdateUi(); }
public Win_Bug(Win_Home pHomeWindow) //This is for new bugs { //helps with data integrity (everything is updated at once) InitializeComponent(); MyBug = Data.ActiveProduct.NewBug(); MyBugControl = null; MyHomeWindow = pHomeWindow; User TempUser = Data.ActiveUser; TempUser.Get(); label_RaisedBy.Content = TempUser.FullName; /*UpdateTags(); * UpdateNotes();*/ }
//This is for editing bugs public Win_Bug(Ctrl_Bug pBugControl) //Much faster to pass tags rather than re-download them. Also { //helps with data integrity (everything is updated at once) InitializeComponent(); MyBug = pBugControl.MyBug; MyBugControl = pBugControl; MyHomeWindow = pBugControl.MyHomeWindow; User TempUser = new User(pBugControl.MyBug.RaisedBy.Id); TempUser.Get(); label_RaisedBy.Content = TempUser.FullName; input_Title.Text = pBugControl.MyBug.Title; input_Description.Text = pBugControl.MyBug.Description; combo_Severity.Text = pBugControl.MyBug.Severity.ToString(); BackupNotes(); BackupTags(); BackupAssignees(); UpdateTags(); UpdateNotes(); UpdateAssignees(); }
private void LogIn() { //Styles are defined at the top of the function Style style_TextBoxError = Application.Current.FindResource("TextBoxError") as Style; Style style_PasswordBoxError = Application.Current.FindResource("PasswordBoxError") as Style; //Success bool will be set to false if there is an error bool ValidateSuccess = true; //Checks that username/email is not blank if (input_UsernameOrEMail.Text == "") { ValidateSuccess = false; input_UsernameOrEMail.Style = style_TextBoxError; MessageBox.Show("You cannot leave the username / e-mail field blank", "Blank Field", MessageBoxButton.OK, MessageBoxImage.Error); } //Checks password is not blank if (input_Password.Password == "") { ValidateSuccess = false; input_Password.Style = style_PasswordBoxError; MessageBox.Show("You cannot leave the password field blank", "Blank Field", MessageBoxButton.OK, MessageBoxImage.Error); } if (ValidateSuccess) { User MyUser = new User(); if (input_UsernameOrEMail.Text.Contains("@")) { MyUser.EMail = input_UsernameOrEMail.Text; } else { MyUser.Username = input_UsernameOrEMail.Text; } MyUser.Password = input_Password.Password; Mouse.OverrideCursor = Cursors.Wait; if (MyUser.LogIn()) { if (RememberMe.IsChecked == true) { Configuration config = ConfigurationManager.OpenExeConfiguration(AppDomain.CurrentDomain.BaseDirectory + "BTS WPF.exe"); try { config.AppSettings.Settings["UsernameOrEmail"].Value = input_UsernameOrEMail.Text; } catch (System.NullReferenceException) { config.AppSettings.Settings.Add("UsernameOrEmail", input_UsernameOrEMail.Text); } try { config.AppSettings.Settings["Password"].Value = input_Password.Password; } catch (System.NullReferenceException) { config.AppSettings.Settings.Add("Password", input_Password.Password); } config.Save(ConfigurationSaveMode.Minimal); ConfigurationManager.RefreshSection("appSettings"); } //MessageBox.Show("Initialising"); Win_SplashScreen TempSplash = new Win_SplashScreen(); TempSplash.Show(); //This is a check to see if the window has been initialised. Had a problem where //sometimes after Window.Show(), the window would be blank until Data.Initialise() //had completed which made the splash screen a bit pointless. Data.Initialise(); /*if (TempSplash.Ready()) { * Data.Initialise(); * } * else { * throw new Exception("App failed to initialise"); * };*/ TempSplash.Close(); //MessageBox.Show("Initialised"); Mouse.OverrideCursor = null; Win_Home HomeWindow = new Win_Home(); HomeWindow.Show(); this.Close(); if (!UserRemembered) { MessageBox.Show("Logged in successfully!", "Success!", MessageBoxButton.OK, MessageBoxImage.Information); } } else { Mouse.OverrideCursor = null; MessageBox.Show("Could not log in: " + MyUser.ErrMsg, "Error", MessageBoxButton.OK, MessageBoxImage.Error); }; } }