Example #1
0
 public DataTable GetOrderProductInformation(AseldQuery ase)
 {
     try
     {
         return _aseldDao.GetOrderProductInformation(ase);
     }
     catch (Exception ex)
     {
         throw new Exception("AseidMgr-->GetOrderProductInformation-->" + ex.Message, ex);
     }
 }
Example #2
0
 public string AddIwsRecord(AseldQuery a)
 {
     try
     {
         return _aseldDao.AddIwsRecord(a);
     }
     catch (Exception ex)
     {
         throw new Exception("AseldMgr-->UpdateAseld-->" + ex.Message, ex);
     }
 }
Example #3
0
        public DataTable GetAseldTable(AseldQuery ase,out int total)
        {
            ase.Replace4MySQL();
            total = 0;
            string sql = "";
            StringBuilder strAll = new StringBuilder();
            StringBuilder strWhr = new StringBuilder();
            StringBuilder strLimit=new StringBuilder();
            StringBuilder strJoin=new StringBuilder();
            strAll.Append("SELECT a.assg_id,p.product_id,p.product_name,pi.item_id,ps.spec_name AS spec,ps2.spec_name as spec_name2 ,SUM(out_qty)out_qty,SUM(act_pick_qty)act_pick_qty,SUM(a.ord_qty)ord_qty, a.create_dtim,");
            strAll.Append(" case ic.lcat_id when 'S' then i.loc_id else IFNULL(ic.lcat_id,case p.product_mode when 2 then 'YY999999' when 3 then 'ZZ999999' else i.loc_id end ) end as loc_id,i.loc_id as loc_id1, ");
            strAll.Append(" temp.parameterName,ic.lcat_id,ic.lcat_id as upc_id   FROM aseld  a ");
            strJoin.Append(" inner JOIN product_item pi ON a.item_id=pi.item_id");
            strJoin.Append(" inner JOIN product p ON p.product_id=pi.product_id");
            strJoin.Append(" LEFT JOIN iplas i ON pi.item_id=i.item_id");
            strJoin.Append(" left JOIN iloc ic ON ic.loc_id=i.loc_id");
            strJoin.Append(" LEFT JOIN product_spec ps ON pi.spec_id_1= ps.spec_id ");
            strJoin.Append(" LEFT JOIN product_spec ps2 ON pi.spec_id_2= ps2.spec_id");
            strJoin.Append(" LEFT JOIN (select parameterCode,parameterName from t_parametersrc where parameterType ='product_mode') temp ON p.product_mode=temp.parameterCode");

            strWhr.Append(" WHERE a.wust_id<>'COM'");
            if (!string.IsNullOrEmpty(ase.assg_id))
            {
                strWhr.AppendFormat(" and a.assg_id='{0}' ", ase.assg_id);
            }
            if (ase.start_dtim!=DateTime.MinValue)
            {
                strWhr.AppendFormat(" and a.create_dtim between '{0}' and  '{1}'", CommonFunction.DateTimeToString(ase.start_dtim), CommonFunction.DateTimeToString(ase.change_dtim));
            }
            strWhr.Append(" GROUP BY a.item_id,a.assg_id  ORDER BY loc_id asc ");
            if(ase.IsPage)
            {
                total = Convert.ToInt32(_access.getDataTable("SELECT count(item_id) FROM(SELECT a.item_id,case ic.lcat_id when 'S' then i.loc_id else IFNULL(ic.lcat_id,case p.product_mode when 2 then 'YY999999' when 3 then 'ZZ999999' else i.loc_id end ) end as loc_id FROM aseld a " + strJoin.ToString() + strWhr.ToString() + ") temp").Rows[0][0]);
                strLimit.AppendFormat(" LIMIT {0},{1};",ase.Start,ase.Limit);
            }
            try
            {

                sql = strAll.ToString()+strJoin.ToString()+strWhr.ToString() + strLimit.ToString();
                DataTable _dt = _access.getDataTable(sql);
                foreach (DataRow item in _dt.Rows)
                {
                    item["spec"] = string.IsNullOrEmpty(item["spec"].ToString()) ? item["spec_name2"] : (string.IsNullOrEmpty(item["spec_name2"].ToString()) ? item["spec"].ToString() : item["spec"].ToString() + "-" + item["spec_name2"].ToString());
                }
                return _dt;
            }
            catch (Exception ex)
            {
                throw new Exception("AseldDao.GetAseldTable-->" + ex.Message + sql, ex);
            }
        }
Example #4
0
        /// <summary>
        /// 缺貨總報表
        /// </summary>
        /// <returns></returns>
        public DataTable GetNComJobSimple(AseldQuery query=null)
        {
            StringBuilder sql = new StringBuilder();
            StringBuilder sqlwhere = new StringBuilder();
            sql.AppendLine(@"SELECT ase.assg_id as '工作代號',CASE when ase.assg_id LIKE 'N%' THEN '常溫' WHEN ase.assg_id LIKE 'F%' THEN '冷凍' END AS '溫層',");
            sql.AppendLine(@"SUM(out_qty) as'缺貨數量' ,CASE(commodity_type) when 2 THEN '寄倉' WHEN 3 THEN '調度' END AS '寄倉/調度',ase.create_dtim as '生成理貨單時間' ");
            sql.AppendLine(@" from aseld_master am INNER JOIN aseld ase on am.assg_id =ase.assg_id");
            sqlwhere.AppendLine(@" where 1=1  ");
            if (query != null)
            {
                if (query.create_dtim > DateTime.MinValue)
                {
                    sqlwhere.AppendFormat(@" and ase.create_dtim >='{0}'", query.create_dtim.ToString("yyyy-MM-dd 00:00:00"));
                }
                if (query.create_dtim2 > DateTime.MinValue)
                {
                    sqlwhere.AppendFormat(@" and ase.create_dtim <='{0}'", query.create_dtim2.ToString("yyyy-MM-dd 23:59:59"));
                }
            }

            sqlwhere.Append(" and wust_id <>'COM'  GROUP BY ase.assg_id, commodity_type");
            try
            {
                return _access.getDataTable(sql.ToString() + sqlwhere.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("AseldDao.GetNComJobSimple-->" + ex.Message + sql.ToString(), ex);
            }

        }
Example #5
0
        /// <summary>
        /// 通過item_id查詢product_ext里的數據
        /// </summary>
        /// <param name="ase"></param>
        /// <returns></returns>

        #region 判斷調度是否完成
        /// <summary>
        /// 判斷調度是否檢完,檢完了是否檢夠,檢夠了訂單下的寄倉+調度是否檢夠,然後返回是否可以裝箱
        /// </summary>
        /// <param name="ase">實體</param>
        /// <param name="commodity_type">調度 3</param>
        /// <returns></returns>
        public int DecisionBulkPicking(AseldQuery ase, int commodity_type)//判断检货
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                #region 判断调度检货
                sb.AppendFormat(@"select seld_id from aseld where ord_id='{0}' and commodity_type='{1}' and deliver_id='{2}' and wust_id <>'COM' and scaned='0';", ase.ord_id, commodity_type, ase.deliver_id);/*调度,先判断检完没有*/
                DataTable result = _access.getDataTable(sb.ToString());
                sb.Clear();
                if (result.Rows.Count > 0)//调度未检的货物
                {
                    //訂單下的商品未撿完,繼續循環
                    return 1;
                }
                //撿完
                else
                {
                    sb.AppendFormat(@"select seld_id from aseld where ord_id='{0}' and commodity_type='{1}' and wust_id <> 'COM';", ase.ord_id, commodity_type);/*调度,先判断检完没有*/
                    DataTable dt = _access.getDataTable(sb.ToString());
                    sb.Clear();
                    if (dt.Rows.Count == 0)
                    {
                        sb.AppendFormat(@"select seld_id from aseld where ord_id='{0}' and wust_id <> 'COM' ;", ase.ord_id, commodity_type);/*查询此訂單下所有商品,不管寄仓或调度*/
                        DataTable result2 = _access.getDataTable(sb.ToString());
                        if (result2.Rows.Count == 0)
                        {
                            if (SelComC(ase) == 0)
                            {
                                return 3;//提示所有商品<寄仓+调度>已经检够。可以装箱
                            }
                            else
                            {
                                return 5;//提示有退換貨商品,請示領導!
                            }
                        }
                        else
                        {
                            return 4;//此訂單下尚有寄倉商品未撿完
                        }

                    }
                    else
                    {
                        //此訂單下調度商品已撿完,但有商品缺貨
                        return 2;
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                throw new Exception("AseldDao-->DecisionBulkPicking-->" + ex.Message + sb.ToString(), ex);
            }
        }
Example #6
0
        /// <summary>
        /// 調度頁面數據
        /// </summary>
        /// <returns></returns>
        public DataTable GetOrderProductInformation(AseldQuery ase)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(@"SELECT assg_id,ase.seld_id,CONCAT(v.brand_name,'-',p.product_name) as description,ase.prod_sz,ase.ord_qty,ase.out_qty,ase.ordd_id,");
            sql.AppendFormat(@"pe.cde_dt_shp,pe.pwy_dte_ctl,ase.deliver_id,ase.deliver_code,o.note_order from aseld ase");
            sql.AppendLine(@" left JOIN product_ext pe on pe.item_id=ase.item_id  ");
            sql.AppendLine(@"  LEFT JOIN product_item pi ON pi.item_id=ase.item_id  ");
            sql.AppendLine(@" LEFT JOIN product p ON pi.product_id=p.product_id   ");
            sql.AppendLine(@" LEFT JOIN vendor_brand v ON p.brand_id=v.brand_id  ");
            sql.AppendLine(@"  LEFT JOIN order_master o ON ase.ord_id=o.order_id  ");           

            if (!string.IsNullOrEmpty(ase.upc_id))
            {
                sql.AppendLine(@" left JOIN iupc upc on upc.item_id=ase.item_id ");
            }
            sql.AppendFormat(@"where ord_id='{0}' and commodity_type=3 and wust_id <>'COM'", ase.ord_id);
            if (ase.item_id != 0)
            {
                sql.AppendFormat(@" and ase.item_id='{0}'", ase.item_id);
            }
            if (!string.IsNullOrEmpty(ase.upc_id))
            {
                sql.AppendFormat(@" and upc.upc_id='{0}'", ase.upc_id);
            }
            if (!string.IsNullOrEmpty(ase.deliver_code))
            {
                sql.AppendFormat(@" and deliver_code='{0}'", ase.deliver_code);
            }
            if (!string.IsNullOrEmpty(ase.freight_set) && ase.freight_set!="0")
            {
                sql.AppendFormat(@" and assg_id like '{0}%' ", ase.freight_set);
            }
            sql.AppendLine(@" limit 1 ");
            try
            {
                return _access.getDataTable(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("AseidDao.GetOrderProductInformation-->" + ex.Message + sql.ToString(), ex);
            }
        }
        public HttpResponseBase GETMarkTallyWD()
        {
            StringBuilder sb = new StringBuilder();
            string json = String.Empty;
            AseldQuery m = new AseldQuery();
            List<AseldQuery> list = new List<AseldQuery>();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            int flag = 2;
            int try1 = 0;
            try
            {
                m.seld_id = Int32.Parse(Request.Params["seld_id"]);//aseld的流水號
                m.commodity_type = Request.Params["commodity_type"];//獲取寄倉2和調度3
                m.ord_qty = Int32.Parse(Request.Params["ord_qty"]);//需要訂貨數量
                if (Int32.TryParse(Request.Params["act_pick_qty"], out try1))
                {
                    m.act_pick_qty = Int32.Parse(Request.Params["act_pick_qty"]);
                }
                else
                {
                    m.act_pick_qty = 0;
                }
                m.item_id = uint.Parse(Request.Params["item_id"]);
                m.out_qty = Int32.Parse(Request.Params["out_qty"]) - m.act_pick_qty;//缺貨數量
                m.act_pick_qty = m.ord_qty - m.out_qty;
                m.complete_dtim = DateTime.Now;
                m.assg_id = Request.Params["assg_id"];
                m.ord_id = Int32.Parse(Request.Params["ord_id"]);
                m.ordd_id = int.Parse(Request.Params["ordd_id"]);//商品細項編號。操作iwms_record需要
                m.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                m.deliver_code = Request.Params["deliver_id"];
                m.deliver_id = int.Parse(m.deliver_code.Substring(1, m.deliver_code.Length - 1).ToString());
                if (m.out_qty == 0)
                {//揀完了,判斷缺貨數量是否為0
                    m.wust_id = "COM";
                }
                else
                {//沒拿夠貨物
                    m.wust_id = "SKP";
                }
                sb.Append(_iasdMgr.UpdAseld(m));
                if (m.commodity_type == "2")
                {
                    #region 寄倉--對庫存進行操作
                    Dictionary<string, string> dickuCun = new Dictionary<string, string>();
                    if (Int32.TryParse(Request.Params["act_pick_qty"], out try1))
                    {
                        if (!string.IsNullOrEmpty(Request.Params["pickRowId"]))
                        {
                            string[] iinvd = Request.Params["pickRowId"].Split(',');
                            string[] pick = Request.Params["pickInfo"].Split(',');
                            for (int i = 0; i < iinvd.Length; i++)
                            {
                                if (!dickuCun.Keys.Contains(iinvd[i]))
                                {
                                    dickuCun.Add(iinvd[i], pick[i]);
                                }
                                else
                                {
                                    dickuCun[iinvd[i]] = pick[i];
                                }
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(_iasdMgr.updgry(m, dickuCun)))
                    {
                        sb.Append(_iasdMgr.updgry(m, dickuCun));
                    }
                    if (!string.IsNullOrEmpty(sb.ToString()))
                    {
                        _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理
                    }
                    int ord = 1;
                    int cancel = 0;
                    int ord_id = 0;
                    #region  判斷項目狀態
                    if (_iasdMgr.SelCom(m) == 0)
                    {
                        ord = 0;
                        ord_id = m.ord_id;
                        //訂單揀貨完成,可以封箱
                    }
                    if (_iasdMgr.SelComA(m) == 0)
                    {
                        flag = 0;//項目訂單揀貨完成
                    }
                    if (ord == 0)
                    {//有沒有臨時取消的商品
                        if (_iasdMgr.SelComC(m) > 0)
                        {
                            cancel = 1; ord_id = m.ord_id;
                        }
                    }
                    #endregion
                    json = "{success:true,qty:'" + m.out_qty + "',flag:'" + flag + "',ord:'" + ord + "',cancel:'" + cancel + "',ord_id:'" + ord_id + "'}";//返回json數據  
                    //qty 該物品是否缺貨,如果為零揀貨完成,否則彈框提示缺貨數量。
                    //over:0表示該訂單已經揀貨完畢,如果qty為零則提示該訂單可以封箱,qty不為零則提示該訂單還缺物品的數量。不為零則不提示任何信息。
                    #endregion
                }
                else if (m.commodity_type == "3")
                {
                    #region 調度--對庫存進行操作
                    m.change_user = int.Parse((Session["caller"] as Caller).user_id.ToString());//操作iwms_record 需要插入create_uaer_id。对aseld中的change_user未做任何改变
                    m.act_pick_qty = Int32.Parse(Request.Params["act_pick_qty"]);//下一步插入檢貨記錄表,每檢一次記錄一次,實際撿貨量以傳過來的值為標準
                    if (_iasdMgr.getTime(m).Rows.Count > 0)
                    {//獲取到有效期控管商品的保質期
                        m.cde_dt_incr = int.Parse(_iasdMgr.getTime(m).Rows[0]["cde_dt_incr"].ToString());
                        m.cde_dt_shp = int.Parse(_iasdMgr.getTime(m).Rows[0]["cde_dt_shp"].ToString());
                    }
                    if (!string.IsNullOrEmpty(Request.Params["cde_dt"]))
                    {//獲取有效日期算出製造日期
                        m.cde_dt = DateTime.Parse(Request.Params["cde_dt"]);
                        if (m.cde_dt_incr > 0)
                        {
                            m.made_dt = m.cde_dt.AddDays(-m.cde_dt_incr);
                        }
                        else
                        {
                            m.made_dt = DateTime.Now;
                        }
                    }
                    else if (!string.IsNullOrEmpty(Request.Params["made_dt"]))
                    {//獲取製造日期獲取有效日期
                        m.made_dt = DateTime.Parse(Request.Params["made_dt"]);
                        if (m.cde_dt_incr > 0)
                        {
                            m.cde_dt = m.made_dt.AddDays(m.cde_dt_incr);
                        }
                        else
                        {
                            m.cde_dt = DateTime.Now;
                        }
                    }
                    else
                    {//不是有效期控管
                        m.made_dt = DateTime.Now;
                        m.cde_dt = DateTime.Now;
                    }
                    if (m.act_pick_qty > 0)
                    {
                        sb.Append(_iasdMgr.AddIwsRecord(m));
                    }
                    //m.act_pick_qty = m.ord_qty - m.out_qty;
                    _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理
                    int result = _iasdMgr.DecisionBulkPicking(m, 3);//判斷調度是否檢完,是否檢夠,是否可以裝箱

                    json = "{success:true,msg:'" + result + "'" + "}";//返回json數據  
                    #endregion
                }
            }
            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;
        }
Example #8
0
        public bool RFAutoMarketTally(int seld_id)
        {
            int totalCount = 0;
            List<string> iinvd;
            List<string> pick;
            bool markettally = false;
            try
            {
                //根據seld_id獲取aseld記錄信息;
                AseldQuery query_ase = new AseldQuery();
                query_ase.seld_id = seld_id;
                List<AseldQuery> ase = _aseldDao.GetAllAseldList(query_ase, out totalCount);
                if (ase.Count == 1)
                {
                }
                else
                {
                    return false;
                }

                //根據item_id獲取庫存信息;
                IinvdQuery query_ivd = new IinvdQuery()
                {
                    ista_id = "A"
                };
                query_ivd.item_id = ase[0].item_id;
                int out_qty = ase[0].out_qty;
                if (out_qty < 0)
                {
                    return false;
                }
                List<IinvdQuery> store_ivd = GetIinvdListByItemid(query_ivd, out totalCount);
                int stocksum = GetStockSum(store_ivd, out_qty, out iinvd, out pick);
                //if (ase[0].sel_loc == "YY999999")
                //{
                //    //沒有主料位,記庫存帳卡
                //    //結單
                //    bool markettally = GETMarkTallyWD(ase[0], stocksum, iinvd.ToArray(), pick.ToArray());
                //}
                if (stocksum < out_qty)
                {
                    //庫調
                    int result = RFKT(ase[0], store_ivd[0], out_qty - stocksum + store_ivd[0].prod_qty);
                    if (result == 100)
                    {
                        //刷新庫存信息
                        store_ivd = GetIinvdListByItemid(query_ivd, out totalCount);
                        stocksum = GetStockSum(store_ivd, out_qty, out iinvd, out pick);
                        if (stocksum <= out_qty)
                        {
                            //結單
                            markettally = GETMarkTallyWD(ase[0], stocksum, iinvd.ToArray(), pick.ToArray());
                        }
                        else
                        {
                            markettally = false;
                        }
                    }
                    else
                    {
                        //庫調失敗
                        markettally = false;
                    }
                }
                else if (stocksum >= out_qty)
                {
                    //結單
                    markettally = GETMarkTallyWD(ase[0], out_qty, iinvd.ToArray(), pick.ToArray());
                }
                else
                {
                    markettally = false;
                }
            }
            catch (Exception ex)
            {
                throw new Exception("MarketTallyMgr-->RFAutoMarketTally" + ex.Message, ex);
            }

            return markettally;
        }
Example #9
0
 public DataTable GetAseldTablePDF(AseldQuery aseld)
 {
     try
     {
         return _aseldDao.GetAseldTablePDF(aseld);
     }
     catch (Exception ex)
     {
         throw new Exception("AseldMgr-->GetAseldTablePDF-->" + ex.Message, ex);
     }
 }
Example #10
0
 public DataTable GetAseldTable(AseldQuery ase, out int total)
 {
     try
     {
         return _aseldDao.GetAseldTable(ase, out total);
     }
     catch (Exception ex)
     {
         throw new Exception("AseldMgr-->GetAseldTable-->" + ex.Message, ex);
     }
 } 
Example #11
0
 public DataTable getTime(AseldQuery a)
 {
     try
     {
         return _iinvdDao.getTime(a);
     }
     catch (Exception ex)
     {
         throw new Exception("AseldMgr-->getTime-->" + ex.Message, ex);
     }
 }
Example #12
0
 public DataTable ExportAseldMessage(AseldQuery ase)
 {
     try
     {
         return _aseldDao.ExportAseldMessage(ase);
     }
     catch (Exception ex)
     {
         throw new Exception("AseldMgr-->ExportAseldMessage-->" + ex.Message, ex);
     }
 }
Example #13
0
        public DataTable GetDetailOrSimple(string type, string jobNumbers, AseldQuery query = null)
        {
            try
            {
                if (type == "0")
                {
                    return _aseldDao.GetNComJobSimple(query);
                }
                else
                {
                    return _aseldDao.GetNComJobDetail(jobNumbers,query);
                } 
            }
            catch (Exception ex)
            {
                throw new Exception("AseldMgr-->GetDetailOrSimple-->" + ex.Message, ex);
        }

        }
Example #14
0
        public int DecisionBulkPicking(AseldQuery ase, int commodity_type) 
        {
            try
            {
                return _aseldDao.DecisionBulkPicking(ase, commodity_type);
            }
            catch (Exception ex)
            {

                throw new Exception("AseldMgr-->DecisionBulkPicking-->" + ex.Message, ex);
            }
        }
Example #15
0
        public int RFKT(AseldQuery ase, IinvdQuery ivd,int pnum)
        {
            string json = string.Empty;
            int result = 0;
            IialgQuery q = new IialgQuery();
            uint id = 0; DateTime dt = new DateTime(); int sun = 0;
            _proditemMgr = new ProductItemMgr(mySqlConnectionString);
            ProductItem Proitems = new ProductItem();

            try
            {
                {//商品id
                    q.item_id = ase.item_id;
                    Proitems.Item_Id = ase.item_id;
                }
                // (DateTime.TryParse(Request.Params["made_date"].ToString(), out dt))
                {//商品製造日期
                    //q.made_dt = ivd.made_date;
                    q.made_dt = new DateTime(3000,1,1);
                }
                //if (int.TryParse(Request.Params["prod_qty"].ToString(), out sun))
                {//商品原有數量
                    q.qty_o = ivd.prod_qty;
                }
                //if (int.TryParse(Request.Params["pnum"].ToString(), out sun))
                {//商品撿貨數量
                    q.pnum = pnum;
                }
                //if (!string.IsNullOrEmpty(Request.Params["loc_id"].ToString()))
                {//商品撿貨數量
                    q.loc_id = ase.sel_loc;
                }
                //if (!string.IsNullOrEmpty(Request.Params["order_id"]))
                {
                    q.order_id = ase.ord_id.ToString();
                }
                q.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                //進行庫調
                _iagDao = new IialgDao(mySqlConnectionString);
                Caller call = new Caller();
                call = (System.Web.HttpContext.Current.Session["caller"] as Caller);
                string path = "/WareHouse/KutiaoAddorReduce";
                //if (q.loc_id == "YY999999") 無主料位時也進行庫調
                if (false)
                {
                    json = "{success:false}";
                }
                else
                {
                    Proitems.Item_Stock = q.pnum - q.qty_o;
                    result = _iagDao.addIialgIstock_AutoMarket(q);
                    if (result == 2)
                    {
                        json = "{success:true,msg:2}";
                    }
                    if (result == 100)
                    {
                        //_proditemMgr.UpdateItemStock(Proitems, path, call);
                        json = "{success:true,msg:100}";
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("MarketTallyMgr-->RFKT-->" + ex.Message, ex);
            }
            return result;
        }
Example #16
0
        public bool GETMarkTallyWD(AseldQuery ase, int act_pick_qty,string[] iinvd,string[] pick)
        {
            ////
            StringBuilder sb = new StringBuilder();
            string json = String.Empty;
            AseldQuery m = new AseldQuery();
            List<AseldQuery> list = new List<AseldQuery>();
            _aseldDao = new AseldDao(mySqlConnectionString);
            int flag = 2;
            int try1 = 0;
            try
            {
                m.seld_id = ase.seld_id;//aseld的流水號
                m.commodity_type = "2";//獲取寄倉2和調度3
                m.ord_qty = ase.ord_qty;//需要訂貨數量
                m.act_pick_qty = act_pick_qty;
                
                m.item_id = ase.item_id;
                m.out_qty = ase.out_qty - m.act_pick_qty;//缺貨數量
                m.act_pick_qty = m.ord_qty - m.out_qty;
                m.complete_dtim = DateTime.Now;
                m.assg_id = ase.assg_id;
                m.ord_id = ase.ord_id;
                m.ordd_id = ase.ordd_id;//商品細項編號。操作iwms_record需要
                m.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id;
                m.deliver_code = ase.deliver_code;
                m.deliver_id = int.Parse(m.deliver_code.Substring(1, m.deliver_code.Length - 1).ToString());
                if (m.out_qty == 0)
                {//揀完了,判斷缺貨數量是否為0
                    m.wust_id = "COM";
                }
                else
                {//沒拿夠貨物
                    m.wust_id = "SKP";
                }
                sb.Append(_aseldDao.UpdAseld(m));
                if (m.commodity_type == "2")
                {
                    #region 寄倉--對庫存進行操作
                    Dictionary<string, string> dickuCun = new Dictionary<string, string>();
                    //if (Int32.TryParse(Request.Params["act_pick_qty"], out try1))
                    {
                        //string[] iinvd = Request.Params["pickRowId"].Split(',');
                        //string[] pick = Request.Params["pickInfo"].Split(',');
                        for (int i = 0; i < iinvd.Length; i++)
                        {
                            if (!dickuCun.Keys.Contains(iinvd[i]))
                            {
                                dickuCun.Add(iinvd[i], pick[i]);
                            }
                            else
                            {
                                dickuCun[iinvd[i]] = pick[i];
                            }
                        }
                    }
                    _iinvdDao = new IinvdDao(mySqlConnectionString);
                    if (!string.IsNullOrEmpty(_iinvdDao.updgry(m, dickuCun)))
                    {
                        sb.Append(_iinvdDao.updgry(m, dickuCun));
                    }
                    if (!string.IsNullOrEmpty(sb.ToString()))
                    {
                        _aseldDao.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理
                    }
                    int ord = 1;
                    int can = 0;
                    #region  判斷項目狀態
                    if (_aseldDao.SelCom(m) == 0)
                    {
                        ord = 0;//訂單揀貨完成,可以封箱
                    }
                    if (_aseldDao.SelComA(m) == 0)
                    {
                        flag = 0;//項目訂單揀貨完成
                    }
                    if (ord == 0)
                    {//有沒有臨時取消的商品
                        if (_aseldDao.SelComC(m) > 0)
                        {
                            can = 1;
                        }
                    }
                    #endregion
                    json = "{success:true,qty:'" + m.out_qty + "',flag:'" + flag + "',ord:'" + ord + "',can:'" + can + "'}";//返回json數據  
                    //qty 該物品是否缺貨,如果為零揀貨完成,否則彈框提示缺貨數量。
                    //over:0表示該訂單已經揀貨完畢,如果qty為零則提示該訂單可以封箱,qty不為零則提示該訂單還缺物品的數量。不為零則不提示任何信息。
                    #endregion
                }
                
                //else if (m.commodity_type == "3")
                //{
                //    #region 調度--對庫存進行操作
                //    m.change_user = int.Parse((Session["caller"] as Caller).user_id.ToString());//操作iwms_record 需要插入create_uaer_id。对aseld中的change_user未做任何改变
                //    m.act_pick_qty = Int32.Parse(Request.Params["act_pick_qty"]);//下一步插入檢貨記錄表,每檢一次記錄一次,實際撿貨量以傳過來的值為標準
                //    if (_iasdMgr.getTime(m).Rows.Count > 0)
                //    {//獲取到有效期控管商品的保質期
                //        m.cde_dt_incr = int.Parse(_iasdMgr.getTime(m).Rows[0]["cde_dt_incr"].ToString());
                //        m.cde_dt_shp = int.Parse(_iasdMgr.getTime(m).Rows[0]["cde_dt_shp"].ToString());
                //    }
                //    if (!string.IsNullOrEmpty(Request.Params["cde_dt"]))
                //    {//獲取有效日期算出製造日期
                //        m.cde_dt = DateTime.Parse(Request.Params["cde_dt"]);
                //        if (m.cde_dt_incr > 0)
                //        {
                //            m.made_dt = m.cde_dt.AddDays(-m.cde_dt_incr);
                //        }
                //        else
                //        {
                //            m.made_dt = DateTime.Now;
                //        }
                //    }
                //    else if (!string.IsNullOrEmpty(Request.Params["made_dt"]))
                //    {//獲取製造日期獲取有效日期
                //        m.made_dt = DateTime.Parse(Request.Params["made_dt"]);
                //        if (m.cde_dt_incr > 0)
                //        {
                //            m.cde_dt = m.made_dt.AddDays(m.cde_dt_incr);
                //        }
                //        else
                //        {
                //            m.cde_dt = DateTime.Now;
                //        }
                //    }
                //    else
                //    {//不是有效期控管
                //        m.made_dt = DateTime.Now;
                //        m.cde_dt = DateTime.Now;
                //    }
                //    if (m.act_pick_qty > 0)
                //    {
                //        sb.Append(_iasdMgr.AddIwsRecord(m));
                //    }
                //    //m.act_pick_qty = m.ord_qty - m.out_qty;
                //    _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理
                //    int result = _iasdMgr.DecisionBulkPicking(m, 3);//判斷調度是否檢完,是否檢夠,是否可以裝箱

                //    json = "{success:true,msg:'" + result + "'" + "}";//返回json數據  
                //    #endregion
                //}
            }
            catch (Exception ex)
            {
                throw new Exception("MarketTallyMgr-->GETMarkTallyWD-->" + ex.Message, ex);
            }
            return true;
        }
Example #17
0
        public HttpResponseBase AseldList()
        {
            string json = string.Empty;
            int totalcount = 0;
            AseldQuery query = new AseldQuery();
            query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
            query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
            IAseldImplMgr aseldMgr = new AseldMgr(mySqlConnectionString);

            if (!string.IsNullOrEmpty(Request.Params["assg_id"]))
            {
                query.assg_id = Request.Params["assg_id"];
            }
            DateTime date = DateTime.MinValue;
            if (!string.IsNullOrEmpty(Request.Params["start_time"]))//開始時間
            {
                if (DateTime.TryParse(Request.Params["start_time"], out date))
                {
                    query.start_dtim = Convert.ToDateTime(date.ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }
            if (!string.IsNullOrEmpty(Request.Params["end_time"]))//結束時間
            {
                if (DateTime.TryParse(Request.Params["end_time"], out date))
                {
                    query.change_dtim = Convert.ToDateTime(date.ToString("yyyy-MM-dd HH:mm:ss"));
                }
            }
            DataTable table = aseldMgr.GetAseldTable(query, out totalcount);
            _IiupcMgr = new IupcMgr(mySqlConnectionString);
            IupcQuery queryIupc = new IupcQuery();
            string upc_id = string.Empty;
            List<IupcQuery> list = new List<IupcQuery>();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                //string lcat_id = table.Rows[i]["lcat_id"].ToString();
                //if (lcat_id != "S")
                //{
                //    string parameterName = table.Rows[i]["parameterName"].ToString();
                //    if (parameterName == "寄倉")
                //    {
                //        table.Rows[i]["loc_id"] = "YY999999";
                //    }
                //    else if (parameterName == "調度")
                //    {
                //        table.Rows[i]["loc_id"] = "ZZ999999";
                //    }
                //}
                uint item_id = uint.Parse(table.Rows[i]["item_id"].ToString());
                queryIupc.item_id = item_id;
                queryIupc.upc_type_flg = "1";
                list = _IiupcMgr.GetIupcByType(queryIupc);
                int j = 0;
                if (list.Count > 0)
                {
                    table.Rows[i]["upc_id"] = list[0].upc_id;
                    j++;
                }
                else
                {
                    queryIupc.upc_type_flg = "3";
                    list = _IiupcMgr.GetIupcByType(queryIupc);
                    if (list.Count > 0)
                    {
                        table.Rows[i]["upc_id"] = list[0].upc_id;
                        j++;
                    }
                    else
                    {
                        queryIupc.upc_type_flg = "2";
                        list = _IiupcMgr.GetIupcByType(queryIupc);
                        if (list.Count > 0)
                        {
                            table.Rows[i]["upc_id"] = list[0].upc_id;
                            j++;
                        }
                    }
                }
                if(j==0)
                {
                    table.Rows[i]["upc_id"] ="";
                }
            }
            IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
            timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
            json = "{success:true,totalCount:" + totalcount + ",data:" + JsonConvert.SerializeObject(table, Formatting.Indented, timeConverter) + "}";
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return 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;
        }
Example #19
0
        public void AseldPDFS()
        {
            PdfHelper pdf = new PdfHelper();
            List<string> pdfList = new List<string>();
            float[] arrColWidth = new float[] {  135,50,45, 60,  55, 55,60, 45,  35, 45, 45, 35 };
            int index = 0;
            string newFileName = string.Empty;
            string newName = string.Empty;
            string json = string.Empty;
            BaseFont bf = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED);
            iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bf, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED);
            iTextSharp.text.Font font = new iTextSharp.text.Font(bf, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑  
            string filename = "總量撿貨報表" + DateTime.Now.ToString("yyyyMMddHHmmss");
            Document document = new Document(PageSize.A4.Rotate());
            string newPDFName = Server.MapPath(excelPath) + filename;
            PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create));
            document.Open();


            string user_username = (Session["caller"] as Caller).user_username;
            DataTable aseldTable = new DataTable();
            DataTable assg_idTable = new DataTable();
            AseldQuery ase_query = new AseldQuery();
            ase_query.IsPage = false;
            ase_query.assg_id = string.Empty;
            ase_query.start_dtim = DateTime.MinValue;
            ase_query.change_dtim = DateTime.MinValue;
            int total = 0;

            //PdfHelper pdf = new PdfHelper();
            //List<string> pdfList = new List<string>();
            //string newfilename = string.Empty;
            //string filename = "待撿貨商品報表" + DateTime.Now.ToString("yyyyMMddHHmmss");
            //string newPDFName = Server.MapPath(excelPath) + filename;
            //int index = 0;
            int serchWhr = 0;

            if (!string.IsNullOrEmpty(Request.Params["assg_id"]))
            {
                ase_query.assg_id = Request.Params["assg_id"].Trim();
                serchWhr++;
            }
            DateTime date = DateTime.MinValue;
            if (Request.Params["start_time"] != "null" && Request.Params["end_time"] != "null")
            {
                if (DateTime.TryParse(Request.Params["start_time"], out date))
                {
                    ase_query.start_dtim = Convert.ToDateTime(date.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (DateTime.TryParse(Request.Params["end_time"], out date))
                {
                    ase_query.change_dtim = Convert.ToDateTime(date.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                serchWhr++;
            }
            IAseldImplMgr aseldMgr = new AseldMgr(mySqlConnectionString);

            DataTable _dtBody = new DataTable();
           
            _dtBody.Columns.Add("商品名稱", typeof(string));
            _dtBody.Columns.Add("料位編號", typeof(string));
            _dtBody.Columns.Add("撿貨庫存", typeof(string));
            _dtBody.Columns.Add("本次撿貨量", typeof(string));
            _dtBody.Columns.Add("製造日期", typeof(string)); 
            _dtBody.Columns.Add("有效日期", typeof(string));
            _dtBody.Columns.Add("條碼", typeof(string));
            _dtBody.Columns.Add("細項編號", typeof(string));

            _dtBody.Columns.Add("訂貨量", typeof(string));
            _dtBody.Columns.Add("已撿貨量", typeof(string));
            _dtBody.Columns.Add("待撿貨量", typeof(string));
           
            
            _dtBody.Columns.Add("備註", typeof(string));
            PdfPTable ptablefoot = new PdfPTable(14);
            #region MyRegion



            #region 數據行
            if (ase_query.assg_id != string.Empty)
            {
                _dtBody.Rows.Clear();
                aseldTable = aseldMgr.GetAseldTable(ase_query, out total);
                #region 標頭
                #region 表頭
                PdfPTable ptable = new PdfPTable(12);


                ptable.WidthPercentage = 100;//表格寬度
                ptable.SetTotalWidth(arrColWidth);
                PdfPCell cell = new PdfPCell();
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 4;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("總量撿貨報表", new iTextSharp.text.Font(bf, 18)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;
                cell.Colspan = 5;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("印表人:" + user_username, new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 6;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("印表時間:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                #endregion
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 4;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("工作代號:" + ase_query.assg_id, new iTextSharp.text.Font(bf, 15)));
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                cell.Colspan = 5;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 3;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("商品名稱", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("料位編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("撿貨庫存", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("本次撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("製造日期", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                //cell = new PdfPCell(new Phrase("撿貨料位編號", new iTextSharp.text.Font(bf, 8)));
                //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //cell.DisableBorderSide(8);
                //ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("有效日期", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
               
               
               

                cell = new PdfPCell(new Phrase("訂貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("已撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("待撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
               
           

                //cell = new PdfPCell(new Phrase("創建時間", new iTextSharp.text.Font(bf, 8)));
                //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                ptable.AddCell(cell);
                #endregion
                #region 新增功能


                if (aseldTable.Rows.Count > 0)
                {
                    _iinvd = new IinvdMgr(mySqlConnectionString);//  GetSearchIinvd
                    _IiupcMgr = new IupcMgr(mySqlConnectionString);
                    foreach (DataRow rows in aseldTable.Rows)
                    {
                        IinvdQuery IinvdQuery = new IinvdQuery();
                        IinvdQuery.item_id = uint.Parse(rows["item_id"].ToString());
                        IinvdQuery.ista_id = "A";
                        List<IinvdQuery> Store = new List<IinvdQuery>();
                        Store = _iinvd.GetPlasIinvd(IinvdQuery);
                        int P_num = string.IsNullOrEmpty(rows["out_qty"].ToString()) ? 0 : int.Parse(rows["out_qty"].ToString()); /*要撿貨的數量*/
                        string upc_id = string.Empty;
                        #region 取條碼

                        List<IupcQuery> list = new List<IupcQuery>();
                        IupcQuery iupc_query = new IupcQuery();
                        if (!string.IsNullOrEmpty(rows["item_id"].ToString()))
                        {
                            uint item_id = uint.Parse(rows["item_id"].ToString());
                            iupc_query.item_id = item_id;
                            iupc_query.upc_type_flg = "1";
                            list = _IiupcMgr.GetIupcByType(iupc_query);
                            if (list.Count > 0)
                            {
                                upc_id = list[0].upc_id;
                            }
                            else
                            {
                                iupc_query.upc_type_flg = "3";
                                list = _IiupcMgr.GetIupcByType(iupc_query);
                                if (list.Count > 0)
                                {
                                    upc_id = list[0].upc_id;
                                }
                                else
                                {
                                    iupc_query.upc_type_flg = "2";
                                    list = _IiupcMgr.GetIupcByType(iupc_query);
                                    if (list.Count > 0)
                                    {
                                        upc_id = list[0].upc_id;
                                    }
                                }
                            }
                        }
                        
                        else
                        {
                            upc_id = " ";
                        }
                        #endregion

                        if (Store.Count > 0)
                        {
                            int crorow = 0;
                            for (int i = 0; i < Store.Count; i++)
                            {
                                DataRow row = _dtBody.NewRow();
                                if (Store[i].prod_qty > P_num)
                                {
                                    if (crorow != 0)
                                    {
                                        row["商品名稱"] = "";
                                        row["條碼"] = "";
                                        row["細項編號"] ="";
                                        row["訂貨量"] = "";
                                        row["已撿貨量"] = "";
                                        row["待撿貨量"] = "";
                                        row["料位編號"] = "";
                                    }
                                    else
                                    {
                                        row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                        row["條碼"] = upc_id;
                                        row["細項編號"] = rows["item_id"];
                                        row["訂貨量"] = rows["ord_qty"];
                                        row["已撿貨量"] = rows["act_pick_qty"];
                                        row["待撿貨量"] = rows["out_qty"];
                                        row["料位編號"] = rows["loc_id"];
                                    }
                                    row["製造日期"] = string.IsNullOrEmpty(Store[i].made_date.ToString()) ? " " : Store[i].made_date.ToString("yyyy/MM/dd");
                                    row["有效日期"] = string.IsNullOrEmpty(Store[i].cde_dt.ToString()) ? " " : Store[i].cde_dt.ToString("yyyy/MM/dd");
                                    row["撿貨庫存"] = P_num;
                                    row["本次撿貨量"] = " ";
                                    row["備註"] = " ";
                                    // row["撿貨料位編號"] = Store[i].plas_loc_id;
                                   
                                   
                                  //  row["創建時間"] = rows["create_dtim"];
                                  
                                    _dtBody.Rows.Add(row);
                                    break;
                                }
                                else
                                {
                                    if (crorow != 0)
                                    {
                                        row["商品名稱"] = "";
                                        row["條碼"] = "";
                                        row["細項編號"] = "";
                                        row["訂貨量"] = "";
                                        row["已撿貨量"] = "";
                                        row["待撿貨量"] = "";
                                        row["料位編號"] = "";
                                    }
                                    else
                                    {
                                        row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                        row["條碼"] = upc_id;
                                        row["細項編號"] = rows["item_id"];
                                        row["訂貨量"] = rows["ord_qty"];
                                        row["已撿貨量"] = rows["act_pick_qty"];
                                        row["待撿貨量"] = rows["out_qty"];
                                        row["料位編號"] = rows["loc_id"];
                                    }
                                    row["製造日期"] = string.IsNullOrEmpty(Store[i].made_date.ToString()) ? " " : Store[i].made_date.ToString("yyyy/MM/dd");
                                    row["有效日期"] = string.IsNullOrEmpty(Store[i].cde_dt.ToString()) ? " " : Store[i].cde_dt.ToString("yyyy/MM/dd");
                                    row["撿貨庫存"] = Store[i].prod_qty;
                                    row["本次撿貨量"] = " ";

                                    //row["撿貨料位編號"] = Store[i].plas_loc_id;
                                  //  row["創建時間"] = rows["create_dtim"];
                                    row["備註"] = " ";
                                    _dtBody.Rows.Add(row);
                                    P_num -= Store[i].prod_qty;
                                    crorow++;
                                    if (P_num == 0)
                                        break;
                                }

                            }
                            // _dtBody.Rows.Add(row);
                        }
                        else
                        {
                            DataRow row = _dtBody.NewRow();
                            row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                            row["條碼"] = upc_id;
                            row["細項編號"] = rows["item_id"];
                            row["訂貨量"] = rows["ord_qty"];
                            row["已撿貨量"] = rows["act_pick_qty"];
                            row["待撿貨量"] = rows["out_qty"];
                            row["本次撿貨量"] = " ";
                            row["料位編號"] = rows["loc_id"];
                            //row["撿貨料位編號"] = " ";
                            row["撿貨庫存"] = 0;
                            row["製造日期"] = " ";
                            row["有效日期"] = " ";
                         //   row["創建時間"] = rows["create_dtim"];
                            row["備註"] = " ";
                            _dtBody.Rows.Add(row);
                        }


                    }
                }
                #endregion

                //  pdfList.Add(MakePDF(aseldTable, ase_query.assg_id, user_username, newPDFName, index++));
                newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 12, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                pdfList.Add(newFileName);
            }
            else if (ase_query.start_dtim != DateTime.MinValue && ase_query.change_dtim != DateTime.MinValue || serchWhr == 0)
            {
                assg_idTable = aseldMgr.GetAseldTablePDF(ase_query);
                for (int a = 0; a < assg_idTable.Rows.Count; a++)
                {
                    ase_query.assg_id = assg_idTable.Rows[a]["assg_id"].ToString();
                    aseldTable = aseldMgr.GetAseldTable(ase_query, out total);
                    _dtBody.Rows.Clear();
                    #region 標頭
                    #region 表頭
                    PdfPTable ptable = new PdfPTable(12);


                    ptable.WidthPercentage = 100;//表格寬度
                    ptable.SetTotalWidth(arrColWidth);
                    PdfPCell cell = new PdfPCell();
                    cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 12;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 4;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("總量撿貨報表", new iTextSharp.text.Font(bf, 18)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;
                    cell.Colspan = 5;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 4;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 12;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("印表人:" + user_username, new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 3;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 6;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("印表時間:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                    cell.Colspan = 3;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.Colspan = 12;
                    cell.DisableBorderSide(1);
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    #endregion
                    cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                    cell.Colspan = 4;
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("工作代號:" + ase_query.assg_id, new iTextSharp.text.Font(bf, 15)));
                    cell.VerticalAlignment = Element.ALIGN_CENTER;
                    cell.Colspan = 5;
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                    cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                    cell.Colspan = 3;
                    cell.DisableBorderSide(2);
                    cell.DisableBorderSide(4);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("商品名稱", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("料位編號", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                     cell = new PdfPCell(new Phrase("撿貨庫存", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("本次撿貨量", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("製造日期", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    //cell = new PdfPCell(new Phrase("撿貨料位編號", new iTextSharp.text.Font(bf, 8)));
                    //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    //cell.DisableBorderSide(8);
                    //ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("有效日期", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                    
                   
                   

                    cell = new PdfPCell(new Phrase("訂貨量", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("已撿貨量", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("待撿貨量", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    cell.DisableBorderSide(8);
                    ptable.AddCell(cell);
                   
                  

                    //cell = new PdfPCell(new Phrase("創建時間", new iTextSharp.text.Font(bf, 8)));
                    //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    //ptable.AddCell(cell);

                    cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                    cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                    ptable.AddCell(cell);
                    #endregion


                    #region 新增功能


                    if (aseldTable.Rows.Count > 0)
                    {
                        _iinvd = new IinvdMgr(mySqlConnectionString);//  GetSearchIinvd
                        _IiupcMgr = new IupcMgr(mySqlConnectionString);
                        foreach (DataRow rows in aseldTable.Rows)
                        {
                            IinvdQuery IinvdQuery = new IinvdQuery();
                            IinvdQuery.item_id = uint.Parse(rows["item_id"].ToString());
                            IinvdQuery.ista_id = "A";
                            List<IinvdQuery> Store = new List<IinvdQuery>();
                            Store = _iinvd.GetPlasIinvd(IinvdQuery);
                            int P_num = string.IsNullOrEmpty(rows["out_qty"].ToString()) ? 0 : int.Parse(rows["out_qty"].ToString()); /*要撿貨的數量*/
                            string upc_id = string.Empty;
                            #region 取條碼

                            List<IupcQuery> list = new List<IupcQuery>();
                            IupcQuery iupc_query = new IupcQuery();
                            if (!string.IsNullOrEmpty(rows["item_id"].ToString()))
                            {
                                uint item_id = uint.Parse(rows["item_id"].ToString());
                                iupc_query.item_id = item_id;
                                iupc_query.upc_type_flg = "1";
                                list = _IiupcMgr.GetIupcByType(iupc_query);
                                if (list.Count > 0)
                                {
                                    upc_id = list[0].upc_id;
                                }
                                else
                                {
                                    iupc_query.upc_type_flg = "3";
                                    list = _IiupcMgr.GetIupcByType(iupc_query);
                                    if (list.Count > 0)
                                    {
                                        upc_id = list[0].upc_id;
                                    }
                                    else
                                    {
                                        iupc_query.upc_type_flg = "2";
                                        list = _IiupcMgr.GetIupcByType(iupc_query);
                                        if (list.Count > 0)
                                        {
                                            upc_id = list[0].upc_id;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                upc_id = " ";
                            }
                            #endregion

                            if (Store.Count > 0)
                            {
                                int crorow = 0;
                                for (int i = 0; i < Store.Count; i++)
                                {
                                    DataRow row = _dtBody.NewRow();
                                    if (Store[i].prod_qty > P_num)
                                    {
                                        if (crorow != 0)
                                        {
                                            row["商品名稱"] = "";
                                            row["條碼"] = "";
                                            row["細項編號"] = "";
                                            row["訂貨量"] = "";
                                            row["已撿貨量"] = "";
                                            row["待撿貨量"] = "";
                                            row["料位編號"] = "";
                                        }
                                        else
                                        {
                                            row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                            row["條碼"] = upc_id;
                                            row["細項編號"] = rows["item_id"];
                                            row["訂貨量"] = rows["ord_qty"];
                                            row["已撿貨量"] = rows["act_pick_qty"];
                                            row["待撿貨量"] = rows["out_qty"];
                                            row["料位編號"] = rows["loc_id"];
                                        }
                                        row["製造日期"] = string.IsNullOrEmpty(Store[i].made_date.ToString()) ? " " : Store[i].made_date.ToString("yyyy/MM/dd");
                                        row["有效日期"] = string.IsNullOrEmpty(Store[i].cde_dt.ToString()) ? " " : Store[i].cde_dt.ToString("yyyy/MM/dd");
                                        row["撿貨庫存"] = P_num;
                                        row["本次撿貨量"] = " ";
                                        row["備註"] = " ";
                                        _dtBody.Rows.Add(row);
                                        break;
                                    }
                                    else
                                    {
                                        if (crorow != 0)
                                        {
                                            row["商品名稱"] = "";
                                            row["條碼"] = "";
                                            row["細項編號"] = "";
                                            row["訂貨量"] = "";
                                            row["已撿貨量"] = "";
                                            row["待撿貨量"] = "";
                                            row["料位編號"] = "";
                                        }
                                        else
                                        {
                                            row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                            row["條碼"] = upc_id;
                                            row["細項編號"] = rows["item_id"];
                                            row["訂貨量"] = rows["ord_qty"];
                                            row["已撿貨量"] = rows["act_pick_qty"];
                                            row["待撿貨量"] = rows["out_qty"];
                                            row["料位編號"] = rows["loc_id"];
                                        }
                                        row["製造日期"] = string.IsNullOrEmpty(Store[i].made_date.ToString()) ? " " : Store[i].made_date.ToString("yyyy/MM/dd");
                                        row["有效日期"] = string.IsNullOrEmpty(Store[i].cde_dt.ToString()) ? " " : Store[i].cde_dt.ToString("yyyy/MM/dd");
                                        row["撿貨庫存"] = Store[i].prod_qty;
                                        row["本次撿貨量"] = " ";

                                        //row["撿貨料位編號"] = Store[i].plas_loc_id;
                                        //  row["創建時間"] = rows["create_dtim"];
                                        row["備註"] = " ";
                                        _dtBody.Rows.Add(row);
                                        crorow++;
                                        P_num -= Store[i].prod_qty;
                                        if (P_num == 0)
                                            break;
                                    }

                                }
                                // _dtBody.Rows.Add(row);
                            }
                            else
                            {
                                DataRow row = _dtBody.NewRow();
                                row["商品名稱"] = rows["product_name"] + rows["spec"].ToString();
                                row["條碼"] = upc_id;
                                row["細項編號"] = rows["item_id"];
                                row["訂貨量"] = rows["ord_qty"];
                                row["已撿貨量"] = rows["act_pick_qty"];
                                row["待撿貨量"] = rows["out_qty"];
                                
                                row["本次撿貨量"] = " ";
                                row["料位編號"] = rows["loc_id"];
                                //row["撿貨料位編號"] = " ";
                                row["撿貨庫存"] = 0;
                                row["製造日期"] = " ";
                                row["有效日期"] = " ";
                              //  row["創建時間"] = rows["create_dtim"];
                                row["備註"] = " ";
                                _dtBody.Rows.Add(row);
                            }


                        }
                    }
                    #endregion

                    //  pdfList.Add(MakePDF(aseldTable, ase_query.assg_id, user_username, newPDFName, index++));
                    newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                    pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 12, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                    pdfList.Add(newFileName);
                }
            }
            #endregion

            #endregion
           
          
            if (_dtBody.Rows.Count == 0)
            {
                #region 標頭
                #region 表頭
                PdfPTable ptable = new PdfPTable(12);


                ptable.WidthPercentage = 100;//表格寬度
                ptable.SetTotalWidth(arrColWidth);
                PdfPCell cell = new PdfPCell();
                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 4;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("總量撿貨報表", new iTextSharp.text.Font(bf, 18)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;
                cell.Colspan = 5;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("印表人:" + user_username, new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 6;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("印表時間:" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss"), new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 3;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.Colspan = 12;
                cell.DisableBorderSide(1);
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                #endregion
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 4;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("工作代號:" + ase_query.assg_id, new iTextSharp.text.Font(bf, 15)));
                cell.VerticalAlignment = Element.ALIGN_CENTER;
                cell.Colspan = 5;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase(" ", new iTextSharp.text.Font(bf, 8)));
                cell.VerticalAlignment = Element.ALIGN_RIGHT;//字體水平居右
                cell.Colspan = 3;
                cell.DisableBorderSide(2);
                cell.DisableBorderSide(4);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("商品名稱", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("料位編碼", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("撿貨庫存", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("本次撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("製造日期", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                //cell = new PdfPCell(new Phrase("撿貨料位編號", new iTextSharp.text.Font(bf, 8)));
                //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //cell.DisableBorderSide(8);
                //ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("有效日期", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                cell = new PdfPCell(new Phrase("條碼", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                
               
                cell = new PdfPCell(new Phrase("細項編號", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("訂貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("已撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("待撿貨量", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);
                


                //cell = new PdfPCell(new Phrase("創建時間", new iTextSharp.text.Font(bf, 8)));
                //cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                //ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("備註", new iTextSharp.text.Font(bf, 12)));
                cell.VerticalAlignment = Element.ALIGN_LEFT;//字體水平居左
                ptable.AddCell(cell);
                #endregion
                document = new Document(PageSize.A4.Rotate());
                if (!document.IsOpen())
                {
                    document.Open();
                }
                cell = new PdfPCell(new Phrase(" ", font));
                cell.Colspan = 5;
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                cell.DisableBorderSide(8);
                ptable.AddCell(cell);

                cell = new PdfPCell(new Phrase("此工作代號無數據!", font));
                cell.Colspan = 9;
                cell.DisableBorderSide(4);
                cell.VerticalAlignment = Element.ALIGN_CENTER;//字體水平居左
                ptable.AddCell(cell);


                // document.Add(ptable);
                //document.Add(ptablefoot); 
                newFileName = newPDFName + "_part" + index++ + "." + "pdf";
                pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 12, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
                pdfList.Add(newFileName);

            }
            //else
            //{
            //    newFileName = newPDFName + "_part" + index++ + "." + "pdf";

            //    pdf.ExportDataTableToPDF(_dtBody, false, newFileName, arrColWidth, ptable, ptablefoot, "", "", 11, uint.Parse(_dtBody.Rows.Count.ToString()));/*第一7是列,第二個是行*/
            //    pdfList.Add(newFileName);

            //}

            newFileName = newPDFName + "." + "pdf";
            pdf.MergePDF(pdfList, newFileName);

            Response.Clear();
            Response.Charset = "gb2312";
            Response.ContentEncoding = System.Text.Encoding.UTF8;
            Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename + ".pdf");
            Response.WriteFile(newFileName);

        }
Example #20
0
        public List<AseldQuery> GetAllAseldList(AseldQuery a, out int totalCount)
        {
            StringBuilder sql = new StringBuilder();//left join iloc ic on i.plas_loc_id=ic.loc_id 
            StringBuilder sqlCount = new StringBuilder();
            StringBuilder sqlWhere = new StringBuilder();
            try
            {
                sqlCount.AppendFormat(@"SELECT count(seld_id) as totalCount ");
                sql.AppendFormat(@"SELECT seld_id,assg_id,case when ip.loc_id is null then 'YY999999' else ip.loc_id end as sel_loc,CONCAT('(',a.item_id,')',v.brand_name,'-',p.product_name) as description,concat(IFNULL(ps1.spec_name,''),IFNULL(ps2.spec_name,'')) as prod_sz,ord_qty,out_qty,ord_id,cust_name,a.item_id,ordd_id,upc_id,pe.cde_dt_shp,deliver_id,deliver_code,o.note_order,ic.hash_loc_id ");
                //LEFT JOIN iinvd i ON a.item_id=i.item_id i.cde_dt,
                sqlWhere.AppendFormat(@" FROM aseld a  
LEFT JOIN product_ext pe ON a.item_id = pe.item_id 
LEFT JOIN iplas ip on a.item_id=ip.item_id 
left join iloc ic on ip.loc_id=ic.loc_id  
LEFT JOIN product_item pi ON a.item_id = pi.item_id 
LEFT JOIN product_spec ps1 ON pi.spec_id_1 = ps1.spec_id
LEFT JOIN product_spec ps2 ON pi.spec_id_2 = ps2.spec_id
LEFT JOIN product p ON pi.product_id=p.product_id 
LEFT JOIN vendor_brand v ON p.brand_id=v.brand_id
LEFT JOIN order_master o ON a.ord_id=o.order_id
            WHERE wust_id<>'COM' AND commodity_type='2'");// and scaned='0' 
                if (a.seld_id != 0)
                {
                    sqlWhere.AppendFormat(" and a.seld_id='{0}' ", a.seld_id);
                }
                if (!string.IsNullOrEmpty(a.assg_id))
                {
                    sqlWhere.AppendFormat(" and a.assg_id='{0}' ", a.assg_id);
                }
                if (a.item_id != 0)
                {
                    sqlWhere.AppendFormat(" and a.item_id='{0}' ", a.item_id);
                }
                if (a.ord_id != 0)
                {
                    sqlWhere.AppendFormat(" and a.ord_id='{0}' ", a.ord_id);
                }
                if (!string.IsNullOrEmpty(a.deliver_code))
                {
                    sqlWhere.AppendFormat(" and a.deliver_code='{0}' ", a.deliver_code);
                }
                if (a.start_time != DateTime.MinValue && a.end_time != DateTime.MinValue)
                {
                    sqlWhere.AppendFormat(" and a.create_dtim between '{0}' and '{1}'",
                      CommonFunction.DateTimeToString(a.start_time), CommonFunction.DateTimeToString(a.end_time));

                }
                sqlWhere.AppendFormat(" ORDER BY sel_loc,seld_id ");
                totalCount = 0;
                if (a.IsPage)
                {
                    DataTable _dt = _access.getDataTable(sqlCount.ToString() + sqlWhere.ToString());
                    if (_dt.Rows.Count > 0)
                    {
                        totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]);
                        sqlWhere.AppendFormat(" limit {0},{1};", a.Start, a.Limit);
                    }
                }
                return _access.getDataTableForObj<AseldQuery>(sql.ToString() + sqlWhere.ToString());

            }
            catch (Exception ex)
            {
                throw new Exception("AseldDao.GetAllAseldList-->" + ex.Message + sql.ToString() + sqlWhere.ToString(), ex);
            }
            
        }
Example #21
0
        /// <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;
        }
Example #22
0
 /// <summary>
 /// 检一次货物,插入一条数据进入检货记录
 /// </summary>
 /// <param name="a">实体,通过订单编号和条码编号修改</param>
 /// <returns></returns>
 public string AddIwsRecord(AseldQuery m)
 {
     StringBuilder sb = new StringBuilder();
     try
     {
         //m.item_id;
         sb.AppendFormat("INSERT INTO iwms_record (order_id,detail_id,act_pick_qty,cde_dt,status,create_date,create_user_id,cde_dt_incr,made_dt,cde_dt_shp) VALUES(");
         sb.AppendFormat("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}');", m.ord_id, m.ordd_id, m.act_pick_qty, CommonFunction.DateTimeToString(m.cde_dt), 1, CommonFunction.DateTimeToString(DateTime.Now), m.change_user, m.cde_dt_incr, CommonFunction.DateTimeToString(m.made_dt),m.cde_dt_shp);
         return sb.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception("AseidDao-->AddIwsRecord-->" + ex.Message + sb.ToString(), ex);
     }
 }
Example #23
0
        public void OutUndoneJobExl()
        {
            string type = string.Empty;
            AseldQuery asd = new AseldQuery();
            DataTable dt = new DataTable();
            StringBuilder sbJobsNumber = new StringBuilder();
            _iasdMgr = new AseldMgr(mySqlConnectionString);
            try
            {
                //選擇製作總表,還是產生明細報表
                if (Request.Params["radio1"] == "true")
                {
                    type = "0";
                }
                if (Request.Params["radio2"] == "true")
                {
                    type = "1";
                    if (!string.IsNullOrEmpty(Request.Params["assg_id"]))
                    {
                        //asd.assg_id = Request["assg_id"].Replace(",",",");
                        string str = Request["assg_id"].Replace(",", ",");
                        string[] strs = str.Split(',');
                        foreach (string item in strs)
                        {
                            asd.assg_id = item;
                            sbJobsNumber.AppendFormat("'{0}',", asd.assg_id);
                        }
                    }
                }
                DateTime time;
                asd.create_dtim = DateTime.MinValue;
                if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time) && Request.Params["starttime"].Substring(0, 10) != "1970-01-01")
                {

                    asd.create_dtim = DateTime.Parse(Request.Params["starttime"]).ToString("yyyy-MM-dd") == "1970-01-01" ? DateTime.MinValue : DateTime.Parse(Request.Params["starttime"]);
                }
                if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time) && Request.Params["endtime"].Substring(0, 10) != "1970-01-01")
                {
                    asd.create_dtim2 = DateTime.Parse(Request.Params["endtime"]).ToString("yyyy-MM-dd") == "1970-01-01" ? DateTime.MinValue : DateTime.Parse(Request.Params["endtime"]);
                }
                string jobNumbers = sbJobsNumber.ToString().TrimEnd(',');
                string fileName = string.Empty;
                MemoryStream ms = new MemoryStream();
                if (type == "0")
                {
                    fileName = "缺貨總報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    ms = ExcelHelperXhf.ExportDT(_iasdMgr.GetDetailOrSimple(type, jobNumbers, asd), "總表~未完成理貨工作_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
                }
                else if (type == "1")
                {
                    fileName = "缺貨明細報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
                    ms = ExcelHelperXhf.ExportDT(_iasdMgr.GetDetailOrSimple(type, jobNumbers, asd), "缺貨明細~未完成理貨工作_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
                }

                Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                Response.BinaryWrite(ms.ToArray());
            }
            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);
            }
        }
Example #24
0
        /// <summary>
        /// 缺貨明細報表
        /// </summary>
        /// <returns></returns>
        public DataTable GetNComJobDetail(string jobNumbers,AseldQuery query=null)
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine(@"SELECT assg_id as '工作代號',deliver_code as '出貨單號',CASE when assg_id LIKE 'N%' THEN '常溫' when assg_id LIKE 'F%' THEN '冷凍' END AS '溫層',");
            sql.AppendLine(@"ord_id as '訂單號',aseld.item_id as '品號',CONCAT(v.brand_name,'-',p.product_name) as '品名',concat(IFNULL(ps1.spec_name,''),IFNULL(ps2.spec_name,'')) as '規格',");
            sql.AppendLine(@"CASE when plas.loc_id IS NULL THEN CASE(commodity_type) when 2 THEN 'YY999999' when 3 then 'ZZ999999' END  ELSE plas.loc_id END as '料位'  ,ord_qty as '訂貨量',act_pick_qty as '已撿數量',out_qty as '缺貨數量', ");
            sql.AppendLine(@"CASE(commodity_type) when 2 THEN '寄倉' WHEN 3 THEN '調度' END AS '寄倉/調度',aseld.create_dtim as '生成理貨單時間' ");
            sql.AppendLine(@" from aseld LEFT JOIN  iplas plas ON plas.item_id=aseld.item_id ");
            sql.AppendFormat(@" LEFT JOIN product_item pi ON pi.item_id=aseld.item_id
LEFT JOIN product_spec ps1 ON pi.spec_id_1 = ps1.spec_id
LEFT JOIN product_spec ps2 ON pi.spec_id_2 = ps2.spec_id 
LEFT JOIN product p ON pi.product_id=p.product_id 
LEFT JOIN vendor_brand v ON p.brand_id=v.brand_id
");

            sql.AppendFormat("where wust_id <>'COM' ");
            if (!string.IsNullOrEmpty(jobNumbers))
            {
                sql.AppendFormat(" AND assg_id in({0})", jobNumbers);
            }
            if (query != null)
            {
                if (query.create_dtim > DateTime.MinValue)
                {
                    sql.AppendFormat(@" and aseld.create_dtim >='{0}'", query.create_dtim.ToString("yyyy-MM-dd 00:00:00"));
                }
                if (query.create_dtim2 > DateTime.MinValue)
                {
                    sql.AppendFormat(@" and aseld.create_dtim <='{0}'", query.create_dtim2.ToString("yyyy-MM-dd 23:59:59"));
                }
            }
            try
            {
                return _access.getDataTable(sql.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception("AseldDao.GetNComJobDetail-->" + ex.Message + sql.ToString(), ex);
            }
        }
Example #25
0
 public void ExportAseldMessage()
 {
     string json = string.Empty;
     AseldQuery m = new AseldQuery();
     if (!string.IsNullOrEmpty(Request.Params["job_id"]))
     {//料位開始
         m.assg_id = Request.Params["job_id"];
     }
     if (!string.IsNullOrEmpty(Request.Params["aseld_type"]))
     {
         m.commodity_type = Request.Params["aseld_type"];
     }
     if (!System.IO.Directory.Exists(Server.MapPath(excelPath)))
     {
         System.IO.Directory.CreateDirectory(Server.MapPath(excelPath));
     }
     DataTable dtHZ = new DataTable();
     string newExcelName = string.Empty;
     dtHZ.Columns.Add("出貨單號", typeof(String));
     dtHZ.Columns.Add("訂單編號", typeof(String));
     dtHZ.Columns.Add("料位", typeof(String));
     dtHZ.Columns.Add("數量", typeof(String));
     dtHZ.Columns.Add("已撿", typeof(String));
     dtHZ.Columns.Add("缺", typeof(String));
     dtHZ.Columns.Add("品號", typeof(String));
     dtHZ.Columns.Add("條碼", typeof(String));
     dtHZ.Columns.Add("商品名稱", typeof(String));
     dtHZ.Columns.Add("狀態", typeof(String));
     dtHZ.Columns.Add("規格", typeof(String));
     try
     {
         DataTable dt = new DataTable();
         _iasdMgr = new AseldMgr(mySqlConnectionString);
         _IiupcMgr = new IupcMgr(mySqlConnectionString);
         dt = _iasdMgr.ExportAseldMessage(m);
         foreach (DataRow item in dt.Rows)
         {
             DataRow dr = dtHZ.NewRow();
             dr[0] = item["deliver_code"];
             dr[1] = item["ord_id"];
             //dr[1] = item["sel_loc"];
             if (string.IsNullOrEmpty(item["loc_id"].ToString()))
             {
                 switch (item["commodity_type"].ToString())
                 {
                     case "2": dr[2] = "YY999999"; break;
                     case "3": dr[2] = "ZZ999999"; break;
                 }
             }
             else
             {
                 dr[2] = item["loc_id"];
             }
             dr[3] = item["out_qty"];
             dr[4] = string.Empty;
             dr[5] = string.Empty;
             dr[6] = item["item_id"];
             dr[7] = " " + _IiupcMgr.Getupc(item["item_id"].ToString(), "0");
             dr[8] = item["product_name"];
             dr[9] = item["wust_id"];
             dr[10] = item["prod_sz"];
             dtHZ.Rows.Add(dr);
         }
         string str = "撿貨報表by料位";
         if (!string.IsNullOrEmpty(m.assg_id))
         {
             if (m.assg_id.IndexOf('N') == 0)
             {
                 str = m.assg_id + "(常溫/";
             }
             else if (m.assg_id.IndexOf('N') != 0 && m.assg_id.IndexOf('F') == 0)
             {
                 str = m.assg_id + "(冷凍/";
             }
         }
         if (m.commodity_type == "2")
         {
             str = str + "寄倉)";
         }
         else if (m.commodity_type == "3")
         {
             str = str + "調度)";
         }
         string fileName = str + DateTime.Now.ToString("_yyyyMMddHHmmss") + ".xls";
         MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, str + "_" + DateTime.Now.ToString("yyyyMMddHHmmss"));
         Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
         Response.BinaryWrite(ms.ToArray());
     }
     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,data:[]}";
     }
 }
Example #26
0
        public DataTable ExportAseldMessage(AseldQuery ase)
        {
            StringBuilder strsb = new StringBuilder();
            if (!string.IsNullOrEmpty(ase.assg_id))
            {
                strsb.AppendFormat(" and asd.assg_id='{0}' ", ase.assg_id);
            }
            if (!string.IsNullOrEmpty(ase.commodity_type))
            {
                strsb.AppendFormat(" and asd.commodity_type ='{0}'", ase.commodity_type);
            }
            strsb.Append(" order by loc_id;");
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat(@"
SELECT CONCAT(v.brand_name,'-',p.product_name) AS 'product_name',asd.ord_id,asd.assg_id,asd.item_id,concat(IFNULL(ps1.spec_name,''),IFNULL(ps2.spec_name,'')) as prod_sz,
CASE when plas.loc_id IS NULL THEN CASE(commodity_type) when 2 THEN 'YY999999' when 3 then 'ZZ999999' END  ELSE plas.loc_id END loc_id,asd.deliver_code,
asd.wust_id, asd.out_qty,asd.commodity_type
FROM aseld  asd 
LEFT JOIN product_item pi on asd.item_id =pi.item_id
LEFT JOIN product_spec ps1 ON pi.spec_id_1 = ps1.spec_id
LEFT JOIN product_spec ps2 ON pi.spec_id_2 = ps2.spec_id
LEFT JOIN product p on pi.product_id =p.product_id 
LEFT JOIN vendor_brand v ON p.brand_id=v.brand_id
LEFT JOIN iplas plas ON plas.item_id=asd.item_id WHERE asd.wust_id <> 'COM' ");
            //LEFT JOIN (select item_id,upc_id from iupc GROUP BY item_id) upc on upc.item_id= pi.item_id   upc.upc_id,

            sb.Append(strsb.ToString());
            try
            {
                DataTable _dt = _access.getDataTable(sb.ToString());
                return _dt;
            }
            catch (Exception ex)
            {
                throw new Exception("AseldDao.ExportAseldMessage-->" + ex.Message + sb.ToString(), ex);
            }
        }
Example #27
0
        }//
        #endregion

        #region 理貨員工作的庫存操作+對iwms_record標的新增
        public DataTable getTime(AseldQuery a)
        {
            StringBuilder sql = new StringBuilder();
            DataTable dt = new DataTable();
            sql.AppendFormat(" SELECT cde_dt_incr,cde_dt_shp from product_ext where item_id ='{0}' and  pwy_dte_ctl='Y'  ;", a.item_id);
            dt = _access.getDataTable(sql.ToString());
            return dt;
        }
Example #28
0
 public DataTable GetAseldTablePDF(AseldQuery aseld)
 {
     aseld.Replace4MySQL();
     StringBuilder sbStr = new StringBuilder();
     try
     {
         sbStr.AppendFormat("SELECT a.assg_id FROM aseld a WHERE a.wust_id<>'COM'");
         if (aseld.start_dtim != DateTime.MinValue)
         {
             sbStr.AppendFormat(" AND a.create_dtim between '{0}' and  '{1}'", CommonFunction.DateTimeToString(aseld.start_dtim), CommonFunction.DateTimeToString(aseld.change_dtim));
         }
         if (aseld.assg_id != string.Empty)
         {
             sbStr.AppendFormat(" and a.assg_id='{0}'", aseld.assg_id);
         }
         sbStr.Append("  GROUP BY a.assg_id;");
         return _access.getDataTable(sbStr.ToString());
     }
     catch (Exception ex)
     {
         throw new Exception("AseldDao.GetAseldTablePDF-->" + ex.Message + sbStr.ToString(), ex);
     }           
 }
Example #29
0
        /// <summary>
        /// 自動理貨 獲取所有需要理貨的商品
        /// </summary>
        /// <param name="ase"></param>
        /// <returns></returns>

        public List<AseldQuery> GetAllAseldList(AseldQuery ase,out int totalCount)
        {
            try
            {
                return _aseldDao.GetAllAseldList(ase,out totalCount);
            }
            catch (Exception ex)
            {
                throw new Exception("AseldMgr-->GetAllAseldList-->" + ex.Message, ex);
            }
        }