public List <material> getIndexPageData() { List <material> mList = new List <material>(); SelectCommandBuilder select = new SelectCommandBuilder("materials"); select.SelectColumn("name"); select.SelectColumn("sccj_id"); select.SelectColumn("new_price"); select.SelectColumn("wb_name"); select.ConditionsColumn("1", 1); select.getSelectCommand(); SqlDataReader dr = select.ExecuteReader(); if (dr.HasRows) { while (dr.Read()) { material m = new material() { name = dr.IsDBNull(0) ? "NULL" : dr.GetString(0), sccj = dr.IsDBNull(1) ? "NULL" : getVendorById(dr.GetString(1)), price = dr.IsDBNull(2) ? 0.0 : dr.GetDouble(2), currency = dr.IsDBNull(3) ? "N" : dr.GetString(3), exchangeRate = getexchangeRate(dr.IsDBNull(3) ? "N" : dr.GetString(3)) }; mList.Add(m); } } ViewState["DataTable_GridView_ReferedDataDetail"] = ListToDataaTable(mList); return(mList); }
public List <material> getIndexPageData(string name, string sccj) { List <material> mList = new List <material>(); SelectCommandBuilder select = new SelectCommandBuilder("materials"); select.SelectColumn("name"); select.SelectColumn("sccj_id"); select.SelectColumn("new_price"); select.SelectColumn("wb_name"); select.ConditionsColumn("1", 1); string sql = select.getSelectCommand(); if (!string.IsNullOrEmpty(name)) { sql += "and name like '%" + name + "%'"; } if (!string.IsNullOrEmpty(sccj)) { select.ConditionsColumn("sccj_id", sccj); sql += "and sccj_id = '" + sccj + "'"; } SqlDataReader dr = select.ExecuteReader(sql); if (dr.HasRows) { while (dr.Read()) { material m = new material() { name = dr.GetString(0), sccj = getVendorById(dr.GetString(1)), price = dr.IsDBNull(2) ? 0.00 : dr.GetDouble(2), currency = dr.IsDBNull(3) ? "RMB" : dr.GetString(3), exchangeRate = getexchangeRate(dr.IsDBNull(3) ? "RMB" : dr.GetString(3)) }; mList.Add(m); } } ViewState["DataTable_GridView_ReferedDataDetail"] = ListToDataaTable(mList); return(mList); }