计算机毕业设计介绍:
5.2.4 报表模块
任何业务的显示都少不了报表,下示为本系统的报表
实现方法:
本模块应用了Studio自带的水晶报表,首先在项目中添加一个水晶报表,并在相应窗体中加入水晶报表控件Viewer和Source两个控件,并设置前者绑定到后者,后者绑定到刚刚添加的水晶报表,然后在后台代码中,用编程方法创建一个数据集,并设置水晶报表的数据源为该数据集.
public partial class MemberShip_xxzl : System.Web.UI.Page
{
Sql sql = new Sql();
protected void Page_Load(object sender, EventArgs e)
{
int id = Convert.ToInt32(Request.QueryString["id"].ToString());
string constr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection con = new SqlConnection(constr);
SqlCommand com = new SqlCommand();
com.Connection = con;
con.Open();
string sql = "select * from czxx where id = "+id ;
com.CommandText = sql;
SqlDataReader reader = com.ExecuteReader(CommandBehavior.CloseConnection);
this.DetailsView1.DataSource = reader;
this.DetailsView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
string fangxing = this.DetailsView1.Rows[0].Cells[1].Text.ToString();
string cengshu = this.DetailsView1.Rows[1].Cells[1].Text.ToString();
string mianji = this.DetailsView1.Rows[2].Cells[1].Text.ToString();
string jianyu = this.DetailsView1.Rows[3].Cells[1].Text.ToString();
string jiage = this.DetailsView1.Rows[4].Cells[1].Text.ToString();
string shezhi = this.DetailsView1.Rows[5].Cells[1].Text.ToString();
string dizhi = this.DetailsView1.Rows[6].Cells[1].Text.ToString();
string lianxiren = this.DetailsView1.Rows[7].Cells[1].Text.ToString();
string dianhua = this.DetailsView1.Rows[8].Cells[1].Text.ToString();
string yzr = this.TextBox1.Text.ToString();
string insertSQL = "insert into yz(fangxing,cengshu,mianji,jianyu,zujin,sheshi,dizhi,lianxiren,dianhua,yzr)values('";
insertSQL += fangxing + "','";
insertSQL += cengshu + "','";
insertSQL += mianji + "','";
insertSQL += jianyu + "','";
insertSQL += jiage + "','";
insertSQL += shezhi + "','";
insertSQL += dizhi + "','";
insertSQL += lianxiren + "','";
insertSQL += dianhua + "','";
insertSQL +=yzr + "')";
sql.ExcuteSQL(insertSQL);
〖资料来源:计算机毕业论文 www.xiaoniu168.com〗
第5页为计算机毕业论文部分......