添加表(後臺代碼)

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;
namespace Web.BuyOrder
{
    public partial class AjaxDetail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                bandDetail();
            }
        }
        public void bandDetail()
        {
            string action = Request["action"].ToString();
            string buyOderID = Request["BuyOrderID"].ToString();

            DataTable dtBuyDetail = BLL.B_BuyOrderDetail.GetBuyDetailID(buyOderID).Tables[0];
            StringBuilder sb = new StringBuilder();
            sb.Append("<table><thead><tr><th width=/"80px/">商品編號</th><th width=/"80px/">商品名稱</th><th width=/"80px/">供應商</th><th width=/"80px/">單價</th><th width=/"80px/">數量</th><th width=/"80px/">稅額</th><th width=/"80px/">折扣額</th><th width=/"80px/">應收金額</th></tr>");
            sb.Append("</thead><tbody>");
            for(int i=0; i<dtBuyDetail.Rows.Count;i++)
            {
                string productID = Convert.ToString(dtBuyDetail.Rows[i]["ProductID"]);
                string productName = Convert.ToString(dtBuyDetail.Rows[i]["ProductName"]);
                string supplierName=Convert.ToString(dtBuyDetail.Rows[i]["SupplierName"]);
                decimal price = Convert.ToDecimal(dtBuyDetail.Rows[i]["TotalPrice"]);
                int Quantity = Convert.ToInt32(dtBuyDetail.Rows[i]["Quantity"]);
                decimal taxReta = Convert.ToDecimal(dtBuyDetail.Rows[i]["稅額"]);
                decimal desCountReta = Convert.ToDecimal(dtBuyDetail.Rows[i]["折扣額"]);
                decimal totalMoney = Convert.ToDecimal(dtBuyDetail.Rows[i]["金額"]);
                sb.Append("<tr><td>"+productID+"</td>");
                sb.Append("<td>" + productName + "</td>");
                sb.Append("<td>" + supplierName + "</td>");
                sb.Append("<td>" + price+ "</td>");
                sb.Append("<td>" + Quantity + "</td>");
                sb.Append("<td>" + taxReta + "</td>");
                sb.Append("<td>" +desCountReta + "</td>");
                sb.Append("<td>" + totalMoney + "</td>");
                sb.Append("</tr>");
            }
          
            sb.Append("</tbody></table>");
            Response.Write(sb.ToString());
            Response.End();
           
        }
    }
}
 

發佈了70 篇原創文章 · 獲贊 3 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章