资源简介
输入sql语句导出excel 代码参考
代码片段和文件信息
using System;
using System.Web.UI.WebControls;
namespace CarManagement.Web.Search
{
public partial class AlertSearch : Pagebase
{
private static string _sqlOut = ““;
protected void Page_Load(object sender EventArgs e)
{
if (!IsPostBack)
{
CssSetRed(btnToExcel);
string sql = @“
select s.sysvalues.sysnamenum from dbo.SysDirectory s --where s.SysType=8
left join (
select alarmTypecount(0) as num from devicealarm
group by alarmType
) b on b.alarmType = s.sysvalue and s.SysType=8
where s.SysType=8 and sysvalue in( 34516 )
order by num desc “;
HCom.SetDropDownData(drpType sql);
drpType.Items.Insert(0new ListItem(“全部“ “0“));
drpType.SelectedValue = “0“;
//HCom.SetDropDownData(drpType8 );
Bind();
}
}
private void Bind()
{
string sql = @“
select ROW_NUMBER() OVER (ORDER BY a.alarmtime desc) AS numa.* from (
select da.id
isnull(cd.carnamecd1.carname) as carname
s1.sysname as AlarmType
case AlarmType
when 1 then ‘车牌号‘ + isnull(cd.CarNumber‘---‘) + ‘在‘ + c1.Crname+‘到‘ +
c2.Crname+‘超速,超速速度:‘+cast( alarmvar as varchar(10)) +‘千米/小时‘
when 2 then ‘车牌号‘ + isnull(cd1.CarNumber‘---‘) + c3.Crname +‘闯红灯‘
when 3 then l.lightsName+‘ 出现故障‘
when 4 then c.croname+ r.ReadCardName+‘ 出现故障‘
when 5 then c5.croname + ‘ 出现故障‘
when 16 then r1.ReadCardName+‘ 电量低‘
when 17 then ‘车牌号‘ + isnull(cd1.CarNumber‘---‘) + c3.Crname +‘冒进‘
when 20 then r1.ReadCardName+‘ 超过最大车辆数量:‘+cast( alarmvar as varchar(10)) +‘(辆)‘
when 21 then ‘车牌号‘ + isnull(cd1.CarNumber‘---‘) + c3.Crname +‘超过最大停留时间‘
end as detail alarmtime
from DeviceAlarm da
left join dbo.SysDirectory s1 on s1.sysvalue=da.AlarmType and s1.systype=8
left join cardata cd on cd.CarAdder=da.AlarmID --车辆超速
left join
(select c.croname+rc.readCardName as Crnamerc.devadder as cardid
from crossing c
join dbo.ReadCard rc on rc.CrossingAdder=c.devadder)
c1 on c1.cardid =da. BegPosition --车辆超速
left join
(select c.croname+rc.readCardName as Crnamerc.devadder as cardid
from crossing c
join dbo.ReadCard rc on rc.CrossingAdder=c.devadder)
c2 on c2.cardid =da.EndPosition--车辆超速
left join (select distinct CrossingAdderBranchNumLightsName from lights) l on l.CrossingAdder=da.alarmid and
l.BranchNum = da.alarmvar --红绿灯未安装或损坏 -- alarmid 路口 alarmvar 卡号
left join crossing c on c.DevAdder = da.alarmid --读卡器损坏 路口
left join dbo.ReadCard r on r.DevAdder = da.alarmvar --读卡器损坏 读卡器
left join dbo.ReadCard r1 on r1.DevAdder = da.alarmid --定位卡电量低
left join cardata cd1 on cd1.CarAdder=da.alarmvar --冒进报警
left join
(select c.croname+rc.readCardName as Crnamerc.devadder as cardid
from crossing c
join dbo.ReadCard rc on rc.CrossingAdder=c.devadder)
c3 on c3.cardid = da.AlarmID -
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 5391 2017-07-22 13:25 AlertSearch.aspx.cs
文件 42740 2017-08-09 09:03 Files.cs
文件 3506 2017-07-17 08:52 AlertSearch.aspx
- 上一篇:Qt5基于sqlite数据库的学生管理系统
- 下一篇:试卷生成系统开发与设计
评论
共有 条评论