public List<LogisticsDetailQuery> GetLogistics(LogisticsDetailQuery store, out int totalCount) { try { return _tabshowdao.GetLogistics(store, out totalCount); } catch (Exception ex) { throw new Exception("TabShowMgr-->GetLogistics-->" + ex.Message, ex); } }
public HttpResponseBase GetLogistics() { string json = string.Empty; LogisticsDetailQuery query = new LogisticsDetailQuery(); query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 if (!string.IsNullOrEmpty(Request.Params["Order_Id"])) { query.order_id = Request.Params["Order_Id"]; } try { List<LogisticsDetailQuery> store = new List<LogisticsDetailQuery>(); _tbshow = new TabShowMgr(mySqlConnectionString); int totalCount = 0; store = _tbshow.GetLogistics(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, 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:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public List<LogisticsDetailQuery> GetLogistics(LogisticsDetailQuery store, out int totalCount) { StringBuilder sb = new StringBuilder(); StringBuilder sqlCondi = new StringBuilder(); try { sb.Append(@" SELECT ld.rid,ld.deliver_id,ld.set_time,tp.parameterName as delivery_store_name ,tps.parameterName as logistics_type "); sqlCondi.Append(" FROM logistics_detail ld INNER JOIN deliver_master dm on dm.deliver_id = ld.deliver_id"); sqlCondi.Append(" left join (select parameterCode,parameterName from t_parametersrc where parameterType='Deliver_Store') tp on tp.parameterCode=ld.delivery_store_id "); sqlCondi.Append(" left join (select parameterCode,parameterName from t_parametersrc where parameterType='logistics_type') tps on tps.parameterCode=ld.logisticsType "); sqlCondi.Append(" where 1=1 "); if (!string.IsNullOrEmpty(store.order_id)) { sqlCondi.AppendFormat(" and dm.order_id = '{0}' ",store.order_id); } sqlCondi.Append(" ORDER BY ld.deliver_id,ld.rid ASC "); totalCount = 0; string sqlcount = " select count(ld.rid) as totalCount " + sqlCondi.ToString(); if (store.IsPage) { System.Data.DataTable _dt = _access.getDataTable(sqlcount); if (_dt != null && _dt.Rows.Count > 0) { totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]); } sqlCondi.AppendFormat(" limit {0},{1}", store.Start, store.Limit); } return _access.getDataTableForObj<LogisticsDetailQuery>(sb.ToString() + sqlCondi.ToString()); } catch (Exception ex) { throw new Exception("TabShowDao-->GetLogistics " + ex.Message + sb.ToString(), ex); } }