图6-2 产品类别文护图
相关代码如下:
private void initDg()
{
//显示类别列表
this.GridView1.DataSource = DataBase.Get_Table("select * from 产品类别");
this.GridView1.DataBind();
this.TextBox1.Text = "";
}
protected void Button1_Click(object sender, EventArgs e)
{
//判断信息是否正确
if (this.TextBox1.Text.Trim() == "")
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('类别名称不能为空!');</script>");
return;
}
if (DataBase.Get_Table("select * from 产品类别 where 类别名称='" + this.TextBox1.Text.Trim() + "'").Rows.Count > 0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('类别名称名称重复!');</script>");
return;
}
//添加类别信息
DataBase.ExecSql("insert into 产品类别(类别名称) values('" + this.TextBox1.Text.Trim() + "')");
initDg();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{儿童福利院空间改造设计
if (e.CommandName == "Del")
{
//判断记录是否允许删除
string Key = this.GridView1.DataKeys[Convert.ToInt32(e.CommandArgument)].Value.ToString();
if (DataBase.Get_Table("select * from 产品信息 where 代码=" + Key + "").Rows.Count > 0)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "info", "<script>alert('当前类别在使用!');</script>");
return;
上一页 [1] [2] [3] [4] [5] [6] [7] [8]