//marker="1"是导出选择的数据,="0"是导出全部数据
public DataTable export_all(string marker,string data)
{
DataTable dt = null;
StringBuilder sql = new StringBuilder();
List<SqlParameter> para = new List<SqlParameter>();
if (marker.Equals("1"))
{
string[] list_data = data.Split(',');
sql.Append("SELECT * FROM TB_BEARINGINFORMATION a WHERE a.Id IN ( ");
for (int i = 0; i < list_data.Length-1; i++)
{
sql.AppendFormat("@Id{0},", i);
para.Add(new SqlParameter("@Id" + i, SqlDbType.VarChar, 50) { Value = list_data[i] });
}
sql.Remove(sql.Length - 1, 1).Append(")");
}else{
sql.Append(" SELECT * FROM TB_BEARINGINFORMATION");
}
DBHelper db = new DBHelper();
if (marker.Equals("1")){
dt = db.QueryData(sql.ToString(), para.ToArray()).Tables[0];
}
else {
dt = db.QueryData(sql.ToString()).Tables[0];
}
return dt;
}