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