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