function InitAjaxSalesList()
{
var ajax = null;
try
{
ajax = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e)
{
try
{
ajax = new ActiveXObject("Msxml4.XMLHTTP");
}
catch (e)
{
ajax = null;
}
}
if (ajax == null && typeof XMLHttpRequest != 'undefined')
{
ajax = new XMLHttpRequest();
}
return ajax;
}
//查询列表
function SlectGenerate855list(pageNow)
{
var varChkS = document.getElementById("chkPStatus"); //是否选择PO Status
var varChkPO = document.getElementById("chkSPO"); //STN PO:
var varTxtStnPo = document.getElementById("txtStnPo"); //orderNum
var varDPState = document.getElementById("drpPState"); //PO state
var varPState ="";
var varStnPo ="";
if(varChkS.checked == true)
{
varPState=varDPState.options[varDPState.selectedIndex].value;
}
if(varChkPO.checked == true)
{
varStnPo=varTxtStnPo.value;
}
var http_request = InitAjaxSalesList();
url= "Generate855SelectAjax.aspx?PState="+varPState+"/&StnPo="+varStnPo+"/&pageNow="+pageNow;
http_request.open('post', url, false);
http_request.send(null);
result = http_request.responseText;
var oDoc = new ActiveXObject("MSXML2.DOMDocument");
oDoc.loadXML(result);
items1 = oDoc.selectNodes("//NewDataSet/Table/ORDNUM");
items2 = oDoc.selectNodes("//NewDataSet/Table/ITMNUM");
items3 = oDoc.selectNodes("//NewDataSet/Table/CLIMAT");
items4 = oDoc.selectNodes("//NewDataSet/Table/QCIMAT");
var hidCount = document.getElementById("spanCountY"); //存放有多少頁
var labC = document.getElementById("spanCountT"); //共有多少調記錄
var labP = document.getElementById("spanNow"); //當前為多少頁
if(items1.length>0)
{
var itemsLength=items20[0].text;
var intCout;
if(parseInt(itemsLength)%12 == 0)
{
intCout = parseInt(itemsLength)/12;
}
else
{
intCout = Math.ceil(parseInt(itemsLength)/12);
}
hidCount.innerText = intCout;
labC.innerText = itemsLength;
labP.innerText = pageNow;
}
else
{
hidCount.innerText = 0;
labC.innerText = 0;
labP.innerText = 1;
}
document.getElementById("divTable").innerHTML="";
var str="";
str = "<table width='2000px' bordercolor='#A0BED6' border='1' cellpadding='3' cellspacing='0'>"
+ "<tr class='TableListTR'><td >PO No.</td><td>Item No.</td><td>CPQ Part.</td><td>CPQ Part No.</td>"
+ "<td>Unit Prite</td><td>Order Qty.</td><td>Req.Ship</td><td>FirstCmitDay</td>"
+ "<td>Comm.Ship</td><td>Open</td><td>Fulfill</td><td>Status</td><td>Partial</td>"
+ "<td>Region</td><td>Country</td><td>ERCODE</td><td>Order Date</td><td>Control#</td><td>Ship Way</td></tr>";
var intORDQTY =0;
if(items1.length>0)
{
for(i=0;i<items1.length;i++)
{
str += "<td align='center'> " + items2[i].text + "</td>";
str += "<td align='center'> " + items3[i].text + "</td>";
str += "<td align='center'> " + items4[i].text + "</td>";
str += "<td align='center'> " + items5[i].text+ "</td>";
str += "<td align='center'> " + items19[i].text + "</td></tr>";
}
}
document.getElementById("divTable").innerHTML = str + "</table>";
imgStyle();
}
//翻頁方法
function getCity(pageType)
{
var page=1;
var labP = document.getElementById("spanNow"); //當前為第幾頁
var hidCount = document.getElementById("spanCountY"); //存放有多少頁
var txtCount = hidCount.innerText;
var DangPage = labP.innerText;
if(txtCount ==1 || txtCount==0)
{
return;
}
else
{
if(pageType==1)
{
if(DangPage==1)
{
return;
}
else
{
page=1;
DangPage = 1;
}
}
else if(pageType==2)
{
if(DangPage==1)
{
return;
}
else
{
page =DangPage -1;
DangPage = page;
}
}
else if(pageType ==3)
{
if(DangPage==txtCount)
{
return;
}
else
{
page =DangPage -1+ 2;
DangPage = page;
}
}
else if(pageType ==4)
{
if(DangPage==txtCount)
{
return;
}
else
{
page = txtCount;
DangPage = page;
}
}
labP.innerText = DangPage;
SlectGenerate855list(page);
}
}
Ajax 页面
protected void Page_Load(object sender, EventArgs e)
{
string strWhere = " VBAK.ORDNUM = VBAP.ORDNUM and VBAP.CLIMAT = KNMT.CLIMAT ";
if (Request["PState"].ToString().Trim().Length > 0)
{
strWhere += " AND VBAP.STATUS ='" + Request["PState"].ToString().Trim() + "'";
}
if (Request["StnPo"].ToString().Trim().Length > 0)
{
strWhere += " AND VBAK.ORDNUM ='" + Request["StnPo"].ToString().Trim() + "'";
}
showData(int.Parse(Request["pageNow"].ToString()), strWhere);
}
/// <summary>
/// 查询列表
/// </summary>
/// <param name="PageIndex">显示第几页</param>
/// <param name="strWhere">查询条件</param>
private void showData(int PageIndex, string strWhere)
{
SqlParameter[] myPara = new SqlParameter[9];
//表名
myPara[0] = new SqlParameter("@tblName", SqlDbType.VarChar);
myPara[0].Value = "VBAK,VBAP,KNMT";
//需要返回的列
myPara[1] = new SqlParameter("@strGetFields", SqlDbType.VarChar);
myPara[1].Value = "VBAK.REFNM4, VBAP.CLIRF1, VBAP.CLIRF2, VBAK.ORDNUM, VBAP.ITMNUM, "
+ " VBAP.FULQTY, VBAK.ORDDAT, VBAP.CLIMAT, VBAP.ORDQTY, VBAP.UPRICE, "
+ " VBAP.STATUS, VBAP.DLYDAT, VBAP.REFNM1, VBAP.QRSPDT, VBAP.SCACID, "
+ " VBAP.OPNQTY, KNMT.QCIMAT, VBAK.PARTSH, VBAK.CONTR2, VBAK.CUSCOO, "
+ " VBAP.ERRCODE, VBAK.REFNM2";
//排序的表名
myPara[2] = new SqlParameter("@ordTableName", SqlDbType.VarChar);
myPara[2].Value = "VBAK";
//排序的字段名
myPara[3] = new SqlParameter("@fldName", SqlDbType.VarChar);
myPara[3].Value = "ORDNUM";
//页尺寸
myPara[4] = new SqlParameter("@PageSize", SqlDbType.Int);
myPara[4].Value = 12;
//页码
myPara[5] = new SqlParameter("@PageIndex", SqlDbType.Int);
myPara[5].Value = PageIndex;
//置排序类型, 非 0 值则降序
myPara[6] = new SqlParameter("@OrderType", SqlDbType.Int);
myPara[6].Value = 1;
//查询的条件
myPara[7] = new SqlParameter("@strWhere", SqlDbType.VarChar);
myPara[7].Value = strWhere;
//返回查询出的行数
myPara[8] = new SqlParameter("@Counts", SqlDbType.Int);
myPara[8].Direction = ParameterDirection.Output;
DataSet ds = new DataSet();
ds = sqlH.RunProcedure("PageCut", myPara, connectionString);
XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);
writer.Formatting = Formatting.Indented;
writer.Indentation = 100;
writer.IndentChar = ' ';
//ds.WriteXml(writer);
writer.WriteStartElement("NewDataSet");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
writer.WriteStartElement("Table");
writer.WriteElementString("ORDNUM", ds.Tables[0].Rows[i]["ORDNUM"].ToString());
writer.WriteElementString("ITMNUM", ds.Tables[0].Rows[i]["ITMNUM"].ToString());
writer.WriteElementString("CLIMAT", ds.Tables[0].Rows[i]["CLIMAT"].ToString());
writer.WriteElementString("QCIMAT", ds.Tables[0].Rows[i]["QCIMAT"].ToString());
writer.WriteElementString("UPRICE", ds.Tables[0].Rows[i]["UPRICE"].ToString());
writer.WriteElementString("ORDQTY", ds.Tables[0].Rows[i]["ORDQTY"].ToString());
writer.WriteElementString("DLYDAT", ds.Tables[0].Rows[i]["DLYDAT"].ToString());
writer.WriteElementString("REFNM1", ds.Tables[0].Rows[i]["REFNM1"].ToString());
writer.WriteElementString("QRSPDT", ds.Tables[0].Rows[i]["QRSPDT"].ToString());
writer.WriteElementString("OPNQTY", ds.Tables[0].Rows[i]["OPNQTY"].ToString());
writer.WriteElementString("FULQTY", ds.Tables[0].Rows[i]["FULQTY"].ToString());
string strState ="";
strState = edistate.State(int.Parse(ds.Tables[0].Rows[i]["STATUS"].ToString()));
writer.WriteElementString("STATUS", strState);
writer.WriteElementString("PARTSH", ds.Tables[0].Rows[i]["PARTSH"].ToString());
writer.WriteElementString("CONTR2", ds.Tables[0].Rows[i]["CONTR2"].ToString());
writer.WriteElementString("CUSCOO", ds.Tables[0].Rows[i]["CUSCOO"].ToString());
writer.WriteElementString("ERRCODE", ds.Tables[0].Rows[i]["ERRCODE"].ToString());
writer.WriteElementString("ORDDAT", ds.Tables[0].Rows[i]["ORDDAT"].ToString());
writer.WriteElementString("REFNM4", ds.Tables[0].Rows[i]["REFNM4"].ToString());
writer.WriteElementString("REFNM2", ds.Tables[0].Rows[i]["REFNM2"].ToString());
writer.WriteElementString("Count", myPara[8].Value.ToString());
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.Flush();
Response.End();
writer.Close();
return;
}