//根據工作代號、細項編號 獲取商品數據
        public HttpResponseBase GetAseldListByItemid()
        {//判斷寄倉或者調度
            string json = String.Empty;

            Aseld m = new Aseld();
            List<AseldQuery> list = new List<AseldQuery>();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            try
            {
                m.assg_id = Request.Params["assg_id"].ToString().Trim();
                if (!string.IsNullOrEmpty(Request.Params["item_id"]))
                {
                    m.item_id = Convert.ToUInt32(Request.Params["item_id"].ToString().Trim());
                }
                if (_iasdMgr.GetCountByItem(m) == 0)
                {
                    json = "{success:true,totalCount:" + 0 + ",msg:1,data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回json數據     
                }
                else
                {
                    list = _iasdMgr.GetAseldListByItemid(m);
                    foreach (var item in list)
                    {
                        m.seld_id = item.seld_id;
                    }
                    m.wust_id = "BSY";
                    m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                    _iasdMgr.Updwust(m);
                    json = "{success:true,totalCount:" + list.Count + ",msg:0,data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回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.ToString());
            this.Response.End();
            return this.Response;
        }
        /// <summary>
        /// 撿貨——調度流程頁面加載數據
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetMarkTallyTW()
        {
            string json = string.Empty;
            string ord_id = Request.Params["ord_id"];
            string type = Request.Params["type"];
            AseldQuery ase = new AseldQuery();
            Aseld m = new Aseld();
            try
            {
                if (!string.IsNullOrEmpty(Request.Params["ord_id"]))
                {
                    ase.ord_id = int.Parse(Request.Params["ord_id"]);
                }
                if (!string.IsNullOrEmpty(Request.Params["freight_set"]))
                {
                    ase.freight_set = Request.Params["freight_set"].Substring(0, 1);
                }
                //if (!string.IsNullOrEmpty(Request.Params["deliver_code"]))
                //{
                //    ase.deliver_code = Request.Params["deliver_code"].Substring(0, 1);
                //}
                if (!string.IsNullOrEmpty(Request.Params["item_id"]))
                {
                    if (Request.Params["item_id"].Length == 6)
                    {
                        ase.item_id = uint.Parse(Request.Params["item_id"]);
                    }
                    else
                    {
                        ase.upc_id = Request.Params["item_id"];
                    }
                }
                _iasdMgr = new AseldMgr(mySqlConnectionString);
                DataTable dt = _iasdMgr.GetOrderProductInformation(ase);
                //0代表加載工作代號
                if (type == "0")//141980010
                {
                    if (dt.Rows.Count > 0)
                    {
                        json = "\"" + "assg_id" + "\"" + ":" + "\"" + dt.Rows[0]["assg_id"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "deliver_code" + "\"" + ":" + "\"" + dt.Rows[0]["deliver_code"].ToString() + "\"";
                    }
                }
                else
                {
                    if (dt.Rows.Count > 0)
                    {
                        //json = "\"" + "assg_id" + "\"" + ":" + "\"" + dr["assg_id"].ToString() + "\"";
                        if (!string.IsNullOrEmpty(dt.Rows[0]["prod_sz"].ToString()))
                        {
                            json = "\"" + "product_name" + "\"" + ":" + "\"" + dt.Rows[0]["description"].ToString() + " (" + dt.Rows[0]["prod_sz"].ToString() + ")\"";
                        }
                        else
                        {
                            json = "\"" + "product_name" + "\"" + ":" + "\"" + dt.Rows[0]["description"].ToString() + " " + dt.Rows[0]["prod_sz"].ToString() + "\"";
                        }
                        //json = "\"" + "product_name" + "\"" + ":" + "\"" + dt.Rows[0]["description"].ToString() + " " + dt.Rows[0]["prod_sz"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "seld_id" + "\"" + ":" + "\"" + dt.Rows[0]["seld_id"].ToString() + "\"";//row_id.唯一的
                        json += ",\r\n" + "\"" + "ord_qty" + "\"" + ":" + "\"" + dt.Rows[0]["ord_qty"].ToString() + "\"";//訂貨量
                        json += ",\r\n" + "\"" + "out_qty" + "\"" + ":" + "\"" + dt.Rows[0]["out_qty"].ToString() + "\"";//缺貨量
                        json += ",\r\n" + "\"" + "ordd_id" + "\"" + ":" + "\"" + dt.Rows[0]["ordd_id"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "deliver_id" + "\"" + ":" + "\"" + dt.Rows[0]["deliver_id"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "deliver_code" + "\"" + ":" + "\"" + dt.Rows[0]["deliver_code"].ToString() + "\"";
                        json += ",\r\n" + "\"" + "note_order" + "\"" + ":" + "\"" + dt.Rows[0]["note_order"].ToString() + "\"";
                        if (!string.IsNullOrEmpty(dt.Rows[0]["cde_dt_shp"].ToString()))
                        {
                            json += ",\r\n" + "\"" + "cde_dt_shp" + "\"" + ":" + "\"" + dt.Rows[0]["cde_dt_shp"].ToString() + "\"";//商品的允出天數

                        }
                        else
                        {
                            json += ",\r\n" + "\"" + "cde_dt_shp" + "\"" + ":" + "\"" + "999999" + "\"";//商品的允出天數
                        }
                        if (!string.IsNullOrEmpty(dt.Rows[0]["pwy_dte_ctl"].ToString()))
                        {
                            json += ",\r\n" + "\"" + "pwy_dte_ctl" + "\"" + ":" + "\"" + dt.Rows[0]["pwy_dte_ctl"].ToString() + "\"";//有效期控管
                        }
                        else
                        {
                            json += ",\r\n" + "\"" + "pwy_dte_ctl" + "\"" + ":" + "\"" + "N" + "\"";//有效期控管
                        }
                        #region 查詢商品信息同時把wust_id更改為BSY
                        m.wust_id = "BSY";
                        m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                        if (!string.IsNullOrEmpty(dt.Rows[0]["seld_id"].ToString()))
                        {
                            m.seld_id = int.Parse(dt.Rows[0]["seld_id"].ToString());
                        }
                        _iasdMgr.Updwust(m);
                        #endregion
                    }
                    else
                    {//判斷條碼輸入的是否正確
                        DataTable data = new DataTable();
                        Iupc i = new Iupc();
                        _IiupcMgr = new IupcMgr(mySqlConnectionString);
                        if (!string.IsNullOrEmpty(ase.upc_id))
                        {
                            i.upc_id = ase.upc_id;
                            data = _IiupcMgr.upcid(i);
                            if (data.Rows.Count > 0)
                            {
                                json = "\"" + "item_id" + "\"" + ":" + "\"" + data.Rows[0]["item_id"].ToString() + "\"";
                            }
                        }
                    }
                }
                json = "{success:true,data:\r\n  {\r\n" + json + "\r\n} \r\n" + "}";
            }
            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,data:\r\n  {\r\n" + "" + "\r\n} \r\n" + "}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        //根據工作代號、細項編號 獲取商品數據
        /// <summary>
        /// 自動理貨 根據工作代號/細項編號/訂單號/出貨單號獲取所有商品信息
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetAllAseldList()
        {//判斷寄倉或者調度
            string json = String.Empty;

            AseldQuery m = new AseldQuery();
            List<AseldQuery> list = new List<AseldQuery>();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            int totalCount = 0;
            try
            {

                string search_type = Request.Params["search_type"].ToString().Trim();
                if (!string.IsNullOrEmpty(Request.Params["search_con"].ToString().Trim()))
                {
                    if (search_type == "assg_id")
                    {
                        m.assg_id = Request.Params["search_con"].ToString().Trim();
                    }
                    else if (search_type == "item_id")
                    {
                        m.item_id = Convert.ToUInt32(Request.Params["search_con"].ToString().Trim());
                    }
                    else if (search_type == "ord_id")
                    {
                        m.ord_id = Convert.ToInt32(Request.Params["search_con"].ToString().Trim());
                    }
                    else if (search_type == "deliver_code")
                    {
                        m.deliver_code = Request.Params["search_con"].ToString().Trim();
                    }
                    else
                    {

                    }
                }
                if (!string.IsNullOrEmpty(Request.Params["start_time"]))
                {
                    m.start_time = Convert.ToDateTime(Convert.ToDateTime(Request.Params["start_time"]).ToString("yyyy-MM-dd 00:00:00"));
                }
                if (!string.IsNullOrEmpty(Request.Params["end_time"]))
                {
                    m.end_time = Convert.ToDateTime(Convert.ToDateTime(Request.Params["end_time"]).ToString("yyyy-MM-dd 23:59:59"));
                }
                
                list = _iasdMgr.GetAllAseldList(m, out totalCount);
                foreach (var item in list)
                {
                    m.seld_id = item.seld_id;
                }
                m.wust_id = "BSY";
                m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                _iasdMgr.Updwust(m);
                json = "{success:true,totalCount:"+ totalCount +",data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回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.ToString());
            this.Response.End();
            return this.Response;
        }
 //理貨員工作--寄倉--獲取商品數據
 public HttpResponseBase JudgeAssg()
 {//判斷寄倉或者調度
     string json = String.Empty;
     string id = Request.Params["assg_id"];
     Aseld m = new Aseld();
     List<AseldQuery> list = new List<AseldQuery>();
     _iasdMgr = new AseldMgr(mySqlConnectionString);
     try
     {
         if (id.Length > 9)
         {//獲取寄倉信息
             m.assg_id = id;
             list = _iasdMgr.GetAseldList(m);
             foreach (var item in list)
             {
                 m.seld_id = item.seld_id;
             }
             m.wust_id = "BSY";
             m.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
             _iasdMgr.Updwust(m);
         }
         json = "{success:true,data:" + JsonConvert.SerializeObject(list, Formatting.Indented) + "}";//返回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.ToString());
     this.Response.End();
     return this.Response;
 }