Пример #1
0
        //理貨列表
        public HttpResponseBase GetAseldList()
        {
            string json = string.Empty;
            OrderMasterQuery oderMaster = new OrderMasterQuery();
            oderMaster.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
            oderMaster.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["type_id"]))//判斷id是不是存在.也就是說是否選擇了運送方式.當id不為0時表示選擇了運送方式.
                {

                    List<OrderMasterQuery> store = new List<OrderMasterQuery>();
                    List<OrderMasterQuery> storetwo = new List<OrderMasterQuery>();
                    _iasdMgr = new AseldMgr(mySqlConnectionString);
                    int totalCount = 0;
                    oderMaster.export_id = Convert.ToInt32(Request.Params["type_id"]);
                    if (!string.IsNullOrEmpty(Request.Params["deliver_type"]))
                    {
                        oderMaster.deliver_type = Convert.ToInt32(Request.Params["deliver_type"]);
                    }
                    string i = Request.Params["beforeradio"];
                    if (i == "false" || i == "true")
                    {
                        if (i == "false")//有調度
                        {
                            oderMaster.jdtype = 2;
                        }
                        else if (i == "true")//表示無調度
                        {
                            oderMaster.jdtype = 1;
                        }
                    }
                    else
                    {
                        oderMaster.jdtype = Convert.ToInt32(Request.Params["radio"]);//1 表示沒有調度 2 表示有調度
                    }
                    store = _iasdMgr.GetOrderMasterList(oderMaster, out  totalCount);
                    foreach (var item in store)
                    {
                        oderMaster.deliver_id = item.deliver_id;
                        storetwo = _iasdMgr.GetAllOrderDetail(oderMaster);
                        int count = 0;//寄倉品類數量
                        int dcount = 0;//調度品類數量
                        foreach (var items in storetwo)
                        {
                            //參數表 1 自出 2 寄倉 3 調度
                            if (items.product_mode == 2)
                            {
                                count = count + 1;
                                item.count = count;
                            }
                            else if (items.product_mode == 3)
                            {
                                dcount = dcount + 1;
                                item.dcount = dcount;
                            }
                        }
                        //oderMaster.Order_Id = item.Order_Id;
                        //storetwo = _iasdMgr.GetAllOrderDetail(oderMaster);
                        //int count = 0;//寄倉品類數量
                        //int dcount = 0;//調度品類數量
                        //foreach (var items in storetwo)
                        //{
                        //    //參數表 1 自出 2 寄倉 3 調度
                        //    if (items.product_mode == 2)
                        //    {
                        //        count = count + 1;
                        //        item.count = count;
                        //    }
                        //    else if (items.product_mode == 3)
                        //    {
                        //        dcount = dcount + 1;
                        //        item.dcount = dcount;
                        //    }
                        //}
                    }
                    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數據
                }
                else
                {
                    json = "{success:false,totalCount:0,data:[]}";//返回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;
        }