string SearchItemCode(string sItemCode, string sDecription, string sItemTyp, string sItemStart, int iPageIndex, bool isStore) { string sJson = string.Empty; DataTable dtResult = new DataTable(); DataTable dt = new DataTable(); dt = PurchaseRequestCommon.GetActiveItemCode();/////得到所有的可用的ItemCode数据 EnumerableRowCollection<DataRow> drColle = from dr in dt.AsEnumerable() where (string.IsNullOrEmpty(sItemCode) || AsString(dr["Title"]).StartsWith(sItemCode, StringComparison.CurrentCultureIgnoreCase)) && (string.IsNullOrEmpty(sDecription) || AsString(dr["Description"]).Contains(sDecription)) && (isStore ? AsString(dr["ItemScope"]).Trim().Equals(sItemTyp, StringComparison.CurrentCultureIgnoreCase) : true) //QO,PB...... && (AsString(dr["Title"]).StartsWith(sItemStart, StringComparison.CurrentCultureIgnoreCase) || AsString(dr["Title"]).StartsWith("X", StringComparison.CurrentCultureIgnoreCase))//E,C select dr; DataTable dt10 = drColle.CopyToDataTable(); int iCount = dt10.Rows.Count; if (iCount > 0) { int iCurrentRow = (iPageIndex - 1) * iPageSize; List<DataRow> listDr = new List<DataRow>(); int iMaxRowIndex = iCurrentRow + iPageSize; if (iCount < iPageSize)///当结果行数少于每页显示的行数 { iMaxRowIndex = iCount; } if (iMaxRowIndex > iCount)//请求的最后一页所要求的行数大于所在行数。 { iMaxRowIndex = iCount; } for (int i = iCurrentRow; i < iMaxRowIndex; i++) { listDr.Add(dt10.Rows[i]); } dtResult = listDr.CopyToDataTable(); sJson = PurchaseRequestCommon.DataTableToJson("ItemCode", dtResult, iCount); } return sJson; }
public DataTable GetProductsWithProductId(List<int> ProductID) { DataTable dt=new DataTable(); if (ProductID.Count > 0) { List<DataRow> lstRow = new List<DataRow>(); DataTable dt1 = new DataTable(); foreach (int i in ProductID) { SqlParameter[] parameters = new SqlParameter[1]; parameters[0] = DataAccessLayer.DataAccess.AddParameter("@ProductID", i, System.Data.SqlDbType.Int, 20); dt1 = DataAccessLayer.DataAccess.ExecuteDTByProcedure("SP_GetCartProduct", parameters); DataRow dr; dr = dt1.Rows[0]; lstRow.Add(dr); } dt = lstRow.CopyToDataTable(); } return dt; }