public DataTable GetIdiffCountBookList(IdiffcountbookQuery idiffQuery, out int totalCount) { try { return idiffDao.GetIdiffCountBookList(idiffQuery, out totalCount); } catch (Exception ex) { throw new Exception("IdiffcountbookMgr-->GetIdiffCountBookList-->" + ex.Message, ex); } }
public DataTable GetIdiffCountBookList(IdiffcountbookQuery idiffQuery, out int totalCount) { StringBuilder sql = new StringBuilder(); StringBuilder sqlcount = new StringBuilder(); StringBuilder sqlcondition = new StringBuilder(); totalCount = 0; try { sql.Append(@"SELECT icb.book_id,icb.cb_jobid,icb.loc_id,icb.pro_qty,icb.st_qty,icb.create_time,icb.item_id,icb.made_date,icb.cde_dt,mu.user_username FROM idiff_count_book icb LEFT JOIN manage_user mu on icb.create_user=mu.user_id where 1=1 "); sqlcount.Append(@"SELECT icb.book_id FROM idiff_count_book icb LEFT JOIN manage_user mu on icb.create_user=mu.user_id where 1=1 "); if (!string.IsNullOrEmpty(idiffQuery.loc_id)) { sql.AppendFormat(" and icb.loc_id like '%{0}%' ",idiffQuery.loc_id); } if (idiffQuery.item_id!=0) { sql.AppendFormat(" and icb.item_id='{0}' ", idiffQuery.item_id); } if (!string.IsNullOrEmpty(idiffQuery.cb_jobid)) { sql.AppendFormat(" and icb.cb_jobid like '%{0}%' ", idiffQuery.cb_jobid); } if (idiffQuery.IsPage) { System.Data.DataTable _dt = _access.getDataTable(sqlcount.ToString()+sqlcondition.ToString()); if (_dt != null && _dt.Rows.Count > 0) { totalCount = _dt.Rows.Count; } sqlcondition.AppendFormat(" order by icb.book_id limit {0},{1};", idiffQuery.Start, idiffQuery.Limit); } return _access.getDataTable(sql.ToString()+sqlcondition.ToString()); } catch (Exception ex) { throw new Exception("IdiffcountbookDao-->GetIdiffCountBookList-->" + ex.Message + sql.ToString()+sqlcondition.ToString(), ex); } }
public HttpResponseBase GetIdiffCountBookList() { string json = string.Empty; IdiffcountbookQuery idiffQuery = new IdiffcountbookQuery(); idiffQuery.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 idiffQuery.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 if (!string.IsNullOrEmpty(Request.Params["s_job_id"].Trim())) { idiffQuery.cb_jobid = Request.Params["s_job_id"].Trim(); } if (!string.IsNullOrEmpty(Request.Params["s_item_id"].Trim())) { idiffQuery.item_id = Convert.ToInt32(Request.Params["s_item_id"].Trim()); } if (!string.IsNullOrEmpty(Request.Params["s_loc_id"].Trim())) { idiffQuery.loc_id = Request.Params["s_loc_id"].Trim(); } try { DataTable _dtstore = new DataTable(); IdiffcountbookMgr idiffMgr = new IdiffcountbookMgr(mySqlConnectionString); int totalCount = 0; _dtstore = idiffMgr.GetIdiffCountBookList(idiffQuery, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; IinvdMgr iinvdMgr = new IinvdMgr(mySqlConnectionString); json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(_dtstore, Formatting.Indented, timeConverter) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }