Esempio n. 1
0
 /// <summary>
 /// 添加车辆
 /// </summary>
 public int AddCar(QW_CarsModel model)
 {
     using (Entities db = new Entities())
     {
         qw_cars qcmodel = db.qw_cars.FirstOrDefault(a => a.carnumber == model.carnumber || a.code == model.code);
         if (qcmodel != null)
         {
             return(-1);
         }
         else
         {
             qw_cars cmodel = new qw_cars();
             cmodel.carid        = model.carid;
             cmodel.code         = model.code;
             cmodel.carstatus    = model.carstatus;
             cmodel.cartypeid    = model.cartypeid;
             cmodel.unitid       = model.unitid;
             cmodel.carnumber    = model.carnumber;
             cmodel.cartel       = model.cartel;
             cmodel.isonline     = model.isonline;
             cmodel.createuserid = model.createuserid;
             cmodel.createtime   = DateTime.Now;
             cmodel.status       = model.status;
             cmodel.ssbc         = model.ssbc;
             db.qw_cars.Add(cmodel);
             db.SaveChanges();
             return(cmodel.carid);
         }
     }
 }
Esempio n. 2
0
 /// <summary>
 /// 修改车辆
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int EditCar(QW_CarsModel model)
 {
     using (Entities db = new Entities())
     {
         IQueryable <qw_cars> qcoldmodel = db.qw_cars.Where(a => a.carnumber == model.carnumber || a.code == model.code);
         int count = qcoldmodel.Where(a => a.carid != model.carid).Count();
         if (count != 0)
         {
             return(-1);
         }
         else
         {
             qw_cars qcmodel = db.qw_cars.FirstOrDefault(a => a.carid == model.carid);
             if (qcmodel != null)
             {
                 qcmodel.code         = model.code;
                 qcmodel.carstatus    = model.carstatus;
                 qcmodel.cartypeid    = model.cartypeid;
                 qcmodel.unitid       = model.unitid;
                 qcmodel.carnumber    = model.carnumber;
                 qcmodel.cartel       = model.cartel;
                 qcmodel.createuserid = model.createuserid;
                 qcmodel.ssbc         = model.ssbc;
             }
         }
         return(db.SaveChanges());
     }
 }
Esempio n. 3
0
 /// <summary>
 /// 删除车辆
 /// </summary>
 /// <param name="carid"></param>
 /// <returns></returns>
 public int DeleteCar(int carid)
 {
     using (Entities db = new Entities())
     {
         qw_cars qcmodel = db.qw_cars.FirstOrDefault(a => a.carid == carid);
         if (qcmodel != null)
         {
             qcmodel.status = 1;
         }
         return(db.SaveChanges());
     }
 }