private void btnAddDeptList_Click(object sender, EventArgs e) { ContextDepartmentService deptService = new ContextDepartmentService(); for (int i = 0; i < 100; i++) { Department dept = new Department(); dept.DepartmentID = deptService.GetMaxId() + 1; dept.Administrator = 99 + i; dept.Budget = 100 + i; dept.Name = i.ToString(); dept.StartDate = DateTime.Now; deptService.Save(dept); } }
private void btnMaxId_Click(object sender, EventArgs e) { ContextDepartmentService deptService = new ContextDepartmentService(); MessageBox.Show(deptService.GetMaxId().ToString()); }