IE订单的打印处理办法

在一个商城项目应用中我需要把客户在网上下的订单使用IE打印出来

首先必须控制订单不能出现IE的页眉页脚(需要使用ScriptX)

<OBJECT id="factory" style="DISPLAY: none" codeBase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360"
    classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" viewastext>
</OBJECT>
<SCRIPT defer>
function println() {
  factory.printing.header = ""
  factory.printing.footer = ""
  factory.printing.Print(true)
  factory.printing.leftMargin = 0.2
  factory.printing.topMargin = 0.5
  factory.printing.rightMargin = 0.2
  factory.printing.bottomMargin = 1.5
  window.print();
  }
</SCRIPT>
然后主要是控制订单数据输出用什么办法显示出来,为了灵活的控制输出效果,我这里使用的是循环读入数据(定购的商品)的办法(下面的代码是我使用的)

        public string myOrder(string B_No)
        {
            doData.conn.Open();
            string strFirstMenu =null;
            string    strSql = "select Items_Type,Items_Name,Items_Unit,Items_Count,Items_Price from [OrderItems] where Order_No = '"+B_No+"'  order by ID desc";
            SqlDataAdapter da = new SqlDataAdapter(strSql,doData.conn);
            DataSet ds = new DataSet();
            da.Fill(ds,"myOrder");
            int count = ds.Tables[0].Rows.Count;
            string Items_Type,Items_Name,Items_Price,Items_Count,Items_Unit,Items_TotalPrice;
            Double Items_AllTotalPrice = 0;
            int Items_TotalCount = 0;

            string begin = "<table id =\"inc\"style=\"BORDER-COLLAPSE: collapse\" borderColor=\"#111111\" height=\"35\" cellSpacing=\"0\" cellPadding=\"0\" width=\"95%\" border=\"1\"><tr><td align=\"center\" width=\"14%\" height=\"35\">商品编号</td><td align=\"center\" width=\"25%\" height=\"35\">商品名称</td><td align=\"center\" width=\"10%\" height=\"35\">单位</td><td align=\"center\" width=\"10%\" height=\"35\">数量</td><td align=\"center\" width=\"20%\" height=\"35\">单价(元)</td><td align=\"center\" width=\"21%\" height=\"35\">金额(元)</td></tr>";

            for(int rb = 0; rb < count;rb++)
            {
                Items_Type = ds.Tables[0].Rows[rb][0].ToString();
                Items_Name = ds.Tables[0].Rows[rb][1].ToString();
                Items_Unit = ds.Tables[0].Rows[rb][2].ToString();
                Items_Count = ds.Tables[0].Rows[rb][3].ToString();
                Items_Price = Double.Parse(ds.Tables[0].Rows[rb][4].ToString()).ToString("0.00");
                Items_TotalPrice = (Double.Parse(Items_Price)*Double.Parse(Items_Count)).ToString("0.00");

                Items_AllTotalPrice += Double.Parse(Items_TotalPrice);
                Items_TotalCount += Int32.Parse(Items_Count);

                strFirstMenu += "<tr><td width=\"14%\" height=\"20\"> "+Items_Type+"</td><td width=\"25%\" height=\"20\">"+Items_Name+"</td><td width=\"10%\" height=\"20\">"+Items_Unit+"</td><td width=\"10%\" height=\"20\">"+Items_Count+"</td><td width=\"20%\" height=\"20\">"+Items_Price+"</td><td width=\"21%\" height=\"20\">"+Items_TotalPrice+"</td></tr>";
            }

            string FirstMenu = begin+strFirstMenu+"</table>";

            doData.conn.Close();
            return FirstMenu;
        }

posted on 2006-03-31 15:50  aliketen  阅读(709)  评论(0)    收藏  举报

导航