Exemplo n.º 1
0
    /// <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);
        }
    }
Exemplo n.º 2
0
    //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);
    }