1

嗨,我正在研究项目车辆跟踪系统,我想生成停机报告,它可以在 php 和 extjs 中正常工作,但现在正在使用 C# 将项目更改为 asp.net。我有 4 个不同的查询来显示报告,但在 asp 中。 net gridview 如何绑定所有 4 个不同的查询以在带有分页的 gridview 中显示。

这是我的 PHP 代码

$NewID = "";
        $OldID = "";        
         //echo("Select gps_id,lat,lon,tdate,ttime,tdate_time,speed,lname from gps_data where vehicle_no = '$vno' and (CONVERT(tdate_time, DATETIME) between '$FromDate' and '$ToDate') and speed > 1 order by gps_id asc");

    $sql1 = mysql_query("Select gps_id,latitude,longtitude,get_date,get_time,get_date_time,speed,location from gps_data where device_id = '$device_id' and host_name = '". $host  ."' and (CONVERT(get_date_time, DATETIME) between '$FromDate' and '$ToDate') and speed > 1 order by gps_id asc");
    while($row = mysql_fetch_row($sql1))
    {

        $NewID = $row[0];
        //echo($OldID);
        if($OldID > 0)
        {
         // echo("Select CONVERT(tdate_time, DATETIME) from gps_data where gps_id = ". $OldID ."");
           $query = mysql_query("Select get_date_time,date_time from gps_data where gps_id = ". $OldID ." and host_name = '". $host  ."'");

           if($result = mysql_fetch_row($query))
           {
              $show_old_get_date_time = $result[0];  
              $old_get_date_time = $result[1];
              //echo($old_get_date_time);
           }

           $query1 = mysql_query("Select get_date_time,date_time from gps_data where gps_id = ". $NewID ." and host_name = '". $host  ."'");
           if($result1 = mysql_fetch_row($query1))
           {
                  $show_new_get_date_time = $result1[0];
                  $new_get_date_time      = $result1[1];
           }

        //echo("Select gps_id,lat,lon,tdate,ttime,tdate_time,speed,lname from gps_data where vehicle_no = '$vno' and gps_id > ". $OldID ." and gps_id < ". $NewID ." and (CONVERT(tdate_time, DATETIME) between '$FromDate' and '$ToDate') order by gps_id asc");
            $sql2 = mysql_query("Select gps_id,latitude,longtitude,get_date,get_time,get_date_time,speed,location from gps_data where device_id = '$device_id' and host_name = '". $host  ."' and gps_id > ". $OldID ." and gps_id < ". $NewID ." and (CONVERT(get_date_time, DATETIME) between '$FromDate' and '$ToDate') order by gps_id asc");
            if($rowA = mysql_fetch_row($sql2))
            {

                $NewLoc = parseD($rowA[7]);
                //echo("SELECT TIMEDIFF('". $new_get_date_time ."','". $old_get_date_time ."')");
                $sql3 = mysql_query("SELECT TIMEDIFF('". $new_get_date_time ."','". $old_get_date_time ."')");  
                    if($rowB = mysql_fetch_row($sql3))
                    {

                            $cnt = $cnt + 1;
                            $DTDiff = $rowB[0];

                            $strBld .= $comm."{slno:\"". $cnt ."\",get_date:\"". $rowA[3] ."\",get_date_time:\"". $show_old_get_date_time." "."-"." ". $show_new_get_date_time ."\",stoppedTm:\"". $DTDiff ."\",loc_name:\"". $NewLoc ."\",latitude:\"".$rowA[1]."\",longitude:\"".$rowA[2]."\"}";
                            $comm = ",";

                    }


            } //while($rowA = mysql_fetch_row($sql2))


        } //if($OldID > 0)

        $OldID = $row[0];   
        //echo($OldID);
    } //while($row = mysql_fetch_row($sql1))    
4

1 回答 1

0

分页用于显示剩余数据。但似乎你有不同的情况。您可以使用这些案例编写查询,然后将它们合并并将此查询绑定为 gridview 的数据源。或者您可以为每种情况设置按钮或任何其他 ui 控件来更改 gridview 的数据源。

于 2013-04-08T10:35:11.983 回答