//#region 到貨確認//到貨確認功能棄用 //public HttpResponseBase BatchSendProd() //{ // string jsonStr = String.Empty; // StringBuilder sb = new StringBuilder(); // string smIDs = string.Empty; // try // { // if (!string.IsNullOrEmpty(Request.Params["slaveMasterIds"])) // { // smIDs = Request.Params["slaveMasterIds"].ToString(); // _orderSlaveMasterMgr = new OrderSlaveMasterMgr(mySqlConnectionString); // //獲取當前用戶和ip // System.Net.IPAddress[] addlist = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList; // string userIP = addlist[0].ToString(); // string userName = (System.Web.HttpContext.Current.Session["caller"] as Caller).user_username; // if (_orderSlaveMasterMgr.BatchSendProd(smIDs, userName, userIP)) // { // jsonStr = "{success:true,msg:1}";//成功 // } // else // { // jsonStr = "{success:false,msg:0}"; // } // } // } // catch (Exception ex) // { // Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); // logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); // logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; // log.Error(logMessage); // jsonStr = "{success:false,msg:0}"; // } // this.Response.Clear(); // this.Response.Write(jsonStr.ToString()); // this.Response.End(); // return this.Response; //} //#endregion #endregion #region 當匯出pdf之後,改變表中的狀態 public HttpResponseBase UpdateTicketStatus() { string json = string.Empty; try { TicketQuery tdquery = new TicketQuery(); tdquery.type_id = Convert.ToInt32(Request.Params["type"]); string temp = Request.Params["tickets"].ToString(); tdquery.ticket_idto_str = temp.Remove(temp.LastIndexOf(',')); _tkMgr = new TicketMgr(mySqlConnectionString); if (_tkMgr.UpdateTicketStatus(tdquery) > 0) { json = "{success:true}"; } else { json = "{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); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public void GetPDF() { string filename = string.Empty; string jsonStr = String.Empty; try { if (!string.IsNullOrEmpty(Request.Params["ticket_id"])) { filename = "picking_detail" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"; string newPDFName = Server.MapPath(excelPath) + filename; if (System.IO.File.Exists(newPDFName)) { //設置文件的屬性,以防刪除文件的時候因為文件的屬性造成無法刪除 System.IO.File.SetAttributes(newPDFName, FileAttributes.Normal); System.IO.File.Delete(newPDFName); } TicketQuery query = new TicketQuery(); string temp = Request.Params["ticket_id"].ToString(); temp = temp.Remove(temp.LastIndexOf(',')); query.ticketIds = temp; _tkMgr = new TicketMgr(mySqlConnectionString); List<TicketQuery> store = _tkMgr.GetPickingDetail(query); List<TicketQuery> FMode = new List<TicketQuery>(); List<TicketQuery> CMode = new List<TicketQuery>(); foreach (var item in store) { if (item.combined_mode > 1) { if (item.item_mode == 1) { FMode.Add(item); } else { CMode.Add(item); } } else { CMode.Add(item); } } foreach (var fitem in FMode) { foreach (var citem in CMode) { if (fitem.parent_id == citem.parent_id && fitem.pack_id == citem.pack_id) { citem.buy_num = citem.buy_num * citem.parent_num; } } } string[] strId = query.ticketIds.ToString().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string str = strId[strId.Length - 1].ToString(); int de = 8 - str.Length; for (int z = 0; z < de; z++) { str = str.Insert(0, "0"); } str = str.Insert(0, "P"); BarCode.Code128 _Code = new BarCode.Code128(); _Code.ValueFont = new System.Drawing.Font("宋体", 20); System.Drawing.Bitmap imgTemp = _Code.GetCodeImage(str, BarCode.Code128.Encode.Code128A); imgTemp.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "BarCode.gif", System.Drawing.Imaging.ImageFormat.Gif); BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bfChinese, 14, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED); iTextSharp.text.Font font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.GetStyleValue("font-size:xx-small"), new iTextSharp.text.BaseColor(0, 0, 0));//黑 iTextSharp.text.Font bigFont = new iTextSharp.text.Font(bfChinese, 10, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑 Document document = new Document(PageSize.A4.Rotate(), (float)5, (float)5, (float)5, (float)0.5); PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.OpenOrCreate)); document.Open(); Phrase ph = new Phrase("\n ", font); iTextSharp.text.Image IMG = iTextSharp.text.Image.GetInstance(Server.MapPath("../ImportUserIOExcel/BarCode.gif")); IMG.ScaleToFit(100, 30); Chunk ck = new Chunk(IMG, 580, -30); //图片可设置 偏移 ph.Add(ck); document.Add(ph); Phrase p1 = new Phrase("\n \n", font); document.Add(p1); PdfPTable table = new PdfPTable(7); //table.BorderWidth = 0; //table.Cellpadding = 3; //table.Cellspacing = 3; table.SpacingBefore = 5; table.SetWidths(new int[] { 20, 30, 20, 40, 10, 15, 15 }); PdfPCell cell = new PdfPCell(new Phrase("付款單號", font)); cell.BorderWidthLeft = 0; cell.BorderWidthBottom = 0.5f; cell.BorderWidthRight = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("付款日期", font)); cell.BorderWidthLeft = 0; cell.BorderWidthBottom = 0.5f; cell.BorderWidthRight = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("供應商", font)); cell.BorderWidthLeft = 0; cell.BorderWidthBottom = 0.5f; cell.BorderWidthRight = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("商品名稱", font)); cell.BorderWidthLeft = 0; cell.BorderWidthBottom = 0.5f; cell.BorderWidthRight = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("數量", font)); cell.BorderWidthLeft = 0; cell.BorderWidthBottom = 0.5f; cell.BorderWidthRight = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("收件人", font)); cell.BorderWidthLeft = 0; cell.BorderWidthBottom = 0.5f; cell.BorderWidthRight = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase("訂購人", font)); cell.BorderWidthLeft = 0; cell.BorderWidthBottom = 0.5f; cell.BorderWidthRight = 0; table.AddCell(cell); for (int i = 0; i < CMode.Count; i++) { if (i == 0) { cell = new PdfPCell(new Phrase(CMode[i].order_id.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CommonFunction.GetNetTime(CMode[i].order_date_pay).ToString("yyyy-MM-dd HH:mm:ss"), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].vendor_name_simple.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].product_name.ToString() + CMode[i].spec_name.ToString() + CMode[i].spec_name1.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].buy_num.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].delivery_name.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].order_name.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); } else { if (CMode[i].order_id == CMode[i - 1].order_id) { cell = new PdfPCell(new Phrase(CMode[i].order_id.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CommonFunction.GetNetTime(CMode[i].order_date_pay).ToString("yyyy-MM-dd HH:mm:ss"), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].vendor_name_simple.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].product_name.ToString() + CMode[i].spec_name.ToString() + CMode[i].spec_name1.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].buy_num.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].delivery_name.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].order_name.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0; cell.BorderWidthBottom = 0; table.AddCell(cell); } else { cell = new PdfPCell(new Phrase(CMode[i].order_id.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0.5f; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CommonFunction.GetNetTime(CMode[i].order_date_pay).ToString("yyyy-MM-dd HH:mm:ss"), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0.5f; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].vendor_name_simple.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0.5f; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].product_name.ToString() + CMode[i].spec_name.ToString() + CMode[i].spec_name1.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0.5f; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].buy_num.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0.5f; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].delivery_name.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0.5f; cell.BorderWidthBottom = 0; table.AddCell(cell); cell = new PdfPCell(new Phrase(CMode[i].order_name.ToString(), font)); cell.BorderWidthLeft = 0; cell.BorderWidthRight = 0; cell.BorderWidthTop = 0.5f; cell.BorderWidthBottom = 0; table.AddCell(cell); } } } document.Add(table); document.Close(); Response.Clear(); Response.Charset = "gb2312"; Response.ContentEncoding = System.Text.Encoding.UTF8; // Response.AddHeader("Content-Disposition", "attach-ment;filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + ".pdf "); Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename); Response.WriteFile(newPDFName); } } 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,result:0}"; } }
//public HttpResponseBase GetDeliversPDF() //{ // string filename = string.Empty; // string jsonStr = String.Empty; // try // { // TicketQuery query = new TicketQuery(); // string str = Request.Params["ticket_id"].ToString(); // str = str.Remove(str.LastIndexOf(',')); // query.ticketIds = str; // query.type = 1; // _tkMgr = new TicketMgr(mySqlConnectionString); // List<TicketQuery> list = _tkMgr.GetTicketDetail(query); // BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); // iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bfChinese, 14, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED); // iTextSharp.text.Font font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // iTextSharp.text.Font bigFont = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.BOLD, new iTextSharp.text.BaseColor(0, 0, 0));//黑 // int temp = 0; // if (int.TryParse(str, out temp)) // { // filename = "order_delivers_T" + str.ToString().PadLeft(8, '0') + ".pdf"; // } // else // { // filename = "order_delivers_all.pdf"; // } // Rectangle pageSize = new Rectangle(PageSize.A4.Rotate()); // Document document = new Document(pageSize, (float)0.5, (float)5, (float)0.5, (float)0.5); // string newPDFName = Server.MapPath(excelPath) + filename; // PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.OpenOrCreate)); // foreach (var item in list) // { // item.orderCreatedate = CommonFunction.GetNetTime(item.order_createdate).ToString("yyyy-MM-dd HH:mm:ss"); // item.moneyCollectDate = CommonFunction.GetNetTime(item.money_collect_date).ToString("yyyy-MM-dd HH:mm:ss"); // item.holidayDeliver = item.holiday_deliver == 1 ? "可" : "不可"; // if (item.estimated_arrival_period == 0) // { // item.arrival_period_name = "不限時"; // } // else if (item.estimated_arrival_period == 1) // { // item.arrival_period_name = "12:00以前"; // } // else if (item.estimated_arrival_period == 2) // { // item.arrival_period_name = "12:00-17:00"; // } // else if (item.estimated_arrival_period == 3) // { // item.arrival_period_name = "17:00-20:00"; // } // if (item.freight_set == 1) // { // item.freight_set_name = "常溫"; // } // else if (item.freight_set == 2) // { // item.freight_set_name = "冷凍"; // } // else if (item.freight_set == 3) // { // item.freight_set_name = "常溫免運"; // } // else if (item.freight_set == 4) // { // item.freight_set_name = "冷凍免運"; // } // else if (item.freight_set == 5) // { // item.freight_set_name = "冷藏"; // } // else if (item.freight_set == 6) // { // item.freight_set_name = "冷藏免運"; // } // if (item.delivery_store == 12) // { // item.deliveryStore = "*自取(取貨地址:台北市南港區八德路4段768巷7號6樓之1,取貨時間週一~週五,AM9:00~PM6:00)"; // } // else if (item.delivery_store == 13) // { // item.deliveryStore = "*自取(取貨地址:新北市板橋區三民路二段33號21樓,取貨時間週一~週五,AM9:00~PM6:00)"; // } // else if (item.delivery_store == 14) // { // item.deliveryStore = "*自取(取貨地址:新北市永和區成功路一段80號20樓,取貨時間週一~週五,AM9:00~PM6:00)"; // } // } // for (int m = 0; m < list.Count; m++) // { // _tkMgr = new TicketMgr(mySqlConnectionString); // list[m].type = 1; // DataTable li = _tkMgr.GetOrderDelivers(list[m]); // string strId = list[m].deliver_id.ToString(); // int de = 8 - strId.Length; // for (int z = 0; z < de; z++) // { // strId = strId.Insert(0, "0"); // } // strId = strId.Insert(0, "D"); // document.Open(); // Phrase ph = new Phrase("\n \n", font); // BarCode.Code128 _Code = new BarCode.Code128(); // _Code.ValueFont = new System.Drawing.Font("宋体", 20); // System.Drawing.Bitmap imgTemp = _Code.GetCodeImage(strId, BarCode.Code128.Encode.Code128A); // imgTemp.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "Code.gif", System.Drawing.Imaging.ImageFormat.Gif); // iTextSharp.text.Image IMG = iTextSharp.text.Image.GetInstance(Server.MapPath("../ImportUserIOExcel/Code.gif")); // IMG.ScaleToFit(134, 60); // Chunk ck = new Chunk(IMG, 0, 0); //图片可设置 偏移 // ph.Add(ck); // //document.Add(ck); // // if (orderdeliver.Rows[0]["channel"].ToString() != "1") // // { // // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["channel_name_simple"].ToString(), 80, 700, 0); // // } // // if (orderdeliver.Rows[0]["retrieve_mode"].ToString() == "1") // // { // // cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "7-11取貨", 200, 700, 0); // // } // PdfPTable tab = new PdfPTable(2); // //tab.Border = 0; // //tab.BorderWidth = 1; // //tab.BorderColor = new iTextSharp.text.BaseColor(0, 0, 255); // //tab.Cellpadding = 2; // //tab.Cellspacing = 2; // //tab.SetWidths(new int[] { 5, 30, 20, 5,10, 30 }); // PdfPCell cel = new PdfPCell(); // cel = new PdfPCell(new Phrase("吉甲地市集出貨明細\n", bigFont)); // cel.HorizontalAlignment = 1; // cel.Border = 0; // tab.AddCell(cel); // cel = new PdfPCell(new Phrase(list[m].freight_set_name + "\n" + list[m].arrival_period_name + "\n", font)); // //cel.Add(new Phrase(list[m].arrival_period_name + "\n", font)); // cel.AddElement(ph); // cel.Border = 0; // cel.HorizontalAlignment = 1; // if (li.Rows[0]["channel"].ToString() != "1") // { // Paragraph channel_name_simple = new Paragraph(new Chunk(li.Rows[0]["channel_name_simple"].ToString() + "\n", font)); // cel.AddElement(channel_name_simple); // } // if (li.Rows[0]["retrieve_mode"].ToString() == "1") // { // Paragraph retrieve_mode = new Paragraph(new Chunk("7-11取貨\n", font)); // cel.AddElement(retrieve_mode); // } // tab.AddCell(cel); // document.Add(tab); // Paragraph p1 = new Paragraph(new Chunk("\n", FontFactory.GetFont(FontFactory.HELVETICA, 3))); // document.Add(p1); // PdfPTable tabShow = new PdfPTable(4); // tabShow.SetWidths(new int[] { 15, 30, 15, 40 }); // iTextSharp.text.pdf.PdfPCell cellShow = new PdfPCell(); // cellShow = new PdfPCell(new Phrase("訂購人:", font)); // cellShow.Border = 0; // cellShow.PaddingRight = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].order_name, font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // //cel.HorizontalAlignment = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("收件人:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].delivery_name, font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("付款單號:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].order_id.ToString(), font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("收件地址:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].zip_name.ToString(), font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("訂購時間:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].orderCreatedate, font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("聯絡電話:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].delivery_mobile, font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("付款時間:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].moneyCollectDate, font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("假日可收貨:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].holidayDeliver.ToString(), font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("出貨備註:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].note_order, font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // cellShow.Colspan = 3; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase("訂單明細:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(list[m].deliveryStore, font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // cellShow.Colspan = 3; // tabShow.AddCell(cellShow); // if (li.Rows[0]["receivable"].ToString() != "0") // { // cellShow = new PdfPCell(new Phrase("應付金額:", font)); // cellShow.Border = 0; // tabShow.AddCell(cellShow); // cellShow = new PdfPCell(new Phrase(li.Rows[0]["receivable"].ToString(), font)); // cellShow.Border = 0; // cellShow.PaddingLeft = 0; // cellShow.Colspan = 3; // tabShow.AddCell(cellShow); // } // document.Add(tabShow); // PdfPTable table = new PdfPTable(7); // table.SpacingBefore = 5; // table.SetWidths(new int[] { 10, 50, 10, 5, 8, 10, 8 }); // PdfPCell cell = new PdfPCell(new Phrase("商品編號", font)); // cell.BorderWidth = (float)0.1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("商品名稱", font)); // cell.BorderWidth = (float)0.1; // cell.HorizontalAlignment = 1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("托運單屬性", font)); // cell.BorderWidth = (float)0.1; // cell.HorizontalAlignment = 1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("數量", font)); // cell.BorderWidth = (float)0.1; // cell.HorizontalAlignment = 1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("本次出貨", font)); // cell.BorderWidth = (float)0.1; // cell.HorizontalAlignment = 1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("預計出貨日", font)); // cell.BorderWidth = (float)0.1; // cell.HorizontalAlignment = 1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("供應商自出", font)); // cell.BorderWidth = (float)0.1; // cell.HorizontalAlignment = 1; // table.AddCell(cell); // for (int i = 0; i < li.Rows.Count; i++) // { // string item_id = string.Empty; // if (li.Rows[i]["item_mode"].ToString() == "1") // { // item_id = li.Rows[i]["parent_id"].ToString(); // } // else // { // item_id = li.Rows[i]["item_id"].ToString(); // } // cell = new PdfPCell(new Phrase(item_id.ToString(), font)); // cell.BorderWidth = (float)0.1; // table.AddCell(cell); // string datacontent = ((li.Rows[i]["product_mode"].ToString() == "2" && li.Rows[i]["item_mode"].ToString() == "1") ? "*" : " ") + li.Rows[i]["brand_name"].ToString() + "-" + li.Rows[i]["product_name"].ToString() + li.Rows[i]["product_spec_name"].ToString(); // if (li.Rows[i]["combined_mode"].ToString() != "0" && li.Rows[i]["item_mode"].ToString() == "2") // { // datacontent = " " + datacontent; // } // cell = new PdfPCell(new Phrase(datacontent.ToString(), font)); // cell.HorizontalAlignment = 1; // cell.BorderWidth = (float)0.1; // table.AddCell(cell); // string freight_set_name = string.Empty; // if (Convert.ToInt32(li.Rows[i]["freight_set"]) == 1) // { // freight_set_name = "常溫"; // } // else if (Convert.ToInt32(li.Rows[i]["freight_set"]) == 2) // { // freight_set_name = "冷凍"; // } // else if (Convert.ToInt32(li.Rows[i]["freight_set"]) == 3) // { // freight_set_name = "常溫免運"; // } // else if (Convert.ToInt32(li.Rows[i]["freight_set"]) == 4) // { // freight_set_name = "冷凍免運"; // } // else if (Convert.ToInt32(li.Rows[i]["freight_set"]) == 5) // { // freight_set_name = "冷藏"; // } // else if (Convert.ToInt32(li.Rows[i]["freight_set"]) == 6) // { // freight_set_name = "冷藏免運"; // } // cell = new PdfPCell(new Phrase(freight_set_name, font)); // cell.HorizontalAlignment = 1; // cell.BorderWidth = (float)0.1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase(li.Rows[i]["item_mode"].ToString() != "1" ? li.Rows[i]["buy_num"].ToString() : "", font)); // cell.HorizontalAlignment = 1; // cell.BorderWidth = (float)0.1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("", font)); // cell.HorizontalAlignment = 1; // cell.BorderWidth = (float)0.1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("", font)); // cell.HorizontalAlignment = 1; // cell.BorderWidth = (float)0.1; // table.AddCell(cell); // cell = new PdfPCell(new Phrase("", font)); // cell.HorizontalAlignment = 1; // cell.BorderWidth = (float)0.1; // table.AddCell(cell); // } // cell = new PdfPCell(new Phrase("備註:", font)); // cell.BorderWidth = (float)0.1; // cell.MinimumHeight = 50; // cell.Colspan = 7; // //cell.BorderWidthBottom = 0; // //cell.BorderWidthRight = 0; // //cell.BorderWidthLeft = 0; // table.AddCell(cell); // Paragraph jine = new Paragraph(new Chunk(" 應收金額:", font)); // document.Add(table); // Paragraph bz0 = new Paragraph(new Chunk(" 吉甲地市集網路平台購物發票說明:\n", font)); // document.Add(bz0); // Paragraph bz1 = new Paragraph(new Chunk(" 若您訂購時未選擇開立三聯式發票,平台一律開發電子發票。\n", font)); // document.Add(bz1); // Paragraph bz2 = new Paragraph(new Chunk(" 發票將於該筆訂單商品完全出貨之後第10天開立並以E-mail通知您。\n", font)); // document.Add(bz2); // Paragraph bz4 = new Paragraph(new Chunk(" 如需紙本發票請來信客服中心,會計部門將會依需求將電子發票印出並以平信郵寄約2~7個工作天送達。\n", font)); // document.Add(bz4); // Paragraph bz6 = new Paragraph(new Chunk(" 託管發票將會在單月26日進行兌獎作業後,系統將會發信通知中獎發票持有人,\n", font)); // document.Add(bz6); // Paragraph bz7 = new Paragraph(new Chunk(" 且為保障您的權益,我們將在七個工作天內,以掛號方式把中獎發票寄給您。\n", font)); // document.Add(bz7); // Paragraph bz8 = new Paragraph(new Chunk(" 祝您購物愉快!\n", bigFont)); // document.Add(bz8); // document.NewPage(); // } // document.Close(); // jsonStr = "{success:'true',filename:'" + filename + "'}"; // } // 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,result:0}"; // } // this.Response.Clear(); // this.Response.Write(jsonStr.ToString()); // this.Response.End(); // return this.Response; //} #endregion #region 出貨單+void GetDeliversPDF() /// <summary> /// 出貨單 /// </summary> public void GetDeliversPDF() { TicketQuery query = new TicketQuery(); string strTemp = Request.Params["ticket_id"].ToString(); strTemp = strTemp.Remove(strTemp.LastIndexOf(',')); query.ticketIds = strTemp; query.type = 1; _tkMgr = new TicketMgr(mySqlConnectionString); List<TicketQuery> list = _tkMgr.GetTicketDetail(query); Dictionary<string, string> dicproduct_freight_set = new Dictionary<string, string> { { "1", "1" }, { "2", "2" }, { "3", "1" }, { "4", "2" }, { "5", "5" }, { "6", "5" } }; BaseFont bfChinese = BaseFont.CreateFont("C:\\WINDOWS\\Fonts\\simsun.ttc,1", BaseFont.IDENTITY_H, BaseFont.NOT_EMBEDDED); iTextSharp.text.Font fontChinese = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.UNDERLINE, iTextSharp.text.BaseColor.RED); iTextSharp.text.Font font = new iTextSharp.text.Font(bfChinese, 12, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 int tTemp = 0; if (int.TryParse(strTemp, out tTemp)) { filename = "order_details_D" + strTemp.PadLeft(8, '0') + ".pdf"; } else { filename = "order_details_all.pdf"; } Document document = new Document(PageSize.A4, (float)5, (float)5, (float)20, (float)0.5); string newPDFName = Server.MapPath(excelPath) + filename; PdfWriter writer = PdfWriter.GetInstance(document, new FileStream(newPDFName, FileMode.Create)); document.Open(); //cb.SetTextMatrix(document.Left, document.Bottom - 15); if (list.Count > 0) { foreach (var m in list) { string deliver_id = m.deliver_id.ToString(); _DeliverDetailMgr = new DeliverDetailMgr(mySqlConnectionString); DataTable orderdeliver = _DeliverDetailMgr.GetOrderDelivers(deliver_id); PdfContentByte cb = writer.DirectContent; cb.BeginText(); Phrase ph = new Phrase("\n \n", font); BarCode.Code128 _Code = new BarCode.Code128(); _Code.ValueFont = new System.Drawing.Font("宋体", 20); System.Drawing.Bitmap imgTemp = _Code.GetCodeImage("D" + deliver_id.PadLeft(8, '0'), BarCode.Code128.Encode.Code128A); imgTemp.Save(System.AppDomain.CurrentDomain.BaseDirectory + "\\ImportUserIOExcel\\" + "Code.gif", System.Drawing.Imaging.ImageFormat.Gif); iTextSharp.text.Image IMG = iTextSharp.text.Image.GetInstance(Server.MapPath("../ImportUserIOExcel/Code.gif")); IMG.ScaleToFit(200, 30); IMG.SetAbsolutePosition(345, 740); //IMG. //Chunk ck = new Chunk(IMG, 345, -40); //图片可设置 偏移 //ph.Add(ck); //document.Add(ph); cb.SetFontAndSize(bfChinese, 20); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "吉甲地市集出貨明細", 30, 750, 0); if (orderdeliver.Rows[0]["priority"].ToString() == "1") { PdfPTable ot = new PdfPTable(1); ot.SetTotalWidth(new float[] { 190 }); PdfPCell c = new PdfPCell(new Phrase("", font)); c.FixedHeight = 30; c.BorderWidthBottom = 0.5f; c.BorderWidthLeft = 0.5f; c.BorderWidthRight = 0.5f; c.BorderWidthTop = 0.5f; ot.AddCell(c); ot.WriteSelectedRows(0, -1, 29, 770, cb); } cb.AddImage(IMG); if (orderdeliver.Rows.Count > 0) { if (orderdeliver.Rows[0]["channel"].ToString() != "1") { cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["channel_name_simple"].ToString(), 80, 700, 0); } if (orderdeliver.Rows[0]["retrieve_mode"].ToString() == "1") { cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "7-11取貨", 200, 700, 0); } cb.SetFontAndSize(bfChinese, 10); string freight_set = string.Empty; switch (orderdeliver.Rows[0]["freight_set"].ToString().Trim()) { case "1": freight_set = "常溫"; break; case "2": freight_set = "冷凍"; break; case "5": freight_set = "冷藏"; break; } cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, freight_set, 345, 785, 0); string estimated_arrival_period = string.Empty; if (orderdeliver.Rows[0]["estimated_arrival_period"].ToString() != "0") { switch (orderdeliver.Rows[0]["estimated_arrival_period"].ToString().Trim()) { case "0": estimated_arrival_period = "不限時"; break; case "1": estimated_arrival_period = "12:00以前"; break; case "2": estimated_arrival_period = "12:00-17:00"; break; case "3": estimated_arrival_period = "17:00-20:00"; break; } cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, estimated_arrival_period, 345, 773, 0); } } cb.SetFontAndSize(bfChinese, 10); //cb.SetTextMatrix(150,20); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "訂購人:", 10, 680, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "收件人:", 200, 680, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "付款單號:", 10, 660, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "收件地址:", 200, 660, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "訂購時間:", 10, 640, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "聯絡電話:", 200, 640, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "付款時間:", 10, 620, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "假日可收貨:", 200, 620, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "出貨備註:", 10, 600, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "訂單明細:", 10, 580, 0); if (orderdeliver.Rows.Count > 0) { if (orderdeliver.Rows[0]["receivable"].ToString() != "0") { cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "應收金額:" + orderdeliver.Rows[0]["receivable"].ToString(), 200, 580, 0); } } string address = string.Empty; string deliver_note = string.Empty; if (orderdeliver.Rows.Count > 0) { cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["order_name"].ToString(), 65, 680, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["delivery_name"].ToString(), 250, 680, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["order_id"].ToString(), 65, 660, 0); address += CommonFunction.ZipAddress(orderdeliver.Rows[0]["delivery_zip"].ToString()) + orderdeliver.Rows[0]["delivery_address"].ToString(); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, address, 250, 660, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["order_createdate"].ToString() != "0" ? CommonFunction.GetNetTime(long.Parse(orderdeliver.Rows[0]["order_createdate"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "", 65, 640, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["delivery_mobile"].ToString(), 250, 640, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["money_collect_date"].ToString() != "0" ? CommonFunction.GetNetTime(long.Parse(orderdeliver.Rows[0]["money_collect_date"].ToString())).ToString("yyyy-MM-dd HH:mm:ss") : "", 65, 620, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["holiday_deliver"].ToString() == "1" ? "可" : "不可", 260, 620, 0); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, orderdeliver.Rows[0]["note_order"].ToString(), 65, 600, 0); if (orderdeliver.Rows[0]["delivery_store"].ToString() == "12") { deliver_note = "*自取(取貨地址:台北市南港區八德路4段768巷7號6樓之1,取貨時間週一~週五,AM9:00~PM6:00)"; } else if (orderdeliver.Rows[0]["delivery_store"].ToString() == "13") { deliver_note = "*自取(取貨地址:新北市板橋區三民路二段33號21樓,取貨時間週一~週五,AM9:00~PM6:00)"; } else if (orderdeliver.Rows[0]["delivery_store"].ToString() == "14") { deliver_note = "*自取(取貨地址:新北市永和區成功路一段80號20樓,取貨時間週一~週五,AM9:00~PM6:00)"; } cb.SetFontAndSize(bfChinese, 8); cb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, deliver_note, 65, 580, 0); } cb.EndText(); PdfPTable ptable = new PdfPTable(7); ptable.SetTotalWidth(new float[] { 50, 280, 50, 50, 50, 50, 50 }); ptable.WidthPercentage = 98; PdfPCell cell; font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 cell = new PdfPCell(new Phrase("商品編號", font)); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("商品名稱", font)); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("托運單屬性", font)); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("數量", font)); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("本次出貨", font)); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("預計出貨日", font)); cell.DisableBorderSide(2); cell.DisableBorderSide(8); ptable.AddCell(cell); cell = new PdfPCell(new Phrase("供應商自出", font)); cell.DisableBorderSide(2); ptable.AddCell(cell); PdfPCell td; string lastdeliverid = "0"; ArrayList normal = new ArrayList(); ArrayList low = new ArrayList(); ArrayList lowstore = new ArrayList(); DataRow[] sinceorder = new DataRow[] { }; DataRow[] singleproduct = new DataRow[] { };//單一商品 DataRow[] fatherproduct = new DataRow[] { };//組合商品中的父商品 DataRow[] sonproduct = new DataRow[] { };//組合商品中的子商品 ArrayList combine = new ArrayList(); List<DataRow[]> orderdelivers = new List<DataRow[]>(); sinceorder = orderdeliver.Select("dtype=2 and combined_mode<=1 ", "item_id asc");//自出商品 singleproduct = orderdeliver.Select("dtype <>2 and combined_mode<=1 ", "item_id asc");//單一商品 if (singleproduct.Count() > 0) { orderdelivers.Add(singleproduct); } fatherproduct = orderdeliver.Select(" combined_mode>1 and item_mode=1", "item_id asc");//組合商品中父商品是否存在 foreach (var item in fatherproduct) { combine.Add(item); sonproduct = orderdeliver.Select(" combined_mode>1 and item_mode<>1 and parent_id=" + item["parent_id"] + " and pack_id=" + item["pack_id"], "item_id asc");//對應組合商品中的子商品 foreach (var son in sonproduct) { son["buy_num"] = (int.Parse(son["buy_num"].ToString()) * int.Parse(son["parent_num"].ToString())).ToString(); combine.Add(son); } } if (combine.Count > 0) { orderdelivers.Add((DataRow[])combine.ToArray(typeof(DataRow))); } //區分常溫、冷凍、冷藏 foreach (var item in orderdelivers) { foreach (var row in item) { string s = row["product_freight_set"].ToString(); switch (row["product_freight_set"].ToString()) { case "1": case "3": normal.Add(row);//常溫 break; case "2": case "4": low.Add(row);//冷凍 break; case "5": case "6": lowstore.Add(row);//冷藏 break; default: break; } } } orderdelivers = new List<DataRow[]>(); if (normal.Count > 0) { orderdelivers.Add((DataRow[])normal.ToArray(typeof(DataRow))); } if (low.Count > 0) { orderdelivers.Add((DataRow[])low.ToArray(typeof(DataRow))); } if (lowstore.Count > 0) { orderdelivers.Add((DataRow[])lowstore.ToArray(typeof(DataRow))); } if (sinceorder.Count() > 0) { orderdelivers.Add(sinceorder); } int j = 0; foreach (var item in orderdelivers) { j++; for (int i = 0; i < item.Count(); i++) { if (item[i]["ddeliver_id"].ToString() != lastdeliverid || i == 0) { lastdeliverid = item[i]["ddeliver_id"].ToString();//以一個出貨單號為界限 if (lastdeliverid != "0" || i == 0) { td = new PdfPCell(); td.Colspan = 7; td.DisableBorderSide(2); td.DisableBorderSide(4); td.DisableBorderSide(8); //td.BorderWidthTop = 0.2f; ptable.AddCell(td); } } string item_id = string.Empty; if (item[i]["item_mode"].ToString() == "1") { item_id = item[i]["parent_id"].ToString(); } else { item_id = item[i]["item_id"].ToString(); } font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 td = new PdfPCell(new Phrase(item_id, font)); td.DisableBorderSide(1); td.DisableBorderSide(2); td.DisableBorderSide(8); ptable.AddCell(td); string datacontent = ((item[i]["product_mode"].ToString() == "2" && item[i]["item_mode"].ToString() == "1") ? "*" : " ") + item[i]["brand_name"].ToString() + "-" + item[i]["product_name"].ToString() + item[i]["product_spec_name"].ToString(); if (item[i]["combined_mode"].ToString() != "0" && item[i]["item_mode"].ToString() == "2") { datacontent = " " + datacontent; } td = new PdfPCell(new Phrase(datacontent, font)); td.DisableBorderSide(1); td.DisableBorderSide(2); td.DisableBorderSide(8); ptable.AddCell(td); string value = string.Empty; string freight_set = string.Empty; if (dicproduct_freight_set.TryGetValue(item[i]["product_freight_set"].ToString(), out value)) { } switch (value) { case "1": freight_set = "常温"; break; case "2": freight_set = "冷冻"; break; case "5": freight_set = "冷藏"; break; } td = new PdfPCell(new Phrase(freight_set, font)); td.DisableBorderSide(1); td.DisableBorderSide(2); td.DisableBorderSide(8); ptable.AddCell(td); font = new iTextSharp.text.Font(bfChinese, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 td = new PdfPCell(new Phrase(item[i]["item_mode"].ToString() != "1" ? item[i]["buy_num"].ToString() : "", font)); td.DisableBorderSide(1); td.DisableBorderSide(2); td.DisableBorderSide(8); ptable.AddCell(td); td = new PdfPCell(new Phrase("", font)); td.DisableBorderSide(1); td.DisableBorderSide(2); td.DisableBorderSide(8); ptable.AddCell(td); td = new PdfPCell(new Phrase("", font)); td.DisableBorderSide(1); td.DisableBorderSide(2); td.DisableBorderSide(8); ptable.AddCell(td); Image image = Image.GetInstance(Server.MapPath("../Content/img/icons/mark.png")); image.ScalePercent(5, 5); if (item[i]["dtype"].ToString() == "2") { td = new PdfPCell(image, false); } else { td = new PdfPCell(); } td.HorizontalAlignment = Element.ALIGN_CENTER; td.VerticalAlignment = Element.ALIGN_MIDDLE; td.DisableBorderSide(1); td.DisableBorderSide(2); ptable.AddCell(td); } } string note_order = orderdeliver.Rows.Count.ToString() != "0" ? orderdeliver.Rows[0]["note_order"].ToString() : ""; cell = new PdfPCell(new Phrase("備註:" + note_order, font)); cell.Colspan = 7; cell.HorizontalAlignment = Element.ALIGN_LEFT; cell.BorderColor = new iTextSharp.text.BaseColor(0, 0, 0); ptable.AddCell(cell); PdfPTable nulltable = new PdfPTable(2); nulltable.SetWidths(new int[] { 20, 20 }); nulltable.DefaultCell.DisableBorderSide(1); nulltable.DefaultCell.DisableBorderSide(2); nulltable.DefaultCell.DisableBorderSide(4); nulltable.DefaultCell.DisableBorderSide(8); nulltable.AddCell(""); nulltable.AddCell(""); nulltable.SpacingAfter = 250; document.Add(nulltable); ptable.SpacingAfter = 50; document.Add(ptable); font = new iTextSharp.text.Font(bfChinese, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 document.Add(new Phrase("吉甲地市集網路平台購物發票說明:\n", font)); font = new iTextSharp.text.Font(bfChinese, 8, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 document.Add(new Phrase("若您訂購時未選擇開立三聯式發票,平台一律開立電子發票。\n", font)); document.Add(new Phrase("發票將於該筆訂單商品完全出貨之後第10天開立並以E-Mail通知您。\n", font)); document.Add(new Phrase("如需紙本發票請來信客服中心,會計部門將會依需求將電子發票印出並以平信郵寄約2~7個工作天內送達。\n", font)); document.Add(new Phrase("託管發票將會在單月26日進行對獎作業後,系統將會發信通知中獎發票持有人,\n", font)); document.Add(new Phrase("且為保障您的權益,我們將在七個工作天內,以掛號方式把中獎發票寄給您。\n", font)); font = new iTextSharp.text.Font(bfChinese, 10, iTextSharp.text.Font.NORMAL, new iTextSharp.text.BaseColor(0, 0, 0));//黑 document.Add(new Phrase("祝您購物愉快!", font)); document.NewPage(); } } else { PdfPTable nulltable = new PdfPTable(2); nulltable.SetWidths(new int[] { 20, 20 }); nulltable.DefaultCell.DisableBorderSide(1); nulltable.DefaultCell.DisableBorderSide(2); nulltable.DefaultCell.DisableBorderSide(4); nulltable.DefaultCell.DisableBorderSide(8); nulltable.AddCell(""); nulltable.AddCell(""); nulltable.SpacingAfter = 250; document.Add(nulltable); } document.Close(); Response.Clear(); Response.Charset = "gb2312"; Response.ContentEncoding = System.Text.Encoding.UTF8; // Response.AddHeader("Content-Disposition", "attach-ment;filename=" + System.Web.HttpUtility.UrlEncode(filename, System.Text.Encoding.UTF8) + ".pdf "); Response.AddHeader("Content-Disposition", "attach-ment;filename=" + filename); Response.WriteFile(newPDFName); }
public HttpResponseBase Getnewticketslist() { string jsonStr = String.Empty; StringBuilder sb = new StringBuilder(); List<TicketQuery> store = new List<TicketQuery>(); TicketQuery tqQuery = new TicketQuery(); try { tqQuery.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量 tqQuery.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");//用於分頁的變量 _tkMgr = new TicketMgr(mySqlConnectionString); int totalCount = 0; string condition = string.Empty; int deliver_type = Convert.ToInt32(Request.Params["deliver_type"]);//批次出貨類別 int vendorcondition = 0; if (!string.IsNullOrEmpty(Request.Params["vendorcondition"])) { vendorcondition = int.Parse(Request.Params["vendorcondition"]);//出貨廠商 } int shipment = 0; if (!string.IsNullOrEmpty(Request.Params["shipment"])) { shipment = int.Parse(Request.Params["shipment"]);//物流商 } int gongyinshang = 0; if (!string.IsNullOrEmpty(Request.Params["gongyinshang"])) { gongyinshang = int.Parse(Request.Params["gongyinshang"]); } int scheduling = int.Parse(Request.Params["scheduling"]);//調度狀態 int screen = int.Parse(Request.Params["screen"]);//批次出貨狀態 int lytype = int.Parse(Request.Params["lytype"]);//列印處理狀態 int ystype = int.Parse(Request.Params["ystype"]);//運送方式 string search = Request.Params["search"].Trim();//搜索內容 if (deliver_type == 1) //批次出貨類別 { condition = condition + " and Ticket.type = 1 "; } else { condition = condition + " and Ticket.type = 2 "; } #region 出貨廠商 if (vendorcondition == 0)//出貨廠商 所有 對 { condition = condition + ""; } else { condition = condition + " and Export.vendor_id=" + vendorcondition; } #endregion #region 物流商或者是供應商 if (shipment == 0)//物流商 { condition = condition + ""; } else { condition = condition + " and Ticket.delivery_store=" + shipment; } if (gongyinshang == 0)//物流商 { condition = condition + ""; } else { condition = condition + " and Ticket.delivery_store=" + shipment; } #endregion if (scheduling == 0)//調度狀態 { condition = condition + " and warehouse_status=0 "; } else if (scheduling == 1) { condition = condition + " and warehouse_status=1 "; } if (screen == -1)//批次出貨狀態 { condition = condition + ""; } else if (screen == 0) { condition = condition + " and ticket_status=0 "; } else if (screen == 1) { condition = condition + " and ticket_status=1 "; } if (lytype == 0)//列印處理狀態 現在php後台好像沒有作用 { condition = condition + " "; } else { condition = condition + " "; } if (ystype == 1)//運送方式 { condition = condition + " and freight_set=1 "; } else if (ystype == 2) { condition = condition + " and freight_set=2 "; } else if (ystype == 5) { condition = condition + " and freight_set=5 "; } if (!string.IsNullOrEmpty(search))//搜索條件 { condition = condition + string.Format(" AND ((Ticket.ticket_id like '%{0}%') OR (Export.vendor_name_simple like '%{0}%'))", search); } store = _tkMgr.GetTicketList(tqQuery, out totalCount, condition); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd"; jsonStr = "{success:true,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); jsonStr = "{success:false,msg:0}"; } this.Response.Clear(); this.Response.Write(jsonStr.ToString()); this.Response.End(); return this.Response; }