public List <C_STATION_DETAIL> GetDataByColumn(string column, string data, OleExec DB) { List <C_STATION_DETAIL> list = new List <C_STATION_DETAIL>(); string sql = ""; if (string.IsNullOrEmpty(column)) { sql = $@"select * from C_station where station_name =:data"; } else { sql = $@"select * from C_station where {column} =:data"; } DataSet res = DB.ExecSelect(sql, new System.Data.OleDb.OleDbParameter[1] { new System.Data.OleDb.OleDbParameter("data", data) }); DataTable dt = res.Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { C_STATION_DETAIL ep = new C_STATION_DETAIL(); ep = RowToStation(item); list.Add(ep); } } return(list); }
private C_STATION_DETAIL RowToStation(DataRow item) { C_STATION_DETAIL ep = new C_STATION_DETAIL(); ep.ID = item["ID"].ToString(); ep.Station_Name = item["Station_Name"].ToString(); ep.Type = item["Type"].ToString(); return(ep); }
public List <C_STATION_DETAIL> ShowAllData(OleExec DB) { List <C_STATION_DETAIL> list = new List <C_STATION_DETAIL>(); string sql = $@"select * from C_station"; DataTable dt = new DataTable(); dt = DB.ExecSelect(sql).Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { C_STATION_DETAIL ep = new C_STATION_DETAIL(); ep = RowToStation(item); list.Add(ep); } } return(list); }