Exemplo n.º 1
0
 /// <summary>
 /// 新增车辆
 /// </summary>
 public static void Insert(CoCar car)
 {
     try
     {
         LDLLogisticsEntities context = new LDLLogisticsEntities();
         //查找该车辆是否存在
         if (context.CoCar.Any(obj => obj.Code == car.Code && car.Valid == true))
             throw new FaultException(string.Format("车辆编码[{0}]已存在!", car.Code));
         context.CoCar.AddObject(car);    //新增
         context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoCarAdapter01", Define.Insert, car));   //记录日志
         context.SaveChanges();  //提交保存
     }
     catch (Exception ex)
     {
         throw new FaultException(ex.Message);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// 修改车辆
        /// </summary>
        public static void Update(CoCar car)
        {
            try
            {
                LDLLogisticsEntities context = new LDLLogisticsEntities();
                //查找该车辆是否存在
                CoCar _car = context.CoCar.FirstOrDefault(obj => obj.ID == car.ID);
                if (_car == null)
                    throw new FaultException(string.Format("该车辆[{0}]不存在!", car.LicenseNumber));
                EntityObjectHelper.Copyto(car, ref _car); //利用反射动态赋值

                context.SysOperationLog.AddObject(SysOperationLogAdapter.GetOperationtLog("CoCarAdapter03", Define.Update, _car));   //记录日志
                context.SaveChanges();  //提交保存
            }
            catch (Exception ex)
            {
                throw new FaultException(ex.Message);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 创建新的 CoCar 对象。
 /// </summary>
 /// <param name="id">ID 属性的初始值。</param>
 /// <param name="code">Code 属性的初始值。</param>
 /// <param name="licenseNumber">LicenseNumber 属性的初始值。</param>
 /// <param name="siteCode">SiteCode 属性的初始值。</param>
 /// <param name="valid">Valid 属性的初始值。</param>
 public static CoCar CreateCoCar(global::System.Int32 id, global::System.String code, global::System.String licenseNumber, global::System.String siteCode, global::System.Boolean valid)
 {
     CoCar coCar = new CoCar();
     coCar.ID = id;
     coCar.Code = code;
     coCar.LicenseNumber = licenseNumber;
     coCar.SiteCode = siteCode;
     coCar.Valid = valid;
     return coCar;
 }
Exemplo n.º 4
0
 /// <summary>
 /// 用于向 CoCar EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet&lt;T&gt; 属性的 .Add 方法。
 /// </summary>
 public void AddToCoCar(CoCar coCar)
 {
     base.AddObject("CoCar", coCar);
 }
Exemplo n.º 5
0
 public void UpdateCar(CoCar car)
 {
     CoCarAdapter.Update(car);
 }
Exemplo n.º 6
0
 public void InsertCar(CoCar car)
 {
     CoCarAdapter.Insert(car);
 }