// TODO: Update database (rating) private void Rate(object sender, RoutedEventArgs e) { // Update with int chosenRating using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME, GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD)) { if (db.Open()) { // select the provider first IPreparedStatement provStmt = new GetProviderIDStatement(providerName); provStmt.Prepare(db.connection); using (var reader = db.ExecutePreparedStatementReader(provStmt)) { if (reader != null && reader.HasRows) { reader.Read(); providerID = reader.GetInt32(0); } } // now rate the provider int userID = GlobalVariables.User.Id; IPreparedStatement stmt = new VendorRatingStatement(userID, providerID, chosenRating); stmt.Prepare(db.connection); db.ExecutePreparedStatementNonQuery(stmt); } } Window.Current.Close(); }
private void Send(object sender, RoutedEventArgs e) { string question = questionBox.Text; using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME, GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD)) { if (db.Open()) { int ID = GlobalVariables.User.Id; IPreparedStatement stmt = new CreateFragenStatement(question, ID); stmt.Prepare(db.connection); db.ExecutePreparedStatementNonQuery(stmt); StatusMessage.Text = "New question was send, you will soon get an answer :-)"; } } }
// TODO: Update database private void Button_Click(object sender, RoutedEventArgs e) { username = UsernameBox.Text; password = pwBox.Password; birthday = DateBox.Date.Date; residence = AddressBox.Text; using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME, GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD)) { if (db.Open()) { IPreparedStatement stmt = new CreateUserStatement(username, password, birthday, residence); stmt.Prepare(db.connection); db.ExecutePreparedStatementNonQuery(stmt); } else { } } }
private void Update_Click(object sender, RoutedEventArgs e) { using (var db = new InsuranceDataBaseAccess(GlobalVariables.DATABASE.SERVERNAME, GlobalVariables.DATABASE.USERNAME, GlobalVariables.DATABASE.PASSWORD)) { if (db.Open()) { //TODO: pass user data to stmt IPreparedStatement stmt = new UpdateUserStatement("Max Mustermann", "Password123", DateTime.UtcNow, "Wolfsburg"); stmt.Prepare(db.connection); if (db.ExecutePreparedStatementNonQuery(stmt) == 1) { //TODO: print success } else { //TODO: print error } } } }