private void btnSaveChanges_Click(object sender, EventArgs e)
        {
            CarRentalEntities _db = new CarRentalEntities();

            var newCar = new TypeOfCar
            {
                Make            = txtMake.Text,
                Model           = txtModel.Text,
                Year            = int.Parse(txtYear.Text),
                LicensePlateNum = txtLicensePlateNum.Text
            };

            if (isEditMode == false)
            {
                //Add
                _db.TypeOfCars.Add(newCar);
            }
            else
            {
                // Edit

                int id  = int.Parse(lbID.Text);
                var car = _db.TypeOfCars.Find(id);
                if (car != null)
                {
                    car.Make            = txtMake.Text;
                    car.Model           = txtModel.Text;
                    car.Year            = int.Parse(txtYear.Text);
                    car.LicensePlateNum = txtLicensePlateNum.Text;
                }
            }
            _db.SaveChanges();
            _manageVehicleListing.PopulateGrid();

            // ManageVehicleListing gridPage = new ManageVehicleListing();
            // gridPage.PopulateGrid();
            this.Close();
        }
Beispiel #2
0
 public ManageRentalRecords()
 {
     InitializeComponent();
     _db = new CarRentalEntities();
     PopulateGrid();
 }
 public ManageVehicleListing()
 {
     InitializeComponent();
     _db = new CarRentalEntities();
 }
Beispiel #4
0
 public AddRentalRecord()
 {
     InitializeComponent();
     tbmCost.Text      = "350.00";
     carRentalEntities = new CarRentalEntities();
 }
Beispiel #5
0
 public Login()
 {
     InitializeComponent();
     _db = new CarRentalEntities();
 }