protected void BackHome_Click(object sender, EventArgs e)
{
Response.Redirect("default.aspx");
}
protected void DropDownList1_SelectedIndexChanged1(object sender, EventArgs e)
{
string ConnSql = "Data Source=.;Initial Catalog=货品信息管理;Integrated Security=True";
//声明Conn为一个SQL Server连接对象
SqlConnection Conn = new SqlConnection(ConnSql);
Conn.Open(); //打开连接 本文来自辣.文'论.文·网原文请找腾讯3249'114
SqlDataAdapter da = new SqlDataAdapter();
string SelectSql = "select * from tb_Goods where 货品代码 ='" + DropDownList1.Text + "'";
da.SelectCommand = new SqlCommand(SelectSql, Conn);
SqlCommandBuilder scb = new SqlCommandBuilder(da);
DataSet ds = new DataSet();
da.Fill(ds);
Conn.Close();
DataRow MyRow = ds.Tables[0].Rows[0]; //
论文网http://www.751com.cn/ 从表对象中得到要修改的行
TextBox1.Text = MyRow["生产商"].ToString();
TextBox2.Text = MyRow["经办人"].ToString();
TextBox3.Text = MyRow["采购日期"].ToString();
TextBox4.Text = MyRow["货品名称"].ToString();
TextBox5.Text = MyRow["单价"].ToString();
TextBox6.Text = MyRow["数量"].ToString();
}
5 信息删除模块
向页面添加一HTML表,1个Label,两个命令按钮BUTTON,2个sqldatasource,一个GridView和一个DropDownList。Label的ID改为MsgLabel,Text改为空. 2个botton,把他的ID改为Submit,BackHome .代码如下:
using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e)
{
this.Title = "删除记录";
MsgLable.Text = "单击“删除”将删除当前记录";
}
protected void BackHome_Click(object sender, EventArgs e)
{
Response.Redirect("default.aspx");
}
protected void Button2_Click(object sender, EventArgs e)
{
string ConnSql = "Data Source=.;Initial Catalog=货品信息管理;Integrated Security=True";
SqlConnection Conn = new SqlConnection(ConnSql);
Conn.Open(); //打开连接
SqlDataAdapter da = new SqlDataAdapter();
string SelectSql = "select * from tb_Goods where 货品代码 ='" + DropDownList1.Text + "'";
da.SelectCommand = new SqlCommand(SelectSql, Conn);
SqlCommandBuilder scb = new SqlCommandBuilder(da); //为DataAdapter自动生成更新命令
DataSet ds = new DataSet();
da.Fill(ds);
Conn.Close();
DataRow DeleteRow = ds.Tables[0].Rows[0]; //指定要删除的行索引值(删除第4条记录)
DeleteRow.Delete(); //调用行删除方法
da.Update(ds);本文来自辣.文'论.文·网原文请找腾讯3249,114
DropDownList1.DataSourceID = "SqlDataSource1";
DropDownList1.DataBind();
GridView1.DataSourceID = "SqlDataSource2";
GridView1.DataBind();
Response.Write("<script language=javascript>alert('记录删除成功!');</script>");
上一页 [1] [2] [3] [4]
asp.net+sqlserver货品信息管理系统源代码+实验报告+运行流程图 第4页下载如图片无法显示或论文不完整,请联系qq752018766