private void BtPrelungeste_Click(object sender, RoutedEventArgs e) { connectionString = Properties.Settings.Default.CazareDBConnectionString; string quary; quary = "UPDATE Turisti SET ziuaP = @ziua, lunaP = @luna, anulP = @anul WHERE codT = @cod"; try { using (SqlConnection conn = new SqlConnection(connectionString)) { SqlCommand command = new SqlCommand(quary, conn); command.Parameters.AddWithValue("@ziua", tbZiua.Text); command.Parameters.AddWithValue("@luna", tbLuna.Text); command.Parameters.AddWithValue("@anul", tbAnul.Text); command.Parameters.AddWithValue("@cod", tbCod.Text); if (tbZiua.Text == "" || tbLuna.Text == "" || tbAnul.Text == "" || tbCod.Text == "") { MessageBox.Show("Introdu toate datele."); } else { dataGrid.ItemsSource = null; conn.Open(); command.ExecuteNonQuery(); SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Turisti", conn); DataTable dt = new DataTable(); adapter.Fill(dt); dataGrid.ItemsSource = dt.DefaultView; conn.Close(); MessageBox.Show("Termenul a fost prelungit"); tbZiua.Text = ""; tbLuna.Text = ""; tbAnul.Text = ""; tbCod.Text = ""; } } } catch (Exception) { MessageBox.Show("Eroare! Incorect formatul de date."); prelungeste = new prelungesteSejurul(); this.Close(); prelungeste.Show(); } }
private void btnPrelSej_Click(object sender, RoutedEventArgs e) { prelungesteSejurul = new prelungesteSejurul(); prelungesteSejurul.Show(); this.Close(); }