private void btn_delete_Click(object sender, EventArgs e) { try { TypeBLL.InsertType(this.txt_typename.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { this.dgv_xiangqing.AutoGenerateColumns = false; this.dgv_xiangqing.DataSource = TypeBLL.selecttype(); this.txt_typename.Text = ""; } }
protected void Add_Click(object sender, EventArgs e) { TypeModel type = new TypeModel(); type.TypeID = Convert.ToInt32(DDLType.SelectedValue); type.Name = txtName.Text.Trim(); bool flag = bll.InsertType(type); if (flag) { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加成功');</script>"); CodeGridView.DataSource = bll.GetTypeByID(Convert.ToInt32(DDLType.SelectedValue)); CodeGridView.DataBind(); } else { Page.ClientScript.RegisterStartupScript(GetType(), "OnSubmit", "<script>alert('添加失败');</script>"); } txtName.Text = ""; }