/// <summary> /// 判断是否有重复 /// </summary> /// <param name="resume"></param> /// <param name="p"></param> /// <returns></returns> private bool theSameProject(ProjectExperience temp) { for (int i = 0; i < projectexperienceList.Count; i++) { if (projectexperienceList[i].ResumeId == temp.ResumeId && projectexperienceList[i].ProjectName == temp.ProjectName && projectexperienceList[i].ProjectIsIt == temp.ProjectIsIt) return true; } return false; //throw new NotImplementedException(); }
/// <summary> /// 添加新的项目经验并刷新列表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSaveAndAddNew_Click(object sender, EventArgs e) { projectexperience = new ProjectExperience(); projectexperience.ResumeId =resume.Id; projectexperience.ProjectName = txtProjectName.Text; projectexperience.ProjectExpStartDate = dtStart.Value.Date; projectexperience.ProjectExpEndDate = dtEnd.Value.Date; if (this.txtProjectName.Text == "") { MessageBox.Show("带*项为必填","Warning",MessageBoxButtons.OK,MessageBoxIcon.Warning); this.label2.ForeColor = Color.Red; return; } if (cbIsIT.Checked == true) { projectexperience.ProjectIsIt = 1; projectexperience.ProjectSoftwareEnv = txtSoftWare.Text; projectexperience.ProjectHardwareEnv = txtHardWare.Text; projectexperience.ProjectDevelopEnv = txtDevelop.Text; projectexperience.ProjectDesc = txtItDesc.Text; projectexperience.ProjectDuty = txtItDuty.Text; if (this.txtItDesc.Text == "" || this.txtItDuty.Text == "") { DialogResult dr = MessageBox.Show("内容不完整,是否继续", "Warring", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.Cancel) return; } } else { projectexperience.ProjectIsIt = 0; projectexperience.ProjectDesc = txtDesc.Text; projectexperience.ProjectDuty = txtDuty.Text; projectexperience.ProjectSoftwareEnv = null; projectexperience.ProjectHardwareEnv = null; projectexperience.ProjectDevelopEnv = null; if (this.txtDesc.Text == "" || this.txtDuty.Text == "") { DialogResult dr = MessageBox.Show("内容不完整,是否继续", "Warring", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.Cancel) return; } } if (dtStart.Value > dtEnd.Value) { MessageBox.Show("开始时间不能大于结束时间"); return; } if (theSameProject(projectexperience)) { MessageBox.Show("项目【"+projectexperience.ProjectName.ToString()+"】已经存在","Error",MessageBoxButtons.OK,MessageBoxIcon.Error); clearInfo(); return; } projectexperienceService.AddOrUpdate(projectexperience); refreshDgvData(this.resume); //保存后清空数据 clearInfo(); }
/// <summary> /// 操作数据表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dgvProjExperience_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (dgvProjExperience.Columns.Count < 0) return; if (dgvProjExperience.Columns[e.ColumnIndex].Name == "Delete") { List<ProjectExperience> temp = dgvProjExperience.DataSource as List<ProjectExperience>; ProjectExperience projexp = GetProjectExperienceFromDgv(e.RowIndex); DialogResult result = MessageBox.Show("确定要删除该项?删除后不可恢复", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (result == DialogResult.Yes) { try { projectexperienceService.Delete(projexp); } catch (Exception ex) { MessageBox.Show("删除记录出错" + ex.Message); } dgvProjExperience.DataSource = null; temp.Remove(projexp); dgvProjExperience.DataSource = temp; } } if (dgvProjExperience.Columns[e.ColumnIndex].Name == "Modify") { List<ProjectExperience> tempPe = dgvProjExperience.DataSource as List<ProjectExperience>; projectexperience = tempPe[e.RowIndex]; this.txtProjectName.Text = projectexperience.ProjectName; this.dtStart.Value = projectexperience.ProjectExpStartDate.Value; this.dtEnd.Value = projectexperience.ProjectExpEndDate.Value; if (projectexperience.ProjectIsIt == 1) { this.cbIsIT.Checked = true; this.txtSoftWare.Text = projectexperience.ProjectSoftwareEnv; this.txtHardWare.Text = projectexperience.ProjectHardwareEnv; this.txtDevelop.Text = projectexperience.ProjectDevelopEnv; this.txtItDesc.Text = projectexperience.ProjectDesc; this.txtItDuty.Text = projectexperience.ProjectDuty; } else { this.cbIsIT.Checked = false; this.txtDesc.Text = projectexperience.ProjectDesc; this.txtDuty.Text = projectexperience.ProjectDuty; } } }