分享
 
 
 

面向过程的.NET(一工作代码)

王朝asp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

.net in-line script 做过的一个查询页,记录一下

今天TOP 20 某一会员某一天统计 会员所有天记录统计<script runat="server">

void Page_Load(object sender, EventArgs e) {

//查询时间默认为今天

if(!Page.IsPostBack){

txtReportTime.Text = System.DateTime.Today.ToString();

bindGrid();

}

else{

//开始进行查询

if(ddlReportType.SelectedValue == "0"){//0为今天TOP20

//if(QueryControls.Visible){//首进为今天天TOP20,隐藏查询条件面板

QueryControls.Visible = false;

QueryControls02.Visible = false;

//}

}

bindGrid();

}

}

void bindGrid(){

System.Data.IDataReader dr;

dr = MyQueryMethod();

dgDotReport.DataSource = dr;

dgDotReport.DataBind();

}

void disposeGrid(){

//清掉datagrid

dgDotReport.Dispose();

dgDotReport.DataSource = "";

dgDotReport.DataBind();

}

System.Data.IDataReader MyQueryMethod() {

string connectionString = "server=\'(local)\'; user id=\'sa\'; password=\'kemin%@)9999\'; database=\'diligencexxx\'";

System.Data.IDbConnection dbConnection = new System.Data.SqlClient.SqlConnection(connectionString);

string queryString;

System.Data.IDbCommand dbCommand = new System.Data.SqlClient.SqlCommand();

if(ddlReportType.SelectedValue == "0"){//默认今天TOP 20

queryString = "SELECT TOP 20 incept AS '会员', u.usename AS [昵称], " +

"[1朵鲜花] = SUM(CASE lpid WHEN '5F016DD5-7C82-4155-A8A7-32EB3430B359' THEN num ELSE 0 END)," +

"[9朵鲜花] = SUM(CASE lpid WHEN '3BF9C5CC-4380-44FF-8488-AF20C8964FD4' THEN num ELSE 0 END)," +

"[99朵鲜花] = SUM(CASE lpid WHEN '171BCE1A-DAC0-4898-894B-0EAAF9FE12B0' THEN num ELSE 0 END)," +

"[钻戒] = SUM(CASE lpid WHEN '7F179E09-ADDA-4250-9DEA-249E045FE2C5' THEN num ELSE 0 END)," +

"[别墅] = SUM(CASE lpid WHEN 'E32870E9-EE54-44A7-A9FD-853C9BA03D58' THEN num ELSE 0 END)," +

"[总点值] = SUM(CASE lpid WHEN '5F016DD5-7C82-4155-A8A7-32EB3430B359' THEN num ELSE 0 END)*10 + SUM(CASE lpid WHEN '3BF9C5CC-4380-44FF-8488-AF20C8964FD4' THEN num ELSE 0 END)*80 + SUM(CASE lpid WHEN '171BCE1A-DAC0-4898-894B-0EAAF9FE12B0' THEN num ELSE 0 END) * 500 + SUM(CASE lpid WHEN '7F179E09-ADDA-4250-9DEA-249E045FE2C5' THEN num ELSE 0 END)*3000 + SUM(CASE lpid WHEN 'E32870E9-EE54-44A7-A9FD-853C9BA03D58' THEN num ELSE 0 END)*8000" +

"FROM gift_incept g " +

"INNER JOIN use_userinfo u " +

"ON g.incept = u.id" +

" WHERE indate BETWEEN '"+ DateTime.Today.ToString() +"' AND '"+ DateTime.Today.AddDays(1).ToString() +"'" +//.NET 时间

" GROUP BY incept, u.usename " +

" ORDER BY [总点值] DESC";

}else{

string sReportTime;

bool bReportOneDay;

string sMemberId;

//统计某一天,或所有天

if(ddlReportType.SelectedValue == "1"){

sReportTime = " AND indate BETWEEN @theDate AND @theDateAfter";

bReportOneDay = true;

}else{

sReportTime = " ";

bReportOneDay = false;

}

disposeGrid();

//打开查询条件面板

if(ddlReportType.SelectedValue == "1"){

QueryControls.Visible = true;

QueryControls02.Visible = false;

sMemberId = txtMemberId.Text;

}else{

QueryControls02.Visible = true;

QueryControls.Visible = false;

sMemberId = txtMemberId02.Text;

}

queryString = "SELECT incept AS '会员', u.usename AS [昵称], " +

"[1朵鲜花] = SUM(CASE lpid WHEN '5F016DD5-7C82-4155-A8A7-32EB3430B359' THEN num ELSE 0 END)," +

"[9朵鲜花] = SUM(CASE lpid WHEN '3BF9C5CC-4380-44FF-8488-AF20C8964FD4' THEN num ELSE 0 END)," +

"[99朵鲜花] = SUM(CASE lpid WHEN '171BCE1A-DAC0-4898-894B-0EAAF9FE12B0' THEN num ELSE 0 END)," +

"[钻戒] = SUM(CASE lpid WHEN '7F179E09-ADDA-4250-9DEA-249E045FE2C5' THEN num ELSE 0 END)," +

"[别墅] = SUM(CASE lpid WHEN 'E32870E9-EE54-44A7-A9FD-853C9BA03D58' THEN num ELSE 0 END)," +

"[总点值] = SUM(CASE lpid WHEN '5F016DD5-7C82-4155-A8A7-32EB3430B359' THEN num ELSE 0 END)*10 + SUM(CASE lpid WHEN '3BF9C5CC-4380-44FF-8488-AF20C8964FD4' THEN num ELSE 0 END)*80 + SUM(CASE lpid WHEN '171BCE1A-DAC0-4898-894B-0EAAF9FE12B0' THEN num ELSE 0 END) * 500 + SUM(CASE lpid WHEN '7F179E09-ADDA-4250-9DEA-249E045FE2C5' THEN num ELSE 0 END)*3000 + SUM(CASE lpid WHEN 'E32870E9-EE54-44A7-A9FD-853C9BA03D58' THEN num ELSE 0 END)*8000" +

" FROM gift_incept g " +

" INNER JOIN use_userinfo u " +

" ON g.incept = u.id" +

" WHERE incept = @MemberId " +

sReportTime +

" GROUP BY incept, u.usename " +

" ORDER BY [总点值] DESC";

//MemberId

System.Data.IDataParameter dbParam_MemberId = new System.Data.SqlClient.SqlParameter();

dbParam_MemberId.ParameterName = "@MemberId";

dbParam_MemberId.Value = sMemberId;

dbParam_MemberId.DbType = System.Data.DbType.String;

dbCommand.Parameters.Add(dbParam_MemberId);

if(bReportOneDay){

//theDate

System.Data.IDataParameter dbParam_theDate = new System.Data.SqlClient.SqlParameter();

dbParam_theDate.ParameterName = "@theDate";

DateTime thDate = Convert.ToDateTime(txtReportTime.Text);

dbParam_theDate.Value = thDate;

dbParam_theDate.DbType = System.Data.DbType.Date;

dbCommand.Parameters.Add(dbParam_theDate);

//theDateAfter

System.Data.IDataParameter dbParam_theDateAfter = new System.Data.SqlClient.SqlParameter();

dbParam_theDateAfter.ParameterName = "@theDateAfter";

DateTime thDateAfter = new DateTime();

thDateAfter = thDate.AddDays(1);

dbParam_theDateAfter.Value = thDateAfter;

dbParam_theDateAfter.DbType = System.Data.DbType.Date;

dbCommand.Parameters.Add(dbParam_theDateAfter);

}

}

dbCommand.CommandText = queryString;

dbCommand.Connection = dbConnection;

dbConnection.Open();

System.Data.IDataReader dataReader = dbCommand.ExecuteReader(System.Data.CommandBehavior.CloseConnection);

return dataReader;

}

///处理从日历读取时间数据

private void fillReportTime(object sender, System.EventArgs e)

{

txtReportTime.Text = calReportTime.SelectedDate.ToString();

calReportTime.Visible = false;

//disposeGrid();

}

private void showCalendar(object sender, System.EventArgs e){

calReportTime.Visible = true;

disposeGrid();

}

</script>

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有