/// <summary> /// 生成拼接sql参数列表 /// </summary> /// <param name="entity"></param> /// <returns></returns> public List <SqlParameter> ParseToSqlParameters(searchAppUpdateEntity entity) { List <SqlParameter> paraList = new List <SqlParameter>(); //table paraList.Add(CPTable(entity)); //fields paraList.Add(CPFields(entity)); //filter_SqlWhere paraList.Add(CPWhere(entity)); //order paraList.Add(CPOrder(entity)); //pagesize paraList.Add(new SqlParameter("@pageSize", entity.PageSize)); //pageindex paraList.Add(new SqlParameter("@pageIndex", entity.PageIndex)); paraList.Add(new SqlParameter() { ParameterName = "@Records", Value = 0, Direction = ParameterDirection.Output }); return(paraList); }
public DataTable GetAppUpdateList(searchAppUpdateEntity entity, out int totalcnt) { DataTable table = null; totalcnt = 0; try { SqlParameter[] prms = ParseToSqlParameters(entity).ToArray(); if (entity.UseDBPagination) { table = SQlHelper.ExecuteDataset(SQlHelper.MyConnectStr, CommandType.StoredProcedure, "sp_pager06", prms).Tables[0]; totalcnt = int.Parse(prms[prms.Length - 1].Value.ToString()); } else { throw new NotImplementedException(); } } catch (Exception ex) { totalcnt = -1; LogUtil.WriteLog(ex); } return(table); }
private DataTable GetQueryData(bool isDownload) { searchAppUpdateEntity entity = new searchAppUpdateEntity(); int totalcnt = 0; int AppType = 0; BCtrl_Common bll = new BCtrl_Common(); if (!string.IsNullOrEmpty(txtStartTime)) { string.Format("{0} 00:00:00", txtStartTime); entity.txtStartTime = txtStartTime; } if (!string.IsNullOrEmpty(txtEndTime)) { string.Format("{0} 23:59:59", txtEndTime); entity.txtEndTime = txtEndTime; } if (!string.IsNullOrEmpty(txtVersion)) { entity.txtVersion = txtVersion; } int.TryParse(selAppType, out AppType); entity.selAppType = AppType; entity.PageSize = base.PageSize; entity.PageIndex = base.PageIndex; entity.UseDBPagination = !isDownload; entity.OrderfieldType = OrderFieldType.Desc; DataTable db = bll.GetAppUpdateList(entity, out totalcnt); base.TotalRecords = totalcnt; return(db); }
/// <summary> /// 设置表关联 /// </summary> /// <param name="entity"></param> /// <returns></returns> private SqlParameter CPTable(searchAppUpdateEntity entity) { StringBuilder sbtable = new StringBuilder(); //基本表 sbtable.Append(" M_AppUpdate "); return(new SqlParameter("@TableName", sbtable.ToString())); }
/// <summary> /// 设置显示字段 /// </summary> /// <param name="entity"></param> /// <returns></returns> private SqlParameter CPFields(searchAppUpdateEntity entity) { StringBuilder sbfileds = new StringBuilder(); if (entity.UseDBPagination) { sbfileds.Append(@" appId,appType,version,downloadUrl,forcedUpdate,convert(varchar(19),createTime,121) as createTime,appSize,updateProfile"); } else { throw new NotImplementedException(); } return(new SqlParameter("@Fields", sbfileds.ToString())); }
/// <summary> /// 设置排序 /// </summary> /// <param name="enity"></param> /// <returns></returns> private SqlParameter CPOrder(searchAppUpdateEntity enity) { StringBuilder sborder = new StringBuilder(); if (enity.OrderfieldType == OrderFieldType.Desc) { sborder.Append(" createTime DESC "); } else { sborder.Append(" createTime ASC "); } return(new SqlParameter("@OrderField", sborder.ToString())); }
/// <summary> /// 查询条件 /// </summary> /// <param name="entity"></param> /// <returns></returns> private SqlParameter CPWhere(searchAppUpdateEntity entity) { StringBuilder sbwhere = new StringBuilder("1=1"); if (entity.selAppType != 0) { sbwhere.Append("and appType='" + entity.selAppType + "'"); } if (!string.IsNullOrEmpty(entity.txtVersion)) { sbwhere.Append("and version='" + entity.txtVersion + "'"); } if (!string.IsNullOrEmpty(entity.txtStartTime)) { sbwhere.Append("and createTime >='" + entity.txtStartTime + "'"); } if (!string.IsNullOrEmpty(entity.txtEndTime)) { sbwhere.Append("and createTime <='" + entity.txtEndTime + "'"); } return(new SqlParameter("@sqlWhere", sbwhere.ToString())); }
public DataTable GetAppUpdateList(searchAppUpdateEntity entity, out int totalcnt) { return(commonobj.GetAppUpdateList(entity, out totalcnt)); }