public HttpResponseBase OrderWaitClick()
        {
            string json = string.Empty;
            OrderMasterStatusQuery query = new OrderMasterStatusQuery();
            _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
            uint id;
            try
            {
                if (uint.TryParse(Request.Params["order_id"].ToString(), out id))
                {
                    query.order_id = id;
                }
                if (!string.IsNullOrEmpty(Request.Params["remark"].ToString()))
                {
                    query.status_description = "Writer : (" + (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id + ")" + (System.Web.HttpContext.Current.Session["caller"] as Caller).user_username + ":" + Request.Params["remark"];
                }
                query.order_status=0;//等待付款

                System.Net.IPAddress[] addlist = Dns.GetHostByName(Dns.GetHostName()).AddressList;
                query.status_ipfrom = addlist[0].ToString();
                json =  _orderDetailMgr.OrderWaitClick(query);//"{success:true}";//返回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:flase,msg:1}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public HttpResponseBase GetNewOrderRevenueList()
        {
            string json = string.Empty;
            try
            {
                OrderDetailQuery query = new OrderDetailQuery();
                #region 前置查詢條件
                if (!string.IsNullOrEmpty(Request.Params["Brand_Id"]))/*品牌編號*/
                {
                    query.Brand_Id_In = Request.Params["Brand_Id"];
                }
                if (!string.IsNullOrEmpty(Request.Params["product_manage"]))//管理人員 
                {//獲取管理人
                    query.product_manage = int.Parse(Request.Params["product_manage"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
                {
                    query.time_start = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateOne"]).ToString("yyyy/MM/dd 00:00:00"));
                }
                if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
                {
                    query.time_end = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateTwo"]).ToString("yyyy/MM/dd 23:59:59"));
                }
                long start = query.time_start;//開始時間
                long end = query.time_end;//結束時間
                if (!string.IsNullOrEmpty(Request.Params["Channel_Id"]))//賣場
                {
                    query.channel = int.Parse(Request.Params["Channel_Id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["slave_status"]))//訂單狀態
                {
                    query.Status = int.Parse(Request.Params["slave_status"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["order_payment"]))//付款方式
                {
                    query.order_payment = int.Parse(Request.Params["order_payment"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["selecttype"]))//關鍵字查詢類型
                {
                    query.select_type = int.Parse(Request.Params["selecttype"]);
                    if (!string.IsNullOrEmpty(Request.Params["searchcon"]))//關鍵字查詢內容
                    {
                        query.select_con = Request.Params["searchcon"];
                    }
                }


                #endregion
                VendorBrandQuery Vendorbrandquery = new VendorBrandQuery();
                Dictionary<uint, VendorBrandQuery> brands = new Dictionary<uint, VendorBrandQuery>();///字典----儲存供應商編號,供應商名稱和錧別,錧別編號的信息
                Dictionary<uint, Dictionary<string, Dictionary<string, uint>>> brandDailyTotal = new Dictionary<uint, Dictionary<string, Dictionary<string, uint>>>();///字典,儲存錧別,每天的計算和每天的購物金
                ///////////////brand_id//////////daysum,dayduct/////日期///值
                List<VendorBrandQuery> aDB_Brand_Select = new List<VendorBrandQuery>();
                _vbrand = new VendorBrandMgr(mySqlConnectionString);
                aDB_Brand_Select = _vbrand.GetBandList(Vendorbrandquery);//把錧別和供應商信息保存到字典里
                for (int i = 0; i < aDB_Brand_Select.Count; i++)
                {
                    if (!brands.Keys.Contains(aDB_Brand_Select[i].Brand_Id))
                    {
                        brands.Add(aDB_Brand_Select[i].Brand_Id, aDB_Brand_Select[i]);
                    }
                }

                bool CrossMonth = CommonFunction.GetNetTime(start).Month == CommonFunction.GetNetTime(end).Month ? false : true;
                string timelong = "";
                while (start <= end)//時間格式化,用來保存每天的小計
                {
                    timelong += CommonFunction.GetNetTime(start).ToString("yyyy/MM/dd") + ",";
                    start += 86400;
                }
                timelong = timelong.Substring(0, timelong.LastIndexOf(","));
                string[] times = timelong.Split(',');
                Dictionary<string, uint> timetro = new Dictionary<string, uint>();
                for (int i = 0; i < times.Count(); i++)//字典加上日期時間
                {
                    timetro.Add(times[i], 0);
                }
                Dictionary<string, Dictionary<string, uint>> daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();//保存每個商品每日的小計和購物金
                daysum_deduct.Add("daysum", timetro);//每日小計
                daysum_deduct.Add("daydeduct", timetro);//每日小計


                _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                List<OrderDetailQuery> ordertailList = new List<OrderDetailQuery>();
                ordertailList = _orderDetailMgr.GetOrderDetailList(query);//通過查詢條件獲取的數據
                //if (ordertailList.Count == 0)
                //{
                //    json = "{success:true,msg:\"" + "<div style='overflow:auto;text-align:center;width:1650px;height:550px;><p tyle='text-align:center'>~~暫無數據~~</p></div>" + "\"}";
                //}
                //else
                //{
                 string[] quanxuan = query.Brand_Id_In.Split(',');
                    foreach (uint item in brands.Keys)
                    {
                        if (!brandDailyTotal.Keys.Contains(item))
                        {
                            daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();
                            timetro = new Dictionary<string, uint>();
                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daysum", timetro);//每日小計
                            timetro = new Dictionary<string, uint>();

                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daydeduct", timetro);//購物金
                            brandDailyTotal.Add(item, daysum_deduct);
                        }
                    }
                    for (int i = 0; i < ordertailList.Count; i++)
                    {
                        ordertailList[i].subtotal = ordertailList[i].Single_Money * ordertailList[i].Buy_Num;
                        ordertailList[i].cost = (ordertailList[i].Event_Cost != 0 && ordertailList[i].Single_Cost != ordertailList[i].Single_Money) ? ordertailList[i].Event_Cost : ordertailList[i].Single_Cost;
                        if (!brands.Keys.Contains(ordertailList[i].Brand_Id))
                        {
                            VendorBrandQuery brand = new VendorBrandQuery();
                            brand.Vendor_Id = ordertailList[i].Vendor_Id;
                            brand.Brand_Name = ordertailList[i].Brand_Name;
                            brand.Brand_Id = ordertailList[i].Brand_Id;
                            brand.vendor_name_simple = ordertailList[i].Vendor_Name_Simple;
                            brands.Add(ordertailList[i].Brand_Id, brand);
                        }
                        if (!brandDailyTotal.Keys.Contains(ordertailList[i].Brand_Id))
                        {
                            daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();
                            timetro = new Dictionary<string, uint>();
                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daysum", timetro);//每日小計
                            timetro = new Dictionary<string, uint>();

                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daydeduct", timetro);//購物金

                            brandDailyTotal.Add(ordertailList[i].Brand_Id, daysum_deduct);
                        }
                        string time = CommonFunction.GetNetTime(ordertailList[i].Order_Createdate).ToString("yyyy/MM/dd");
                        brandDailyTotal[ordertailList[i].Brand_Id]["daysum"][time] += ordertailList[i].subtotal;//每個商品的小計
                        brandDailyTotal[ordertailList[i].Brand_Id]["daydeduct"][time] += ordertailList[i].Deduct_Bonus;//每個商品的購物金小計
                    }
                    Dictionary<string, uint> daysum_allbrand = new Dictionary<string, uint>();//所有品牌的每日小計
                    Dictionary<string, uint> deductsum_allbrand = new Dictionary<string, uint>();//所有品牌的每日購物金
                    foreach (uint key in brandDailyTotal.Keys)
                    {
                        foreach (string time in brandDailyTotal[key]["daysum"].Keys)//循環每個品牌的每日小計,計算到所有品牌的每日小計
                        {
                            if (!daysum_allbrand.Keys.Contains(time))
                            {
                                daysum_allbrand.Add(time, brandDailyTotal[key]["daysum"][time]);
                            }
                            else
                            {
                                daysum_allbrand[time] += brandDailyTotal[key]["daysum"][time];
                            }
                        }
                        foreach (string time in brandDailyTotal[key]["daydeduct"].Keys)//循環每個品牌的每日購物金小計,計算到所有品牌的每日小計
                        {
                            if (!deductsum_allbrand.Keys.Contains(time))
                            {
                                deductsum_allbrand.Add(time, brandDailyTotal[key]["daydeduct"][time]);
                            }
                            else
                            {
                                deductsum_allbrand[time] += brandDailyTotal[key]["daydeduct"][time];
                            }
                        }

                    }
                    StringBuilder html_table = new StringBuilder();//匯出html頁面
                    html_table.AppendFormat(@"<div style='overflow:auto;text-align:right;width:1590px;height:580px;'><table style='border:0px;'>");

                    html_table.AppendFormat("<thead style='text-align:center;border-bottom: 1px solid #ccc;color: #000;'><tr><td style='border-bottom: 1px solid #ccc;color: #000;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center; text-align: center;'>&nbsp;&nbsp;品牌名稱&nbsp;&nbsp;</td>");
                    html_table.AppendFormat("<td style='border-bottom: 1px solid #ccc;color: #000;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center; text-align: center;'>&nbsp;&nbsp;供應商名稱&nbsp;&nbsp;</td>");
                    string ym_last = "";
                    foreach (string it in timetro.Keys)
                    {
                        string ym = it.Substring(0, 7);
                        if (string.IsNullOrEmpty(ym_last))
                            ym_last = ym;
                        if (!ym_last.Equals(ym))
                        {
                            html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", ym_last.Split('/')[1] + "月小計");
                            ym_last = ym;
                        }
                        html_table.AppendFormat("<td style='color: #000;border-bottom: 1px solid #ccc; text-align: center;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", it);
                    }
                    if (CrossMonth)
                    {
                        html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px; text-align: center;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", ym_last.Split('/')[1] + "月小計");
                    }
                    html_table.AppendFormat("<td style= 'color: #c00;border-bottom: 1px solid #ccc;line-height: 1.2em;white-space: nowrap;font-size: 12px;  text-align: center;'>&nbsp;&nbsp;品牌總計&nbsp;&nbsp;</td></tr>");






                    html_table.AppendFormat("<tr><td colspan='2' style= 'text-align: right;border-bottom: 1px solid #ccc;color: #000;'>&nbsp;&nbsp;每日小計&nbsp;&nbsp;</td>");
                    ym_last = "";
                    uint sum_monthly = 0;
                    uint sum_year = 0;
                    foreach (string it in daysum_allbrand.Keys)
                    {
                        string ym = it.Substring(0, 7);
                        if (string.IsNullOrEmpty(ym_last))
                            ym_last = ym;
                        if (!ym_last.Equals(ym))
                        {
                            html_table.AppendFormat("<td style= 'border-bottom: 1px solid #ccc; text-align: right;color: #c00; '>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", sum_monthly);
                            ym_last = ym;
                            sum_monthly = 0;
                        }
                        sum_monthly += daysum_allbrand[it];
                        sum_year += daysum_allbrand[it];
                        html_table.AppendFormat("<td style='text-align:right;border-bottom: 1px solid #ccc; '>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", daysum_allbrand[it]);

                    }
                    if (CrossMonth)
                    {
                        html_table.AppendFormat("<td style= 'text-align:right;color: #c00;border-bottom: 1px solid #ccc; '>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", sum_monthly);
                    }
                    html_table.AppendFormat("<td style= 'text-align:right;color: #c00;border-bottom: 1px solid #ccc; '>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td></tr></thead>", sum_year);
                    html_table.AppendFormat("<tbody>");

                    foreach (uint it in brandDailyTotal.Keys)
                    {

                        ym_last = "";
                        sum_monthly = 0;
                        sum_year = 0;
                        if (brands.Keys.Contains(it))
                        {
                            html_table.AppendFormat("<tr><td style=' white-space: nowrap;text-align:left;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td><td style='text-align:left; white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{1}&nbsp;&nbsp;</td>", brands[it].Brand_Name, brands[it].vendor_name_simple);
                        }
                        else
                        {
                            html_table.AppendFormat("<tr><td>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td><td >&nbsp;&nbsp;{1}&nbsp;&nbsp;</td>", " ", " ");
                        }
                        foreach (string ite in brandDailyTotal[it]["daysum"].Keys)
                        {
                            string ym = ite.Substring(0, 7);
                            if (string.IsNullOrEmpty(ym_last))
                                ym_last = ym;
                            if (!ym_last.Equals(ym))
                            {
                                html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", sum_monthly);
                                ym_last = ym;
                                sum_monthly = 0;
                            }
                            sum_monthly += brandDailyTotal[it]["daysum"][ite];
                            sum_year += brandDailyTotal[it]["daysum"][ite];
                            html_table.AppendFormat("<td style='text-align:right;white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", brandDailyTotal[it]["daysum"][ite]);
                        }
                        if (CrossMonth)
                        {
                            html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td>", sum_monthly);
                        }
                        html_table.AppendFormat("<td style= 'text-align:right;color: #c00; white-space: nowrap;line-height: 1.2em;font-size: 12px;'>&nbsp;&nbsp;{0}&nbsp;&nbsp;</td> </tr>", sum_year);



                    }
                    html_table.AppendFormat("</tbody></table>");
                    json = "{success:true,msg:\"" + html_table.ToString() + "\"}";
                }


           // }
            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;


        }
        /// <summary>
        /// 出貨管理:檢索>傳票明細
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase SubPoenaDetailList()
        {
            int ticket_id = Convert.ToInt32(Request.Params["ticket_id"]);
            string jsonStr = String.Empty;
            List<OrderDetailQuery> store = new List<OrderDetailQuery>();
            OrderDetailQuery query = new OrderDetailQuery();
            List<OrderDetailQuery> na = new List<OrderDetailQuery>();
            try
            {
                query.Ticket_Id = ticket_id;
                _IOrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                int totalCount = 0;
                store = _IOrderDetailMgr.SubPoenaDetail(query);
                #region MyRegion


                // List<OrderDetailQuery> one_product = new List<OrderDetailQuery>();		//單一商品
                // List<OrderDetailQuery> combination = new List<OrderDetailQuery>();			//組合商品
                // List<OrderDetailQuery> combination_head = new List<OrderDetailQuery>();		//組合品名
                // List<OrderDetailQuery> combination_tail = new List<OrderDetailQuery>();		//子商品名
                // List<OrderDetailQuery> new_order_detail = new List<OrderDetailQuery>(); ;    //新商品資料
                // List<OrderDetailQuery> since_order = new List<OrderDetailQuery>();	   //自出商品
                // Dictionary<int, string> freight_set_map = new Dictionary<int, string>();
                // freight_set_map.Add(1, "常溫");
                // freight_set_map.Add(2, "冷凍");
                // freight_set_map.Add(5, "冷藏");
                // Dictionary<int, string> product_freight_set_mapping = new Dictionary<int, string>();
                // product_freight_set_mapping.Add(1, "1");
                // product_freight_set_mapping.Add(2, "2");
                // product_freight_set_mapping.Add(3, "1");
                // product_freight_set_mapping.Add(4, "2");
                // product_freight_set_mapping.Add(5, "5");
                // product_freight_set_mapping.Add(6, "5");

                // foreach (var item in store)
                // {
                //     if (item.Combined_Mode > 1)
                //     {
                //         if (item.item_mode == 1)
                //             combination_head.Add(item);
                //         else
                //             combination_tail.Add(item);
                //     }
                //     else
                //     {
                //         uint freight = item.Product_Freight_Set;
                //         item.Product_Freight_Set =uint.Parse(product_freight_set_mapping[int.Parse(item.Product_Freight_Set.ToString())]);
                //         one_product.Add(item);
                //         item.Product_Freight_Set = freight;
                //     }
                // }
                // foreach (var item in combination_head)
                // {
                //     uint freight = item.Product_Freight_Set;
                //     item.Product_Freight_Set = uint.Parse(product_freight_set_mapping[int.Parse(item.Product_Freight_Set.ToString())]);
                //     combination.Add(item);
                //     item.Product_Freight_Set = freight;
                //     foreach (var items in combination_tail)
                //     {
                //         if (item.Parent_Id == items.Parent_Id && item.pack_id == items.pack_id)
                //         {
                //             items.Buy_Num = items.Buy_Num * items.parent_num;
                //             combination.Add(items);
                //         }
                //     }
                // }
                #endregion

                //(合併數據來自www/Model/Deliver.Php,第1391~1463行)
                #region 測試方法

                List<Parametersrc> Shipment = new List<Parametersrc>();
                _ptersrc = new ParameterMgr(mySqlConnectionString);
                Shipment = _ptersrc.GetAllKindType("order_status");//訂單狀態
                Dictionary<string, string> _dtOrderStatus = new Dictionary<string, string>();
                foreach (var item in Shipment)
                {
                    _dtOrderStatus.Add(item.ParameterCode, item.remark);
                }
                Dictionary<int, string> freight_set_map = new Dictionary<int, string>();
                freight_set_map.Add(1, "常溫");
                freight_set_map.Add(2, "冷凍");
                freight_set_map.Add(5, "冷藏");
                Dictionary<int, string> product_freight_set_mapping = new Dictionary<int, string>();
                product_freight_set_mapping.Add(1, "1");
                product_freight_set_mapping.Add(2, "2");
                product_freight_set_mapping.Add(3, "1");
                product_freight_set_mapping.Add(4, "2");
                product_freight_set_mapping.Add(5, "5");
                product_freight_set_mapping.Add(6, "5");
                Dictionary<string, List<OrderDetailQuery>> one_product = new Dictionary<string, List<OrderDetailQuery>>();		//單一商品
                Dictionary<string, List<OrderDetailQuery>> combination = new Dictionary<string, List<OrderDetailQuery>>();		//組合商品
                List<OrderDetailQuery> combination_head = new List<OrderDetailQuery>();		//組合品名
                List<OrderDetailQuery> combination_tail = new List<OrderDetailQuery>();		//子商品名
                List<OrderDetailQuery> new_order_detail = new List<OrderDetailQuery>(); ;    //新商品資料
                List<OrderDetailQuery> since_order = new List<OrderDetailQuery>();	   //自出商品
                since_order.AddRange(new_order_detail);
                int w = since_order.Count;

                string frest;
                #region 把所有的商品,把單一和組合拆分開
                //把所有的商品,把單一和組合區分開,然後把組合的商品運送方式區分開(常溫冷凍冷藏)
                foreach (var item in store)
                {
                    if (item.Combined_Mode > 1)
                    {
                        if (item.item_mode == 1)
                            combination_head.Add(item);
                        else
                            combination_tail.Add(item);
                    }
                    else
                    {

                        frest = "";
                        frest = product_freight_set_mapping[int.Parse(item.Product_Freight_Set.ToString())];
                        if (!one_product.Keys.Contains(frest))
                        {
                            List<OrderDetailQuery> s = new List<OrderDetailQuery>();
                            one_product.Add(frest, s);
                        }
                        one_product[frest].Add(item);
                        //one_product.Add(frest, item);
                    }
                }
                #endregion

                #region 把組合商品中拆分開子商品和父商品
                //把組合商品拆分開,并計算子商品的數量,把子商品按照運送方式再次拆開
                foreach (var item in combination_head)
                {

                    frest = "";
                    frest = product_freight_set_mapping[int.Parse(item.Product_Freight_Set.ToString())];
                    if (!combination.Keys.Contains(frest))
                    {
                        List<OrderDetailQuery> s = new List<OrderDetailQuery>();
                        combination.Add(frest, s);
                    }
                    //combination.Add(frest, item);
                    combination[frest].Add(item);
                    foreach (var items in combination_tail)
                    {
                        if (item.Parent_Id == items.Parent_Id && item.pack_id == items.pack_id)
                        {
                            items.Buy_Num = items.Buy_Num * items.parent_num;
                            //combination.Add(frest, item);
                            combination[frest].Add(items);
                        }
                    }
                }
                #endregion

                #region 把單一商品,組合商品,子商品 根據運送方式在此組合在一起

                foreach (var item in freight_set_map)
                {
                    ////List<OrderDetailQuery> s = new List<OrderDetailQuery>();
                    ////if (combination.ContainsKey(item.Key.ToString()))
                    ////{
                    ////    s.AddRange(combination[item.Key.ToString()]);
                    ////}
                    ////if (s.Count > 0)
                    ////{
                    ////    new_order_detail.AddRange(combination[item.Key.ToString()]);
                    ////}
                    ////else
                    ////{
                    ////    if (one_product.ContainsKey(item.Key.ToString()))
                    ////    {
                    ////        new_order_detail.AddRange(one_product[item.Key.ToString()]);
                    ////    }
                    ////}
                    if (one_product.ContainsKey(item.Key.ToString()))
                    {
                        new_order_detail.AddRange(one_product[item.Key.ToString()]);
                    }
                    if (combination.ContainsKey(item.Key.ToString()))
                    {
                        //new_order_detail.Add(combination[item.Key.ToString()]);
                        new_order_detail.AddRange(combination[item.Key.ToString()]);
                    }
                    ///--------------------------------------------------
                    //string a = item.Key.ToString();
                    //if (combination[item.Key.ToString()].Count > 0)
                    //{
                    //    new_order_detail.AddRange(combination[item.Key.ToString()]);
                    //}
                    //else if (one_product[item.Key.ToString()].Count > 0)
                    //{
                    //    //new_order_detail.Add(combination[item.Key.ToString()]);
                    //    new_order_detail.AddRange(one_product[item.Key.ToString()]);
                    //}
                }
                #endregion

                #region 這個根據什麼條件篩選出來


                for (int i = 0; i < new_order_detail.Count; i++)
                {
                    new_order_detail[i].Product_Freight_Set_Str = _dtOrderStatus[(new_order_detail[i].Detail_Status).ToString()];
                    if (new_order_detail[i].Combined_Mode >= 1 && new_order_detail[i].item_mode == 1)
                    {
                        continue;
                    }
                    else
                    {
                        na.Add(new_order_detail[i]);
                    }
                }
                #endregion

                #endregion

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(na, 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;
        }
        /// <summary>
        /// 拆分細項
        /// </summary>
        /// <returns></returns>
        public JsonResult split_detail()//Admin/Controller/DeliversController/第325行 split_detail
        {

            string json = string.Empty;
            OrderDetailQuery query = new OrderDetailQuery();
            if (!string.IsNullOrEmpty(Request.Params["Detail_Id"]))
            {
                query.Detail_Id = uint.Parse(Request.Params["Detail_Id"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["Deliver_Id"]))
            {
                query.Deliver_Id = uint.Parse(Request.Params["Deliver_Id"]);
            }

            _IOrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
            if (_IOrderDetailMgr.split_detail(query) == 1)
            {
                return Json(new { success = "true", msg = "" });
            }
            else
            {
                return Json(new { success = "false", msg = "" });
            }

        }
 public HttpResponseBase OrderVendorProducesList()
 {
     OrderDetailQuery query = new OrderDetailQuery();
     List<OrderDetailQuery> store = new List<OrderDetailQuery>();
     string json = string.Empty;
     int totalCount = 0;
     BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
     try
     {
         query.Vendor_Id = vendor.vendor_id;
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
         query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
         if (!string.IsNullOrEmpty(Request.Params["select_type"]))
         {
             query.select_type = Convert.ToInt32(Request.Params["select_type"]);
             if (!string.IsNullOrEmpty(Request.Params["search_con"]))
             {
                 query.select_con = Request.Params["search_con"];
             }
         }
         if (!string.IsNullOrEmpty(Request.Params["date"]))
         {
             query.date = Convert.ToInt32(Request.Params["date"]);
             if (!string.IsNullOrEmpty(Request.Params["start_time"]))
             {
                 query.start_time = Convert.ToDateTime(Request.Params["start_time"]);
             }
             if (!string.IsNullOrEmpty(Request.Params["end_time"]))
             {
                 query.end_time = Convert.ToDateTime(Request.Params["end_time"]);
             }
         }
         query.radiostatus = Convert.ToInt32(Request.Params["radiostatus"]);
         query.promodel = Convert.ToInt32(Request.Params["proModel"]);
         _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
         store = _OrderDetailMgr.OrderVendorProducesList(query, out totalCount);
         foreach (var item in store)
         {
             if (item.slave_date_delivery != 0)
             {
                 item.s_slave_date_delivery = CommonFunction.DateTimeToString(CommonFunction.GetNetTime(item.slave_date_delivery));
             }
             else
             {
                 //還沒有出貨不顯示出貨時間
                 item.s_slave_date_delivery = "-";
             }
             if (item.item_mode == 2)
             {
                 item.Buy_Num = item.Buy_Num * item.parent_num;
             }
             if (item.spec_image != "")
             {
                 item.spec_image = imgServerPath + specPath + item.spec_image.Substring(0, 2) + "/" + item.spec_image.Substring(2, 2) + "/" + item.spec_image;
             }
         }
         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:false,totalCount:0,data:[]}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
 public HttpResponseBase GetLeaveproductList()
 {
     BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
     uint vendor_id = vendor.vendor_id;
     StringBuilder sb = new StringBuilder();
     OrderDetailQuery query = new OrderDetailQuery();
     string jsonStr = String.Empty;
     try
     {
         if (Convert.ToInt32(Request.Params["serch_type"]) == 1)//等於1表示選擇了商品名稱
         {
             if (!string.IsNullOrEmpty(Request.Params["searchcomment"].Trim()))
             {
                 sb.AppendFormat(" AND od.product_name LIKE '%{0}%'", Request.Params["searchcomment"]);
             }
         }
         if (Convert.ToInt32(Request.Params["serch_time_type"]) == 1)//等於1表示選擇了出貨日期
         {
             if (!string.IsNullOrEmpty(Request.Params["time_start"].Trim()) && !string.IsNullOrEmpty(Request.Params["time_end"].Trim()))
             {
                 sb.AppendFormat("AND os.slave_date_delivery >= '{0}' AND os.slave_date_delivery <='{1}' ", CommonFunction.GetPHPTime(Request.Params["time_start"]), CommonFunction.GetPHPTime(Request.Params["time_end"]));
             }
         }
         //query.Search_Type = Convert.ToInt32(Request.Params["serch_type"]);
         //if (!string.IsNullOrEmpty(Request.Params["searchcomment"].Trim()))
         //{
         //    query.SearchComment = Request.Params["searchcomment"].Trim();
         //}
         //query.Serch_Time_Type = Convert.ToInt32(Request.Params["serch_time_type"]);
         if (!string.IsNullOrEmpty(vendor_id.ToString()))
         {
             query.Vendor_Id = vendor_id;
         }
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
         query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
         DataTable dt = new DataTable();
         _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
         int totalCount = 0;
         dt = _OrderDetailMgr.GetLeaveproductList(query, out totalCount, sb.ToString());//查询出供應商出貨單
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd";
         jsonStr = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(dt, 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;
 }
        /// <summary>
        /// 供應商自行出貨確認
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase SelfConfirmShipment()
        {
            string jsonStr = String.Empty;
            BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            BLL.gigade.Model.OrderSlaveMaster master = new OrderSlaveMaster();
            OrderDeliverQuery query = new OrderDeliverQuery();
            uint Slave_Id = 0;//要出貨的訂單;
            string Select_Did = "";//選中要出貨的出貨單號
            DateTime sendProTime = DateTime.MinValue;//出貨時間
            string delivery_note = "";//出貨單備註
            uint DeliverStores = 0;//物流單號
            string delivery_Code = "";//物流業者
            string IP = "";
            string Description = "";
            #region 獲取條件
            if (!string.IsNullOrEmpty(Request.Params["Slave_Id"]))
            {
                Slave_Id = uint.Parse(Request.Params["Slave_Id"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["Select_Did"]))
            {
                Select_Did = Request.Params["Select_Did"];
            }
            if (!string.IsNullOrEmpty(Request.Params["sendProTime"]))
            {
                sendProTime = DateTime.Parse(Request.Params["sendProTime"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["delivery_note"]))
            {
                delivery_note = Request.Params["delivery_note"];
            }
            if (!string.IsNullOrEmpty(Request.Params["DeliverStores"]))
            {
                DeliverStores = uint.Parse(Request.Params["DeliverStores"]);
            }
            if (!string.IsNullOrEmpty(Request.Params["delivery_Code"]))
            {
                delivery_Code = Request.Params["delivery_Code"];
            }
            #endregion
            string did = Select_Did.TrimEnd(',');//去掉最後一個分割符號
            string[] Sid_Row = did.Split(',');//拆分
            List<OrderDetailQuery> store = new List<OrderDetailQuery>();
            OrderDetailQuery querys = new OrderDetailQuery();
            querys.Slave_Id = Slave_Id;
            querys.Vendor_Id = vendor.vendor_id;
            _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
            store = _OrderDetailMgr.DeliveryInformation(querys, null);//查询出供應商出貨單Vendor delivery
            int reslut = 0;
            if (Sid_Row.Length != store.Count)
            {
                #region 轉換數據
                DataTable All_Did = new DataTable();
                All_Did.Columns.Add("detail_id", typeof(String));
                All_Did.Columns.Add("product_name", typeof(String));
                All_Did.Columns.Add("product_freight_set", typeof(String));
                All_Did.Columns.Add("product_spec_name", typeof(String));
                All_Did.Columns.Add("single_money", typeof(String));
                All_Did.Columns.Add("parent_name", typeof(String));
                All_Did.Columns.Add("parent_num", typeof(String));
                All_Did.Columns.Add("combined_mode", typeof(String));
                All_Did.Columns.Add("item_mode", typeof(String));
                All_Did.Columns.Add("buy_num", typeof(String));
                foreach (var item in store)
                {
                    DataRow dr = All_Did.NewRow();
                    dr[0] = item.Detail_Id;
                    dr[1] = item.Product_Name;
                    dr[2] = item.Product_Freight_Set;
                    dr[3] = item.Product_Spec_Name;
                    dr[4] = item.Single_Money;
                    dr[5] = item.parent_name;
                    dr[6] = item.parent_num;
                    dr[7] = item.Combined_Mode;
                    dr[8] = item.item_mode;
                    dr[9] = item.Buy_Num;
                    All_Did.Rows.Add(dr);
                }
                #endregion
                //
                //調用宋東亞
                _OrderDeliverMgr = new OrderDeliverMgr(mySqlConnectionString);
                _OrderDeliverMgr.DismantleSlave(int.Parse(querys.Slave_Id.ToString()), Select_Did, All_Did);
            }

            master.creator = vendor.vendor_id;
            System.Net.IPAddress[] addlist = Dns.GetHostByName(Dns.GetHostName()).AddressList;
            if (addlist.Length > 0)
            {
                IP = addlist[0].ToString();
            }

            try
            {
                OrderDeliver deliver = new OrderDeliver();
                deliver.slave_id = Slave_Id;
                deliver.deliver_store = DeliverStores;
                deliver.deliver_code = delivery_Code;
                deliver.deliver_note = delivery_note;
                deliver.deliver_time = uint.Parse(CommonFunction.GetPHPTime(sendProTime.ToString("yyyy-MM-dd")).ToString());
                deliver.deliver_ipfrom = IP;
                DataTable _dtSms = new DataTable();
                _dtSms.Columns.Add("sms_id", typeof(String));
                DataRow row = _dtSms.NewRow();//需發簡訊通知的item
                row[0] = 113552;
                _dtSms.Rows.Add(row);
                row = _dtSms.NewRow();
                row[0] = 113550;
                _dtSms.Rows.Add(row);
                Description = "Writer : vendor(" + vendor.vendor_id + ") " + vendor.vendor_name_simple;
                _OrderMgr = new OrderMgr(mySqlConnectionString);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                _OrderMgr.SelfThingsMethod(_dtSms, deliver, Description);//出貨成功!

                jsonStr = "{success:true}";//返回json數據
                //   jsonStr = "{success:true,msg:\"" + 1 + "\"}";
            }
            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 GetOrderChildList()
 {
     List<OrderDetailQuery> stores = new List<OrderDetailQuery>();
     string json = string.Empty;
     try
     {
         OrderDetailQuery query = new OrderDetailQuery();
         query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
         query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "5");//用於分頁的變量
         //付款單號
         query.Order_Id = Convert.ToUInt32(Request.Params["OrderId"].ToString());
         query.Parent_Id = Convert.ToInt32(Request.Params["ParentId"].ToString());
         query.pack_id = Convert.ToUInt32(Request.Params["PackId"].ToString());
         query.isChildItem = 1;
         _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
         int totalCount = 0;
         stores = _orderDetailMgr.GetOrderDetailList(query, out totalCount);
         IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
         //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
         timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
         //listUser是准备转换的对象
         foreach (var item in stores)
         {//訂單內容頁面查詢的是自商品信息需要*parent_num
             item.Buy_Num = item.Buy_Num * item.parent_num;
         }
         json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, 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 HttpResponseBase GetOrderDeliverDetailList()
        {
            StringBuilder addsql = new StringBuilder();
            string json = string.Empty;
            string startTime = Request.Params["start_time"];
            string endTime = Request.Params["end_time"];

            if (!string.IsNullOrEmpty(startTime))
            {
                addsql.AppendFormat(" and om.order_date_pay>='{0}' ", CommonFunction.GetPHPTime(DateTime.Parse(startTime).ToString("yyyy/MM/dd 00:00:00")));
            }
            if (!string.IsNullOrEmpty(endTime))
            {
                addsql.AppendFormat(" and om.order_date_pay<='{0}' ", CommonFunction.GetPHPTime(DateTime.Parse(endTime).ToString("yyyy/MM/dd 23:59:59")));
            }
            addsql.Append(" 	AND od.detail_status = 2	AND product_mode = 1 ");

            BLL.gigade.Model.Vendor modelVendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            StringBuilder sbHtml = new StringBuilder();
            
            try
            {
                //OrderSlave
                OrderSlaveQuery orderSlaveQuery = new OrderSlaveQuery()
                {
                    vendor_id = modelVendor.vendor_id,
                    Slave_Status = 2,//待出貨
                    IsPage = false
                };
                OrderSlaveQuery orderSlave = new OrderSlaveQuery();
                DataTable dtOrderSlave = new DataTable();
                _OrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString);

                //OrderDetail
                OrderDetailQuery orderDetailQuery = new OrderDetailQuery();

                List<OrderDetailQuery> list = new List<OrderDetailQuery>();
                _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                int totalCount_OrderDetail = 0;
                Dictionary<OrderDetailQuery, List<OrderDetailQuery>> product_freight_set_mapping = new Dictionary<OrderDetailQuery, List<OrderDetailQuery>>();

                //根據時間搜索order_id
                dtOrderSlave = _OrderSlaveMgr.GetListPrint(orderSlaveQuery, addsql.ToString());
                if (dtOrderSlave.Rows.Count > 0)
                {
                    //循環order_id
                    foreach (DataRow item in dtOrderSlave.Rows)
                    {
                        //orderSlave
                        orderSlave.order_id = Convert.ToUInt32(item["order_id"]);
                        orderSlave.order_createdate = Convert.ToDateTime(item["order_createdate"]).ToString("yyyy-MM-dd HH:mm:ss");
                        orderSlave.pay_time = Convert.ToDateTime(item["order_date_pay"]).ToString("yyyy-MM-dd HH:mm:ss");
                        orderSlave.order_name = item["order_name"].ToString();
                        orderSlave.delivery_name = item["delivery_name"].ToString();
                        orderSlave.estimated_arrival_period = Convert.ToInt32(item["estimated_arrival_period"]);
                        orderSlave.note_order = item["note_order"].ToString();
                        orderSlave.dispatch = 0;
                        orderSlave.delivery_zip = Convert.ToUInt32(item["delivery_zip"]);
                        orderSlave.delivery_address = item["delivery_address"].ToString();
                        orderSlave.delivery_mobile = item["delivery_mobile"].ToString();

                        //供查詢列表使用
                        orderDetailQuery.Slave_Id = Convert.ToUInt32(item["slave_id"]);
                        list = _OrderDetailMgr.GetOrderDetailList(orderDetailQuery, out totalCount_OrderDetail);
                        sbHtml.Append(GetOrderDeliverDetailHtml(orderSlave, list));
                    }
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                //json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
                json = "{success:true,msg:\"" + sbHtml.ToString() + "\"}";
            }
            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,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
示例#10
0
        /// <summary>
        /// 供應商自行出貨信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase DeliveryInformation()
        {
            string jsonStr = String.Empty;
            StringBuilder sb = new StringBuilder();

            _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
            try
            {
                List<OrderDetailQuery> store = new List<OrderDetailQuery>();

                OrderDetailQuery query = new OrderDetailQuery();
                uint slave_id = 0;
                if (!string.IsNullOrEmpty(Request.Params["sid"]))
                {
                    slave_id = uint.Parse(Request.Params["sid"]);
                }
                query.Slave_Id = slave_id;

                query.Vendor_Id = ((BLL.gigade.Model.Vendor)Session["vendor"]).vendor_id;



                store = _OrderDetailMgr.DeliveryInformation(query, sb.ToString());//查询出供應商出貨單Vendor delivery

                #region 貨運單屬性
                List<Parametersrc> paramentFreight = new List<Parametersrc>();
                DataTable _dtProductFreightSet = new DataTable();
                _ptersrc = new ParameterMgr(mySqlConnectionString);

                paramentFreight = _ptersrc.GetAllKindType("product_freight");//物流業者

                _dtProductFreightSet.Columns.Add("parametercode", typeof(String));
                _dtProductFreightSet.Columns.Add("parameterName", typeof(String));
                _dtProductFreightSet.Columns.Add("remark", typeof(String));
                foreach (var item in paramentFreight)
                {
                    DataRow dr = _dtProductFreightSet.NewRow();
                    dr[0] = item.ParameterCode;
                    dr[1] = item.parameterName;
                    dr[2] = item.remark;
                    _dtProductFreightSet.Rows.Add(dr);
                }
                #endregion

                List<OrderDetailQuery> stores = new List<OrderDetailQuery>();
                foreach (var item in store)
                {
                    if (item.Combined_Mode >= 1 && item.Product_Mode == 1)
                        continue;
                    if (item.item_mode == 2)
                    {
                        item.Buy_Num = item.Buy_Num * item.parent_num;
                        // item.Sub_Total = item.Single_Money * item.parent_num;
                    }
                    //else 
                    //{
                    //    item.Sub_Total = item.Single_Money * item.Buy_Num;
                    //}
                    DataRow[] rows = _dtProductFreightSet.Select("ParameterCode='" + item.Product_Freight_Set + "'");
                    item.Product_Freight_Set_Str = item.Product_Freight_Set.ToString();
                    foreach (DataRow row in rows)//篩選出的最多只有一條數據,
                    {
                        if (!string.IsNullOrEmpty(row["ParameterCode"].ToString()))
                        {
                            item.Product_Freight_Set_Str = row["ParameterName"].ToString();//---送貨時段
                        }
                    }
                    if (!string.IsNullOrEmpty(item.Product_Spec_Name))
                    {
                        item.Product_Name = item.Product_Spec_Name;
                    }
                    stores.Add(item);

                }

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                jsonStr = "{success:true,data:" + JsonConvert.SerializeObject(stores, 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;
        }
示例#11
0
        public HttpResponseBase GetOrderDeliverDetail()
        {
            string json = string.Empty;
            string order_id = Request.Params["oid"];
            string p_mode = Request.Params["p_mode"];
            BLL.gigade.Model.Vendor modelVendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            //OrderSlave
            OrderSlaveQuery orderSlaveQuery = new OrderSlaveQuery()
            {
                order_id = Convert.ToUInt32(order_id),
                vendor_id = modelVendor.vendor_id,
                Slave_Status = 2,//待出貨
                IsPage = false
            };
            OrderSlaveQuery orderSlave = new OrderSlaveQuery();
            DataTable dtOrderSlave = new DataTable();
            _OrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString);
            int totalCount_OrderSlave = 0;

            //OrderDetail
            OrderDetailQuery orderDetailQuery = new OrderDetailQuery();
            //orderDetailQuery.Order_Id = uint.Parse(order_id);
            List<OrderDetailQuery> list = new List<OrderDetailQuery>();
            _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
            int totalCount_OrderDetail = 0;

            try
            {
                dtOrderSlave = _OrderSlaveMgr.GetList(orderSlaveQuery, out totalCount_OrderSlave);
                if (dtOrderSlave.Rows.Count > 0)
                {
                    //orderSlave
                    orderSlave.order_id = Convert.ToUInt32(dtOrderSlave.Rows[0]["order_id"]);
                    orderSlave.order_createdate = dtOrderSlave.Rows[0]["order_createdate"].ToString();
                    orderSlave.pay_time = dtOrderSlave.Rows[0]["order_date_pay"].ToString();
                    orderSlave.order_name = dtOrderSlave.Rows[0]["order_name"].ToString();
                    orderSlave.delivery_name = dtOrderSlave.Rows[0]["delivery_name"].ToString();
                    orderSlave.estimated_arrival_period = Convert.ToInt32(dtOrderSlave.Rows[0]["estimated_arrival_period"]);
                    orderSlave.note_order = dtOrderSlave.Rows[0]["note_order"].ToString();
                    orderSlave.dispatch = modelVendor.dispatch;
                    orderSlave.delivery_zip = Convert.ToUInt32(dtOrderSlave.Rows[0]["delivery_zip"]);
                    orderSlave.delivery_address = dtOrderSlave.Rows[0]["delivery_address"].ToString();
                    orderSlave.delivery_mobile = dtOrderSlave.Rows[0]["delivery_mobile"].ToString();

                    //供查詢列表使用
                    orderDetailQuery.Slave_Id = Convert.ToUInt32(dtOrderSlave.Rows[0]["slave_id"]);
                }

                list = _OrderDetailMgr.GetOrderDetailList(orderDetailQuery, out totalCount_OrderDetail);
                List<OrderDetailQuery> stroes = new List<OrderDetailQuery>();
                stroes = getList(list);
                string html = GetOrderDeliverDetailHtml(orderSlave, stroes);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                //json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據
                json = "{success:true,msg:\"" + html + "\"}";
            }
            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,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
示例#12
0
        public HttpResponseBase ProduceGroupExcel()
        {
            string json = string.Empty;
            OrderDetailQuery query = new OrderDetailQuery();
            BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            try
            {
                query.Vendor_Id = vendor.vendor_id;
                if (!string.IsNullOrEmpty(Request.Params["select_type"]))
                {
                    query.select_type = Convert.ToInt32(Request.Params["select_type"]);
                    if (!string.IsNullOrEmpty(Request.Params["search_con"]))
                    {
                        query.select_con = Request.Params["search_con"];
                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["date"]))
                {
                    query.date = Convert.ToInt32(Request.Params["date"]);
                    if (!string.IsNullOrEmpty(Request.Params["start_time"]))
                    {
                        query.start_time = Convert.ToDateTime(Request.Params["start_time"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["end_time"]))
                    {
                        query.end_time = Convert.ToDateTime(Request.Params["end_time"]);
                    }
                }
                query.radiostatus = Convert.ToInt32(Request.Params["radiostatus"]);
                query.promodel = Convert.ToInt32(Request.Params["proModel"]);
                _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                DataTable _dt = _OrderDetailMgr.ProduceGroupExcel(query);
                string[] ColumnName = { "付款單號", "供應商", "商品名稱", "規格", "數量", "訂購姓名", "狀態", "出貨日期", "備註" };
                string headerText = "報表";
                string fileName = "報表.xls";
                string newFileName = Server.MapPath(ProduceGroupCsvPath) + fileName;
                #region 轉到新錶

                DataTable _newDt = new DataTable();
                for (int i = 0; i < ColumnName.Length; i++)
                {

                    _newDt.Columns.Add(ColumnName[i], typeof(string));
                }
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    DataRow _newRow = _newDt.NewRow();
                    for (int j = 0; j < _dt.Columns.Count; j++)
                    {


                        if (j == 7)
                        {
                            _newRow[j] = _dt.Rows[i][j];
                            if (_newRow[j].ToString() == "0")
                            {
                                _newRow[j] = "-";
                            }
                            else
                            {
                                _newRow[j] = CommonFunction.GetNetTime(Convert.ToInt32(_dt.Rows[i][j])).ToString("yyyy-MM-dd HH:mm:ss");
                            }
                        }
                        else if (j == 4)
                        {
                            if (_dt.Rows[i]["item_mode"].ToString() == "2")
                            {
                                _newRow[j] = Convert.ToInt32(_dt.Rows[i]["buy_num"]) * Convert.ToInt32(_dt.Rows[i]["parent_num"]);
                            }
                            else
                            {
                                _newRow[j] = _dt.Rows[i]["buy_num"];
                            }
                        }
                        else
                        {
                            if (j == 0 || j == 1 || j == 2 || j == 3 || j == 5 || j == 6 || j == 8)
                            {
                                _newRow[j] = _dt.Rows[i][j];
                            }
                        }

                    }
                    _newDt.Rows.Add(_newRow);
                }
                #endregion
                ExcelHelperXhf.ExportDTtoExcel(_newDt, headerText, newFileName);
                json = "{success:'true',filename:'" + fileName + "'}";
            }
            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'}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
示例#13
0
 public HttpResponseBase ProduceGroupCsv()
 {
     string json = string.Empty;
     OrderDetailQuery query = new OrderDetailQuery();
     BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
     try
     {
         query.Vendor_Id = vendor.vendor_id;
         if (!string.IsNullOrEmpty(Request.Params["select_type"]))
         {
             query.select_type = Convert.ToInt32(Request.Params["select_type"]);
             if (!string.IsNullOrEmpty(Request.Params["search_con"]))
             {
                 query.select_con = Request.Params["search_con"];
             }
         }
         if (!string.IsNullOrEmpty(Request.Params["date"]))
         {
             query.date = Convert.ToInt32(Request.Params["date"]);
             if (!string.IsNullOrEmpty(Request.Params["start_time"]))
             {
                 query.start_time = Convert.ToDateTime(Request.Params["start_time"]);
             }
             if (!string.IsNullOrEmpty(Request.Params["end_time"]))
             {
                 query.end_time = Convert.ToDateTime(Request.Params["end_time"]);
             }
         }
         query.radiostatus = Convert.ToInt32(Request.Params["radiostatus"]);
         query.promodel = Convert.ToInt32(Request.Params["proModel"]);
         _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
         DataTable _dt = _OrderDetailMgr.ProduceGroupCsv(query);
         string[] columnName = { "商品細項編號", "商品名稱", "數量" };
         string fileName = "ovp_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".csv";
         string newFileName = Server.MapPath(ProduceGroupCsvPath) + fileName;
         string title = "撿貨單" + query.start_time.ToString("yyyy/MM/dd") + "至" + query.end_time.ToString("yyyy/MM/dd");
         CsvHelper.TitleCsv(_dt, newFileName, title, columnName, true);
         json = "{success:'true',filename:'" + fileName + "'}";
     }
     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'}";
     }
     this.Response.Clear();
     this.Response.Write(json);
     this.Response.End();
     return this.Response;
 }
示例#14
0
        /// <summary>
        /// 品牌營業額統計匯出
        /// </summary>
        /// <returns></returns>
        public void GetNewOrderRevenueExprot()
        {
            string json = string.Empty;
            try
            {
                OrderDetailQuery query = new OrderDetailQuery();

                #region 前置查詢條件
                if (!string.IsNullOrEmpty(Request.Params["Brand_Id"]))/*品牌編號*/
                {
                    query.Brand_Id_In = Request.Params["Brand_Id"];

                }
                if (!string.IsNullOrEmpty(Request.Params["product_manage"]) && Request.Params["product_manage"] != "null")//管理人員 
                {//獲取管理人
                    query.product_manage = int.Parse(Request.Params["product_manage"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
                {
                    query.time_start = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateOne"]).ToString("yyyy/MM/dd 00:00:00"));
                }
                if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
                {
                    query.time_end = CommonFunction.GetPHPTime(DateTime.Parse(Request.Params["dateTwo"]).ToString("yyyy/MM/dd 23:59:59"));
                }
                long start = query.time_start;//開始時間
                long end = query.time_end;//結束時間
                if (!string.IsNullOrEmpty(Request.Params["Channel_Id"]) && Request.Params["Channel_Id"] != "null")//賣場
                {
                    query.channel = int.Parse(Request.Params["Channel_Id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["slave_status"]) && Request.Params["slave_status"]!="null")//訂單狀態
                {
                    query.Status = int.Parse(Request.Params["slave_status"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["order_payment"]) && Request.Params["order_payment"] != "null")//付款方式
                {
                    query.order_payment = int.Parse(Request.Params["order_payment"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["selecttype"]))//關鍵字查詢類型
                {
                    query.select_type = int.Parse(Request.Params["selecttype"]);
                    if (!string.IsNullOrEmpty(Request.Params["searchcon"]))//關鍵字查詢內容
                    {
                        query.select_con = Request.Params["searchcon"];
                    }
                }


                #endregion
                VendorBrandQuery Vendorbrandquery = new VendorBrandQuery();
                Dictionary<uint, VendorBrandQuery> brands = new Dictionary<uint, VendorBrandQuery>();///字典----儲存供應商編號,供應商名稱和錧別,錧別編號的信息
                Dictionary<uint, Dictionary<string, Dictionary<string, uint>>> brandDailyTotal = new Dictionary<uint, Dictionary<string, Dictionary<string, uint>>>();///字典,儲存錧別,每天的計算和每天的購物金
                ///////////////brand_id//////////daysum,dayduct/////日期///值
                List<VendorBrandQuery> aDB_Brand_Select = new List<VendorBrandQuery>();
                _vbrand = new VendorBrandMgr(mySqlConnectionString);
                aDB_Brand_Select = _vbrand.GetBandList(Vendorbrandquery);//把錧別和供應商信息保存到字典里
                for (int i = 0; i < aDB_Brand_Select.Count; i++)
                {
                    if (!brands.Keys.Contains(aDB_Brand_Select[i].Brand_Id))
                    {
                        brands.Add(aDB_Brand_Select[i].Brand_Id, aDB_Brand_Select[i]);
                    }
                }

                bool CrossMonth = CommonFunction.GetNetTime(start).Month == CommonFunction.GetNetTime(end).Month ? false : true;
                string timelong = "";
                while (start <= end)//時間格式化,用來保存每天的小計
                {
                    timelong += CommonFunction.GetNetTime(start).ToString("yyyy/MM/dd") + ",";
                    start += 86400;
                }
                timelong = timelong.Substring(0, timelong.LastIndexOf(","));
                string[] times = timelong.Split(',');
                Dictionary<string, uint> timetro = new Dictionary<string, uint>();
                for (int i = 0; i < times.Count(); i++)//字典加上日期時間
                {
                    timetro.Add(times[i], 0);
                }
                Dictionary<string, Dictionary<string, uint>> daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();//保存每個商品每日的小計和購物金
                daysum_deduct.Add("daysum", timetro);//每日小計
                daysum_deduct.Add("daydeduct", timetro);//每日小計


                _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                List<OrderDetailQuery> ordertailList = new List<OrderDetailQuery>();
                DataTable _dt = new DataTable();
                ordertailList = _orderDetailMgr.GetOrderDetailList(query);//通過查詢條件獲取的數據
                string[] quanxuan = query.Brand_Id_In.Split(',');
                foreach (uint item in brands.Keys)
                {
                    if (!brandDailyTotal.Keys.Contains(item))
                    {
                        daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();
                        timetro = new Dictionary<string, uint>();
                        for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                        {
                            timetro.Add(times[a], 0);
                        }
                        daysum_deduct.Add("daysum", timetro);//每日小計
                        timetro = new Dictionary<string, uint>();

                        for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                        {
                            timetro.Add(times[a], 0);
                        }
                        daysum_deduct.Add("daydeduct", timetro);//購物金
                        brandDailyTotal.Add(item, daysum_deduct);
                    }
                }
                
                //if (ordertailList.Count > 0)
                //{
                    for (int i = 0; i < ordertailList.Count; i++)
                    {
                        ordertailList[i].subtotal = ordertailList[i].Single_Money * ordertailList[i].Buy_Num;
                        ordertailList[i].cost = (ordertailList[i].Event_Cost != 0 && ordertailList[i].Single_Cost != ordertailList[i].Single_Money) ? ordertailList[i].Event_Cost : ordertailList[i].Single_Cost;
                        if (!brands.Keys.Contains(ordertailList[i].Brand_Id))
                        {
                            VendorBrandQuery brand = new VendorBrandQuery();
                            brand.Vendor_Id = ordertailList[i].Vendor_Id;
                            brand.Brand_Name = ordertailList[i].Brand_Name;
                            brand.Brand_Id = ordertailList[i].Brand_Id;
                            brand.vendor_name_simple = ordertailList[i].Vendor_Name_Simple;
                            brands.Add(ordertailList[i].Brand_Id, brand);
                        }
                        if (!brandDailyTotal.Keys.Contains(ordertailList[i].Brand_Id))
                        {
                            daysum_deduct = new Dictionary<string, Dictionary<string, uint>>();
                            timetro = new Dictionary<string, uint>();
                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daysum", timetro);//每日小計
                            timetro = new Dictionary<string, uint>();

                            for (int a = 0; a < times.Count(); a++)//字典加上日期時間
                            {
                                timetro.Add(times[a], 0);
                            }
                            daysum_deduct.Add("daydeduct", timetro);//購物金

                            brandDailyTotal.Add(ordertailList[i].Brand_Id, daysum_deduct);
                        }
                        string time = CommonFunction.GetNetTime(ordertailList[i].Order_Createdate).ToString("yyyy/MM/dd");
                        brandDailyTotal[ordertailList[i].Brand_Id]["daysum"][time] += ordertailList[i].subtotal;//每個商品的小計
                        brandDailyTotal[ordertailList[i].Brand_Id]["daydeduct"][time] += ordertailList[i].Deduct_Bonus;//每個商品的購物金小計
                    }
                    Dictionary<string, uint> daysum_allbrand = new Dictionary<string, uint>();//所有品牌的每日小計
                    Dictionary<string, uint> deductsum_allbrand = new Dictionary<string, uint>();//所有品牌的每日購物金
                    foreach (uint key in brandDailyTotal.Keys)
                    {
                        foreach (string time in brandDailyTotal[key]["daysum"].Keys)//循環每個品牌的每日小計,計算到所有品牌的每日小計
                        {
                            if (!daysum_allbrand.Keys.Contains(time))
                            {
                                daysum_allbrand.Add(time, brandDailyTotal[key]["daysum"][time]);
                            }
                            else
                            {
                                daysum_allbrand[time] += brandDailyTotal[key]["daysum"][time];
                            }
                        }
                        foreach (string time in brandDailyTotal[key]["daydeduct"].Keys)//循環每個品牌的每日購物金小計,計算到所有品牌的每日小計
                        {
                            if (!deductsum_allbrand.Keys.Contains(time))
                            {
                                deductsum_allbrand.Add(time, brandDailyTotal[key]["daydeduct"][time]);
                            }
                            else
                            {
                                deductsum_allbrand[time] += brandDailyTotal[key]["daydeduct"][time];
                            }
                        }

                    }

                    //
                    _dt.Columns.Add("品牌名稱", typeof(String));
                    _dt.Columns.Add("供應商名稱", typeof(String));


                    string ym_last = "";
                    foreach (string it in timetro.Keys)
                    {
                        string ym = it.Substring(0, 7);
                        if (string.IsNullOrEmpty(ym_last))
                            ym_last = ym;
                        if (!ym_last.Equals(ym))
                        {
                            _dt.Columns.Add(ym_last.Split('/')[1] + "月小計", typeof(String));
                            _dt.Columns.Add("購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String));
                            _dt.Columns.Add("扣除購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String));
                            ym_last = ym;
                        }
                        _dt.Columns.Add(it, typeof(String));
                        _dt.Columns.Add("購物金(" + it + ")", typeof(String));
                        _dt.Columns.Add("扣除購物金(" + it + ")", typeof(String));
                    }
                    if (CrossMonth)
                    {
                        _dt.Columns.Add(ym_last.Split('/')[1] + "月小計", typeof(String));
                        _dt.Columns.Add("購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String));
                        _dt.Columns.Add("扣除購物金(" + ym_last.Split('/')[0] + "/" + ym_last.Split('/')[1] + "月)", typeof(String));
                    }
                    _dt.Columns.Add("品牌總計", typeof(String));
                    _dt.Columns.Add(" 購物金總計", typeof(String));
                    _dt.Columns.Add(" 扣除購物金總計", typeof(String));

                    DataRow addrow = _dt.NewRow();//添加一行
                    addrow[0] = " ";
                    addrow[1] = "每日小計";
                    int r = 2;
                    ym_last = "";
                    uint sum_monthly = 0;//每月小計
                    uint deduct_monthly = 0;//每月購物金小計
                    uint sum_year = 0;//總計
                    uint deduct_year = 0;//購物金總計
                    foreach (string it in daysum_allbrand.Keys)
                    {
                        string ym = it.Substring(0, 7);
                        if (string.IsNullOrEmpty(ym_last))
                            ym_last = ym;
                        if (!ym_last.Equals(ym))
                        {
                            addrow[r] = sum_monthly;
                            r++;
                            addrow[r] = deduct_monthly;
                            r++;
                            addrow[r] = sum_monthly - deduct_monthly;
                            r++;
                            ym_last = ym;
                            sum_monthly = 0;
                            deduct_monthly = 0;
                        }
                        sum_monthly += daysum_allbrand[it];
                        deduct_monthly += deductsum_allbrand[it];
                        sum_year += daysum_allbrand[it];
                        deduct_year += deductsum_allbrand[it];
                        addrow[r] = daysum_allbrand[it];
                        r++;
                        addrow[r] = deductsum_allbrand[it];
                        r++;
                        addrow[r] = daysum_allbrand[it] - deductsum_allbrand[it];
                        r++;

                    }
                    if (CrossMonth)
                    {
                        addrow[r] = sum_monthly;
                        r++;
                        addrow[r] = deduct_monthly;
                        r++;
                        addrow[r] = sum_monthly - deduct_monthly;
                        r++;
                    }
                    addrow[r] = sum_year;
                    r++;
                    addrow[r] = deduct_year;
                    r++;
                    addrow[r] = sum_year - deduct_year;
                    _dt.Rows.Add(addrow);

                    foreach (uint it in brandDailyTotal.Keys)
                    {
                        ym_last = "";
                        sum_monthly = 0;
                        deduct_monthly = 0;
                        sum_year = 0;
                        deduct_year = 0;
                        r = 0;
                        addrow = _dt.NewRow();
                        if (brands.Keys.Contains(it))
                        {
                            addrow[r] = brands[it].Brand_Name;
                            r++;
                            addrow[r] = brands[it].vendor_name_simple;
                            r++;
                        }
                        else
                        {
                            addrow[r] = " ";
                            r++;
                            addrow[r] = " ";
                            r++;
                        }
                        foreach (string ite in brandDailyTotal[it]["daysum"].Keys)
                        {
                            string ym = ite.Substring(0, 7);
                            if (string.IsNullOrEmpty(ym_last))
                                ym_last = ym;
                            if (!ym_last.Equals(ym))
                            {
                                addrow[r] = sum_monthly;
                                r++;
                                addrow[r] = deduct_monthly;
                                r++;
                                addrow[r] = sum_monthly - deduct_monthly;
                                r++;
                                ym_last = ym;
                                sum_monthly = 0;
                                deduct_monthly = 0;
                            }
                            sum_monthly += brandDailyTotal[it]["daysum"][ite];
                            sum_year += brandDailyTotal[it]["daysum"][ite];
                            deduct_monthly += brandDailyTotal[it]["daydeduct"][ite];
                            deduct_year += brandDailyTotal[it]["daydeduct"][ite];
                            addrow[r] = brandDailyTotal[it]["daysum"][ite];
                            r++;
                            addrow[r] = brandDailyTotal[it]["daydeduct"][ite];
                            r++;
                            addrow[r] = brandDailyTotal[it]["daysum"][ite] - brandDailyTotal[it]["daydeduct"][ite];
                            r++;
                        }
                        if (CrossMonth)
                        {
                            addrow[r] = sum_monthly;
                            r++;
                            addrow[r] = deduct_monthly;
                            r++;
                            addrow[r] = sum_monthly - deduct_monthly;
                            r++;
                        }
                        addrow[r] = sum_year;
                        r++;
                        addrow[r] = deduct_year;
                        r++;
                        addrow[r] = sum_year - deduct_year;
                        _dt.Rows.Add(addrow);
                    }
               // }

                //if (_dt.Rows.Count > 0)
                //{
                    //string fileName = "品牌營業額匯出_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    //MemoryStream ms = ExcelHelperXhf.ExportDT(_dt, "");
                    //Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    //Response.BinaryWrite(ms.ToArray());
                    string fileName = "品牌營業額匯出_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
                    //MemoryStream ms = ExcelHelperXhf.ExportDT(_dt, "");
                    //Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    //Response.BinaryWrite(ms.ToArray());
                    StringWriter sw = ExcelHelperXhf.SetCsvFromData(_dt, fileName);
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    Response.ContentType = "application/ms-excel";
                    Response.ContentEncoding = Encoding.Default;
                    Response.Write(sw);
                    Response.End();
                //}
                //else
                //{
                //    Response.Write("匯出數據不存在");
                //}

            }
            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);

            }



        }
示例#15
0
        /// <summary>
        /// 供應商後台:訂單管理>供應商調度出貨>要出的貨物信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase AllOrderDeliver()
        {
            uint Normal_Subtotal = 0;//常溫商品總額--
            uint Hypothermia_Subtotal = 0;//低溫商品總額---
            uint All_Normal_Subtotal = 0;//當日常溫運費總額
            uint All_Hypothermia_Subtotal = 0;//當日低溫運費總額
            uint Order_Freight_Normal = 0;//常溫運費
            uint Order_Freight_Low = 0;//低溫運費
            uint All_Order_Freight_Normal = 0;//當日常溫運費--
            uint All_Order_Freight_Low = 0;//當日低溫運費--

            string json = string.Empty;
            try
            {
                string detail_id = "";
                if (!string.IsNullOrEmpty(Request.Params["rowIDs"]))
                {
                    detail_id = Request.Params["rowIDs"];
                }
                detail_id = detail_id.TrimEnd(',');//去掉最後一個分割符號
                string[] Sid_Row = detail_id.Split(',');//拆分
                string Sid = Sid_Row[Sid_Row.Length - 1];//獲取最後一個計算出出貨時間
                //通過sid去order_slave查詢order_id;
                //通過order_id查詢在order_master中order_date_pay。
                OrderSlaveQuery query = new OrderSlaveQuery();
                query.Slave_Id = uint.Parse(Sid);
                _IOrderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString);
                DateTime time = _IOrderSlaveMgr.GetOrderDatePay(query).order_date_pay;
                long endtime = CommonFunction.GetPHPTime(time.ToString("yyyy/MM/dd 23:59:59"));
                uint vendor_id = (Session["vendor"] as BLL.gigade.Model.Vendor).vendor_id;
                //(計算這些數據參照自vendor.gigade100.com/order/all_order_deliver.php 第209~266行)
                #region 計算供應商當天的常溫和冷凍的總運費
                List<OrderDetailQuery> query1 = new List<OrderDetailQuery>();
                _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                query1 = _OrderDetailMgr.GetOrderDetailToSum(vendor_id, endtime);

                foreach (var item in query1)
                {
                    if (item.item_mode == 1)
                        continue;
                    if (item.Product_Freight_Set == PRODUCT_FREIGHT_NORMAL || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_NORMAL)//常溫,常溫免運
                    {
                        if (item.item_mode == 2)//組合商品
                        {
                            All_Normal_Subtotal += item.Single_Price * item.parent_num;
                        }
                        else
                        {
                            All_Normal_Subtotal += item.Single_Price * item.Buy_Num;
                        }
                    }
                    else if (item.Product_Freight_Set == PRODUCT_FREIGHT_LOW || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_LOW) //冷凍,冷凍免運
                    {
                        if (item.item_mode == 2)//組合商品
                        {
                            All_Hypothermia_Subtotal += item.Single_Price * item.parent_num;
                        }
                        else
                        {
                            All_Hypothermia_Subtotal += item.Single_Price * item.Buy_Num;
                        }
                    }
                }
                #endregion

                #region 計算運費


                OrderDetailQuery oddquery = new OrderDetailQuery();
                oddquery.Vendor_Id = vendor_id;
                _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                int total = 0;

                string sq = string.Format(" AND os.slave_id in ({0}) ORDER BY od.slave_id ASC ,od. combined_mode ASC , od.item_mode ASC ", detail_id);
                List<OrderDetailQuery> query2 = new List<OrderDetailQuery>();
                oddquery.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                oddquery.Limit = Convert.ToInt32(Request.Params["limit"] ?? "10");//用於分頁的變量
                query1 = _OrderDetailMgr.AllOrderDeliver(oddquery, out total, sq);

                //uint Normal_Subtotal = 0;//常溫商品總額--
                //uint Hypothermia_Subtotal = 0;//低溫商品總額---
                //uint All_Normal_Subtotal = 0;//當日常溫運費總額
                //uint All_Hypothermia_Subtotal = 0;//當日低溫運費總額
                //uint Order_Freight_Normal = 0;//常溫運費
                //uint Order_Freight_Low = 0;//低溫運費
                //uint All_Order_Freight_Normal = 0;//當日常溫運費--
                //uint All_Order_Freight_Low = 0;//當日低溫運費--


                foreach (var item in query1)
                {
                    if (item.item_mode == 1)
                        continue;
                    //商品總額計算(當下出貨金額與運費)
                    if (item.Product_Freight_Set == PRODUCT_FREIGHT_NORMAL || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_NORMAL)//常溫,常溫免運
                    {
                        if (item.item_mode == 2)
                        {

                            Normal_Subtotal += item.Single_Price * item.parent_num;
                            item.Buy_Num = item.Buy_Num * item.parent_num;
                            item.Single_Price = item.Single_Price * item.parent_num;

                            //Normal_Subtotal += item.Single_Price * item.parent_num;//---
                            //item.Buy_Num = item.Buy_Num * item.parent_num;//-------
                            //item.Single_Money = item.Single_Price * item.Buy_Num;//---------
                        }
                        else
                        {
                            Normal_Subtotal += item.Single_Price * item.Buy_Num;
                            item.Single_Money = item.Single_Price * item.Buy_Num;
                        }
                    }
                    else if (item.Product_Freight_Set == PRODUCT_FREIGHT_LOW || item.Product_Freight_Set == PRODUCT_FREIGHT_NO_LOW)//低溫,低溫免運
                    {
                        if (item.item_mode == 2)
                        {
                            Hypothermia_Subtotal += item.Single_Price * item.parent_num;
                            item.Buy_Num = item.Buy_Num * item.parent_num;
                            item.Single_Price = item.Single_Price * item.parent_num;
                            //Hypothermia_Subtotal += item.Single_Price * item.parent_num;//--------
                            //item.Buy_Num = item.Buy_Num * item.parent_num;//------------
                            //item.Single_Money = item.Single_Price * item.Buy_Num;//---------
                        }
                        else
                        {
                            Hypothermia_Subtotal += item.Single_Price * item.Buy_Num;
                            item.Single_Money = item.Single_Price * item.Buy_Num;
                        }
                    }
                    query2.Add(item);
                }
                _VendorMgr = new VendorMgr(mySqlConnectionString);
                BLL.gigade.Model.Vendor vendor = new BLL.gigade.Model.Vendor();
                vendor.vendor_id = vendor_id;
                vendor = _VendorMgr.GetSingle(vendor);
                //當下運費計算
                if (Normal_Subtotal != 0)
                {
                    if (vendor.freight_normal_limit > Normal_Subtotal)
                    {
                        Order_Freight_Normal = vendor.freight_normal_money;
                    }
                }
                if (Hypothermia_Subtotal != 0)
                {
                    if (vendor.freight_low_limit > Hypothermia_Subtotal && Hypothermia_Subtotal > 0)
                    {
                        Order_Freight_Low = vendor.freight_low_money;
                    }
                }
                //批次單總額運費
                if (All_Normal_Subtotal != 0)
                {
                    if (vendor.freight_normal_limit > All_Normal_Subtotal)
                    {
                        All_Order_Freight_Normal = vendor.freight_normal_money;
                    }
                }
                if (All_Hypothermia_Subtotal != 0)
                {
                    if (vendor.freight_low_limit > All_Order_Freight_Low)
                    {
                        All_Order_Freight_Low = vendor.freight_low_money;
                    }
                }

                #endregion
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                json = "{success:true,Normal_Subtotal:" + Normal_Subtotal + ",Hypothermia_Subtotal:" + Hypothermia_Subtotal + ",Order_Freight_Normal:" + Order_Freight_Normal + ",Order_Freight_Low:" + Order_Freight_Low;
                json += ",All_Order_Freight_Normal:" + All_Order_Freight_Normal + ",All_Order_Freight_Low:" + All_Order_Freight_Low + ",data:" + JsonConvert.SerializeObject(query2, 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,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
示例#16
0
        public HttpResponseBase GetOrderDetailList()
        {
            List<OrderDetailQuery> stores = new List<OrderDetailQuery>();
            string json = string.Empty;
            try
            {
                OrderDetailQuery query = new OrderDetailQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                //付款單號
                query.Order_Id = Convert.ToUInt32(Request.Params["OrderId"].ToString());
                query.isChildItem = 0;
                _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                int totalCount = 0;
                stores = _orderDetailMgr.GetOrderDetailList(query, out totalCount);

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                //listUser是准备转换的对象
                //獲取供應商後臺登陸的vendorMd5加密
                _vendorImp = new VendorMgr(mySqlConnectionString);
                foreach (OrderDetailQuery item in stores)
                {
                    string str = _vendorImp.GetLoginId(Convert.ToInt32(item.Vendor_Id));
                    if (str != "")
                    {
                        HashEncrypt hmd5 = new HashEncrypt();
                        string mdlogin_id = hmd5.Md5Encrypt(str, "MD5");
                        item.VendorMd5 = hmd5.Md5Encrypt(mdlogin_id + str, "MD5");
                    }                 
                    if (item.item_mode == 2)
                    {
                        item.subtotal = (item.Single_Money * item.parent_num)-uint.Parse(item.Deduct_Happygo_Money.ToString())-item.Deduct_Welfare-item.Deduct_Bonus;
                    }
                    else
                    {
                        item.subtotal = (item.Single_Money * item.Buy_Num) -uint.Parse( item.Deduct_Happygo_Money.ToString()) - item.Deduct_Welfare - item.Deduct_Bonus;
                    }
                }
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, 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;
        }
示例#17
0
        /// <summary>
        /// 供應商後台:訂單管理>供應商調度出貨>批次檢貨明細列印
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase PickingPrintList()
        {
            BLL.gigade.Model.Vendor vendor = Session["vendor"] as BLL.gigade.Model.Vendor;
            uint vendor_id = vendor.vendor_id;
            string json = String.Empty;
            StringBuilder sb = new StringBuilder();
            List<OrderDetailQuery> store = new List<OrderDetailQuery>();
            OrderDetailQuery query = new OrderDetailQuery();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["rowIDs"]))
                {
                    string detail_id = Request.Params["rowIDs"];
                    detail_id = detail_id.TrimEnd(',');
                    sb.AppendFormat(" AND os.slave_id in ({0})", detail_id);
                }
                query.Vendor_Id = vendor_id;

                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量
                _OrderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
                int totalCount = 0;
                store = _OrderDetailMgr.VendorPickPrint(query, out totalCount, sb.ToString());//查询出供應商出貨單
                #region 為了監視數據,方便後期維護
                //DataTable dtH = new DataTable();
                //dtH.Columns.Add("item_id", typeof(String));
                //dtH.Columns.Add("product_name", typeof(string));
                //dtH.Columns.Add("order_id", typeof(String));
                //dtH.Columns.Add("order_name", typeof(String));
                //dtH.Columns.Add("delivery_name", typeof(String));
                //dtH.Columns.Add("buy_num", typeof(String));
                //dtH.Columns.Add("single_price", typeof(String));
                //dtH.Columns.Add("item_code", typeof(String));
                //dtH.Columns.Add("note_order", typeof(String));
                //foreach (var item in store)
                //{
                //     DataRow dr = dtH.NewRow();
                //        dr[0] = item.Item_Id;
                //        dr[1] = item.Product_Name;
                //        dr[2] = item.Order_Id;
                //        dr[3] = item.Order_Name;
                //        dr[4] =item.Delivery_Name;
                //        dr[5] = item.Buy_Num;
                //        dr[6] =item.Single_Price;
                //        dr[7] = item.Item_Code;
                //        dr[8] =item.Note_Order;
                //        dtH.Rows.Add(dr);
                //}
                #endregion
                Dictionary<string, List<OrderDetailQuery>> MergeDate = new Dictionary<string, List<OrderDetailQuery>>();//在這裡合併數據  
                //(合併數據,計算這些數據參照自vendor.gigade100.com/order/all_order_deliver_detail_print.php 第59~108行)
                #region 測試一次
                foreach (var item in store)//原數據循環
                {
                    if (item.Combined_Mode >= 1 && item.item_mode == 1)//提取组合商品,计算价格和数量
                        continue;

                    string item_id = item.Item_Id.ToString();
                    if (item.item_mode == 2)//子商品
                    {
                        item.Buy_Num = item.Buy_Num * item.parent_num;
                        item.Single_Price = item.Single_Price * item.parent_num;
                    }
                    else //母商品
                    {
                        item.Single_Price = item.Single_Price * item.Buy_Num;
                    }
                    if (!MergeDate.Keys.Contains(item_id))//不存在商品編號的添加
                    {
                        List<OrderDetailQuery> s = new List<OrderDetailQuery>();
                        MergeDate.Add(item_id, s);
                    }
                    MergeDate[item_id].Add(item);//通過商品編號把相同商品房在同一個集合里
                }
                StringBuilder html_table = new StringBuilder();//匯出html頁面
                html_table.AppendFormat(@"<div>&nbsp;<table style='border:1px solid; text-align:center'>");//550//滚动条overflow:auto;
                html_table.AppendFormat("<tr style='background-color:Lime'><td style='height:50px;border:1px solid;'>商品編號</td><td style='border:1px solid; '>商品名稱</td><td style='border:1px solid;'>數量</td>");
                html_table.AppendFormat("<td style='border:1px solid;'>廠商自訂編號</td><td style='border:1px solid;'>付款單編號</td><td style='border:1px solid;'>訂購人</td>");
                html_table.AppendFormat(" <td style='border:1px solid;'>收件人</td><td style='border:1px solid;'>數量</td><td style='border:1px solid;'>總價</td><td style='border:1px solid;'>備註</td></tr>");
                //   int subtotal = 1;
                foreach (var item in MergeDate.Keys)//這個循環商品編號,然後再循環同一種編號下面的集合
                {
                    uint SumNo = 0;//計算總數量
                    foreach (var items in MergeDate[item])//循環同一種商品編號下面的集合
                    {
                        SumNo += items.Buy_Num;
                    }
                    int r = 0;
                    foreach (var items in MergeDate[item])//循環同一種商品編號下面的集合
                    {
                        int row = MergeDate[item].Count;//合併的列
                        //if (subtotal % 28 == 0)
                        //{
                        //    html_table.AppendFormat("<tr style='page-break-after:always;'>");//
                        //}
                        //else
                        //{
                        html_table.AppendFormat("<tr>");
                        //}
                        if (r == 0)//合併數據
                        {
                            html_table.AppendFormat("<td rowspan='{0}' style='border:1px solid;'>{1}</td>", row, items.Item_Id);//商品編號
                            items.Product_Name = items.Product_Name.Replace("\n", "");
                            html_table.AppendFormat("<td rowspan='{0}' style='border:1px solid;'>{1}</td>", row, items.Product_Name);//商品名稱
                            html_table.AppendFormat("<td rowspan='{0}' style='border:1px solid;'>{1}</td>", row, SumNo);//數量
                            html_table.AppendFormat("<td rowspan='{0}' style='border:1px solid;'>{1}</td>", row, items.Item_Code);//廠商自訂編號
                        }
                        html_table.AppendFormat("<td style='border:1px solid;'>{0}</td>", items.Order_Id);//付款單編號
                        html_table.AppendFormat("<td style='border:1px solid;'>{0}</td>", items.Order_Name);//訂購人
                        html_table.AppendFormat("<td style='border:1px solid;'>{0}</td>", items.Delivery_Name);//收件人
                        html_table.AppendFormat("<td style='border:1px solid;'>{0}</td>", items.Buy_Num);//數量
                        html_table.AppendFormat("<td style='border:1px solid;'>{0}</td>", items.Single_Price);//總價
                        items.Note_Order = items.Note_Order.Replace("\n", "");
                        html_table.AppendFormat("<td style='border:1px solid;'>{0}</td>", items.Note_Order);//備註
                        //subtotal += 1;
                        html_table.AppendFormat("</tr>");
                        r++;
                    }
                }
                #endregion
                html_table.AppendFormat("</table></div>");

                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd";
                string n = html_table.ToString();
                json = "{success:true,msg:\"" + html_table.ToString() + "\"}";
            }
            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,msg:0}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
示例#18
0
 //根據vendorid獲取供應商信息        
 public HttpResponseBase GetVendorDetail()
 {
     List<Vendor> stores = new List<Vendor>();
     Vendor q= new Vendor();
     _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
     string json = string.Empty;
     try
     {
         if (!string.IsNullOrEmpty(Request.Params["vid"]))
         {
             q.vendor_id = uint.Parse(Request.Params["vid"].ToString());
             stores = _orderDetailMgr.GetVendor(q);
             json = "{success:true,data:" + JsonConvert.SerializeObject(stores) + "}";//返回json數據
         }
         else
         {
             json = "{success:false}";
         }
     }
     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;
 }
示例#19
0
        public HttpResponseBase GetAmountDetial()
        {
            string json = string.Empty;
            try
            {
                _orderDetialMgr = new OrderDetailMgr(connectionString);
                OrderDetailQuery query = new OrderDetailQuery();
                int totalCount = 0;
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");//用於分頁的變量
                if (!string.IsNullOrEmpty(Request.Params["category_id"]))
                {
                    query.category_id = Convert.ToUInt32(Request.Params["category_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["category_status"]))
                {
                    query.category_status = Convert.ToInt32(Request.Params["category_status"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["date_stauts"]))
                {
                    query.date_stauts = Convert.ToInt32(Request.Params["date_stauts"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["date_start"]))
                {
                    query.date_start = Convert.ToDateTime(Request.Params["date_start"]);
                    query.date_start = Convert.ToDateTime(query.date_start.ToString("yyyy-MM-dd 00:00:00"));
                }
                if (!string.IsNullOrEmpty(Request.Params["date_end"]))
                {
                    query.date_end = Convert.ToDateTime(Request.Params["date_end"]);
                    query.date_end = Convert.ToDateTime(query.date_end.ToString("yyyy-MM-dd 23:59:59"));
                }
                int money;
                if (int.TryParse(Request.Params["c_money"], out money))
                {
                    query.c_money = money;
                }
                if (int.TryParse(Request.Params["c_money1"], out money))
                {
                    query.c_money1 = money;
                }


                DataTable store = _orderDetialMgr.GetAmountDetial(query, out totalCount);
                if (store != null && store.Rows.Count > 0)
                {
                    IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                    timeConverter.DateTimeFormat = "yyyy-MM-dd";
                    json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";
                }
            }
            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}";
            }


            this.Response.Clear();
            this.Response.Write(json.ToString());
            this.Response.End();
            return this.Response;
        }