Beispiel #1
0
        public int Save(car mycar)
        {
            Car u;
            bool found = false;

            if (mycar.CarId == -1)
            {
                // new record
                u = new Car();
                db.Car.InsertOnSubmit(u);
                found = true;
            }
            else
            {
                // existing record
                u = (from Mycar in db.Car where Mycar.CarId == mycar.CarId select Mycar).FirstOrDefault();
                if (u != null)
                {
                    found = true;
                    u.CarId = mycar.CarId;
                }
            }
            if (found)
            {
                u.Comment = mycar.Comment;
                u.Driver = mycar.Driver;
                u.DriverEmail = mycar.DriverEmail;
                u.LicenseNumber = mycar.LicenseNumber;
                u.LoadCapacity = mycar.LoadCapacity;
                u.ModelNumber = mycar.ModelNumber;
                u.SeatingNumber = mycar.seatingNumber;
                u.Status = mycar.Status;
                u.UseCarTypeID = mycar.Usecartype.UseCarTypeID;
                try
                {
                    db.SubmitChanges();
                }
                catch (ChangeConflictException)
                {
                    db.ChangeConflicts.ResolveAll(RefreshMode.OverwriteCurrentValues);
                    db.SubmitChanges();
                }
                return u.CarId;
            }
            else
                return -1;
        }
Beispiel #2
0
 private static car FillRecord(Car i)
 {
     car Result = null;
     if (i != null)
     {
         Result = new car();
         Result.CarId = i.CarId;
         Result.Status = i.Status;
         Result.Driver = i.Driver;
         Result.DriverEmail = i.DriverEmail;
         Result.Comment = i.Comment;
         Result.LicenseNumber = i.LicenseNumber;
         Result.ModelNumber = i.LicenseNumber;
         Result.seatingNumber = i.SeatingNumber;
         Result.LoadCapacity = i.LoadCapacity;
         Result.Usecartype = new YunShanOA.DataAccess.UseCar.UsecarTypeHelp().GetUsecarType(i.UseCarTypeID);
     }
     return Result;
 }
 partial void DeleteCar(Car instance);
 partial void UpdateCar(Car instance);
 partial void InsertCar(Car instance);
		private void detach_Car(Car entity)
		{
			this.SendPropertyChanging();
			entity.UseCarType = null;
		}
		private void attach_Car(Car entity)
		{
			this.SendPropertyChanging();
			entity.UseCarType = this;
		}