public bool UpdateSubjectView(V_EmployeeSurveySubject requireSubjectView) { try { EmployeeSurveysAnswerDal esaDal = new EmployeeSurveysAnswerDal(); if (requireSubjectView.SubjectInfo.T_OA_REQUIREMASTER.EntityKey == null) { requireSubjectView.SubjectInfo.T_OA_REQUIREMASTER.EntityKey = new System.Data.EntityKey("SMT_OA_EFModelContext.T_OA_REQUIREMASTER", "REQUIREMASTERID", requireSubjectView.SubjectInfo.T_OA_REQUIREMASTER.REQUIREMASTERID); } T_OA_REQUIREDETAIL2 tmpobj = base.GetObjectByEntityKey(requireSubjectView.SubjectInfo.EntityKey) as T_OA_REQUIREDETAIL2; base.Update(requireSubjectView.SubjectInfo); int i = SaveContextChanges(); if (i < 0) { return(false); } else { return(true); } } catch (Exception ex) { throw (ex); } }
//选中题目时,获取答案 private void GetAnswer(V_EmployeeSurveySubject v) { if (v.AnswerList != null & v.AnswerList.Count > 0) { foreach (T_OA_REQUIREDETAIL i in v.AnswerList) { switch (i.CODE) { case "A": txtA.Text = i.CONTENT; break; case "B": txtB.Text = i.CONTENT; break; case "C": txtC.Text = i.CONTENT; break; case "D": txtD.Text = i.CONTENT; break; case "E": txtE.Text = i.CONTENT; break; case "F": txtF.Text = i.CONTENT; break; case "G": txtG.Text = i.CONTENT; break; case "H": txtH.Text = i.CONTENT; break; } } } }
public int DeleteEmployeeSurveySubjectView(V_EmployeeSurveySubject subjectInfo) { try { EmployeeSurveySubjectBll subjectBll = new EmployeeSurveySubjectBll(); EmployeeSurveysAnswerBll answerBll = new EmployeeSurveysAnswerBll(); foreach (T_OA_REQUIREDETAIL anserInfo in subjectInfo.AnswerList) { if (!answerBll.DeleteEmployeeSurveysAnswer(anserInfo.REQUIREDETAILID)) { return(-1); } } if (!subjectBll.DeleteEmployeeSurveySubject(subjectInfo.SubjectInfo.REQUIREDETAIL2ID)) { return(-1); } return(1); } catch (Exception ex) { Tracer.Debug("员工调查EmployeeSurveySubjectViewBll-DeleteEmployeeSurveySubjectView" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(-1); } }
//答案更改后保存在 集合中 private void txtAnswer_KeyUp(object sender, KeyEventArgs e) { //V_EmployeeSurveySubject sub = dg.SelectedItem as V_EmployeeSurveySubject; V_EmployeeSurveySubject sub = new V_EmployeeSurveySubject(); TextBox txt = (TextBox)sender; switch (txt.Name) { case "txtA": sub.AnswerList[0].CONTENT = txtA.Text; break; case "txtB": sub.AnswerList[1].CONTENT = txtB.Text; break; case "txtC": sub.AnswerList[2].CONTENT = txtC.Text; break; case "txtD": sub.AnswerList[3].CONTENT = txtD.Text; break; case "txtE": sub.AnswerList[4].CONTENT = txtE.Text; break; case "txtF": sub.AnswerList[5].CONTENT = txtF.Text; break; case "txtG": sub.AnswerList[6].CONTENT = txtG.Text; break; case "txtH": sub.AnswerList[7].CONTENT = txtH.Text; break; } }
public bool AddSubjectView(V_EmployeeSurveySubject requireSubjectView) { try { if (requireSubjectView.SubjectInfo.T_OA_REQUIREMASTER.EntityKey == null) { requireSubjectView.SubjectInfo.T_OA_REQUIREMASTER.EntityKey = new System.Data.EntityKey("SMT_OA_EFModelContext.T_OA_REQUIREMASTER", "REQUIREMASTERID", requireSubjectView.SubjectInfo.T_OA_REQUIREMASTER.REQUIREMASTERID); } requireSubjectView.SubjectInfo.T_OA_REQUIREMASTER = base.GetObjectByEntityKey(requireSubjectView.SubjectInfo.T_OA_REQUIREMASTER.EntityKey) as T_OA_REQUIREMASTER; //objModelContext.AddObject("T_OA_REQUIREDETAIL2", requireSubjectView.SubjectInfo); base.Add(requireSubjectView.SubjectInfo); int i = SaveContextChanges(); if (i > 0) { foreach (T_OA_REQUIREDETAIL anserInfo in requireSubjectView.AnswerList) { if (!esaDal.AddAnswer(anserInfo)) { return(false); } } return(true); } else { return(false); } } catch (Exception ex) { throw (ex); } }
//行加载删除按钮 2 private void dg_LoadingRow(object sender, DataGridRowEventArgs e) { V_EmployeeSurveySubject tmp = (V_EmployeeSurveySubject)e.Row.DataContext; ImageButton MyButton_Delbaodao = dg.Columns[3].GetCellContent(e.Row).FindName("myDelete") as ImageButton; MyButton_Delbaodao.Margin = new Thickness(0); MyButton_Delbaodao.AddButtonAction("/SMT.SaaS.FrameworkUI;Component/Images/ToolBar/ico_16_delete.png", Utility.GetResourceStr("DELETE")); MyButton_Delbaodao.Tag = tmp; }
public int AddEmployeeSurveySubjectView(V_EmployeeSurveySubject subjectInfo) { try { EmployeeSurveySubjectViewDal subjectViewDal = new EmployeeSurveySubjectViewDal(); return(subjectViewDal.AddSubjectView(subjectInfo) ? 1 : -1); } catch (Exception ex) { Tracer.Debug("员工调查EmployeeSurveySubjectViewBll-AddEmployeeSurveySubjectView" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(-1); } }
/// <summary> /// 设置 题目其它信息 /// </summary> /// <param name="i"></param> private static void SetSubject(ref V_EmployeeSurveySubject i) { i.SubjectInfo.CREATEDATE = System.DateTime.Now; i.SubjectInfo.CREATEUSERID = Common.CurrentLoginUserInfo.EmployeeID; i.SubjectInfo.CREATECOMPANYID = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; i.SubjectInfo.CREATEDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; i.SubjectInfo.CREATEPOSTID = Common.CurrentLoginUserInfo.UserPosts[0].PostID; i.SubjectInfo.CREATEUSERNAME = Common.CurrentLoginUserInfo.EmployeeName; i.SubjectInfo.OWNERID = Common.CurrentLoginUserInfo.EmployeeID; i.SubjectInfo.OWNERCOMPANYID = Common.CurrentLoginUserInfo.UserPosts[0].CompanyID; i.SubjectInfo.OWNERDEPARTMENTID = Common.CurrentLoginUserInfo.UserPosts[0].DepartmentID; i.SubjectInfo.OWNERPOSTID = Common.CurrentLoginUserInfo.UserPosts[0].PostID; i.SubjectInfo.OWNERNAME = Common.CurrentLoginUserInfo.EmployeeName; }
//删除题目 private void Delete_Click(object sender, RoutedEventArgs e) { if (_osub.Count > 1) //必须有派车单,司机才能根据派车单提交费用 单 { V_EmployeeSurveySubject i = ((Button)sender).DataContext as V_EmployeeSurveySubject; _osub.Remove(i); if (i.SubjectInfo.REQUIREDETAIL2ID != null) //删除已经保存到服务器中的数据 { ObservableCollection <V_EmployeeSurveySubject> o = new ObservableCollection <V_EmployeeSurveySubject>(); o.Add(i); _VM.DeleteEmployeeSurveySubjectViewAsync(o); RefreshUI(RefreshedTypes.HideProgressBar); } } }
//根据 回车键,判断 是否新增行,保存修改行。行加载后, 重新计算行题号 1 private void txtSub_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { if (dg.SelectedIndex == _osub.Count - 1) { V_EmployeeSurveySubject vsub = _osub.LastOrDefault(); if (vsub.SubjectInfo.CONTENT != null && vsub.SubjectInfo.CONTENT.Trim().Length > 0) { NewSubject(); } else { Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("ERROR"), Utility.GetResourceStr("OAESURVEYSUBJECTNULL")); } } } }
public int UpdateEmployeeSurveySubjectView(V_EmployeeSurveySubject subjectInfo) { try { EmployeeSurveySubjectBll subjectBll = new EmployeeSurveySubjectBll(); EmployeeSurveysAnswerBll answerBll = new EmployeeSurveysAnswerBll(); if (subjectBll.UpdateEmployeeSurveySubject(subjectInfo.SubjectInfo) == -1) { return(-1); } return(1); } catch (Exception ex) { Tracer.Debug("员工调查EmployeeSurveySubjectViewBll-UpdateEmployeeSurveySubjectView" + System.DateTime.Now.ToString() + " " + ex.ToString()); return(-1); } }
public V_EmployeeSurveySubject GetInfoByTitle(string masterTitle) { V_EmployeeSurveySubject listAll = new V_EmployeeSurveySubject(); string masterId = listAll.Master.REQUIREMASTERID; using (EmployeeSurveysMasterBll masterBll = new EmployeeSurveysMasterBll()) { IQueryable <T_OA_REQUIREMASTER> masterList = masterBll.GetInfoListByTitle(masterTitle); if (masterList == null) { return(null); } else { listAll.Master = masterList.ToList()[0]; } } using (EmployeeSurveySubjectBll questionBll = new EmployeeSurveySubjectBll()) { IQueryable <T_OA_REQUIREDETAIL2> questionList = questionBll.GetInfoListByMasterId(masterId); if (questionList == null) { return(null); } else { listAll.Question = questionList.ToList()[0]; } } using (EmployeeSurveysAnswerBll answerBll = new EmployeeSurveysAnswerBll()) { IQueryable <T_OA_REQUIREDETAIL> answerList = answerBll.GetInfoByMasterId(masterId); if (answerList == null) { return(null); } else { listAll.Answer = answerList.ToList()[0]; } } return(listAll); }
//删除题目 private void Delete_Click(object sender, RoutedEventArgs e) { if (_osub.Count > 1) //必须有派车单,司机才能根据派车单提交费用 单 { V_EmployeeSurveySubject i = ((Button)sender).DataContext as V_EmployeeSurveySubject; _osub.Remove(i); if (!i.IsAdd) //删除已经保存到服务器中的数据 { ObservableCollection <V_EmployeeSurveySubject> o = new ObservableCollection <V_EmployeeSurveySubject>(); o.Add(i); _VM.DeleteEmployeeSurveySubjectViewAsync(o); RefreshUI(RefreshedTypes.HideProgressBar); } } else { Utility.ShowCustomMessage(MessageTypes.Error, Utility.GetResourceStr("TIPS"), Utility.GetResourceStr("REQUIRED", "SubjectContent")); return; } }
/// <summary> /// 添加一个题目 /// </summary> private void NewSubject() { V_EmployeeSurveySubject sub = new V_EmployeeSurveySubject(); sub.SubjectInfo = new T_OA_REQUIREDETAIL2(); sub.SubjectInfo.REQUIREDETAIL2ID = Guid.NewGuid().ToString(); sub.SubjectInfo.REQUIREMASTERID = _Survey.RequireMaster.REQUIREMASTERID; sub.SubjectInfo.T_OA_REQUIREMASTER = _survey.RequireMaster; if (_osub.Count > 0) { V_EmployeeSurveySubject i = _osub[_osub.Count - 1]; sub.SubjectInfo.SUBJECTID = i.SubjectInfo.SUBJECTID + 1; } else { sub.SubjectInfo.SUBJECTID = 1;// 添加保存后,不能全部删除所有题目。 } SetSubject(ref sub); sub.AnswerList = InitAnswers(ref sub); _osub.Add(sub); }
/// <summary> /// 增加题目时 增加 初始化答案(复制) /// </summary> /// <returns></returns> private ObservableCollection <T_OA_REQUIREDETAIL> InitAnswers(ref V_EmployeeSurveySubject sub) { ObservableCollection <T_OA_REQUIREDETAIL> O = new ObservableCollection <T_OA_REQUIREDETAIL>(); T_OA_REQUIREDETAIL info = new T_OA_REQUIREDETAIL(); info.CODE = "A"; info.CONTENT = txtA.Text.Trim() == "" ? "无" : txtA.Text.Trim(); O.Add(info); T_OA_REQUIREDETAIL infoB = new T_OA_REQUIREDETAIL(); infoB.CODE = "B"; infoB.CONTENT = txtB.Text.Trim() == "" ? "无" : txtB.Text.Trim(); O.Add(infoB); T_OA_REQUIREDETAIL infoC = new T_OA_REQUIREDETAIL(); infoC.CODE = "C"; infoC.CONTENT = txtC.Text.Trim() == "" ? "无" : txtC.Text.Trim(); O.Add(infoC); T_OA_REQUIREDETAIL infoD = new T_OA_REQUIREDETAIL(); infoD.CODE = "D"; infoD.CONTENT = txtD.Text.Trim() == "" ? "无" : txtD.Text.Trim(); O.Add(infoD); T_OA_REQUIREDETAIL infoE = new T_OA_REQUIREDETAIL(); infoE.CODE = "E"; infoE.CONTENT = txtE.Text.Trim() == "" ? "无" : txtE.Text.Trim(); O.Add(infoE); T_OA_REQUIREDETAIL infoF = new T_OA_REQUIREDETAIL(); infoF.CODE = "F"; infoF.CONTENT = txtF.Text.Trim() == "" ? "无" : txtF.Text.Trim(); O.Add(infoF); T_OA_REQUIREDETAIL infoG = new T_OA_REQUIREDETAIL(); infoG.CODE = "G"; infoG.CONTENT = txtG.Text.Trim() == "" ? "无" : txtG.Text.Trim(); O.Add(infoG); T_OA_REQUIREDETAIL infoH = new T_OA_REQUIREDETAIL(); infoH.CODE = "H"; infoH.CONTENT = txtH.Text.Trim() == "" ? "无" : txtH.Text.Trim(); O.Add(infoH); for (int i = 0; i < O.Count; i++) { T_OA_REQUIREDETAIL v = O[i]; v.REQUIREDETAILID = Guid.NewGuid().ToString(); v.SUBJECTID = sub.SubjectInfo.SUBJECTID; v.REQUIREMASTERID = sub.SubjectInfo.REQUIREMASTERID; SetAnswer(ref v); } return(O); }
/// <summary> /// 增加题目时 增加 初始化答案(复制) /// </summary> /// <returns></returns> private ObservableCollection<T_OA_REQUIREDETAIL> InitAnswers(ref V_EmployeeSurveySubject sub) { ObservableCollection<T_OA_REQUIREDETAIL> O = new ObservableCollection<T_OA_REQUIREDETAIL>(); T_OA_REQUIREDETAIL info = new T_OA_REQUIREDETAIL(); info.CODE = "A"; info.CONTENT = txtA.Text.Trim() == "" ? "无" : txtA.Text.Trim(); O.Add(info); T_OA_REQUIREDETAIL infoB = new T_OA_REQUIREDETAIL(); infoB.CODE = "B"; infoB.CONTENT = txtB.Text.Trim() == "" ? "无" : txtB.Text.Trim(); O.Add(infoB); T_OA_REQUIREDETAIL infoC = new T_OA_REQUIREDETAIL(); infoC.CODE = "C"; infoC.CONTENT = txtC.Text.Trim() == "" ? "无" : txtC.Text.Trim(); O.Add(infoC); T_OA_REQUIREDETAIL infoD = new T_OA_REQUIREDETAIL(); infoD.CODE = "D"; infoD.CONTENT = txtD.Text.Trim() == "" ? "无" : txtD.Text.Trim(); O.Add(infoD); T_OA_REQUIREDETAIL infoE = new T_OA_REQUIREDETAIL(); infoE.CODE = "E"; infoE.CONTENT = txtE.Text.Trim() == "" ? "无" : txtE.Text.Trim(); O.Add(infoE); T_OA_REQUIREDETAIL infoF = new T_OA_REQUIREDETAIL(); infoF.CODE = "F"; infoF.CONTENT = txtF.Text.Trim() == "" ? "无" : txtF.Text.Trim(); O.Add(infoF); T_OA_REQUIREDETAIL infoG = new T_OA_REQUIREDETAIL(); infoG.CODE = "G"; infoG.CONTENT = txtG.Text.Trim() == "" ? "无" : txtG.Text.Trim(); O.Add(infoG); T_OA_REQUIREDETAIL infoH = new T_OA_REQUIREDETAIL(); infoH.CODE = "H"; infoH.CONTENT = txtH.Text.Trim() == "" ? "无" : txtH.Text.Trim(); O.Add(infoH); for (int i = 0; i < O.Count; i++) { T_OA_REQUIREDETAIL v = O[i]; v.REQUIREDETAILID = Guid.NewGuid().ToString(); v.SUBJECTID = sub.SubjectInfo.SUBJECTID; v.REQUIREMASTERID = sub.SubjectInfo.REQUIREMASTERID; SetAnswer(ref v); } return O; }
private void Save() { _Survey.RequireMaster.REQUIRETITLE = txtTitle.Text.Trim(); _Survey.RequireMaster.CONTENT = txtContent.Text.Trim(); _Survey.RequireMaster.CHECKSTATE = _survey.RequireMaster.CHECKSTATE; if (_isAdd) { SetSurvey(); for (int i = 0; i < _osub.Count; i++) { if (_osub[i].SubjectInfo != null && _osub[i].SubjectInfo.CONTENT != null && _osub[i].SubjectInfo.CONTENT != "无" && _osub[i].SubjectInfo.CONTENT.Trim().Length > 0) { V_EmployeeSurveySubject sub = _osub[i]; _Survey.SubjectViewList.Add(sub); //题目id } } _VM.AddEmployeeSurveyViewAsync(_Survey);//新增 } else { ObservableCollection <V_EmployeeSurveySubject> addLst = new ObservableCollection <V_EmployeeSurveySubject>(); ObservableCollection <V_EmployeeSurveySubject> updLst = new ObservableCollection <V_EmployeeSurveySubject>(); foreach (V_EmployeeSurveySubject i in _osub) { if (i.IsAdd) { addLst.Add(i); } else { updLst.Add(i); } } //先更新 方案,然后 添加 和修改题目、答案 _VM.Upd_ESurveyAsync(_survey.RequireMaster, addLst, updLst);//更改数据 } }
/// <summary> /// 添加一个题目,及答案 /// </summary> private void NewSubject() { V_EmployeeSurveySubject sub = new V_EmployeeSurveySubject(); sub.SubjectInfo = new T_OA_REQUIREDETAIL2(); sub.SubjectInfo.T_OA_REQUIREMASTER = _Survey.RequireMaster; sub.SubjectInfo.REQUIREDETAIL2ID = Guid.NewGuid().ToString(); sub.SubjectInfo.REQUIREMASTERID = _Survey.RequireMaster.REQUIREMASTERID; sub.IsAdd = true; //添加之后 更新时用 if (_osub.Count > 0) { V_EmployeeSurveySubject i = _osub[_osub.Count - 1]; sub.SubjectInfo.SUBJECTID = i.SubjectInfo.SUBJECTID + 1; } else sub.SubjectInfo.SUBJECTID = 1;// 添加保存后,不能全部删除所有题目。 SetSubject(ref sub); sub.AnswerList = InitAnswers(ref sub); _osub.Add(sub); }
//选中题目时,获取答案 private void GetAnswer(V_EmployeeSurveySubject v) { if (v.AnswerList != null & v.AnswerList.Count > 0) foreach (T_OA_REQUIREDETAIL i in v.AnswerList) switch (i.CODE) { case "A": txtA.Text = i.CONTENT; break; case "B": txtB.Text = i.CONTENT; break; case "C": txtC.Text = i.CONTENT; break; case "D": txtD.Text = i.CONTENT; break; case "E": txtE.Text = i.CONTENT; break; case "F": txtF.Text = i.CONTENT; break; case "G": txtG.Text = i.CONTENT; break; case "H": txtH.Text = i.CONTENT; break; } }
public bool UpdateSubjectView(V_EmployeeSurveySubject requireSubjectView) { EmployeeSurveySubjectViewDal essvDal = new EmployeeSurveySubjectViewDal(); return(essvDal.UpdateSubjectView(requireSubjectView)); }