private void tsbAdd_Click(object sender, EventArgs e) { if (tsbtxtRoleName.Text == "") { MessageBox.Show("请输入要添加的角色名称!"); } else { if (RoleBll.GetRole(tsbtxtRoleName.Text)) { try { RoleBll.AddRole(tsbtxtRoleName.Text); dataGridView1.DataSource = RoleBll.RoleFillDs().Tables[0]; MessageBox.Show("添加成功!"); } catch (Exception ee) { MessageBox.Show("添加失败!" + ee); throw; } } else { MessageBox.Show("角色已存在!"); } } }
public IActionResult GetOne(Role model) { if (model.id == 0) { var defalut = new ApiResult <Role>() { Result = true, Data = new Role() }; return(Json(defalut)); } var bll = new RoleBll(); var rst = bll.GetRole(model); return(Json(rst)); }