//寄倉-庫存-輸入撿貨量 public HttpResponseBase GetSum() { string json = string.Empty; _iinvd = new IinvdMgr(mySqlConnectionString); Iinvd i = new Iinvd(); int S = 0;//主料位庫存 int R = 0;//輔料位庫存 uint item; try { if (Request.Params["lcat_id"].ToString() == "S") { if (uint.TryParse(Request.Params["item_id"].ToString(), out item)) { i.item_id = item; S = _iinvd.sum(i, "S"); R = _iinvd.sum(i, "R"); json = "{success:true,S:'" + S + "',R:'" + R + "'}";//返回json數據 } } else if (Request.Params["lcat_id"].ToString() == "R") {//查詢輔料位該日期的庫存 if (uint.TryParse(Request.Params["item_id"].ToString(), out item)) { i.item_id = item; i.made_date = DateTime.Parse(Request.Params["made_date"].ToString()); R = _iinvd.sum(i, "R"); json = "{success:true,S:'" + S + "',R:'" + R + "'}";//返回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}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public void OutPalletSuggest() { IinvdQuery model = new IinvdQuery(); _iinvd = new IinvdMgr(mySqlConnectionString); _ipalet = new PalletMoveMgr(mySqlConnectionString); try { if (!string.IsNullOrEmpty(Request.Params["item_id"])) { string itemid = Request.Params["item_id"]; DataTable dt = _ipalet.GetProdInfo(itemid); if (dt.Rows.Count > 0) { model.item_id = uint.Parse(dt.Rows[0]["item_id"].ToString()); } else { model.item_id = 0; } } if (!string.IsNullOrEmpty(Request.Params["locid"])) { model.loc_id = Request.Params["locid"].ToUpper(); } if (!string.IsNullOrEmpty(Request.Params["startIloc"])) { model.startIloc = Request.Params["startIloc"].ToUpper(); } if (!string.IsNullOrEmpty(Request.Params["endIloc"])) { model.endIloc = Request.Params["endIloc"] + "Z"; model.endIloc = model.endIloc.ToUpper(); } if (!string.IsNullOrEmpty(Request.Params["number"])) { model.sums = int.Parse(Request.Params["number"]); } if (Request.Params["Auto"] == "true") { model.auto = 1; } DataTable dtHZ=_iinvd.ExportExcel(model); if(dtHZ.Rows.Count>0) { string fileName = "補貨建議報表_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "補貨建議報表(FIFO;副料位到主料位_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ")"); Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); Response.BinaryWrite(ms.ToArray()); } else { Response.Clear(); this.Response.Write("無數據存在<br/>"); } } 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); } }
//理货员工作--寄仓--庫存信息 public HttpResponseBase GetStockByItemid() { string json = string.Empty; int totalCount = 0; int islock = 0; _iinvd = new IinvdMgr(mySqlConnectionString); IinvdQuery query = new IinvdQuery() { ista_id = "A" }; try { if (!string.IsNullOrEmpty(Request.Params["item_id"].ToString().Trim())) { query.item_id = Convert.ToUInt32(Request.Params["item_id"].ToString().Trim()); List<IinvdQuery> listIinvdQuery = _iinvd.GetIinvdListByItemid(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 //timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; timeConverter.DateTimeFormat = "yyyy-MM-dd"; if (totalCount > listIinvdQuery.Count) { islock = 1; } //實際能檢的庫存listIinvdQuery.Count if (listIinvdQuery.Count > 0) { json = JsonConvert.SerializeObject(listIinvdQuery, Formatting.Indented, timeConverter) ;//返回json數據 } else { IinvdQuery m = new IinvdQuery(); m.prod_qty = 0; m.made_date = DateTime.Now; m.cde_dt = DateTime.Now; listIinvdQuery.Add(m); json = JsonConvert.SerializeObject(listIinvdQuery, Formatting.Indented, timeConverter);//返回json數據 } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public ActionResult IinvdCheck() { _IlocMgr = new IlocMgr(mySqlConnectionString); StringBuilder strHtml = new StringBuilder(); string loc_id = Request.Params["loc_id"]; IlocQuery ilocquery=new IlocQuery(); ilocquery.loc_id = loc_id; loc_id = _IlocMgr.GetIlocCount(ilocquery); ViewBag.loc_id = loc_id; ViewBag.lcat_id = ""; ViewBag.upc_id = ""; ViewBag.iplas = ""; _iinvd = new IinvdMgr(mySqlConnectionString); if (loc_id != "") { List<IinvdQuery> list = _iinvd.GetIinvdList(loc_id); IupcQuery iupc = new IupcQuery(); _IiupcMgr = new IupcMgr(mySqlConnectionString); if (list.Count > 0) { ViewBag.product_name = list[0].product_name; ViewBag.spec = list[0].spec; ViewBag.item_id = list[0].item_id.ToString() ; ViewBag.pwy_dte_ctl = list[0].pwy_dte_ctl; iupc.item_id=uint.Parse(ViewBag.item_id); List<IupcQuery> listiupc=new List<IupcQuery>(); if (iupc.item_id!=0) { listiupc = _IiupcMgr.GetIupcByItemID(iupc); } if (listiupc.Count > 0) { ViewBag.upc_id = listiupc[0].upc_id; } if (list[0].pwy_dte_ctl == "Y") { ViewBag.count = list.Count; } else { int prod_qty = 0; for (int i = 0; i < list.Count; i++) { prod_qty += list[i].prod_qty; } list[0].prod_qty = prod_qty; ViewBag.count = 1; } ViewBag.data = list; IlocQuery lsta_id = _IlocMgr.GetIlocLsta_id(loc_id); Iloc iloc = new Iloc(); if (lsta_id != null) { if (lsta_id.lsta_id == "F") { iloc.row_id = lsta_id.row_id; iloc.lsta_id = "A"; iloc.change_dtim = DateTime.Now; iloc.change_user = (Session["caller"] as Caller).user_id; _IlocMgr.UpdateIlocLock(iloc); } } } else { ViewBag.product_name =""; ViewBag.spec = ""; ViewBag.item_id = "此料位暫無商品"; IinvdQuery iinvd = new IinvdQuery(); iinvd.prod_qty = 0; list.Add(iinvd); ViewBag.pwy_dte_ctl = Request.Params["pwy_dte_ctl"]; ; ViewBag.count = 0; ViewBag.data = list; IIlocImplMgr ilocMgr = new IlocMgr(mySqlConnectionString); IplasDao iplas = new IplasDao(mySqlConnectionString); int total = 0; ilocquery.loc_id = loc_id; ilocquery.lcat_id = "0"; ilocquery.lsta_id = ""; ilocquery.IsPage = false; List<IlocQuery> listiloc = ilocMgr.GetIocList(ilocquery, out total); if (listiloc.Count > 0) { string lcat_id =listiloc.Count==0?"": listiloc[0].lcat_id; if (lcat_id == "S") { string item_id = iplas.Getlocid(loc_id); if (item_id != "") { ViewBag.item_id = item_id; iupc.item_id = uint.Parse(ViewBag.item_id); List<IupcQuery> listiupc = _IiupcMgr.GetIupcByItemID(iupc); if (listiupc.Count > 0) { ViewBag.upc_id = listiupc[0].upc_id; } DataTable table = iplas.GetProduct(item_id); if (table.Rows.Count > 0) { ViewBag.product_name = table.Rows[0]["product_name"]; ViewBag.spec = table.Rows[0]["spec"]; ViewBag.lcat_id = lcat_id; } DataTable tablePwy = _iinvd.Getprodubybar(item_id); if (tablePwy.Rows.Count > 0) { ViewBag.pwy_dte_ctl = tablePwy.Rows[0]["pwy_dte_ctl"].ToString(); } } else { IlocQuery lsta_id = _IlocMgr.GetIlocLsta_id(loc_id); Iloc iloc = new Iloc(); if (lsta_id != null) { if (lsta_id.lsta_id != "H") { iloc.row_id = lsta_id.row_id; iloc.lsta_id = "F"; iloc.change_dtim = DateTime.Now; iloc.change_user = (Session["caller"] as Caller).user_id; _IlocMgr.UpdateIlocLock(iloc); } } ViewBag.iplas = "false"; ViewBag.pwy_dte_ctl = "N"; } } else { IlocQuery lsta_id = _IlocMgr.GetIlocLsta_id(loc_id); Iloc iloc = new Iloc(); if(lsta_id!=null) { if(lsta_id.lsta_id!="H") { iloc.row_id=lsta_id.row_id; iloc.lsta_id = "F"; iloc.change_dtim = DateTime.Now; iloc.change_user = (Session["caller"] as Caller).user_id; _IlocMgr.UpdateIlocLock(iloc); } } ViewBag.pwy_dte_ctl = "N"; } } } if (ViewBag.pwy_dte_ctl==null) { ViewBag.pwy_dte_ctl = ""; } } return View(); }
public HttpResponseBase InsertIialg() { string json = string.Empty; IialgQuery iagQuery = new IialgQuery(); Iinvd invd = new Iinvd(); int result = 0; try { invd.row_id = Convert.ToInt32(Request.Params["row_id"]);//行號碼 _iinvd = new IinvdMgr(mySqlConnectionString); DataTable dt = _iinvd.GetRowMsg(invd);//首先根據row_id 獲取到製造日期和有效日期 iagQuery.made_dt = Convert.ToDateTime(dt.Rows[0]["made_date"]);//製造日期 iagQuery.cde_dt = Convert.ToDateTime(dt.Rows[0]["cde_dt"]);//有效日期 if (!string.IsNullOrEmpty(Request.Params["item_id"]))//商品細項編號 { iagQuery.item_id = Convert.ToUInt32(Request.Params["item_id"]); } if (!string.IsNullOrEmpty(Request.Params["po_id"])) { iagQuery.po_id = Request.Params["po_id"];//採購單編號 } if (!string.IsNullOrEmpty(Request.Params["iarc_id"])) { iagQuery.iarc_id = Request.Params["iarc_id"];//庫調原因 } if (!string.IsNullOrEmpty(Request.Params["ktloc_id"])) { iagQuery.loc_id = Request.Params["ktloc_id"].ToUpper();//料位編號 } if (!string.IsNullOrEmpty(Request.Params["doc_no"])) { iagQuery.doc_no = Request.Params["doc_no"];//庫調單號 } if (!string.IsNullOrEmpty(Request.Params["remarks"])) { iagQuery.remarks = Request.Params["remarks"];//庫調單號 } if (!string.IsNullOrEmpty(Request.Params["made_date"]))//創建時間 { iagQuery.made_dt = Convert.ToDateTime(Request.Params["made_date"]); } if (!string.IsNullOrEmpty(Request.Params["end_date"]))//有效日期 { iagQuery.cde_dt = Convert.ToDateTime(Request.Params["end_date"]);//庫調單號 } int kucuncount = Convert.ToInt32(Request.Params["benginnumber"]);//庫存數量 int tiaozhengcount = Convert.ToInt32(Request.Params["changenumber"]);//調整數量 int kucuntype = Convert.ToInt32(Request.Params["kutiaotype"]);//庫存類型 if (kucuntype == 1) { iagQuery.adj_qty = tiaozhengcount; //調整庫存 } else { iagQuery.adj_qty = tiaozhengcount * (-1);//調整庫存 } iagQuery.qty_o = kucuncount;//原來庫存 iagQuery.create_dtim = DateTime.Now; iagQuery.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; if (!string.IsNullOrEmpty(Request.Params["ktloc_id"])) { iagQuery.loc_id = Request.Params["ktloc_id"]; } if (!string.IsNullOrEmpty(Request.Params["doc_no"])) { iagQuery.doc_no = Request.Params["doc_no"]; } _iagMgr = new IialgMgr(mySqlConnectionString); result = _iagMgr.insertiialg(iagQuery); if (result > 0) { json = "{success:true}";//返回json數據 } else { json = "{success:false}";//返回json數據 } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase Updateiinvdstqty() { int result = 0; string json = string.Empty; Iinvd invd = new Iinvd(); if (!string.IsNullOrEmpty(Request.Params["row_id"].Trim())) { invd.row_id = Convert.ToInt32(Request.Params["row_id"].Trim());//獲取工作編號 } if (!string.IsNullOrEmpty(Request.Params["stqty"].Trim())) { invd.st_qty = Convert.ToInt32(Request.Params["stqty"].Trim());//獲取工作編號 } invd.create_dtim = DateTime.Now; //創建時間 invd.create_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; try { _iinvd = new IinvdMgr(mySqlConnectionString); result = _iinvd.Updateiinvdstqty(invd); if (result > 0) { json = "{success:true}";//返回json數據 } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
// 用商品編號獲取品名 public HttpResponseBase Getprodbyid() { string jsonStr = String.Empty; try { int id; _iinvd = new IinvdMgr(mySqlConnectionString); DataTable dt = new DataTable(); //if (int.TryParse(Request.Params["id"].ToString(), out id) && Request.Params["id"].ToString().Length == 6) //{//獲取商品編號 // dt = _iinvd.Getprodu(int.Parse(Request.Params["id"].ToString())); //} //else //{//獲取條碼 dt = _iinvd.Getprodubybar(Request.Params["id"].ToString()); // } if (dt.Rows.Count > 0) {//pwy_dte_ctl是否是有效期控管的商品,cde_dt_shp:允出天數,cde_dt_var:允收天數,cde_dt_incr 保存天數 string spec = string.Empty; if (!string.IsNullOrEmpty(dt.Rows[0]["spec_name"].ToString())) { spec += dt.Rows[0]["spec_name"].ToString(); } if (!string.IsNullOrEmpty(dt.Rows[0]["spec_name1"].ToString())) { if (spec.Length > 0) { spec += ","; } spec += dt.Rows[0]["spec_name1"].ToString(); } if (spec.Length > 0) { spec = "(" + spec + ")"; } jsonStr = "{success:true,msg:\"" + dt.Rows[0]["product_name"] + spec + "\",locid:'" + dt.Rows[0]["loc_id"].ToString().ToUpper() + "',item_id:'" + dt.Rows[0]["item_id"] + "',day:'" + dt.Rows[0]["cde_dt_var"] + "',cde_dt_shp:'" + dt.Rows[0]["cde_dt_shp"] + "',pwy_dte_ctl:'" + dt.Rows[0]["pwy_dte_ctl"] + "',cde_dt_var:'" + dt.Rows[0]["cde_dt_var"] + "',cde_dt_incr:'" + dt.Rows[0]["cde_dt_incr"] + "',vendor_id:'" + dt.Rows[0]["vendor_id"] + "'}";//返回json數據 } else { jsonStr = "{success:false,msg:0}";//返回json數據 } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }
public HttpResponseBase GetCountBookOBK() { string json = string.Empty; IinvdQuery m = new IinvdQuery(); CbjobMaster cm = new CbjobMaster(); CbjobDetail cd = new CbjobDetail(); try { #region 條件 if (!string.IsNullOrEmpty(Request.Params["startIloc"])) {//料位開始 m.startIloc = Request.Params["startIloc"].ToUpper(); } if (!string.IsNullOrEmpty(Request.Params["endIloc"])) { m.endIloc = Request.Params["endIloc"] + "Z"; m.endIloc = m.endIloc.ToUpper(); } if (!string.IsNullOrEmpty(Request.Params["startcost"]))//金額 { m.startcost = int.Parse(Request.Params["startcost"].ToString()); } if (!string.IsNullOrEmpty(Request.Params["endcost"]))//金額 { m.endcost = int.Parse(Request.Params["endcost"].ToString()); } #endregion _iinvd = new IinvdMgr(mySqlConnectionString); DataTable dt = _iinvd.CountBookOBK(m); if (dt.Rows.Count > 0) { #region 生成報表 DataTable dtCountBook = new DataTable(); dtCountBook.Columns.Add("編號", typeof(String)); dtCountBook.Columns.Add("料位", typeof(String)); dtCountBook.Columns.Add("狀態", typeof(String)); dtCountBook.Columns.Add("商品細項編號", typeof(String)); dtCountBook.Columns.Add("成本", typeof(String)); dtCountBook.Columns.Add("商品名稱", typeof(String)); dtCountBook.Columns.Add("商品規格", typeof(String)); dtCountBook.Columns.Add("製造日期", typeof(String)); dtCountBook.Columns.Add("有效日期", typeof(String)); dtCountBook.Columns.Add("原有數量", typeof(String)); dtCountBook.Columns.Add("現有數量", typeof(String)); dtCountBook.Columns.Add("差異金額", typeof(String)); foreach (DataRow item in dt.Rows) { DataRow dr = dtCountBook.NewRow(); dr[0] = item["row_id"]; dr[1] = item["loc_id"]; dr[2] = item["lsta_id"]; dr[3] = item["item_id"]; dr[4] = item["cost"]; dr[5] = item["product_name"]; dr[6] = GetProductSpec(item["item_id"].ToString()); dr[7] = DateTime.Parse(item["made_date"].ToString()).ToString("yyyy/MM/dd"); dr[8] = DateTime.Parse(item["cde_dt"].ToString()).ToString("yyyy/MM/dd"); dr[9] = item["prod_qty"]; dr[10] = item["st_qty"]; dr[11] = item["money"]; dtCountBook.Rows.Add(dr); } #endregion string fileName = "盤點差異報表OBK" + DateTime.Now.ToString("_yyyyMMddHHmmss") + ".xls"; String str = "盤點差異報表OBK" + DateTime.Now.ToString("_yyyyMMddHHmmss"); MemoryStream ms = ExcelHelperXhf.ExportDT(dtCountBook, str); Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); Response.BinaryWrite(ms.ToArray()); } else { Response.Clear(); this.Response.Write("該範圍內沒有差異數據<br/>"); } } 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); } return this.Response; }
public HttpResponseBase InsertIinvd() { string jsonStr = String.Empty; Int64 aaa = 0; //無用變數 uint p = 0; //無用變數 try { Iinvd m = new Iinvd(); IialgQuery ia = new IialgQuery(); Iupc iu = new Iupc(); ProductItem proitem = new ProductItem(); Caller call = new Caller(); IstockChangeQuery stock = new IstockChangeQuery(); call = (System.Web.HttpContext.Current.Session["caller"] as Caller); string path = ""; _iinvd = new IinvdMgr(mySqlConnectionString); _iagMgr = new IialgMgr(mySqlConnectionString); _IiupcMgr = new IupcMgr(mySqlConnectionString); #region 獲取數據往 if (Int64.TryParse(Request.Params["item_id"].ToString(), out aaa)) { if (uint.TryParse(Request.Params["item_id"].ToString(), out p)) { m.item_id = uint.Parse(Request.Params["item_id"].ToString()); } if (Request.Params["item_id"].ToString().Length > 6) { m.item_id = uint.Parse(_iinvd.Getprodubybar(Request.Params["item_id"].ToString()).Rows[0]["item_id"].ToString()); } } else { if (Request.Params["item_id"].ToString().Length > 6) { m.item_id = uint.Parse(_iinvd.Getprodubybar(Request.Params["item_id"].ToString()).Rows[0]["item_id"].ToString()); } } m.dc_id = 1; m.whse_id = 1; m.prod_qty = Int32.Parse(Request.Params["prod_qty"].ToString());//數量 DateTime today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")); DateTime dtime; if (DateTime.TryParse(Request.Params["startTime"].ToString(), out dtime)) {//用戶填寫創建時間算出有效日期 DateTime start = DateTime.Parse(Request.Params["startTime"].ToString()); m.made_date = start; if (uint.TryParse(Request.Params["cde_dt_incr"].ToString(), out p)) { m.cde_dt = start.AddDays(Int32.Parse(Request.Params["cde_dt_incr"].ToString())); } else { m.cde_dt = DateTime.Now; } } else { if (DateTime.TryParse(Request.Params["cde_dt"].ToString(), out dtime)) {//用戶填寫有效日期算出製造日期 m.cde_dt = DateTime.Parse(Request.Params["cde_dt"].ToString());//有效時間 if (uint.TryParse(Request.Params["cde_dt_incr"].ToString(), out p)) { m.made_date = m.cde_dt.AddDays(-Int32.Parse(Request.Params["cde_dt_incr"].ToString())); } else { m.made_date = today; } } else { m.cde_dt = today; m.made_date = today; } } m.cde_dt = DateTime.Parse(m.cde_dt.ToShortDateString()); m.made_date = DateTime.Parse(m.made_date.ToShortDateString()); m.plas_loc_id = Request.Params["plas_loc_id"].ToString().ToUpper();//上架料位 string loc_id = Request.Params["loc_id"].ToString().ToUpper(); m.change_dtim = DateTime.Now;//編輯時間 m.receipt_dtim = DateTime.Now;//收貨時間 m.create_user = (Session["caller"] as Caller).user_id; #endregion #region 獲取數據添加打iialg ia.loc_id = m.plas_loc_id.ToString().ToUpper(); ia.item_id = m.item_id; stock.sc_trans_type = 0; if (!string.IsNullOrEmpty(Request.Params["iarc_id"].ToString())) { ia.iarc_id = Request.Params["iarc_id"].ToString(); } else { ia.iarc_id = "PC"; stock.sc_trans_type = 1;//收貨上架 } //if (ia.iarc_id == "DR" || ia.iarc_id == "KR") //{ // type = 2;//RF理貨 //} ia.create_dtim = DateTime.Now; ia.create_user = m.create_user; ia.doc_no = "P" + DateTime.Now.ToString("yyyyMMddHHmmss"); if (!string.IsNullOrEmpty(Request.Params["doc_num"])) { ia.doc_no = Request.Params["doc_num"]; stock.sc_trans_id = ia.doc_no;//交易單號 } if (!string.IsNullOrEmpty(Request.Params["Po_num"])) { ia.po_id = Request.Params["Po_num"]; stock.sc_cd_id = ia.po_id;//前置單號 } if (!string.IsNullOrEmpty(Request.Params["remark"])) { ia.remarks = Request.Params["remark"]; stock.sc_note = ia.remarks;//備註 } ia.made_dt = m.made_date; ia.cde_dt = m.cde_dt; #endregion #region 獲取店內條碼-=添加條碼 if (!string.IsNullOrEmpty(Request.Params["vendor_id"].ToString())) { iu.upc_id = CommonFunction.GetUpc(m.item_id.ToString(), Request.Params["vendor_id"].ToString(), m.cde_dt.ToString("yyMMdd")); } iu.item_id = m.item_id; iu.upc_type_flg = "2";//店內碼 iu.create_user = m.create_user; string result = _IiupcMgr.IsExist(iu);//是否有重複的條碼 if (result == "0") { if (_IiupcMgr.Insert(iu) < 1) { jsonStr = "{success:true,msg:2}"; } } #endregion #region 新增/編輯 #region 庫存調整的時候,商品庫存也要調整 _proditemMgr = new ProductItemMgr(mySqlConnectionString); int item_stock = m.prod_qty; proitem.Item_Stock = item_stock; proitem.Item_Id = m.item_id; #endregion if (_iinvd.IsUpd(m, stock) > 0) {//編輯 ia.qty_o = _iinvd.Selnum(m); ia.adj_qty = m.prod_qty; m.prod_qty = ia.qty_o + m.prod_qty; if (m.prod_qty >= 0) { if (_iinvd.Upd(m) > 0) { if (Request.Params["iialg"].ToString() == "Y") {// if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改 { path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); } if (_iagMgr.insertiialg(ia) > 0) { jsonStr = "{success:true,msg:0}";//更新成功 } else { jsonStr = "{success:false,msg:1}";//更新失敗 } } else { jsonStr = "{success:true,msg:0}";//更新成功 } } else { jsonStr = "{success:false,msg:1}";//更新失敗 } } else { jsonStr = "{success:false,msg:1}";//庫存為負數 } } else {//新增 m.ista_id = "A"; m.create_dtim = DateTime.Now; //創建時間 if (_iinvd.Insert(m) > 0) { _IlocMgr = new IlocMgr(mySqlConnectionString); Iloc loc = new BLL.gigade.Model.Iloc(); loc.change_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); loc.change_dtim = DateTime.Now; loc.loc_id = m.plas_loc_id.ToString().ToUpper(); if (loc_id.Trim() != m.plas_loc_id.Trim())//判斷如果是主料位不需要進行多餘的操作 { if (_IlocMgr.SetIlocUsed(loc) > 0) { if (Request.Params["iialg"].ToString() == "Y") { if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改 { path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); } ia.qty_o = 0; ia.adj_qty = m.prod_qty; if (_iagMgr.insertiialg(ia) > 0) { jsonStr = "{success:true,msg:0}";//更新成功 } else { jsonStr = "{success:false,msg:1}";//更新失敗 } } else { jsonStr = "{success:true,msg:0}";//新增成功 } } else { jsonStr = "{success:false,msg:1}";//新增失敗 } } else { if (Request.Params["iialg"].ToString() == "Y") { if (ia.iarc_id != "PC" && ia.iarc_id != "NE")//------------庫存調整的時候商品庫存也更改,收貨上架的時候不更改,RF理貨的時候也是不更改 { path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); } ia.qty_o = 0; ia.adj_qty = m.prod_qty; if (_iagMgr.insertiialg(ia) > 0) { jsonStr = "{success:true,msg:0}";//更新成功 } else { jsonStr = "{success:false,msg:1}";//更新失敗 } } else { jsonStr = "{success:true,msg:0}";//新增成功 } } } else { jsonStr = "{success:false,msg:1}"; } } #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); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }
// 變更數量--丟棄 public HttpResponseBase UpdProdqty() { Iinvd m = new Iinvd(); IinvdLog il = new IinvdLog(); _iinvd = new IinvdMgr(mySqlConnectionString); string jsonStr = String.Empty; StringBuilder sb = new StringBuilder(); _iasdMgr = new AseldMgr(mySqlConnectionString); try { il.nvd_id = Int32.Parse(Request.Params["row_id"].ToString()); il.change_num = Int32.Parse(Request.Params["change_num"].ToString()); il.from_num = Int32.Parse(Request.Params["from_num"].ToString()); il.create_user = (Session["caller"] as Caller).user_id; il.create_date = DateTime.Now; m.row_id = il.nvd_id; m.prod_qty = il.change_num + il.from_num; m.change_dtim = DateTime.Now; m.change_user = (Session["caller"] as Caller).user_id; if (m.prod_qty >= 0) { sb.Append(_iinvd.UpdProdqty(m)); sb.Append(_iinvd.InsertIinvdLog(il)); _iasdMgr.InsertSql(sb.ToString());//執行SQL語句裡面有事物處理 jsonStr = "{success:true,msg:0}"; } else { jsonStr = "{success:true,msg:1}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }
// 收貨上架列表頁 public HttpResponseBase GetIinvdList() { string json = string.Empty; IinvdQuery iivd = new IinvdQuery(); iivd.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 iivd.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 string content = string.Empty; //變更的時候記得把匯出也修改了獲取條件是同時的 if (!string.IsNullOrEmpty(Request.Params["search_type"])) { iivd.serch_type = int.Parse(Request.Params["search_type"]); if (!string.IsNullOrEmpty(Request.Params["searchcontent"]) && Request.Params["searchcontent"].Trim().Length > 0)//有查詢內容就不管時間 { switch (iivd.serch_type) { case 1: case 2: iivd.serchcontent = Request.Params["searchcontent"].Trim(); break; case 3: #region 之後的更改 content = Request.Params["searchcontent"].Replace(',', ',').Replace('|', ',').Replace(' ', ',');//.Replace(' ',',') string[] list = content.Split(','); string test = "^[0-9]*$"; int count = 0;//實現最後一個不加, for (int i = 0; i < list.Length; i++) { if (!string.IsNullOrEmpty(list[i])) { if (Regex.IsMatch(list[i], test)) { count = count + 1; if (count == 1) { iivd.serchcontent = list[i]; } else { iivd.serchcontent = iivd.serchcontent + "," + list[i]; } } else { iivd.serchcontent = iivd.serchcontent + list[i] + ","; } } } #endregion break; default: break; } } } DateTime time; if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time)) { iivd.starttime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss")); } if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time)) { iivd.endtime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss")); } try { List<IinvdQuery> store = new List<IinvdQuery>(); _iinvd = new IinvdMgr(mySqlConnectionString); int totalCount = 0; store = _iinvd.GetIinvdList(iivd, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; foreach (var item in store) { item.product_name += GetProductSpec(item.item_id.ToString()); } json = "{success:true,'msg':'user',totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public JsonResult IinvdSave() { bool falg = false; string message ="保存失敗"; try { string row_id = ""; int prod_qty = 0; if (Request.Params["rowid"].Length > 5) { row_id = Request.Params["rowid"].Substring(5); } string changeStore = Request.Params["changeStore"]; int temp1=0; if (int.TryParse(changeStore, out temp1)) { if (temp1 < 0) { falg = false; message = "庫存不能小於1"; } else { _iinvd = new IinvdMgr(mySqlConnectionString); IinvdQuery iinvd = new IinvdQuery(); iinvd.pwy_dte_ctl = Request.Params["pwy_dte_ctl"]; if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { iinvd.plas_loc_id = Request.Params["loc_id"]; } int id = 0; if (int.TryParse(row_id, out id)) { iinvd.row_id = id; } if (int.TryParse(changeStore, out id)) { iinvd.prod_qty = id; } if (!string.IsNullOrEmpty(Request.Params["item_id"])) { if (int.TryParse(Request.Params["item_id"], out id)) { iinvd.item_id = uint.Parse(Request.Params["item_id"]); } } iinvd.create_user = (Session["caller"] as Caller).user_id; iinvd.create_dtim = DateTime.Now; iinvd.change_user = iinvd.create_user; iinvd.change_dtim = iinvd.create_dtim; iinvd.prod_qtys = _iinvd.GetProd_qty(Convert.ToInt32(iinvd.item_id), iinvd.plas_loc_id, "", iinvd.row_id.ToString()); if (iinvd.pwy_dte_ctl == "Y") { List<DateTime> list = new List<DateTime>(); list=_iinvd.GetCde_dt(iinvd.row_id); if(list.Count>0) { iinvd.cde_dt = list[0]; iinvd.made_date = list[1]; } } else { iinvd.made_date = iinvd.create_dtim; iinvd.cde_dt = iinvd.create_dtim; } if (iinvd.row_id != 0) { if (iinvd.pwy_dte_ctl == "Y") { prod_qty = _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id, iinvd.pwy_dte_ctl, iinvd.row_id.ToString()); if (prod_qty == iinvd.prod_qty) { falg = true; return Json(new { success = falg, message = message }); } else if (_iinvd.SaveIinvd(iinvd) == 1) { falg = true; } } if (iinvd.pwy_dte_ctl == "N" || iinvd.pwy_dte_ctl == "") { iinvd.row_id = 0; if (iinvd.prod_qtys < iinvd.prod_qty) { iinvd.ista_id = "A"; iinvd.prod_qty = iinvd.prod_qty - iinvd.prod_qtys; iinvd.cde_dt = DateTime.Now; int result=_iinvd.GetIinvdCount(iinvd); if (result>1) { prod_qty = result - 1; falg = true; } else { if (_iinvd.Insert(iinvd) == 1) { falg = true; } } } else if (iinvd.prod_qtys> iinvd.prod_qty) { if (_iinvd.SaveIinvd(iinvd) == 1) { falg = true; return Json(new { success = falg, message = message }); } } else if (iinvd.prod_qtys == iinvd.prod_qty) { falg = true; return Json(new { success = falg, message = message }); } } IialgQuery iialg = new IialgQuery(); iialg.cde_dt = iinvd.cde_dt; iialg.qty_o = prod_qty;//原始庫存數量 iialg.loc_id = iinvd.plas_loc_id; iialg.item_id = iinvd.item_id; iialg.iarc_id = "循環盤點"; if (iinvd.pwy_dte_ctl == "Y") { iialg.adj_qty = iinvd.prod_qty - prod_qty; } else { iialg.adj_qty = iinvd.prod_qty-prod_qty;//轉移數量 } iialg.create_dtim = DateTime.Now; iialg.create_user = iinvd.create_user; iialg.type = 2; iialg.doc_no = "C" + DateTime.Now.ToString("yyyyMMddHHmmss"); iialg.made_dt = iinvd.made_date; iialg.cde_dt = iinvd.cde_dt; _iialgMgr = new IialgMgr(mySqlConnectionString); _iialgMgr.insertiialg(iialg); IstockChangeQuery istock = new IstockChangeQuery(); istock.sc_trans_id = iialg.doc_no; istock.item_id = iinvd.item_id; istock.sc_istock_why = 2; istock.sc_trans_type = 2; istock.sc_num_old = iinvd.prod_qtys;//原始庫存數量 istock.sc_num_chg = iialg.adj_qty;//轉移數量 istock.sc_num_new = _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id,"","");//結餘數量 istock.sc_time = iinvd.create_dtim; istock.sc_user = iinvd.create_user; istock.sc_note = "循環盤點"; IstockChangeMgr istockMgr = new IstockChangeMgr(mySqlConnectionString); istockMgr.insert(istock); } else { return Json(new { success = falg }); } } } else { message = "庫存不能小於1"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } return Json(new { success = falg,message=message }); }
public HttpResponseBase SaveIinvd() { string json = "{success:false,message:'系統異常'}"; try { int temp = 0; if (int.TryParse(Request.Params["prod_qty"], out temp)) { if (temp > 0) { IinvdQuery iinvd = new IinvdQuery(); if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { iinvd.plas_loc_id = Request.Params["loc_id"]; } if (!string.IsNullOrEmpty(Request.Params["item_id"])) { if (int.TryParse(Request.Params["item_id"], out temp)) { iinvd.item_id = uint.Parse(Request.Params["item_id"]); } } #region 判斷是否指定主料位 IlocQuery ilocquery = new IlocQuery(); _IiplasMgr = new IplasMgr(mySqlConnectionString); IplasQuery iplasquery = new IplasQuery(); iplasquery.item_id = iinvd.item_id; IIlocImplMgr ilocMgr = new IlocMgr(mySqlConnectionString); IplasDao iplasdao = new IplasDao(mySqlConnectionString); int total = 0; ilocquery.loc_id = iinvd.plas_loc_id; ilocquery.lcat_id = "0"; ilocquery.lsta_id = ""; ilocquery.IsPage = false; List<IlocQuery> listiloc = ilocMgr.GetIocList(ilocquery, out total); if (listiloc.Count > 0) { string lcat_id = listiloc.Count == 0 ? "" : listiloc[0].lcat_id; if (lcat_id == "S") { string item_id = iplasdao.Getlocid(ilocquery.loc_id); if (item_id == "") { Iplas iplas = new Iplas(); if (int.TryParse(Request.Params["item_id"], out temp)) { iplas.item_id = uint.Parse(Request.Params["item_id"]); if (_IiplasMgr.IsTrue(iplas) == "false") { json = "{success:false,message:'不存在該商品編號'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } if (_IiplasMgr.GetIplasid(iplasquery) > 0) { json = "{success:false,message:'此商品主料位非該料位'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } Iloc iloc = new Iloc(); iloc.loc_id = iinvd.plas_loc_id; if (_IiplasMgr.GetLocCount(iloc) <= 0) { json = "{success:false,message:'該料位已鎖定或被指派'}"; this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; } iplas.loc_id = iloc.loc_id; iplas.loc_stor_cse_cap = 100; iplas.create_user = (Session["caller"] as Caller).user_id; iplas.create_dtim = DateTime.Now; iplas.change_user = (Session["caller"] as Caller).user_id; iplas.change_dtim = DateTime.Now; _IiplasMgr.InsertIplas(iplas); } } } } #endregion iinvd.create_user = (Session["caller"] as Caller).user_id; iinvd.create_dtim = DateTime.Now; iinvd.change_user = iinvd.create_user; iinvd.change_dtim = iinvd.create_dtim; iinvd.ista_id = "A"; if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { iinvd.plas_loc_id = Request.Params["loc_id"]; } int change_prod_qty = int.Parse(Request.Params["prod_qty"]); iinvd.prod_qty = change_prod_qty; if (!string.IsNullOrEmpty(Request.Params["st_qty"])) { if (int.TryParse(Request.Params["st_qty"], out temp)) { iinvd.st_qty = int.Parse(Request.Params["st_qty"]); } } if (!string.IsNullOrEmpty(Request.Params["item_id"])) { if (int.TryParse(Request.Params["item_id"], out temp)) { iinvd.item_id = uint.Parse(Request.Params["item_id"]); } } DateTime date = DateTime.Now; if (DateTime.TryParse(Request.Params["datetimepicker1"], out date)) { iinvd.made_date = date; } else { iinvd.made_date = DateTime.Now; } _iinvd = new IinvdMgr(mySqlConnectionString); if (Request.Params["pwy_dte_ctl"] == "Y") { iinvd.pwy_dte_ctl = "Y"; IProductExtImplMgr productExt = new ProductExtMgr(mySqlConnectionString); int Cde_dt_incr = productExt.GetCde_dt_incr((int)iinvd.item_id); iinvd.cde_dt = date.AddDays(Cde_dt_incr); } else { iinvd.cde_dt = DateTime.Now; } iinvd.prod_qtys = _iinvd.GetProd_qty(Convert.ToInt32(iinvd.item_id), iinvd.plas_loc_id, "", iinvd.row_id.ToString()); IialgQuery iialg = new IialgQuery(); iialg.cde_dt = iinvd.cde_dt; int prod_qty = 0;// _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id, "", ""); int row = _iinvd.GetIinvdCount(iinvd); if (row > 1) { prod_qty = row - 1; json = "{success:true}"; } else { if (_iinvd.Insert(iinvd) == 1) { json = "{success:true}"; } } iialg.qty_o = prod_qty; iialg.loc_id = iinvd.plas_loc_id; iialg.item_id = iinvd.item_id; iialg.iarc_id = "循環盤點"; iialg.adj_qty = change_prod_qty; iialg.create_dtim = DateTime.Now; iialg.create_user = iinvd.create_user; iialg.type = 2; iialg.doc_no = "C" + DateTime.Now.ToString("yyyyMMddHHmmss"); iialg.made_dt = iinvd.made_date; iialg.cde_dt = iinvd.cde_dt; _iialgMgr = new IialgMgr(mySqlConnectionString); _iialgMgr.insertiialg(iialg); IstockChangeQuery istock = new IstockChangeQuery(); istock.sc_trans_id = iialg.doc_no; istock.item_id = iinvd.item_id; istock.sc_istock_why = 2; istock.sc_trans_type = 2; istock.sc_num_old = iinvd.prod_qtys; istock.sc_num_chg = iialg.adj_qty; istock.sc_num_new = _iinvd.GetProd_qty((int)iinvd.item_id, iinvd.plas_loc_id,"N",""); istock.sc_time = iinvd.create_dtim; istock.sc_user = iinvd.create_user; istock.sc_note = "循環盤點"; IstockChangeMgr istockMgr = new IstockChangeMgr(mySqlConnectionString); istockMgr.insert(istock); } else { json = "{success:false,message:'庫存不能小於1'}"; } } else { json = "{success:false,message:'庫存請輸入數字'}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public void PastProductExportlist() { string json = string.Empty; string fileName = ""; string fileNametwo = ""; IinvdQuery invd = new IinvdQuery(); try { _iinvd = new IinvdMgr(mySqlConnectionString); _IiupcMgr = new IupcMgr(mySqlConnectionString); invd.notimeortimeout = Convert.ToInt32(Request.Params["time_type"]); if (!string.IsNullOrEmpty(Request.Params["startIloc"]))//model中默認為F { invd.startIloc = Request.Params["startIloc"].ToUpper(); } else { invd.startIloc = string.Empty; } if (!string.IsNullOrEmpty(Request.Params["endIloc"])) { invd.endIloc = Request.Params["endIloc"] + "Z"; invd.endIloc = invd.endIloc.ToUpper(); } else { invd.endIloc = string.Empty; } if (!string.IsNullOrEmpty(Request.Params["startDay"])) { invd.startDay = Convert.ToInt32(Request.Params["startDay"]); } else { invd.startDay = 0; } if (!string.IsNullOrEmpty(Request.Params["endDay"])) { invd.endDay = Convert.ToInt32(Request.Params["endDay"]); } else { invd.endDay = 0; } int yugao = 0; if (int.TryParse(Request.Params["yugaoDay"], out yugao)) { invd.yugaoDay = yugao; } else { invd.yugaoDay = 0; } 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)); dtHZ.Columns.Add("溫層", typeof(String)); dtHZ.Columns.Add("即期日期", typeof(String)); dtHZ.Columns.Add("庫存鎖", typeof(String)); DataTable dt = new DataTable(); dt = _iinvd.PastProductExportExcel(invd); for (int i = 0; i < dt.Rows.Count; i++) { DataRow dr = dtHZ.NewRow(); if (invd.notimeortimeout == 2)//(Convert.ToDateTime(dt.Rows[i]["cde_dt"]) <= DateTime.Now.AddDays(invd.yugaoDay))//過期有效期<=今天 { dr[0] = "過期"; fileName = "過期品"; fileNametwo = "過期品"; } else if (invd.notimeortimeout == 1)//(Convert.ToDateTime(dt.Rows[i]["cde_dt"]) <= DateTime.Now.AddDays(int.Parse(dt.Rows[i]["cde_dt_shp"].ToString() + invd.yugaoDay))) { dr[0] = "即期"; fileName = "即期品"; fileNametwo = "即期品"; } else { dr[0] = "錯誤"; } dr[1] = dt.Rows[i]["plas_loc_id"]; dr[2] = dt.Rows[i]["lcat_id"]; dr[3] = dt.Rows[i]["item_id"]; dr[4] = dt.Rows[i]["prod_qty"]; dr[5] = dt.Rows[i]["product_name"]; dr[6] = GetProductSpec(dt.Rows[i]["item_id"].ToString()); dr[7] = " " + _IiupcMgr.Getupc(dt.Rows[i]["item_id"].ToString(), "0"); dr[8] = dt.Rows[i]["cde_dt_shp"]; dr[9] = Convert.ToDateTime(dt.Rows[i]["cde_dt"]).ToString("yyyy-MM-dd"); dr[10] = dt.Rows[i]["prepaid"].ToString() == "1" ? "是" : "否"; if (dt.Rows[i]["product_freight_set"].ToString() == "1") { dr[11] = "常溫"; } else if (dt.Rows[i]["product_freight_set"].ToString() == "2") { dr[11] = "冷凍"; } else { dr[11] = ""; } dr[12] = DateTime.Parse(dt.Rows[i]["cde_dt"].ToString()).AddDays(-int.Parse(dt.Rows[i]["cde_dt_shp"].ToString())).ToString("yyyy-MM-dd"); dr[13] = dt.Rows[i]["ista_id"]; dtHZ.Rows.Add(dr); } if (System.IO.File.Exists(newExcelName)) { System.IO.File.Delete(newExcelName); } fileName += "預告報表預告天數:" + invd.yugaoDay + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; fileNametwo += " 預告報表 預告天數:" + invd.yugaoDay + " _" + DateTime.Now.ToString("yyyyMMddHHmm"); MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, fileNametwo); 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:[]}"; } }
//判斷上架料位是否存在和被佔用 public HttpResponseBase Islocid() { string jsonStr = String.Empty; try { string id = Request.Params["plas_loc_id"].ToString().ToString().ToUpper();//料位 string zid = Request.Params["loc_id"].ToString().ToString().ToUpper();//主料位 string prod_id = Request.Params["prod_id"].ToString();//商品編號 _iinvd = new IinvdMgr(mySqlConnectionString); int msg = _iinvd.Islocid(id, zid, prod_id); jsonStr = "{success:true,msg:" + msg + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }
public void ExportKucunLockList() { string json = string.Empty; IinvdQuery m = new IinvdQuery(); if (!string.IsNullOrEmpty(Request.Params["startIloc"])) {//料位開始 m.startIloc = Request.Params["startIloc"].ToUpper(); } if (!string.IsNullOrEmpty(Request.Params["endIloc"])) { m.endIloc = Request.Params["endIloc"] + "Z"; m.endIloc = m.endIloc.ToUpper(); } _iinvd = new IinvdMgr(mySqlConnectionString); if (!String.IsNullOrEmpty(Request.Params["item_id"]))//料位和條碼不再通過長度來判斷了 { ////if (Request.Params["item_id"].ToString().Length >= 8) ////{ DataTable dt = new DataTable(); dt = _iinvd.Getprodubybar(Request.Params["item_id"].ToString()); if (dt.Rows.Count > 0) { m.item_id = Convert.ToUInt32(dt.Rows[0]["item_id"].ToString()); } ////} else { int itemid = 0; } //m.upc_id } 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("有效期/FIFO", typeof(String)); dtHZ.Columns.Add("是否買斷", typeof(String)); dtHZ.Columns.Add("條碼", typeof(String)); dtHZ.Columns.Add("庫鎖原因", typeof(String)); dtHZ.Columns.Add("庫鎖備註", typeof(String)); try { List<IinvdQuery> store = new List<IinvdQuery>(); _iinvd = new IinvdMgr(mySqlConnectionString); _IiupcMgr = new IupcMgr(mySqlConnectionString); store = _iinvd.KucunExport(m); foreach (var item in store) { DataRow dr = dtHZ.NewRow(); dr[0] = item.plas_loc_id; dr[1] = item.prod_qty; dr[2] = item.item_id; dr[3] = item.product_name; dr[4] = GetProductSpec(item.item_id.ToString()); dr[5] = item.cde_dt.ToString("yyyy-MM-dd"); dr[6] = item.prepaid == 0 ? "否" : "是"; dr[7] = " " + _IiupcMgr.Getupc(item.item_id.ToString(), "0"); dr[8] = item.parameterName; m.item_id = uint.Parse(item.item_id.ToString()); m.plas_loc_id = item.plas_loc_id.ToString(); m.made_date = item.made_date; if (item.ista_id.ToString() == "H") { dr[9] = _iinvd.remark(m); } else { dr[9] = ""; } dtHZ.Rows.Add(dr); } string fileName = DateTime.Now.ToString("庫存鎖住管理報表_yyyyMMddHHmmss") + ".xls"; MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "庫存鎖住管理報表_" + 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:[]}"; } }
// 更新表Iinvd庫存鎖的狀態 public JsonResult UpdateIinvdActive() { string jsonStr = string.Empty; try { _iinvd = new IinvdMgr(mySqlConnectionString); Iinvd nvd = new Iinvd(); IialgQuery q = new IialgQuery(); _iagMgr = new IialgMgr(mySqlConnectionString); int id = Convert.ToInt32(Request.Params["id"]); string active = Request.Params["active"]; string lock_id = Request.Params["lock_id"]; if (!string.IsNullOrEmpty(Request.Params["po_id"].ToString())) { q.po_id = Request.Params["po_id"].ToString(); } if (!string.IsNullOrEmpty(Request.Params["remarks"].ToString())) { q.remarks = Request.Params["remarks"].ToString(); } if (active == "H") { nvd.ista_id = "A"; nvd.qity_id = 0; } else if (active == "A") { nvd.qity_id = Convert.ToInt32(lock_id); nvd.ista_id = "H"; } nvd.row_id = id; nvd.change_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); nvd.change_dtim = DateTime.Now; if (_iinvd.UpdateIinvdLock(nvd, q) > 0) { //加鎖成功往iialg插入一條數據;解鎖不需要記錄 if (active == "A") { Iinvd store = _iinvd.GetIinvd(nvd).FirstOrDefault(); q.loc_id = store.plas_loc_id; q.item_id = store.item_id; q.iarc_id = "KS"; q.qty_o = store.prod_qty; q.type = 1; q.adj_qty = -store.prod_qty; q.create_dtim = DateTime.Now; q.create_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); q.made_dt = store.made_date; q.cde_dt = store.cde_dt; if (_iagMgr.insertiialg(q) > 0) { Caller call = new Caller(); call = (System.Web.HttpContext.Current.Session["caller"] as Caller); ProductItem proitem = new ProductItem(); _proditemMgr = new ProductItemMgr(mySqlConnectionString); int item_stock = store.prod_qty; proitem.Item_Stock = -item_stock; proitem.Item_Id = store.item_id; string path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); return Json(new { success = "true" }); } else { return Json(new { success = "false" }); } } else { Iinvd store = _iinvd.GetIinvd(nvd).FirstOrDefault(); q.loc_id = store.plas_loc_id; q.item_id = store.item_id; q.iarc_id = "KS"; q.qty_o = 0; q.type = 1; q.adj_qty = store.prod_qty; q.create_dtim = DateTime.Now; q.create_user = int.Parse((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString()); q.made_dt = store.made_date; q.cde_dt = store.cde_dt; if (_iagMgr.insertiialg(q) > 0) { Caller call = new Caller(); call = (System.Web.HttpContext.Current.Session["caller"] as Caller); ProductItem proitem = new ProductItem(); _proditemMgr = new ProductItemMgr(mySqlConnectionString); int item_stock = store.prod_qty; proitem.Item_Stock = item_stock; proitem.Item_Id = store.item_id; string path = "/WareHouse/KutiaoAddorReduce"; _proditemMgr.UpdateItemStock(proitem, path, call); return Json(new { success = "true" }); } else { return Json(new { success = "false" }); } } } else { return Json(new { success = "false" }); } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); return Json(new { success = "false" }); } }
public HttpResponseBase KutiaoAddorReduce() { string jsonStr = String.Empty; _iinvd = new IinvdMgr(mySqlConnectionString); _iagMgr = new IialgMgr(mySqlConnectionString); Iinvd invd = new Iinvd(); iialg iag = new iialg(); IstockChange Icg = new IstockChange(); ProductItem Proitems = new ProductItem(); int results = 0; try { invd.row_id = Convert.ToInt32(Request.Params["row_id"]);//行號碼 int resultcount = 0; int kucuncount = Convert.ToInt32(Request.Params["benginnumber"]);//庫存數量 int tiaozhengcount = Convert.ToInt32(Request.Params["changenumber"]); int kucuntype = Convert.ToInt32(Request.Params["kutiaotype"]); if (!string.IsNullOrEmpty(Request.Params["item_id"]))//商品細項編號 { Icg.item_id = Convert.ToUInt32(Request.Params["item_id"]); Proitems.Item_Id = Icg.item_id; } int oldsumcount = _iinvd.GetProqtyByItemid(Convert.ToInt32(Icg.item_id));//總庫存 string iarc_id = ""; if (!string.IsNullOrEmpty(Request.Params["iarcid"])) { iarc_id = Request.Params["iarcid"];//庫調原因 } #region 庫存調整的時候,商品庫存也要調整 _proditemMgr = new ProductItemMgr(mySqlConnectionString); int item_stock = 0; #endregion if (kucuntype == 1)//表示選擇了加 { resultcount = kucuncount + tiaozhengcount; item_stock = tiaozhengcount; } else//表示選擇了減號 { resultcount = kucuncount - tiaozhengcount; item_stock = -tiaozhengcount; } Proitems.Item_Stock = item_stock; invd.prod_qty = resultcount;//此時為更改后的庫存 invd.change_dtim = DateTime.Now; invd.change_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; Icg.sc_trans_type = 2; Icg.sc_num_old = oldsumcount; Icg.sc_time = DateTime.Now; Icg.sc_user = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_id; if (!string.IsNullOrEmpty(Request.Params["po_id"])) { Icg.sc_cd_id = Request.Params["po_id"];//採購單編號 } if (!string.IsNullOrEmpty(Request.Params["doc_no"])) { Icg.sc_trans_id = Request.Params["doc_no"];//庫調單號 } if (!string.IsNullOrEmpty(Request.Params["remarks"])) { Icg.sc_note = Request.Params["remarks"];//備註 } _istockMgr = new IstockChangeMgr(mySqlConnectionString); int j = _iinvd.kucunTiaozheng(invd); //更改iloc表中的狀態並且在iialg表中插入數據 string path = "/WareHouse/KutiaoAddorReduce"; Caller call = new Caller(); call = (System.Web.HttpContext.Current.Session["caller"] as Caller); int k = 0; if (iarc_id == "NE" || iarc_id == "RF")//庫存調整-不改動前台庫存 { k = 1; } else { k = _proditemMgr.UpdateItemStock(Proitems, path, call); } int newsumcount = _iinvd.GetProqtyByItemid(Convert.ToInt32(Icg.item_id));//總庫存 Icg.sc_num_chg = newsumcount - oldsumcount; Icg.sc_num_new = newsumcount; Icg.sc_istock_why = 2; if (oldsumcount != newsumcount) { results = _istockMgr.insert(Icg); } else { results = 1; } if (j > 0 && results > 0 && k > 0) { jsonStr = "{success:true}"; } else { jsonStr = "{success:false}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr); this.Response.End(); return this.Response; }
//收貨上架匯出 public void IinvdExcelList() { string json = string.Empty; IinvdQuery iivd = new IinvdQuery(); DataTable dtIinvdExcel = new DataTable(); DateTime dtime = DateTime.Now; _IiupcMgr = new IupcMgr(mySqlConnectionString); try { iivd.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 iivd.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量 string content = string.Empty; if (!string.IsNullOrEmpty(Request.Params["search_type"])) { iivd.serch_type = int.Parse(Request.Params["search_type"]); if (!string.IsNullOrEmpty(Request.Params["searchcontent"]) && Request.Params["searchcontent"].Trim().Length > 0) { switch (iivd.serch_type) { case 1: case 2: iivd.serchcontent = Request.Params["searchcontent"].Trim(); break; case 3: #region 之後的更改 content = Request.Params["searchcontent"].Replace(',', ',').Replace('|', ',').Replace(' ', ',');//.Replace(' ',',') string[] list = content.Split(','); string test = "^[0-9]*$"; int count = 0;//實現最後一個不加, for (int i = 0; i < list.Length; i++) { if (!string.IsNullOrEmpty(list[i])) { if (Regex.IsMatch(list[i], test)) { count = count + 1; if (count == 1) { iivd.serchcontent = list[i]; } else { iivd.serchcontent = iivd.serchcontent + "," + list[i]; } } else { iivd.serchcontent = iivd.serchcontent + list[i] + ","; } } } #endregion break; default: break; } } } DateTime time; if (DateTime.TryParse(Request.Params["starttime"].ToString(), out time)) { iivd.starttime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss")); } if (DateTime.TryParse(Request.Params["endtime"].ToString(), out time)) { iivd.endtime = DateTime.Parse(time.ToString("yyyy-MM-dd HH:mm:ss")); } List<IinvdQuery> store = new List<IinvdQuery>(); _iinvd = new IinvdMgr(mySqlConnectionString); store = _iinvd.GetIinvdExprotList(iivd); #region 列名 dtIinvdExcel.Columns.Add("商品細項編號", typeof(String)); dtIinvdExcel.Columns.Add("商品名稱", typeof(String)); dtIinvdExcel.Columns.Add("數量", typeof(String)); dtIinvdExcel.Columns.Add("有效日期", typeof(String)); dtIinvdExcel.Columns.Add("上架料位", typeof(String)); dtIinvdExcel.Columns.Add("主料位", typeof(String)); dtIinvdExcel.Columns.Add("允收天數", typeof(String)); dtIinvdExcel.Columns.Add("建立日期", typeof(String)); dtIinvdExcel.Columns.Add("建立人員", typeof(String)); dtIinvdExcel.Columns.Add("鎖定狀態", typeof(String)); dtIinvdExcel.Columns.Add("庫鎖原因", typeof(String)); dtIinvdExcel.Columns.Add("店內碼", typeof(String)); dtIinvdExcel.Columns.Add("國際碼", typeof(String)); dtIinvdExcel.Columns.Add("庫鎖備註", typeof(String)); #endregion for (int i = 0; i < store.Count; i++) { string upc = ""; Iupc iu = new Iupc(); DataRow newRow = dtIinvdExcel.NewRow(); newRow[0] = store[i].item_id.ToString(); #region 添加店內碼 if (DateTime.TryParse(store[i].cde_dt.ToString(), out dtime)) { upc = CommonFunction.GetUpc(store[i].item_id.ToString(), store[i].vendor_id.ToString(), dtime.ToString("yyMMdd")); } else { upc = CommonFunction.GetUpc(store[i].item_id.ToString(), store[i].vendor_id.ToString(), dtime.ToString("yyMMdd")); } iu.upc_id = upc; iu.item_id = uint.Parse(store[i].item_id.ToString()); iu.upc_type_flg = "2";//店內碼 iu.create_user = (Session["caller"] as Caller).user_id; string result = _IiupcMgr.IsExist(iu);//是否有重複的條碼 if (result == "0") { _IiupcMgr.Insert(iu); } #endregion newRow[1] = store[i].product_name.ToString(); newRow[2] = store[i].prod_qty.ToString(); newRow[3] = store[i].cde_dt.ToString(); newRow[4] = store[i].plas_loc_id.ToString(); newRow[5] = store[i].loc_id.ToString(); newRow[6] = store[i].cde_dt_var.ToString(); newRow[7] = store[i].create_dtim.ToString(); newRow[8] = store[i].user_name.ToString(); newRow[9] = store[i].ista_id.ToString(); newRow[10] = store[i].qity_name.ToString(); newRow[11] = " " + upc; newRow[12] = " " + store[i].upc_id.ToString(); iivd.item_id = uint.Parse(store[i].item_id.ToString()); iivd.plas_loc_id = store[i].plas_loc_id.ToString(); iivd.made_date = store[i].made_date; if (store[i].ista_id.ToString() == "H") { newRow[13] = _iinvd.remark(iivd); } else { newRow[13] = ""; } dtIinvdExcel.Rows.Add(newRow); } if (dtIinvdExcel.Rows.Count > 0) { string fileName = "收貨上架_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls"; MemoryStream ms = ExcelHelperXhf.ExportDT(dtIinvdExcel, "收貨上架_" + DateTime.Now.ToString("yyyyMMddHHmmss")); Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); Response.BinaryWrite(ms.ToArray()); } else { Response.Write("匯出數據不存在"); } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); } }
public HttpResponseBase AboutItemidLocid() { string json = string.Empty; Iinvd invd = new Iinvd(); int result = 0; try { invd.plas_loc_id = Request.Params["tloc_id"].ToUpper(); invd.item_id = Convert.ToUInt32(Request.Params["titem_id"]); _iinvd = new IinvdMgr(mySqlConnectionString); result = _iinvd.AboutItemidLocid(invd); if (result > 0) { json = "{success:true}";//返回json數據 } else { json = "{success:true,msg:0}";//返回json數據 } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
//判斷某個料位的商品是否被鎖定 public HttpResponseBase GetSearchStock() { string json = string.Empty; int islock = 0; _iinvd = new IinvdMgr(mySqlConnectionString); IinvdQuery query = new IinvdQuery(); if (!string.IsNullOrEmpty(Request.Params["loc_id"])) { query.plas_loc_id = Request.Params["loc_id"]; } if (!string.IsNullOrEmpty(Request.Params["item_id"])) { query.item_id = uint.Parse(Request.Params["item_id"]); } if (!string.IsNullOrEmpty(Request.Params["cde_date"]) && Request.Params["cde_date"] != "null") { query.cde_dt = DateTime.Parse(Request.Params["cde_date"]); } if (!string.IsNullOrEmpty(Request.Params["made_date"]) && Request.Params["made_date"] != "null") { query.made_date = DateTime.Parse(Request.Params["made_date"]); } query.ista_id = "H"; //{ // plas_loc_id = Request.Params["plas_loc_id"], // item_id = uint.Parse(Request.Params["item_id"]), // ista_id = "H", // made_date = string.IsNullOrEmpty(Request.Params["made_date"]) ? DateTime.MinValue : DateTime.Parse(Request.Params["made_date"]), // cde_dt = string.IsNullOrEmpty(Request.Params["cde_dt"]) ? DateTime.MinValue : DateTime.Parse(Request.Params["cde_dt"]) //}; try { if (!string.IsNullOrEmpty(query.plas_loc_id)) { if (query.made_date == query.cde_dt) { query.cde_dt = query.made_date = DateTime.Now; } List<IinvdQuery> listIinvdQuery = _iinvd.GetSearchIinvd(query); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 //timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; timeConverter.DateTimeFormat = "yyyy-MM-dd"; if (listIinvdQuery.Count > 0) { islock = 1; } //實際能檢的庫存listIinvdQuery.Count json = "{success:true,msg:\"" + islock + "\"}"; } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
//public HttpResponseBase SaveWhyLock() //{ // string json = string.Empty; // try // { // Iinvd Iinvd = new Iinvd(); // _iinvd = new IinvdMgr(mySqlConnectionString); // json = "{success:true}"; // } // catch (Exception ex) // { // Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); // logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); // logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; // log.Error(logMessage); // json = "{success:false}"; // } // this.Response.Clear(); // this.Response.Write(json); // this.Response.End(); // return this.Response; //} //public HttpResponseBase GetAseldListByJobidorOrderid() //{ // string json = string.Empty; // AseldQuery asequery = new AseldQuery(); // try // { // List<AseldQuery> store = new List<AseldQuery>(); // _iasdMgr = new AseldMgr(mySqlConnectionString); // store = _iasdMgr.GetAseldList(asequery); // IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); // //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 // timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; // json = "{success:true,data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據 // } // catch (Exception ex) // { // Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); // logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); // logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; // log.Error(logMessage); // json = "{success:false,totalCount:0,data:[]}"; // } // this.Response.Clear(); // this.Response.Write(json); // this.Response.End(); // return this.Response; //} #endregion #region 公共方法 //商品顯示加規格 public string GetProductSpec(string id) { DataTable dt = new DataTable(); _iinvd = new IinvdMgr(mySqlConnectionString); int item_id = 0; string spec = string.Empty; if (int.TryParse(id, out item_id) && id.Length == 6) {//獲取商品編號 dt = _iinvd.Getprodu(item_id); } if (dt.Rows.Count > 0) { if (!string.IsNullOrEmpty(dt.Rows[0]["spec_name"].ToString())) { spec += dt.Rows[0]["spec_name"].ToString(); } if (!string.IsNullOrEmpty(dt.Rows[0]["spec_name1"].ToString())) { if (spec.Length > 0) { spec += ","; } spec += dt.Rows[0]["spec_name1"].ToString(); } if (spec.Length > 0) { spec = "(" + spec + ")"; } return spec; } else { return spec; } }
//理货员工作--寄仓--庫存信息 public HttpResponseBase GetStockByProductId() { string json = string.Empty; int totalCount = 0; int islock = 0; _iinvd = new IinvdMgr(mySqlConnectionString); IinvdQuery query = new IinvdQuery() { plas_loc_id = Request.Params["loc_id"], ista_id = "A" }; try { if (!string.IsNullOrEmpty(query.plas_loc_id)) { List<IinvdQuery> listIinvdQuery = _iinvd.GetIinvdList(query, out totalCount); //處理顯示有效期控管的有效期 #region //foreach (var item in listIinvdQuery) //{ // if (item.pwy_dte_ctl == "Y") // { // if (!string.IsNullOrEmpty(item.cde_dt_incr.ToString())) // { // item.cde_dt = item.made_date.AddDays(item.cde_dt_incr); // } // } //} #endregion IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 //timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; timeConverter.DateTimeFormat = "yyyy-MM-dd"; if (totalCount > listIinvdQuery.Count) { islock = 1; } //實際能檢的庫存listIinvdQuery.Count if (listIinvdQuery.Count > 0) { json = "{success:true,islock:'" + islock + "',totalCount:" + listIinvdQuery.Count + ",data:" + JsonConvert.SerializeObject(listIinvdQuery, Formatting.Indented, timeConverter) + "}";//返回json數據 } else { IinvdQuery m = new IinvdQuery(); m.prod_qty = 0; m.made_date = DateTime.Now; m.cde_dt = DateTime.Now; listIinvdQuery.Add(m); json = "{success:true,islock:'" + islock + "',totalCount:" + listIinvdQuery.Count + ",data:" + JsonConvert.SerializeObject(listIinvdQuery, Formatting.Indented, timeConverter) + "}";//返回json數據 } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
//獲取製造日期,有效日期判斷是否日期控管 public HttpResponseBase JudgeDate() { string jsonStr = "{success:false}"; DateTime dt = new DateTime(); DataTable data = new DataTable(); _iinvd = new IinvdMgr(mySqlConnectionString); int day = 0; try { string dtstring = Request.Params["dtstring"].ToString(); if (DateTime.TryParse(Request.Params["startTime"].ToString(), out dt)) { #region 編號獲取數據 if (!int.TryParse(Request.Params["item_id"].ToString(), out day)) {//獲取條碼 data = _iinvd.Getprodubybar(Request.Params["item_id"].ToString()); } else {//獲取商品編號 data = _iinvd.Getprodu(int.Parse(Request.Params["item_id"].ToString())); } #endregion DateTime dts = DateTime.Parse(Request.Params["startTime"].ToString()); if (data.Rows.Count > 0) {//該商品有數據才往下進行 if (data.Rows[0]["pwy_dte_ctl"].ToString() == "Y") {//需要日期控管才進行操作] DateTime dte = dts, dtss, dtee; dt = DateTime.Now; if (dtstring == "1" || dtstring == "2") { if (dtstring == "1") {//根據製造日期求出有效期 dte = dts.AddDays(int.Parse(data.Rows[0]["cde_dt_incr"].ToString()));//製造日期+保質期=有效期 } if (dtstring == "2") {//根據有效日期求出製造日期 dts = dte.AddDays(-int.Parse(data.Rows[0]["cde_dt_incr"].ToString())); } // if (dts > dt) { jsonStr = "{success:true,msg:'1'}"; } else { dtss = dts.AddDays(int.Parse(data.Rows[0]["cde_dt_var"].ToString()));//製造時間+允出天數 dtee = dt.AddDays(int.Parse(data.Rows[0]["cde_dt_shp"].ToString()));//今天+允出天數 if (dt > dtss) { jsonStr = "{success:true,msg:'2'}"; if (dtee > dte) { jsonStr = "{success:true,msg:'3'}"; if (dte < dt) { jsonStr = "{success:true,msg:'4',dte:'" + dte.ToShortDateString() + "'}"; } } } else { //有效期匯出 jsonStr = "{success:true,msg:'5',dts:'" + dts.ToString("yyyy-MM-dd") + "',dte:'" + dte.ToString("yyyy-MM-dd") + "'}"; } } } else { jsonStr = "{success:false}"; } } else { if (dts > DateTime.Now) { jsonStr = "{success:true,msg:'1'}"; } } } else { if (dts > DateTime.Now) { jsonStr = "{success:true,msg:'1'}"; } } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); jsonStr = "{success:false}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }
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); }