public int Sava(Model.UseCarModel.usecarapplyform myForm)
        {
            UseCarApplyForm u;
            bool found = false;

            if (myForm.UseCarApplyFormID == -1)
            {
                // new record
                u = new UseCarApplyForm();
                db.UseCarApplyForm.InsertOnSubmit(u);
                found = true;
            }
            else
            {
                // existing record
                u = (from myUseCarApplyForm in db.UseCarApplyForm where myUseCarApplyForm.UseCarApplyFormID == myForm.UseCarApplyFormID select myUseCarApplyForm).FirstOrDefault();
                if (u != null)
                {
                    found = true;
                    int id = (int)myForm.UseCarApplyFormID;
                    u.UseCarApplyFormID = id;
                }
            }
            if (found)
            {
                u.ApplyReason = myForm.ApplyReason;
                u.ApplyUserName = myForm.ApplyUserName;
                u.BeginTime = myForm.BeginTime;
                u.EndTime = myForm.EndTime;
                u.Comment = myForm.Comment;
                u.StartDestination = myForm.StartDestination;
                u.EndDestination = myForm.EndDestination;
                u.UseCarTypeID = myForm.usecartype.UseCarTypeID;
                u.ApplyStatus = myForm.ApplyStatus;
                u.WFID = myForm.WFID;
                try
                {

                    db.SubmitChanges();
                    foreach (usecaranduser usecaranduser in myForm.Usecaranduser)
                    {
                        usecaranduser user = new Model.UseCarModel.usecaranduser();
                        user.UseCarUserId = usecaranduser.UseCarUserId;
                        user.UseCarApplyFormID = u.UseCarApplyFormID;
                        user.Name = usecaranduser.Name;
                        user.Email = usecaranduser.Email;
                        new YunShanOA.DataAccess.UseCar.UsecarAndUserHelp().Save(user);
                    }
                    db.SubmitChanges();
                }
                catch (ChangeConflictException)
                {
                    db.ChangeConflicts.ResolveAll(RefreshMode.OverwriteCurrentValues);
                    db.SubmitChanges();
                }
                return u.UseCarApplyFormID;
            }
            else
                return -1;
        }
 private Model.UseCarModel.usecarapplyform FillRecord(UseCarApplyForm i)
 {
     usecarapplyform result = null;
     if (i != null)
     {
         result = new usecarapplyform();
         result.UseCarApplyFormID = i.UseCarApplyFormID;
         result.ApplyUserName = i.ApplyUserName;
         result.usecartype = new YunShanOA.DataAccess.UseCar.UsecarTypeHelp().GetUsecarType(i.UseCarTypeID);
         result.WFID = i.WFID;
         result.BeginTime = i.BeginTime;
         result.EndTime = i.EndTime;
         result.StartDestination = i.StartDestination;
         result.EndDestination = i.EndDestination;
         result.ApplyReason = i.ApplyReason;
         result.ApplyStatus = i.ApplyStatus;
         result.Comment = i.Comment;
         result.Usecaranduser = new YunShanOA.DataAccess.UseCar.UsecarAndUserHelp().GetCarAndUserlistByFormID(i.UseCarApplyFormID);
     }
     return result;
 }
		private void detach_UseCarApplyForm(UseCarApplyForm entity)
		{
			this.SendPropertyChanging();
			entity.UseCarType = null;
		}
 partial void DeleteUseCarApplyForm(UseCarApplyForm instance);
 partial void UpdateUseCarApplyForm(UseCarApplyForm instance);
 partial void InsertUseCarApplyForm(UseCarApplyForm instance);