HR_Train_Course GetCourseInfo() { HR_Train_Course temp = new HR_Train_Course(); HR_Train_AssessType assess = new HR_Train_AssessType(); assess.AssessTypeName = cmbAssess.Text; assess = _ServiceBasicInfo.GetSingleInfo_AssessType(assess); HR_Train_CourseType courseType = new HR_Train_CourseType(); courseType.CourseTypeName = cmbType.Text; courseType = _ServiceBasicInfo.GetSingleInfo_CourseType(courseType); temp.AssessID = assess.ID; temp.ClassHour = numClassHour.Value; temp.CourseName = txtCourseName.Text; temp.Fund = numFund.Value; if (txtCourseName.Tag != null) { temp.ID = Convert.ToInt32(txtCourseName.Tag); } temp.IsOutSide = chbIsOutSide.Checked; temp.Lecturer = txtLecturer.Text; temp.TypeID = courseType.ID; temp.Department = BasicInfo.DeptCode; return(temp); }
public void Operation_AssessType(HR_Train_AssessType obj) { try { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; HR_Train_AssessType temp = new HR_Train_AssessType(); var varData = from a in ctx.HR_Train_AssessType where a.ID == obj.ID select a; if (varData.Count() == 0) { if (obj.ID == 0) { var varkk = from a in ctx.HR_Train_AssessType where a.AssessTypeName == obj.AssessTypeName select a; if (varkk.Count() > 0) { throw new Exception("【名称】:" + obj.AssessTypeName + " 重复"); } } ctx.HR_Train_AssessType.InsertOnSubmit(obj); } else if (varData.Count() == 1) { if (obj.AssessTypeName == null) { ctx.HR_Train_AssessType.DeleteOnSubmit(varData.Single()); } else { temp = varData.Single(); temp.AssessTypeName = obj.AssessTypeName; temp.IsExam = obj.IsExam; } } else { throw new Exception("记录数不唯一"); } ctx.SubmitChanges(); } catch (Exception ex) { throw new Exception(ex.Message); } }
private void btn_Assess_Add_Click(object sender, EventArgs e) { try { HR_Train_AssessType temp = new HR_Train_AssessType(); temp.AssessTypeName = txtAssessTypeName.Text; temp.IsExam = chbIsExam.Checked; _ServiceBasicInfo.Operation_AssessType(temp); MessageDialog.ShowPromptMessage("添加成功"); RefreshGrid_AssessType(); } catch (Exception ex) { MessageDialog.ShowPromptMessage(ex.Message); } }
public HR_Train_AssessType GetSingleInfo_AssessType(HR_Train_AssessType info) { DepotManagementDataContext ctx = CommentParameter.DepotDataContext; var varData = from a in ctx.HR_Train_AssessType where a.ID == info.ID || a.AssessTypeName == info.AssessTypeName select a; if (varData.Count() == 1) { return(varData.Single()); } else { return(null); } }
private void btn_Assess_Delete_Click(object sender, EventArgs e) { try { if (txtAssessTypeName.Tag == null) { MessageDialog.ShowPromptMessage("请选择需要删除的记录"); return; } HR_Train_AssessType temp = new HR_Train_AssessType(); temp.ID = Convert.ToInt32(txtAssessTypeName.Tag); _ServiceBasicInfo.Operation_AssessType(temp); MessageDialog.ShowPromptMessage("删除成功"); RefreshGrid_AssessType(); } catch (Exception ex) { MessageDialog.ShowPromptMessage(ex.Message); } }
private void btn_Assess_Modify_Click(object sender, EventArgs e) { try { if (txtAssessTypeName.Tag == null) { MessageDialog.ShowPromptMessage("请选择需要修改的记录"); return; } HR_Train_AssessType temp = new HR_Train_AssessType(); temp.ID = Convert.ToInt32(txtAssessTypeName.Tag); temp.AssessTypeName = txtAssessTypeName.Text; temp.IsExam = chbIsExam.Checked; _ServiceBasicInfo.Operation_AssessType(temp); MessageDialog.ShowPromptMessage("修改成功"); RefreshGrid_AssessType(); } catch (Exception ex) { MessageDialog.ShowPromptMessage(ex.Message); } }