Advertisement
Guest User

Untitled

a guest
Dec 7th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.SqlClient;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Windows;
  8. using System.Windows.Controls;
  9. using System.Windows.Data;
  10. using System.Windows.Documents;
  11. using System.Windows.Input;
  12. using System.Windows.Media;
  13. using System.Windows.Media.Imaging;
  14. using System.Windows.Shapes;
  15.  
  16. namespace WpfRegistracijaVozila.Forme
  17. {
  18. /// <summary>
  19. /// Interaction logic for frmMarka.xaml
  20. /// </summary>
  21. public partial class frmMarka : Window
  22. {
  23.  
  24. public frmMarka()
  25. {
  26. InitializeComponent();
  27. txtNazivMarke.Focus();
  28. }
  29. SqlConnection konekcija = Konekcija.KreirajKonekciju();
  30. private void btnSacuvaj_Click(object sender, RoutedEventArgs e)
  31. {
  32. try
  33. {
  34. konekcija.Open();
  35. string insert = @"insert into tblMarka(NazivMarke)
  36. values('" + txtNazivMarke.Text + "');";
  37. SqlCommand cmd = new SqlCommand(insert, konekcija);
  38. cmd.ExecuteNonQuery();
  39. this.Close();
  40.  
  41. }
  42. catch(SqlException)
  43. {
  44. MessageBox.Show("Niste uneli odg vrednosti","Greska",MessageBoxButton.OK,MessageBoxImage.Error);
  45. }
  46. finally
  47. {
  48. if (konekcija != null) konekcija.Close();
  49. }
  50.  
  51. }
  52.  
  53. private void btnOtkaži_Click(object sender, RoutedEventArgs e)
  54. {
  55. this.Close();
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement