Process
The. NET In-line script has made a query page that records
- Top 20 today
- A member of a certain day statistics
- Member all day record statistics
<script runat= "Server" >
void Page_Load (object sender, EventArgs e) {
Query time defaults to today
if (! Page.IsPostBack) {
Txtreporttime.text = System.DateTime.Today.ToString ();
Bindgrid ();
}
else{
Start a query
if (Ddlreporttype.selectedvalue = = "0") {//0 for Today TOP20
if (querycontrols.visible) {//First into the day TOP20, hide query criteria panel
Querycontrols.visible = false;
Querycontrols02.visible = false;
//}
}
Bindgrid ();
}
}
void Bindgrid () {
System.Data.IDataReader Dr;
Dr = Myquerymethod ();
Dgdotreport.datasource = Dr;
Dgdotreport.databind ();
}
void Disposegrid () {
Clear out the 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") {//default today 's top
QueryString = "SELECT Top Incept as ' member", U.usename as [nickname], "+
"[1 Flowers] = SUM (case lpid when ' 5f016dd5-7c82-4155-a8a7-32eb3430b359 ' THEN num ELSE 0"), "+
"[9 flowers] = SUM (case lpid when ' 3bf9c5cc-4380-44ff-8488-af20c8964fd4 ' THEN num ELSE 0"), "+
"[99 Flowers] = SUM (case lpid when ' 171bce1a-dac0-4898-894b-0eaaf9fe12b0 ' THEN num ELSE 0"), "+
"[diamond ring] = SUM (case lpid when ' 7f179e09-adda-4250-9dea-249e045fe2c5 ' THEN num ELSE 0"), "+
"[Villa] = SUM (case lpid when ' e32870e9-ee54-44a7-a9fd-853c9ba03d58 ' THEN num ELSE 0"), "+
"[Total point value] = SUM (case lpid when ' 5f016dd5-7c82-4155-a8a7-32eb3430b359 ' THEN num ELSE 0") *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) * + sum (case lpid when ' 7f179e09-adda-4250-9dea-249e045fe2c5 ' THEN num ELSE 0) *3000 + sum (case lpid WH EN ' 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 time
"GROUP by Incept, u.usename" +
"ORDER BY [Total point value] DESC";
}else{
String Sreporttime;
BOOL Breportoneday;
String Smemberid;
Count one day, or all day
if (Ddlreporttype.selectedvalue = = "1") {
Sreporttime = "and Indate BETWEEN @theDate and @theDateAfter";
Breportoneday = true;
}else{
Sreporttime = "";
Breportoneday = false;
}
Disposegrid ();
Open Query Criteria panel
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 ' member", U.usename as [nickname], "+
"[1 Flowers] = SUM (case lpid when ' 5f016dd5-7c82-4155-a8a7-32eb3430b359 ' THEN num ELSE 0"), "+
"[9 flowers] = SUM (case lpid when ' 3bf9c5cc-4380-44ff-8488-af20c8964fd4 ' THEN num ELSE 0"), "+
"[99 Flowers] = SUM (case lpid when ' 171bce1a-dac0-4898-894b-0eaaf9fe12b0 ' THEN num ELSE 0"), "+
"[diamond ring] = SUM (case lpid when ' 7f179e09-adda-4250-9dea-249e045fe2c5 ' THEN num ELSE 0"), "+
"[Villa] = SUM (case lpid when ' e32870e9-ee54-44a7-a9fd-853c9ba03d58 ' THEN num ELSE 0"), "+
"[Total point value] = SUM (case lpid when ' 5f016dd5-7c82-4155-a8a7-32eb3430b359 ' THEN num ELSE 0") *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) * + sum (case lpid when ' 7f179e09-adda-4250-9dea-249e045fe2c5 ' THEN num ELSE 0) *3000 + sum (case lpid WH EN ' 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 [Total point value] 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;
}
Process reading time data from calendar
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>