/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(cloud_componentrepairrecord model, cloud_componentrepairrecordhistory modelhistory) { //带事务的更新(当有复杂层级关系修改时候用到事物z在放开,单表操作不需要事物) IDatabase database = DataFactory.Database(); DbTransaction isOpenTrans = database.BeginTrans(); int i = 0; bool isok = false; StringBuilder strSql = new StringBuilder(); if (model != null) { strSql.Append(" update cloud_componentrepairrecord "); strSql.Append(" SET "); strSql.Append(string.Format(" StartTime = '{0}', ", model.StartTime)); strSql.Append(string.Format(" EndTime = '{0}' ,", model.EndTime)); strSql.Append(string.Format(" UpdateUserId = '{0}' ", model.UpdateUserId)); strSql.Append(" where "); strSql.Append(string.Format(" Id = '{0}'; ", model.Id)); //更新记录写入到维修记录表 strSql.Append(" insert into cloud_componentrepairrecordhistory "); strSql.Append(" ( "); strSql.Append(" Id,"); strSql.Append(" EquipmentId, "); strSql.Append(" Cloud_componentId, "); strSql.Append(" UserId, "); strSql.Append(" HistoryTime, "); strSql.Append(" NextTime, "); strSql.Append(" CreateTime "); strSql.Append(" ) "); strSql.Append(" values"); strSql.Append(" ("); strSql.Append(string.Format(" '{0}', ", modelhistory.Id)); strSql.Append(string.Format(" '{0}', ", modelhistory.EquipmentId)); strSql.Append(string.Format(" '{0}', ", modelhistory.Cloud_componentId)); strSql.Append(string.Format(" '{0}', ", modelhistory.UserId)); strSql.Append(string.Format(" '{0}', ", model.StartTime)); strSql.Append(string.Format(" '{0}', ", model.EndTime)); strSql.Append(string.Format(" '{0}' ", modelhistory.CreateTime)); strSql.Append(" );"); } i = Repository().UpdateBySql(strSql.ToString(), isOpenTrans);//isOpenTrans(不需要事务的时候就传入null) if (i > 0) { isok = true; database.Commit(); } else { database.Rollback(); } return(isok); }
//获取实体 public cloud_componentrepairrecordhistory QueryObject(cloud_componentrepairrecordhistory model) { IList <cloud_componentrepairrecordhistory> list = cloud_componentrepairrecordhistoryDal.getcloud_componentrepairrecordhistoryList(model); if (list.Count > 0) { return(list[0]); } else { return(null); } }
/// <summary> /// 返回总条数 /// </summary> /// <param name="model"></param> /// <returns></returns> public int GetRecordCount(cloud_componentrepairrecordhistory model) { return(cloud_componentrepairrecordhistoryDal.GetRecordCount(model)); #region 缓存用法 //int totalItems = 0; //object obj = CacheHelper.GetCache("cloud_componentrepairrecordhistoryBLL_GetRecordCount"); //key一定要设置的有规律不重复类名+方法名 //if (obj != null) //{ // totalItems = (int)obj; //} //else //{ // totalItems = cloud_componentrepairrecordhistoryDal.GetRecordCount(model); // CacheHelper.SetCacheAbsolute("cloud_componentrepairrecordhistoryBLL_GetRecordCount", totalItems);//写入服务器缓存 //} //return totalItems; #endregion }
/// <summary> /// 获取DataTable列表 /// </summary> /// <param name="model"></param> /// <returns></returns> public DataTable getPageList(cloud_componentrepairrecordhistory model) { return(cloud_componentrepairrecordhistoryDal.getPageList(model)); #region 缓存用法 //DataTable dt = null; //object obj = CacheHelper.GetCache("cloud_componentrepairrecordhistoryBLL_getPageList"); //key一定要设置的有规律不重复类名+方法名 //if (obj != null) //{ // dt = (DataTable)obj; //} //else //{ // dt = cloud_componentrepairrecordhistoryDal.getPageList(model); // CacheHelper.SetCacheAbsolute("cloud_componentrepairrecordhistoryBLL_getPageList", dt);//写入服务器缓存 //} //return dt; #endregion }
//查询List public IList <cloud_componentrepairrecordhistory> getcloud_componentrepairrecordhistoryList(cloud_componentrepairrecordhistory model) { IList <cloud_componentrepairrecordhistory> list = new List <cloud_componentrepairrecordhistory>(); try { list = cloud_componentrepairrecordhistoryDal.getcloud_componentrepairrecordhistoryList(model); } catch { list = null; } return(list); }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(cloud_componentrepairrecordhistory model) { return(cloud_componentrepairrecordhistoryDal.Update(model)); }
/// <summary> /// 新增 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Insert(cloud_componentrepairrecordhistory model) { return(cloud_componentrepairrecordhistoryDal.Insert(model)); }
/// <summary> /// 更新 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool Update(cloud_componentrepairrecord model, cloud_componentrepairrecordhistory modelhistory) { return(cloud_componentrepairrecordDal.Update(model, modelhistory)); }