public List<OrderSlaveMasterQuery> GetSlaveByMasterId(OrderSlaveMasterQuery store)
 {
     try
     {
         return _orderSlaveMasterDao.GetSlaveByMasterId(store);
     }
     catch (Exception ex)
     {
         throw new Exception("OrderSlaveMasterMgr-->GetSlaveByMasterId-->" + ex.Message, ex);
     }
 }
 public List<OrderSlaveMasterQuery> GetBatchList(OrderSlaveMasterQuery store, out int totalCount)
 {
     try
     {
         return _orderSlaveMasterDao.GetBatchList(store, out totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("OrderSlaveMasterMgr-->GetBatchList-->" + ex.Message, ex);
     }
 }
        public List<OrderSlaveMasterQuery> GetBatchList(OrderSlaveMasterQuery store, out int totalCount)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlCondi = new StringBuilder();

            totalCount = 0;
            try
            {//
                sql.Append(@"SELECT	osm.slave_master_id,osm.code_num,osm.paper,osm.order_freight_normal,osm.order_freight_low, ");
                sql.Append(@" osm.normal_subtotal,osm.hypothermia_subtotal,osm.deliver_store,osm.deliver_code,FROM_UNIXTIME(osm.deliver_time) as deliver_date, ");
                sql.Append(@" osm.deliver_note,FROM_UNIXTIME(osm.createdate) as create_date,osm.creator,osm.on_check,v.vendor_name_simple,t_type.parameterName as deliver_name");
                sqlCondi.Append(@"  FROM order_slave_master osm ");
                sqlCondi.Append(@" INNER JOIN vendor  v on osm.creator=v.vendor_id ");
                sqlCondi.Append(@"  LEFT JOIN (SELECT parameterName,parameterCode from  t_parametersrc  where parameterType='Deliver_Store') as t_type on t_type.parameterCode=osm.deliver_store ");
                sqlCondi.Append(@" WHERE 1=1 ");
                if (!string.IsNullOrEmpty(store.code_num))
                {
                    sqlCondi.AppendFormat(" AND osm.code_num like '%{0}%'", store.code_num);
                }
                if (!string.IsNullOrEmpty(store.vendor_name_simple))
                {
                    sqlCondi.AppendFormat(" AND v.vendor_name_simple like '%{0}%'", store.vendor_name_simple);
                }
                if (store.is_check != -1)
                {
                    sqlCondi.AppendFormat(" AND osm.on_check ='{0}'", store.on_check);
                }
                if (store.date_type == 1)
                {
                    sqlCondi.AppendFormat(" AND osm.createdate >='{0}' AND osm.createdate<='{1}'", store.date_start, store.date_end);
                }
                else if (store.date_type == 2)
                {
                    sqlCondi.AppendFormat(" AND osm.deliver_time >='{0}' AND osm.deliver_time<='{1}'", store.date_start, store.date_end);
                }
                sqlCondi.Append(@" ORDER BY  osm.code_num DESC");
                if (store.IsPage)
                {
                    System.Data.DataTable _dt = _dbAccess.getDataTable(string.Format(" select count(1) as totalCount from ( SELECT osm.slave_master_id {0} ) t", sqlCondi.ToString()));
                    if (_dt != null && _dt.Rows.Count > 0)
                    {
                        totalCount = int.Parse(_dt.Rows[0]["totalCount"].ToString());
                    }
                    sqlCondi.AppendFormat(" limit {0},{1}", store.Start, store.Limit);
                }
                sql.Append(sqlCondi.ToString());
                return _dbAccess.getDataTableForObj<OrderSlaveMasterQuery>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("OrderSlaveMasterDao-->GetBatchList-->" + ex.Message + sql.ToString(), ex);
            }
        }
        public List<OrderSlaveMasterQuery> GetSlaveByMasterId(OrderSlaveMasterQuery store)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlCondi = new StringBuilder();


            try
            {//
                sql.Append(@"SELECT	osd.slave_id , om.order_id   ");
                sqlCondi.Append(@"  FROM order_slave_detail osd,order_slave_master osm,order_master om,order_slave os ");
                sqlCondi.Append(@" WHERE osd.slave_master_id = osm.slave_master_id  AND om.order_id = os.order_id AND osd.slave_id = os.slave_id   ");
                if (store.slave_master_id != 0)
                {
                    sqlCondi.AppendFormat(" AND osd.slave_master_id ='{0}'", store.slave_master_id);
                }

                sql.Append(sqlCondi.ToString());
                return _dbAccess.getDataTableForObj<OrderSlaveMasterQuery>(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("OrderSlaveMasterDao-->GetSlaveByMasterId-->" + ex.Message + sql.ToString(), ex);
            }
        }
        public HttpResponseBase GetBatchDetailList()
        {
            string jsonStr = String.Empty;
            StringBuilder sb = new StringBuilder();
            uint isTranUint = 0;
            try
            {
                _orderSlaveMasterMgr = new OrderSlaveMasterMgr(mySqlConnectionString);
                List<OrderSlaveMasterQuery> detailStore = new List<OrderSlaveMasterQuery>();
                OrderSlaveMasterQuery query = new OrderSlaveMasterQuery();
                if (uint.TryParse(Request.Params["slave_master_id"], out isTranUint))
                {
                    string slaveStr = string.Empty;
                    query.slave_master_id = Convert.ToUInt32(Request.Params["slave_master_id"]);
                    List<OrderSlaveMasterQuery> store = _orderSlaveMasterMgr.GetSlaveByMasterId(query);
                    foreach (var item in store)
                    {
                        slaveStr += item.slave_id + ",";
                    }
                    slaveStr = slaveStr.Substring(0, slaveStr.Length - 1);
                    detailStore = _orderSlaveMasterMgr.GetDetailBySlave(slaveStr);
                    int j = 0;
                    for (int i = 1; i < detailStore.Count; i++)
                    {

                        j = i - 1;
                        while (detailStore[j].order_id == 0 && j > 0)
                        {
                            j = j - 1;
                        }
                        if (detailStore[i].order_id == detailStore[j].order_id)
                        {
                            detailStore[i].order_id = 0;
                        }
                        if (detailStore[i].slave_id == detailStore[j].slave_id)
                        {
                            detailStore[i].slave_id = 0;
                        }
                    }
                }

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                jsonStr = "{success:true,data:" + JsonConvert.SerializeObject(detailStore, 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);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase GetBatchList()
        {
            string jsonStr = String.Empty;
            StringBuilder sb = new StringBuilder();
            int isTranUint = 0;
            try
            {
                _orderSlaveMasterMgr = new OrderSlaveMasterMgr(mySqlConnectionString);

                OrderSlaveMasterQuery query = new OrderSlaveMasterQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                if (!string.IsNullOrEmpty(Request.Params["searchType"]))
                {
                    if (Request.Params["searchType"].ToString() == "1")
                    {
                        query.code_num = Request.Params["searchContent"].ToString();
                    }
                    else if (Request.Params["searchType"].ToString() == "2")
                    {
                        query.vendor_name_simple = Request.Params["searchContent"].ToString();
                    }
                }
                if (int.TryParse(Request.Params["status"], out isTranUint))
                {
                    if (Request.Params["status"].ToString() != "-1")
                    {
                        query.is_check = 1;//在條件中加入on_chack搜索
                        query.on_check = Convert.ToUInt32(Request.Params["status"]);
                    }
                    else
                    {
                        query.is_check = -1;
                    }

                }
                if (int.TryParse(Request.Params["dateType"], out isTranUint))
                {
                    query.date_type = Convert.ToUInt32(Request.Params["dateType"]);
                    query.date_start = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["dateStart"]));
                    query.date_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["dateEnd"]));

                }
                int totalCount = 0;
                List<OrderSlaveMasterQuery> store = _orderSlaveMasterMgr.GetBatchList(query, out totalCount);


                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                jsonStr = "{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);
                jsonStr = "{success:false,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }