protected void btnDelete_Click(object sender, EventArgs e) { using (var context = new PPPKContext()) { int deleteId = int.Parse(ddlServiceItem.SelectedValue); ServiceItem temp = context.ServiceItem.FirstOrDefault(x => x.Id == deleteId); context.ServiceItem.Remove(temp); context.SaveChanges(); context.Dispose(); } InitVehicles(); }
protected void btnAddNewService_Click(object sender, EventArgs e) { using (var context = new PPPKContext()) { context.Service.Add(new Service { Date = DateTime.Now, VehicleID = int.Parse(ddlVehicle.SelectedValue) }); context.SaveChanges(); context.Dispose(); } InitVehicles(); }
protected void btnAddService_Click(object sender, EventArgs e) { using (var context = new PPPKContext()) { context.ServiceItem.Add(new ServiceItem { Price = Decimal.Parse(txtPrice.Text), ServiceName = txtServiceName.Text, ServiceID = int.Parse(ddlService.SelectedValue) }); context.SaveChanges(); context.Dispose(); } InitVehicles(); }
protected void btnSave_Click(object sender, EventArgs e) { using (var context = new PPPKContext()) { ServiceItem s = context.ServiceItem.Find(int.Parse(ddlServiceItem.SelectedValue)); s.Price = Decimal.Parse(txtPrice.Text); s.ServiceName = txtServiceName.Text; s.ServiceID = int.Parse(ddlService.SelectedValue); context.SaveChanges(); context.Dispose(); } InitVehicles(); }