private void buttonAdd_Click(object sender, EventArgs e) { if (!CheckData()) { return; } DataRow[] matches = tablePost.Select("Name='" + name + "'"); if (matches.Length > 0) // 岗位名称已经存在 { MessageBox.Show("岗位名称已经存在", "信息提示", MessageBoxButtons.OK); return; } string stat = "Level='" + level + "'"; matches = tablePost.Select(stat); if (matches.Length > 0) // 岗位层级编码已经存在 { MessageBox.Show("岗位层级已经存在", "信息提示", MessageBoxButtons.OK); return; } PostBean b = new PostBean(); b.Level = level; b.Name = name; b.BaseSalary = salary; PostDAO dao = new PostDAO(); dao.AddPost(b); LoadData(); }
public StaffBean() { post = new PostBean(); performance = new PerformanceBean(); benefit = new BenefitBean(); department = new DepartmentBean(); }
private void buttonUpdate_Click(object sender, EventArgs e) { if (!CheckData()) { return; } if (id == -1) { MessageBox.Show("请选择", "信息提示", MessageBoxButtons.OK); return; } string stat = "Name='" + name + "'" + " and Level='" + level + "' and " + "BaseSalary=" + salary; DataRow[] matches = tablePost.Select(stat); if (matches.Length == 1) // 未发生变化不修改 { //MessageBox.Show("未修改", "信息提示", MessageBoxButtons.OK); return; } stat = "Id<>" + id + " AND Name='" + name + "'"; matches = tablePost.Select(stat); if (matches.Length > 0) // 岗位名称已经存在 { MessageBox.Show("岗位名称已经存在", "信息提示", MessageBoxButtons.OK); return; } stat = "Id<>" + id + " AND Level='" + level + "'"; matches = tablePost.Select(stat); if (matches.Length > 0) // 岗位层级编码已经存在 { MessageBox.Show("岗位层级已经存在", "信息提示", MessageBoxButtons.OK); return; } PostBean b = new PostBean(); b.Id = id; b.Level = level; b.Name = name; b.BaseSalary = salary; PostDAO dao = new PostDAO(); dao.UpdatePost(b); LoadData(); }
public int DeletePost(PostBean b) { int count = 0; try { SqlParameter[] sp = { para = new SqlParameter("@Id", b.Id), }; count = sh.RunSql("PR_Post_Delete", sp); } catch (Exception ex) { throw ex; } return(count); }
private void buttonDelete_Click(object sender, EventArgs e) { if (id == -1) { MessageBox.Show("请选择", "信息提示", MessageBoxButtons.OK); return; } PostBean b = new PostBean(); b.Id = id; PostDAO dao = new PostDAO(); dao.DeletePost(b); LoadData(); }
private SqlParameter para; //参数 public int AddPost(PostBean b) { int count = 0; try { SqlParameter[] sp = { para = new SqlParameter("@Name", b.Name), para = new SqlParameter("@Level", b.Level), para = new SqlParameter("@BaseSalary", b.BaseSalary), }; count = sh.RunSql("PR_Post_Add", sp); } catch (Exception ex) { throw ex; } return(count); }