//初始化购物车信息
        protected void initMyCart(string flag)
        {
            table_source = createMyCartTable(flag);

            if (table_source.Rows.Count == 0)
            {
                cart_part.Visible = false;
                no_order.Visible  = true;
            }
            else
            {
                my_cart_datalist.DataSource = table_source;
                my_cart_datalist.DataBind();

                float pay = 0;

                for (int i = 0; i < my_cart_datalist.Items.Count; i++)
                {
                    pay += Convert.ToSingle(table_source.Rows[i]["pay"].ToString());
                }

                if (pay == 0)
                {
                    btn_pay.Enabled = false;
                }
                else
                {
                    btn_pay.Enabled = true;
                }

                ArrayList auto_array = new AutoOrderDAO().getOrdersArray(Session["name"].ToString(), "unpay");


                lb_money.Text = pay.ToString();

                initNoticeInfo(my_cart_datalist, "delete");
            }
        }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string order_number = Request.QueryString["order_number"];
            string info         = Request.QueryString["type"];

            if (order_number != null)
            {
                AutoOrder autoorder            = new AutoOrderDAO().getAutoOrder(order_number);
                ArrayList auto_orderlist_array = new AutoOrderListDAO().getAutoOrderListArray(autoorder.Auto_no);
                int       ordercount           = autoorder.Order_count;
                string[]  pdflist = new string[ordercount];
                for (int ii = 0; ii < ordercount; ii++)
                {
                    AutoOrderList autoorderlist = (AutoOrderList)auto_orderlist_array[ii];
                    string        tracknumber   = autoorderlist.Order_no;
                    pdflist[ii] = Server.MapPath("\\views\\pdf\\" + tracknumber + "2.pdf");
                }
                mergePDFFiles(pdflist, Server.MapPath("\\views\\pdf\\" + order_number + "2.pdf"));
                string filename = Server.MapPath("\\views\\pdf\\" + order_number + "2.pdf");
                HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + order_number + ".pdf");

                HttpContext.Current.Response.WriteFile(filename);
                HttpContext.Current.Response.Flush();
                HttpContext.Current.Response.Close();
            }
            if (info != null)
            {
                if (order_number != null)
                {
                    Order order = new OrderDAO().getOrder(order_number);

                    string parentPath = Server.MapPath("");
                    string filename   = order.Order_number + ".pdf";
                    string path       = parentPath + "/pdf/" + filename;

                    generatePDF(order, path);

                    HttpContext.Current.Response.ClearContent();
                    HttpContext.Current.Response.ClearHeaders();
                    //如果是在网页中显示
                    if (info == "detail")
                    {
                        //在网页中显示
                        HttpContext.Current.Response.ContentType = "application/PDF";
                        HttpContext.Current.Response.AddHeader("content-disposition", "filename=" + filename);
                    }
                    else
                    {
                        //以下载的形式展现
                        HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + filename);
                    }

                    HttpContext.Current.Response.WriteFile(path);
                    HttpContext.Current.Response.Flush();
                    HttpContext.Current.Response.Close();
                }
            }
            else
            {
                if (Session["orders"] != null)
                {
                    ArrayList orders = (ArrayList)Session["orders"];

                    string parentPath = Server.MapPath("");
                    string filename   = "all_orders.pdf";
                    string path       = parentPath + "/pdf/" + filename;

                    generatePDF(orders, path);

                    HttpContext.Current.Response.ClearContent();
                    HttpContext.Current.Response.ClearHeaders();
                    //如果是在网页中显示


                    //以下载的形式展现
                    HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + filename);

                    HttpContext.Current.Response.WriteFile(path);
                    HttpContext.Current.Response.Flush();
                    HttpContext.Current.Response.Close();
                }
            }
        }