reportviewer (VS2010 内で提供されるもの) でレポートを作成するために使用されるストアド プロシージャがあります。4 つのパラメーターがあります - 開始日、終了日 - 単一のパラメーター。複数値パラメーター - ステータス (6 つの選択肢)、場所 (250 の選択肢)。
リクエストされたさまざまなステータス/場所について、日付範囲内のすべてのアイテムがレポートに表示されるようにコーディングする適切な方法を判断できません。
例: (開始日) 2012 年 7 月 1 日と (終了日) 2012 年 9 月 3 日の間で、(場所) Hazleton または Butler からのもので、(ステータス)Available または Out のすべてのパーツを表示します。
ストアド プロシージャを呼び出すコード:
public DataTable StatusRpt(DateTime StartDate, DateTime EndDate)
{
SQLCON = new SqlConnection(connectionString);
SQLCON.Open();
SQLCommand = new SqlCommand("spStatusRpt",SQLCON);
SQLCommand.CommandType = CommandType.Text;
SQLCommand.Parameters.Add("@StartDate", SqlDbType.Date).Value = StartDate;
SQLCommand.Parameters.Add("@EndDate", SqlDbType.Date).Value = EndDate;
//SQLCommand.Parameters.Add("@Status", SqlDbType.Int).Value = Status;
//SQLCommand.Parameters.Add("@OrgName", SqlDbType.VarChar).Value = OrgName;
SqlDataAdapter adapter = new SqlDataAdapter(SQLCommand);
DataTable Detailtable = new DataTable();
adapter.Fill(Detailtable);
return Detailtable;
}
そして、これが私の「onClick」イベントです
protected void btnStatusReport_OnClick(object sender, EventArgs e)
{
int Status = Convert.ToInt32(lbxStatus.SelectedValue);
string OrgName = lbxLocations.SelectedValue;
DateTime StartDate = Convert.ToDateTime(CalStart.SelectedDate);
DateTime EndDate = Convert.ToDateTime(CalEnd.SelectedDate);
lblPrint.Visible = true;
DataTable DetailTable = equip.StatusRpt(StartDate, EndDate);
this.RV1.Reset();
this.RV1.LocalReport.DataSources.Clear();
this.RV1.LocalReport.ReportPath = "Reports/StatusReport.rdlc";
ReportDataSource rds = new ReportDataSource("StatusDS", DetailTable);
this.RV1.LocalReport.DataSources.Add(rds);
this.RV1.DataBind();
}
私はいくつかの調査を行いましたが、私が見つけたものはすべて SSRS の使用に関するものです。誰かがコードを介してフィルターを適用する方法を教えてくれれば、フィルタリングは問題ありません。
どうぞよろしくお願いいたします。シンディ