private void btnEdit_Click(object sender, EventArgs e) { var info = new Models.ClassAModel { ClassName = tbClassNameEdit.Text, ClassNote = tbClassNoteEdit.Text, CreateTime = DateTime.Now }; int result = new BLL.ClassAModelBLL().Update(info); if (result > 0) { MessageBox.Show("更新成功!"); BindData(); } }
private void btnAdd_Click(object sender, EventArgs e) { string errMsg = ""; if (tbClassNameAdd.Text == "") { errMsg += "类别名不能为空!\r\n"; } if (errMsg != "") { MessageBox.Show(errMsg); return; } var canInsert = new BLL.ClassAModelBLL().GetByClassName(tbClassNameAdd.Text); if (canInsert != null) { MessageBox.Show("不能添加重复的类别名称!"); return; } var info = new Models.ClassAModel { ClassName = tbClassNameAdd.Text, ClassNote = tbClassNoteAdd.Text, CreateTime = DateTime.Now }; int result = new BLL.ClassAModelBLL().Add(info); if (result > 0) { MessageBox.Show("添加成功"); BindData(); } }