예제 #1
0
 private void btnSpremi_Click(object sender, EventArgs e)
 {
     if (rbDa.Checked == true)
     {
         kuka = true;
     }
     if (rbNe.Checked == true)
     {
         kuka = false;
     }
     using (var db = new RentacarEntities())
     {
         Vozila vozilo = new Vozila
         {
             Marka       = markaTextBox.Text,
             Model       = modelTextBox.Text,
             Godiste     = int.Parse(godisteComboBox.SelectedItem.ToString()),
             Gorivo      = gorivoComboBox.SelectedItem.ToString(),
             BrojSjedala = int.Parse(brojSjedalaTextBox.Text.ToString()),
             DnevniNajam = Convert.ToDecimal(dnevniNajamTextBox.Text),
             Kuka        = kuka,
             Rezerviran  = false
         };
         db.Vozila.Add(vozilo);
         db.SaveChanges();
     }
     Close();
 }
예제 #2
0
        private void btnObrisiAuto_Click(object sender, EventArgs e)
        {
            Vozila vozilo = vozilaBindingSource.Current as Vozila;

            if (vozilo != null)
            {
                using (var db = new RentacarEntities())
                {
                    db.Vozila.Attach(vozilo);
                    db.Vozila.Remove(vozilo);
                    db.SaveChanges();
                }
            }
            PrikaziVozila();
        }