62,047
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Sql;
using System.Data.SqlClient;
public partial class test : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = "";
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["pubsConnectionString"].ConnectionString);
con.Open();
string sql = "select item,qty,kind from qkind where kind like ('%" + RadioButtonList1.SelectedValue + "%')";
SqlDataAdapter ds = new SqlDataAdapter(sql, con);
DataSet data = new DataSet();
ds.Fill(data, "main");
CheckBoxList1.DataSource = data.Tables["main"];
CheckBoxList1.DataTextField = "item";
CheckBoxList1.DataValueField = "qty";
CheckBoxList1.DataBind();
con.Close();
SqlDataSource1.SelectCommand = "SELECT qreport.reportid, qkind.Item, qkind.kind, qkind.qty, qreport.Report, qreport.Result, qreport.StartDate, qreport.EndDate, qreport.Reportstsus FROM qkind INNER JOIN qreport ON qkind.kindid = qreport.kindid where qkind.kind like ('%" + RadioButtonList1.SelectedValue + "%')";
}
public int total = 0;
protected void CheckBoxList1_SelectedIndexChanged(object sender, EventArgs e)
{
string aa = "";
// aa = "<table cellspacing=1 style='background:blue'><tr style='background:white' height='20'><td align='center'>項目</td><td align='center'>數量</td><td>Test Report</td> <td>Start Date</td><td> End Date</td> <td>Report stsus</td></tr>";
for (int i = 0; i < CheckBoxList1.Items.Count; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
total += Convert.ToInt32(CheckBoxList1.Items[i].Value);
for (int z = 0; z < GridView1.Rows.Count; z++)
{
if (GridView1.Rows[i].Cells[2].Text == CheckBoxList1.Items[i].Text)
GridView1.Rows[i].Visible = true;
}
}
}
// FormView1.ItemTemplate.Equals[aa];
// Response.Write("-------------------------------------------------------------<br>");
// aa += "<tr style='background:white'><td >總數量(PCS):</td><td><strong>" + total + "</strong></td><td></td><td></td><td></td><td></td></tr></table>";
Label1.Text = aa;
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridView1.Rows[i].Visible = false;
}
}
}