using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class ProvideMan_ProvideMan : System.Web.UI.Page
{
DataAccess da = new DataAccess();
protected void Page_Load(object sender, EventArgs e)
{
SqlParameter[] parm = new SqlParameter[1];
parm[0] = new SqlParameter();
parm[0].ParameterName = "@shortened";
parm[0].SqlValue = txb_ProvideManShortened.Text;
DataSet ds = da.RunProcedureToDs("supplier_id_shortened_s", parm);
//provideManTable为div的id
provideManTable.InnerHtml = CreateTable(ds.Tables[0]);
}
public string CreateTable(DataTable dt)
{
string temp = "";
temp += "<table style=/"border-right: #030303 1px solid; border-top: #030303 1px solid; border-left: #030303 1px solid;/" cellspacing=/"0/" cellpadding=/"0/" border=/"1/">";
temp += "<tr style=/"background: #ccd3c9;/">";
//第0列 代号
temp += "<td style=/"width:130px; height: 22px; background-color: #dfd8c6; border-right: #6f6f6f 2px groove;border-bottom-style: none;/">货号</td>";
//第1列 名称
temp += "<td style=/"width:204px; height: 22px; background-color: #dfd8c6; border-right: #6f6f6f 2px groove; border-bottom-style: none;/">名称</td>";
//第2列 地址
temp += "<td style=/"width:80px; height: 22px; background-color: #dfd8c6; border-right: #6f6f6f 2px groove; border-bottom-style: none;/">颜色</td>";
//第3列 联系人
temp += "<td style=/"width:80px; height: 22px; background-color: #dfd8c6; border-right: #6f6f6f 2px groove; border-bottom-style: none;/">单位</td>";
//第4列 电话
temp += "<td style=/"width:80px; height: 22px; background-color: #dfd8c6; border-right: #6f6f6f 2px groove; border-bottom-style: none;/">数量</td>";
temp += "</tr>";
if (dt != null && dt.Rows.Count >= 1 || dt.Rows.Count < 1)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
temp += "<tr style=/"height:24px;/">";
//第0列 代号
temp += "<td style=/"width: 130px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += dt.Rows[i]["id"].ToString();
temp += "</td>";
//第1列 名称
temp += "<td style=/"width: 204px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += dt.Rows[i]["supplier_name"].ToString();
temp += "</td>";
//第2列 地址
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
//temp += dt.Rows[i]["地址"].ToString();
temp += "</td>";
//第3列 联系人
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
//temp += dt.Rows[i]["联系人"].ToString();
temp += "</td>";
//第4列 电话
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
//temp += dt.Rows[i]["电话"].ToString();
temp += "</td>";
temp += "</tr>";
}
for (int k = 0; k < 6 - dt.Rows.Count; k++)
{
temp += "<tr>";
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
temp += "</td>";
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
temp += "</td>";
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
temp += "</td>";
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
temp += "</td>";
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
temp += "</td>";
temp += "</tr>";
}
}
else if (dt != null && dt.Rows.Count > 6)
for (int i = 0; i < dt.Rows.Count; i++)
{
temp += "<tr style=/"height:24px;/">";
//第0列 代号
temp += "<td style=/"width: 130px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += dt.Rows[i]["id"].ToString();
temp += "</td>";
//第1列 名称
temp += "<td style=/"width: 204px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += dt.Rows[i]["supplier_name"].ToString();
temp += "</td>";
//第2列 地址
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
//temp += dt.Rows[i]["地址"].ToString();
temp += "</td>";
//第3列 联系人
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
//temp += dt.Rows[i]["联系人"].ToString();
temp += "</td>";
//第4列 电话
temp += "<td style=/"width: 80px; border-left-style: none; border-right: #c0c0c0 1px solid;/">";
temp += " ";
//temp += dt.Rows[i]["电话"].ToString();
temp += "</td>";
temp += "</tr>";
}
temp += "</table>";
return temp;
}