コード例 #1
0
        public HttpResponseBase Getnewticketslist()
        {
            string jsonStr = String.Empty;
            StringBuilder sb = new StringBuilder();
            List<TicketQuery> store = new List<TicketQuery>();
            TicketQuery tqQuery = new TicketQuery();
            try
            {
                tqQuery.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                tqQuery.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");//用於分頁的變量
                _tkMgr = new TicketMgr(mySqlConnectionString);
                int totalCount = 0;
                string condition = string.Empty;

                int deliver_type = Convert.ToInt32(Request.Params["deliver_type"]);//批次出貨類別
                int vendorcondition = 0;
                if (!string.IsNullOrEmpty(Request.Params["vendorcondition"]))
                {
                    vendorcondition = int.Parse(Request.Params["vendorcondition"]);//出貨廠商
                }
                int shipment = 0;
                if (!string.IsNullOrEmpty(Request.Params["shipment"]))
                {
                    shipment = int.Parse(Request.Params["shipment"]);//物流商
                }
                int gongyinshang = 0;
                if (!string.IsNullOrEmpty(Request.Params["gongyinshang"]))
                {
                    gongyinshang = int.Parse(Request.Params["gongyinshang"]);
                }
                int scheduling = int.Parse(Request.Params["scheduling"]);//調度狀態
                int screen = int.Parse(Request.Params["screen"]);//批次出貨狀態
                int lytype = int.Parse(Request.Params["lytype"]);//列印處理狀態
                int ystype = int.Parse(Request.Params["ystype"]);//運送方式
                string search = Request.Params["search"].Trim();//搜索內容
                if (deliver_type == 1) //批次出貨類別
                {
                    condition = condition + " and Ticket.type = 1  ";
                }
                else
                {
                    condition = condition + " and Ticket.type = 2  ";
                }
                #region 出貨廠商
                if (vendorcondition == 0)//出貨廠商 所有 對
                {
                    condition = condition + "";
                }
                else
                {
                    condition = condition + " and Export.vendor_id=" + vendorcondition;
                }
                #endregion

                #region 物流商或者是供應商
                if (shipment == 0)//物流商
                {
                    condition = condition + "";
                }
                else
                {
                    condition = condition + " and Ticket.delivery_store=" + shipment;
                }
                if (gongyinshang == 0)//物流商
                {
                    condition = condition + "";
                }
                else
                {
                    condition = condition + " and Ticket.delivery_store=" + shipment;
                }
                #endregion

                if (scheduling == 0)//調度狀態
                {
                    condition = condition + " and warehouse_status=0 ";
                }
                else if (scheduling == 1)
                {
                    condition = condition + " and warehouse_status=1 ";
                }
                if (screen == -1)//批次出貨狀態
                {
                    condition = condition + "";
                }
                else if (screen == 0)
                {
                    condition = condition + " and ticket_status=0 ";
                }
                else if (screen == 1)
                {
                    condition = condition + " and ticket_status=1 ";
                }
                if (lytype == 0)//列印處理狀態 現在php後台好像沒有作用
                {
                    condition = condition + " ";
                }
                else
                {
                    condition = condition + " ";
                }
                if (ystype == 1)//運送方式
                {
                    condition = condition + " and freight_set=1 ";
                }
                else if (ystype == 2)
                {
                    condition = condition + " and freight_set=2 ";
                }
                else if (ystype == 5)
                {
                    condition = condition + " and freight_set=5 ";
                }
                if (!string.IsNullOrEmpty(search))//搜索條件
                {
                    condition = condition + string.Format(" AND ((Ticket.ticket_id like '%{0}%') OR (Export.vendor_name_simple like '%{0}%'))", search);
                }
                store = _tkMgr.GetTicketList(tqQuery, out totalCount, condition);
                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;
        }