public NewGeneralEntryPage() { InitializeComponent(); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .WriteTo.File("C:\\Users\\Michael Distler\\source\\repos\\logs_wpf\\log.txt", rollingInterval: RollingInterval.Day) .CreateLogger(); Log.Information("Start: Initialize topic combobox with data"); DB.Database db = new DB.Database(@"URI=file:C:\Users\Michael Distler\source\repos\WPF_Login\test.db"); cbTopic.ItemsSource = db.getTopics(); }
private void BtnSubmit_Click(object sender, RoutedEventArgs e) { user loginUser = new user(txtUsername.Text, txtPassword.Text); DB.Database db = new DB.Database(@"URI=file:C:\Users\Michael Distler\source\repos\WPF_Login\test.db"); // Test log Log.Debug("Button clicked TEST LOGS"); // Check if user exists if (db.userMgt(loginUser, "CheckUserNameExists")) { // Check if password is correct if (db.userMgt(loginUser, "CheckUserPW")) { // Navigate to main window and save current user and get user data from db loginUser = db.getUserData(loginUser); App.Current.Properties["currentUser"] = loginUser; var newWindow = new MainWindow(); this.Close(); newWindow.Show(); } else { lblPasswordCheck.Content = "Password is wrong!"; } } else { lblPasswordCheck.Content = "User does not exist!"; } /* User anlegen * cmd.CommandText = "INSERT INTO user(user_name, password) VALUES(@user_name, @password)"; * cmd.Parameters.AddWithValue("@user_name", txtUsername.Text); * cmd.Parameters.AddWithValue("@password", txtPassword.Text); * cmd.Prepare(); * cmd.ExecuteNonQuery(); * /* Tabelle anlegen * cmd.CommandText = "CREATE TABLE user2(user_id INTEGER PRIMARY KEY, user_name TEXT, password TEXT)"; * cmd.ExecuteNonQuery(); */ //con.Close(); }
private void btn_Click(object sender, RoutedEventArgs e) { //Log.Debug("Combobox: " + cbTopic.Text); //Log.Debug("Combobox: " + cbTopic.SelectedIndex); //Log.Debug("Combobox: " + cbTopic.SelectedItem); //Log.Debug("Combobox: " + cbTopic.SelectedValue); //Log.Debug("Combobox: " + cbTopic.SelectionBoxItem); //Log.Debug("Textfeld: " + txtBoxTopic.Text); // Create new entry and fill it with data Model.Entry entry = new Model.Entry(); user curUser = (user)App.Current.Properties["currentUser"]; entry.user_id = curUser.getID(); entry.typeId = 1; // General Entry, see Database entry.title = txtBoxTitle.Text; entry.entry_abstract = txtBoxDescription.Text; // Content // Topic if (txtBoxTopic.Text == null || txtBoxTopic.Text == "") { entry.topic = cbTopic.Text; Log.Debug("Combobox topic: " + cbTopic.Text); } else { entry.topic = txtBoxTopic.Text; Log.Debug("Textbox topic: " + txtBoxTopic.Text); } entry.topicId = 0; // Tags - später machen !!!!!!! // Save - Check if successful and notify user !!!!!! DB.Database db = new DB.Database(@"URI=file:C:\Users\Michael Distler\source\repos\WPF_Login\test.db"); db.saveEntry(entry); }
private void btnSubmit_Click(object sender, RoutedEventArgs e) { // Check if pw are the same and not empty if ((tboxPassword.Text == tboxPasswordRepeat.Text) && tboxPassword.Text != "") { user newUser = new user(tboxUsername.Text, tboxPassword.Text); DB.Database db = new DB.Database(@"URI=file:C:\Users\Michael Distler\source\repos\WPF_Login\test.db"); if (db.userMgt(newUser, "CreateNewUser")) { lblMessage.Content = "User created! Closing the window in 3 seconds."; //Continue: https://stackoverflow.com/questions/15599884/how-to-put-delay-before-doing-an-operation-in-wpf this.Close(); } else { lblMessage.Content = "Username already exists!"; } } else { lblMessage.Content = "Passwords are different"; } }