Exemplo n.º 1
0
 public bool CheckSysWorkExist(SysWorkModel model)
 {
     using (DataProvider dp = new DataProvider())
     {
         if (!model.Id.HasValue)
         {
             return(dp.PM_SysWork.Count(m => m.WorkNo == model.WorkNo) > 0);
         }
         else
         {
             return(dp.PM_SysWork.Count(m => m.WorkNo == model.WorkNo && m.Id != model.Id.Value) > 0);
         }
     }
 }
Exemplo n.º 2
0
 public bool Save(SysWorkModel model)
 {
     using (DataProvider dp = new DataProvider())
     {
         PM_SysWork entity = null;
         if (model.Id.HasValue)
         {
             entity = data.GetSysWorkById(dp, model.Id.Value);
         }
         if (entity == null)
         {
             model.IsDel      = false;
             model.CreateTime = DateTime.Now;
             dp.PM_SysWork.Add(Mapper.Map <PM_SysWork>(model));
         }
         else
         {
             entity.WorkNo            = model.WorkNo;
             entity.WorkName          = model.WorkName;
             entity.Principal         = model.Principal;
             entity.WorkType          = model.WorkType;
             entity.ProjectLeader     = model.ProjectLeader;
             entity.SpecialConsultant = model.SpecialConsultant;
             entity.FileName          = model.FileName;
             entity.FilePath          = model.FilePath;
             entity.UpdateUser        = model.UpdateUser;
             entity.UpdateTime        = DateTime.Now;
         }
         try
         {
             dp.SaveChanges();
             return(true);
         }
         catch
         {
             throw;
         }
     }
 }
Exemplo n.º 3
0
 public ActionResult Save(SysWorkModel work)
 {
     try
     {
         if (business.CheckSysWorkExist(work))
         {
             return(Json(new JsonMessage(false, "办公编号已存在!")));
         }
         if (work.Id == null)
         {
             work.CreateUser = CurrentUser.Id;
         }
         else
         {
             work.UpdateUser = CurrentUser.Id;
         }
         return(Json(new JsonMessage(business.Save(work))));
     }
     catch (Exception e)
     {
         return(Json(new JsonMessage(false, e.Message)));
     }
 }