public bool Insert(Employee employee) { dao = new EmployeeDao(); Employee[] employees = dao.GetEmployees(); if (!Exists(employee, employees)) { return(dao.Add(employee)); } else { return(false); } }
private void btnSave_Click(object sender, EventArgs e) { if (!validateInput()) { return; } btnSaveEnbaled(false); if (opration == OP_ADD) { HREmployee emp = InputToVo(); // new HREmployee(); //emp.Address = txtAddress.Text; //emp.BankCard = txtBank.Text; //emp.Email = txtEmail.Text; //emp.Id = txtId.Text; //emp.IdCard = txtIdCard.Text; //emp.Name = txtName.Text; //emp.Telephone = txtPhone.Text; //emp.Profession = txtPro.Text; //emp.School = txtSchool.Text; //emp.Education = int.Parse(cboEdu.SelectedValue.ToString()); //emp.Sex = int.Parse(cboSex.SelectedValue.ToString()); //emp.Status = int.Parse(cboStatus.SelectedValue.ToString()); //emp.DeptId = cboDept.SelectedValue != null ? cboDept.SelectedValue.ToString(): ""; //emp.JobId = cboJob.SelectedValue.ToString(); //emp.GraduationTime = dtTime.Text; //emp.PoliticalStatus = int.Parse(cboPo.SelectedValue.ToString()); int ret = dao.Add(emp); if (ret > 0) { listSource.Add(emp); } } else if (opration == OP_UPDATE) { HREmployee empVo = list[grid.CurrentRow.Index]; empVo = InputToVo(empVo); //emp.Address = txtAddress.Text; //emp.BankCard = txtBank.Text; //emp.Email = txtEmail.Text; //emp.IdCard = txtIdCard.Text; //emp.Name = txtName.Text; //emp.Telephone = txtPhone.Text; //emp.Profession = txtPro.Text; //emp.School = txtSchool.Text; //emp.Education = int.Parse(cboEdu.SelectedValue.ToString()); //emp.Sex = int.Parse(cboSex.SelectedValue.ToString()); //emp.Status = int.Parse(cboStatus.SelectedValue.ToString()); //emp.DeptId = cboDept.SelectedValue.ToString(); //emp.JobId = cboJob.SelectedValue.ToString(); //emp.GraduationTime = dtTime.Text; //emp.PoliticalStatus = int.Parse(cboPo.SelectedValue.ToString()); dao.Update(empVo); grid.Refresh(); } CleanData(); }