Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data.SqlClient;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- namespace WpfRegistracijaVozila.Forme
- {
- /// <summary>
- /// Interaction logic for frmMarka.xaml
- /// </summary>
- public partial class frmMarka : Window
- {
- public frmMarka()
- {
- InitializeComponent();
- txtNazivMarke.Focus();
- }
- SqlConnection konekcija = Konekcija.KreirajKonekciju();
- private void btnSacuvaj_Click(object sender, RoutedEventArgs e)
- {
- try
- {
- konekcija.Open();
- string insert = @"insert into tblMarka(NazivMarke)
- values('" + txtNazivMarke.Text + "');";
- SqlCommand cmd = new SqlCommand(insert, konekcija);
- cmd.ExecuteNonQuery();
- this.Close();
- }
- catch(SqlException)
- {
- MessageBox.Show("Niste uneli odg vrednosti","Greska",MessageBoxButton.OK,MessageBoxImage.Error);
- }
- finally
- {
- if (konekcija != null) konekcija.Close();
- }
- }
- private void btnOtkaži_Click(object sender, RoutedEventArgs e)
- {
- this.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement