/// <summary> /// get order sheet record as Ienumerable so we can bind it for formview /// </summary> /// <param name="ordernumber"></param> protected void bind_order(int ordernumber) { try { //get datacontext linq.linq_order_sheet_udfDataContext _linq = new linq.linq_order_sheet_udfDataContext(); //return iqueryable order by order number //IQueryable<order_sheetResult> _order = _linq.order_sheet(1049040); //details for 1st order the linq datacontext only returns 1 record by order number //order details IList<linq.order_sheetResult> _o = _linq.order_sheet(ordernumber).ToList<linq.order_sheetResult>(); this.fmvorder.DataSource = _o; this.fmvorder.DataBind(); } catch (Exception ex) { string _err = ex.Message.ToString(); Response.Write(_err); } }
protected void sub_decks_view(int orderno) { linq.linq_order_sheet_udfDataContext _linq = new linq.linq_order_sheet_udfDataContext(); //order details from table valued function IList<linq.order_sheetResult> _o = _linq.order_sheet(orderno).ToList<linq.order_sheetResult>(); //1st table row ASPxLabel _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblOrderControllerIDName"); if (_lbl != null && _o[0].OrderController!= null) { _lbl.Text = _o[0].OrderController.ToString(); } //office id on original order _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblOfficeIndicatorName"); if (_lbl != null && _o[0].OfficeIndicator != null) { _lbl.Text = _o[0].OfficeIndicator.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblCustomersRefName"); if (_lbl != null && _o[0].CustomersRef != null) { _lbl.Text = _o[0].CustomersRef.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblOperationsControllerIDName"); if (_lbl != null && _o[0].OpsController != null) { _lbl.Text = _o[0].OpsController.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblContactIDName"); if (_lbl != null && _o[0].ContactName != null) { _lbl.Text = _o[0].ContactName.ToString(); } //2nd table row _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblCountryIDName"); if (_lbl != null && _o[0].OriginCountry != null) { _lbl.Text = _o[0].OriginCountry.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblDestinationPortIDName"); if (_lbl != null && _o[0].DestinationPort != null) { _lbl.Text = _o[0].DestinationPort.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblCompanyIDName"); if (_lbl != null && _o[0].CustomerName != null) { _lbl.Text = _o[0].CustomerName.ToString(); } //3rd table row _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblOriginPointIDName"); if (_lbl != null && _o[0].OriginPlace != null) { _lbl.Text = _o[0].OriginPlace.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblFinalDestinationIDName"); if (_lbl != null && _o[0].FinalDestination != null) { _lbl.Text = _o[0].FinalDestination.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblCompanyIDView"); if (_lbl != null) { _lbl.Text = _o[0].CustomerAddress1 != null ? _o[0].CustomerAddress1.ToString() : ""; _lbl.Text += _o[0].CustomerAddress2 != null ? Environment.NewLine + _o[0].CustomerAddress2.ToString() : ""; _lbl.Text += _o[0].CustomerAddress3 != null ? Environment.NewLine + _o[0].CustomerAddress3.ToString() : ""; _lbl.Text += _o[0].CustomerPostCode != null ? Environment.NewLine + _o[0].CustomerPostCode.ToString() : ""; _lbl.Text += _o[0].CustomerCountry != null ? Environment.NewLine + _o[0].CustomerCountry.ToString() : ""; _lbl.Text += _o[0].CustomerTelNo != null ? Environment.NewLine + _o[0].CustomerTelNo.ToString() : ""; } //4th row _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblPortIDName"); if (_lbl != null && _o[0].OriginPort != null) { _lbl.Text = _o[0].OriginPort.ToString(); } //5th row _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblOriginPortControllerIDName"); if (_lbl != null && _o[0].OriginController != null) { _lbl.Text = _o[0].OriginController.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblDestinationPortControllerIDName"); if (_lbl != null && _o[0].DestController != null) { _lbl.Text = _o[0].DestController.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblPrinterIDName"); if (_lbl != null && _o[0].PrinterName != null) { _lbl.Text = _o[0].PrinterName.ToString(); } //6th row _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblPrinterIDView"); if (_lbl != null) { _lbl.Text = _o[0].PrinterAddress1 != null ? _o[0].PrinterAddress1.ToString() : ""; _lbl.Text += _o[0].PrinterAddress2 != null ? Environment.NewLine + _o[0].PrinterAddress2.ToString() : ""; _lbl.Text += _o[0].PrinterAddress3 != null ? Environment.NewLine + _o[0].PrinterAddress3.ToString() : ""; _lbl.Text += _o[0].PrinterPostCode != null ? Environment.NewLine + _o[0].PrinterPostCode.ToString() : ""; _lbl.Text += _o[0].PrinterCountry != null ? Environment.NewLine + _o[0].PrinterCountry.ToString() : ""; _lbl.Text += _o[0].PrinterTelNo != null ? Environment.NewLine + _o[0].PrinterTelNo.ToString() : ""; } //7th row _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblConsigneeIDName"); if (_lbl != null && _o[0].ConsigneeName != null) { _lbl.Text = _o[0].ConsigneeName.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblConsigneeIDView"); if (_lbl != null) { _lbl.Text = _o[0].ConsigneeAddress1 != null ? _o[0].ConsigneeAddress1.ToString() : ""; _lbl.Text += _o[0].ConsigneeAddress2 != null ? Environment.NewLine + _o[0].ConsigneeAddress2.ToString() : ""; _lbl.Text += _o[0].ConsigneeAddress3 != null ? Environment.NewLine + _o[0].ConsigneeAddress3.ToString() : ""; _lbl.Text += _o[0].ConsigneePostCode != null ? Environment.NewLine + _o[0].ConsigneePostCode.ToString() : ""; _lbl.Text += _o[0].ConsigneeCountry != null ? Environment.NewLine + _o[0].ConsigneeCountry.ToString() : ""; _lbl.Text += _o[0].ConsigneeTelNo != null ? Environment.NewLine + _o[0].ConsigneeTelNo.ToString() : ""; } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblAgentAtOriginIDName"); if (_lbl != null && _o[0].OriginAgentName != null) { _lbl.Text = _o[0].OriginAgentName.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblAgentAtOriginIDView"); if (_lbl != null) { _lbl.Text = _o[0].OriginAgentAddress1 != null ? _o[0].OriginAgentAddress1.ToString() : ""; _lbl.Text += _o[0].OriginAgentAddress2 != null ? Environment.NewLine + _o[0].OriginAgentAddress2.ToString() : ""; _lbl.Text += _o[0].OriginAgentAddress3 != null ? Environment.NewLine + _o[0].OriginAgentAddress3.ToString() : ""; _lbl.Text += _o[0].OriginAgentPostCode != null ? Environment.NewLine + _o[0].OriginAgentPostCode.ToString() : ""; _lbl.Text += _o[0].OriginAgentCountry != null ? Environment.NewLine + _o[0].OriginAgentCountry.ToString() : ""; _lbl.Text += _o[0].OriginAgentTelNo != null ? Environment.NewLine + _o[0].OriginAgentTelNo.ToString() : ""; } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblNotifyIDName"); if (_lbl != null && _o[0].NotifyName != null) { _lbl.Text = _o[0].NotifyName.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblNotifyIDView"); if (_lbl != null) { _lbl.Text = _o[0].NotifyAddress1 != null ? _o[0].NotifyAddress1.ToString() : ""; _lbl.Text += _o[0].NotifyAddress2 != null ? Environment.NewLine + _o[0].NotifyAddress2.ToString() : ""; _lbl.Text += _o[0].NotifyAddress3 != null ? Environment.NewLine + _o[0].NotifyAddress3.ToString() : ""; _lbl.Text += _o[0].NotifyAddress4 != null ? Environment.NewLine + _o[0].NotifyAddress4.ToString() : ""; _lbl.Text += _o[0].NotifyCountry != null ? Environment.NewLine + _o[0].NotifyCountry.ToString() : ""; _lbl.Text += _o[0].NotifyTelNo != null ? Environment.NewLine + _o[0].NotifyTelNo.ToString() : ""; } //final row _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblAgentAtDestinationIDName"); if (_lbl != null && _o[0].DestAgentName != null) { _lbl.Text = _o[0].DestAgentName.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblAgentAtDestinationIDView"); if (_lbl != null) { _lbl.Text = _o[0].DestAgentAddress1 != null ? _o[0].DestAgentAddress1.ToString() : ""; _lbl.Text += _o[0].DestAgentAddress2 != null ? Environment.NewLine + _o[0].DestAgentAddress2.ToString() : ""; _lbl.Text += _o[0].DestAgentAddress3 != null ? Environment.NewLine + _o[0].DestAgentAddress3.ToString() : ""; _lbl.Text += _o[0].DestAgentpostCode != null ? Environment.NewLine + _o[0].DestAgentpostCode.ToString() : ""; _lbl.Text += _o[0].DestAgentCountry != null ? Environment.NewLine + _o[0].DestAgentCountry.ToString() : ""; _lbl.Text += _o[0].DestAgentTelNo != null ? Environment.NewLine + _o[0].DestAgentTelNo.ToString() : ""; } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblClearingAgentIDName"); if (_lbl != null && _o[0].ClearingAgentName != null) { _lbl.Text = _o[0].ClearingAgentName.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblClearingAgentIDView"); if (_lbl != null) { _lbl.Text = _o[0].ClearingAgentAddress1 != null ? _o[0].ClearingAgentAddress1.ToString() : ""; _lbl.Text += _o[0].ClearingAgentAddress2 != null ? Environment.NewLine + _o[0].ClearingAgentAddress2.ToString() : ""; _lbl.Text += _o[0].ClearingAgentAddress3 != null ? Environment.NewLine + _o[0].ClearingAgentAddress3.ToString() : ""; _lbl.Text += _o[0].ClearingAgentAddress4 != null ? Environment.NewLine + _o[0].ClearingAgentAddress4.ToString() : ""; _lbl.Text += _o[0].ClearingAgentCountry != null ? Environment.NewLine + _o[0].ClearingAgentCountry.ToString() : ""; _lbl.Text += _o[0].ClearingAgentTelNo != null ? Environment.NewLine + _o[0].ClearingAgentTelNo.ToString() : ""; } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblOnCarriageIDName"); if (_lbl != null && _o[0].OnCarriageName != null) { _lbl.Text = _o[0].OnCarriageName.ToString(); } _lbl = (ASPxLabel)this.fmvTemplate.FindControl("dxlblOnCarriageIDView"); if (_lbl != null) { _lbl.Text = _o[0].OnCarriageAddress1 != null ? _o[0].OnCarriageAddress1.ToString() : ""; _lbl.Text += _o[0].OnCarriageAddress2 != null ? Environment.NewLine + _o[0].OnCarriageAddress2.ToString() : ""; _lbl.Text += _o[0].OnCarriageAddress3 != null ? Environment.NewLine + _o[0].OnCarriageAddress3.ToString() : ""; _lbl.Text += _o[0].OnCarriageAddress4 != null ? Environment.NewLine + _o[0].OnCarriageAddress4.ToString() : ""; _lbl.Text += _o[0].OnCarriageCountry != null ? Environment.NewLine + _o[0].OnCarriageCountry.ToString() : ""; _lbl.Text += _o[0].OnCarriageTelNo != null ? Environment.NewLine + _o[0].OnCarriageTelNo.ToString() : ""; } }
//end advance labels /// <summary> /// or use order_output.aspx /// </summary> /// <param name="ordernumber"></param> /// <returns></returns> public static string order_sheet(int ordernumber) { string _msg = ""; //for testing ordernumber = 1049040; // Document _doc = new Document(); try { //get datacontext linq.linq_order_sheet_udfDataContext _linq = new linq.linq_order_sheet_udfDataContext(); //return iqueryable order by order number //IQueryable<order_sheetResult> _order = _linq.order_sheet(1049040); //details for 1st order the linq datacontext only returns 1 record by order number linq.order_sheetResult _o = _linq.order_sheet(ordernumber).First<linq.order_sheetResult>(); System.IO.MemoryStream _mem = new System.IO.MemoryStream(); PdfWriter _pdf = PdfWriter.GetInstance(_doc, _mem); _doc.Open(); _doc.NewPage(); PdfPTable _tbl1 = new PdfPTable(6); //order number large text top left PdfPCell _c1 = new PdfPCell(new Phrase(_o.OrderNumber.ToString())); _c1.Padding = 3; _c1.Colspan = 4; _c1.Rowspan = 2; _tbl1.AddCell(_c1); //customer top right then customers ref and ex works date underneath PdfPCell _c2 = new PdfPCell(new Phrase(_o.CustomerName)); _c2.Padding = 3; _c2.Colspan = 2; _c2.Rowspan = 1; _tbl1.AddCell(_c2); PdfPCell _c3 = new PdfPCell(new Phrase("Customers Ref:")); _c3.Padding = 3; _c3.Colspan = 1; _c3.Rowspan = 1; _tbl1.AddCell(_c3); PdfPCell _c4 = new PdfPCell(new Phrase(_o.CustomersRef)); _c4.Padding = 3; _c4.Colspan = 1; _c4.Rowspan = 1; _tbl1.AddCell(_c4); PdfPCell _c5 = new PdfPCell(new Phrase("Ex Works:")); _c5.Padding = 3; _c5.Colspan = 1; _c5.Rowspan = 1; _tbl1.AddCell(_c5); PdfPCell _c6 = new PdfPCell(new Phrase(_o.ExWorksDate.ToString())); _c5.Padding = 3; _c5.Colspan = 1; _c5.Rowspan = 1; _tbl1.AddCell(_c6); _tbl1.WriteSelectedRows(0, _tbl1.Rows.Count, _doc.LeftMargin , _doc.PageSize.Height - _doc.TopMargin, _pdf.DirectContent); //end of top section //new table for origin & destination details PdfPTable _tbl2 = new PdfPTable(6); //row 1 origin point + customer contact _c6 = new PdfPCell(new Phrase("Origin Point:")); _c6.Padding = 3; _c6.Colspan = 1; _c6.Rowspan = 1; _tbl2.AddCell(_c6); PdfPCell _c7 = new PdfPCell(new Phrase(_o.OriginPort)); _c7.Padding = 3; _c7.Colspan = 2; _c7.Rowspan = 1; _tbl2.AddCell(_c7); PdfPCell _c8 = new PdfPCell(new Phrase("Customer Contact:")); _c8.Padding = 3; _c8.Colspan = 1; _c8.Rowspan = 1; _tbl2.AddCell(_c8); PdfPCell _c9 = new PdfPCell(new Phrase(_o.ContactName)); _c9.Padding = 3; _c9.Colspan = 2; _c9.Rowspan = 1; _tbl2.AddCell(_c9); //row 2 origin port and order controller PdfPCell _c10 = new PdfPCell(new Phrase("Origin port:")); _c10.Padding = 3; _c10.Colspan = 1; _c10.Rowspan = 1; _tbl2.AddCell(_c10); PdfPCell _c11 = new PdfPCell(new Phrase(_o.OriginPort)); _c11.Padding = 3; _c11.Colspan = 2; _c11.Rowspan = 1; _tbl2.AddCell(_c11); PdfPCell _c = new PdfPCell(new Phrase("Order Controller:")); _c.Padding = 3; _c.Colspan = 1; _c.Rowspan = 1; _tbl2.AddCell(_c); _tbl2.WriteSelectedRows(0, _tbl2.Rows.Count, 0, 0, _pdf.DirectContent); //MultiColumnText columns = new MultiColumnText(); //columns.AddSimpleColumn(36f, 336f); //columns.AddSimpleColumn(360f, _doc.PageSize.Width - 36f); _doc.Close(); //pushes to output stream //direct output client side HttpContext.Current.Response.ContentType = "application/pdf"; HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + ordernumber + ".pdf"); HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.BinaryWrite(_mem.ToArray()); } catch (DocumentException dex) { _msg = dex.Message.ToString(); //throw (dex); //this.dxlblerr.Text = dex.Message.ToString(); //this.dxpageorder.ActiveTabIndex = 4; //error page } catch (IOException ioex) { _msg = ioex.Message.ToString(); //throw (ioex); //this.dxlblerr.Text = ioex.Message.ToString(); //this.dxpageorder.ActiveTabIndex = 4; //error page } finally { _doc.Close(); } return _msg; }