private void AddDepartment_Click(object sender, EventArgs e) //添加部门 { // modify by gatieme at 2015-08-08 16:20 // 为部门添加部门简称 string departmentName = this.DepartmentName.Text.Trim(); string departmentShortCall = this.textBoxDepartmentShortCall.Text.Trim(); if (departmentName == "") { MessageBox.Show("请填写部门名称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (departmentShortCall == "") { MessageBox.Show("请填写部门简称!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (UserHelper.DepList.Where(o => o.Name == departmentName).ToList().Count > 0) { MessageBox.Show("该部门的部门名称与其他部门重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (UserHelper.DepList.Where(o => o.ShortCall == departmentShortCall).ToList().Count > 0) { MessageBox.Show("该部门的部门简称与其他部门重复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Department department = new Department { Id = -1, Name = departmentName, ShortCall = departmentShortCall }; SDepartment sdepartment = new SDepartment(); sdepartment.Id = -1; sdepartment.Name = departmentName; sdepartment.ShortCall = departmentShortCall; if (this.CanBoundary.Checked) { sdepartment.CanBoundary = 1; } else { sdepartment.CanBoundary = 0; } if (this.CanInLand.Checked) { sdepartment.CanInland = 1; } else { sdepartment.CanInland = 0; } if (this.CanEmergency.Checked) { sdepartment.CanEmergency = 1; } else { sdepartment.CanEmergency = 0; } if (this.CanRegular.Checked) { sdepartment.CanRegular = 1; } else { sdepartment.CanRegular = 0; } //string result = _sc.InsertDepartment(department); string result = _sc.InsertSDepartment(sdepartment); //if (result == Response.INSERT_DEPARTMENT_SUCCESS.ToString()) //{ if (result == Response.INSERT_SDEPARTMENT_SUCCESS.ToString()) { MessageBox.Show("添加" + departmentName + "部门成功!"); /////// BindGridViewDataSourece(); /////// } //} else { MessageBox.Show("添加" + departmentName + "部门失败!"); } }