/// <summary> /// 问卷视图呈现 /// </summary> /// <param name="Id"></param> private void RendSurveryView(string Id) { IList <QuestionItem> Ents = QuestionItem.FindAllByProperties(0, QuestionItem.Prop_SortIndex, QuestionItem.Prop_SurveyId, Id); if (Ents.Count > 0) { StringBuilder Stb = new StringBuilder(); for (int i = 0; i < Ents.Count; i++) { StringBuilder SubStb = new StringBuilder(); IList <QuestionAnswerItem> qiEnts = QuestionAnswerItem.FindAllByProperties(0, QuestionAnswerItem.Prop_SortIndex, QuestionAnswerItem.Prop_SurveyId, Ents[i].SurveyId, QuestionAnswerItem.Prop_QuestionItemId, Ents[i].SubItemId); //SubItemId //IList<QuestionAnswerItem> qiEnts = QuestionAnswerItem.FindAllByProperties(0, QuestionAnswerItem.Prop_SortIndex, QuestionAnswerItem.Prop_QuestionItemId, Ents[i].SubItemId); //SubItemId for (int k = 0; k < qiEnts.Count; k++) { if (k > 0) { SubStb.Append(","); } SubStb.Append(JsonHelper.GetJsonString(qiEnts[k])); } Ents[i].SubItems = "[" + SubStb.ToString() + "]"; if (i > 0) { Stb.Append(","); } Stb.Append(JsonHelper.GetJsonString(Ents[i])); } this.PageState.Add("ItemList", "[" + Stb.ToString() + "]"); } if (SqEnt != null) { this.PageState.Add("Survey", SqEnt); } }
private void RendSurveryView(string Id) { IList <QuestionItem> qcEnts = QuestionItem.FindAllByProperties(0, QuestionItem.Prop_SortIndex, QuestionItem.Prop_SurveyId, Id); if (qcEnts.Count > 0) { StringBuilder Stb = new StringBuilder(); for (int i = 0; i < qcEnts.Count; i++) { StringBuilder SubStb = new StringBuilder(); IList <QuestionAnswerItem> qiEnts = QuestionAnswerItem.FindAllByProperties(0, QuestionAnswerItem.Prop_SortIndex, QuestionAnswerItem.Prop_QuestionItemId, qcEnts[i].SubItemId); for (int k = 0; k < qiEnts.Count; k++) { if (k > 0) { SubStb.Append(","); } SubStb.Append(JsonHelper.GetJsonString(qiEnts[k])); } qcEnts[i].SubItems = "[" + SubStb.ToString() + "]"; if (i > 0) { Stb.Append(","); } Stb.Append(JsonHelper.GetJsonString(qcEnts[i])); } this.PageState.Add("ItemList", "[" + Stb.ToString() + "]"); } string sql = @"select * from FL_Culture..SurveyQuestion where Id='{0}' "; this.PageState.Add("Survey", DataHelper.QueryDictList(string.Format(sql, Id))); }
private void DoSelect() { if (!string.IsNullOrEmpty(SurveyId)) { var Ent = SurveyQuestion.Find(SurveyId); if (string.IsNullOrEmpty(Ent.TemplateId)) { string sql = @"select * from FL_Culture..QuestionItem where SurveyId='{0}' order by SortIndex "; sql = string.Format(sql, SurveyId); this.PageState.Add("DataList", DataHelper.QueryDictList(sql)); } else { //判断是否合并过 string SQL = "select * from FL_Culture..QuestionItem where SurveyId='{0}' "; SQL = string.Format(SQL, SurveyId); var Ents = DataHelper.QueryDictList(SQL); if (Ents.Count > 0) { string sql = @"select * from FL_Culture..QuestionItem where SurveyId='{0}' order by SortIndex "; sql = string.Format(sql, SurveyId); this.PageState.Add("DataList", DataHelper.QueryDictList(sql)); //SearchCriterion.SetOrder("SortIndex"); //IList<QuestionItem> Items = QuestionItem.FindAll(SearchCriterion, Expression.Sql(" SurveyId='" + SurveyId + "'")); //this.PageState.Add("DataList", Items); return; } //合并模板 var TemplateId = Ent.TemplateId; var ItemEnts = QuestionItem.FindAllByProperties(QuestionItem.Prop_SurveyId, TemplateId); var SubItemEnts = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_SurveyId, TemplateId); foreach (var ent in ItemEnts) { QuestionItem Item = new QuestionItem(); Item = ent; Item.SurveyId = SurveyId; Item.DoCreate(); } foreach (var subEnt in SubItemEnts) { QuestionAnswerItem subItem = new QuestionAnswerItem(); subItem = subEnt; subItem.SurveyId = SurveyId; subItem.DoCreate(); } SearchCriterion.SetOrder("SortIndex"); IList <QuestionItem> items = QuestionItem.FindAll(SearchCriterion, Expression.Sql(" SurveyId='" + SurveyId + "'")); this.PageState.Add("DataList", items); } } }
//导入模板 private void ImpTpl() { if (!string.IsNullOrEmpty(id)) { string TemplateId = RequestData.Get("TemplateId") + ""; SurveyQuestion TemplateEnt = SurveyQuestion.TryFind(TemplateId); //问卷模板 SurveyQuestion Ent = SurveyQuestion.Find(id); if (string.IsNullOrEmpty(Ent.Description) && TemplateEnt != null) //描述 { Ent.Description = TemplateEnt.Description; } Ent.TemplateId = TemplateId; Ent.DoUpdate(); string SurveyId = id; int SortIndex = 1; string sql = "select count(1) T from FL_Culture..QuestionItem where SurveyId='{0}' "; sql = string.Format(sql, SurveyId); object obj = DataHelper.QueryValue(sql); if (obj != null) { SortIndex += int.Parse(obj.ToString()); } //合并模板 var ItemEnts = QuestionItem.FindAllByProperties(0, QuestionItem.Prop_SortIndex, QuestionItem.Prop_SurveyId, TemplateId); var SubItemEnts = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_SurveyId, TemplateId); foreach (var ents in ItemEnts) { QuestionItem Item = new QuestionItem(); Item = ents; Item.SurveyId = SurveyId; Item.SortIndex = SortIndex; Item.Ext2 = "imp"; //导入标志 imp Item.DoCreate(); SortIndex++; } foreach (var subEnt in SubItemEnts) { QuestionAnswerItem subItem = new QuestionAnswerItem(); subItem = subEnt; subItem.SurveyId = SurveyId; subItem.Ext1 = "imp"; subItem.DoCreate(); } IList <QuestionItem> items = QuestionItem.FindAll(Expression.Sql(" SurveyId='" + SurveyId + "' order by SortIndex ")); this.PageState.Add("QItem", items); } }
/// <summary> /// 转存为模板 /// </summary> private void TurnTempLate() { string Id = RequestData.Get <string>("SurveyId"); if (!string.IsNullOrEmpty(Id)) { //先删除 var tplEnt = SurveyQuestion.FindFirstByProperties(SurveyQuestion.Prop_TurnSurveyId, Id, SurveyQuestion.Prop_IsFixed, "1"); if (tplEnt != null) { string SQL = "delete from FL_Culture..QuestionItem where SurveyId='{0}' "; SQL += " delete from FL_Culture..QuestionAnswerItem where SurveyId='{0}' "; SQL = string.Format(SQL, tplEnt.Id); DataHelper.ExecSql(SQL); tplEnt.DoDelete(); } SurveyQuestion Ent = SurveyQuestion.Find(Id); if (Ent != null) { SurveyQuestion TplEnt = new SurveyQuestion(); TplEnt.IsFixed = "1"; //1 模板标志位 TplEnt.State = "1"; //表示启用 TplEnt.SurveyTitile = Ent.SurveyTitile; TplEnt.Description = Ent.Description; TplEnt.TurnSurveyId = Id; TplEnt.CompanyId = Ent.CompanyId; //公司ID TplEnt.CompanyName = Ent.CompanyName; TplEnt.DoCreate(); var tplItems = QuestionItem.FindAllByProperties(QuestionItem.Prop_SurveyId, Id); var tplSubItems = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_SurveyId, Id); foreach (var Item in tplItems) { QuestionItem tmpItem = new QuestionItem(); tmpItem = Item; tmpItem.SurveyId = TplEnt.Id; tmpItem.DoCreate(); } foreach (var SubItem in tplSubItems) { QuestionAnswerItem tempSubEnt = new QuestionAnswerItem(); tempSubEnt = SubItem; tempSubEnt.SurveyId = TplEnt.Id; tempSubEnt.DoCreate(); } } } }
private void DoSave() { if (!string.IsNullOrEmpty(QuestionItemId)) { var QuestionContent = RequestData.Get("QuestionContent") + ""; var QuestionType = RequestData.Get("QuestionType") + ""; var IsMustAnswer = RequestData.Get("IsMustAnswer") + ""; var IsShowScore = RequestData.Get("IsShowScore") + ""; var IsComment = RequestData.Get("IsComment") + ""; var SortIndex = RequestData.Get("SortIndex") + ""; if (String.IsNullOrEmpty(SortIndex)) { SortIndex = "0"; } //更新 string[] ImgArr = (RequestData.Get("imgItems") + "").Split(','); QuestionItem Ent = QuestionItem.FindAllByProperties(QuestionItem.Prop_SurveyId, SurveyId, QuestionItem.Prop_SubItemId, QuestionItemId).FirstOrDefault(); string[] tempArr = SetImgItem(ImgArr, QuestionItemId); Ent.ImgIds = tempArr[0]; Ent.Ext1 = tempArr[1]; //Ent.Content = HttpUtility.UrlDecode(QuestionContent); //Ent.QuestionType = HttpUtility.UrlDecode(QuestionType); //Ent.IsMustAnswer = HttpUtility.UrlDecode(IsMustAnswer); //Ent.IsShowScore = HttpUtility.UrlDecode(IsShowScore); //Ent.IsComment = HttpUtility.UrlDecode(IsComment); //Ent.SortIndex = int.Parse(SortIndex); Ent.SurveyId = SurveyId; Ent.DoUpdate(); IList <QuestionAnswerItem> qiEnts = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_QuestionItemId, QuestionItemId, QuestionAnswerItem.Prop_SurveyId, SurveyId); foreach (QuestionAnswerItem items in qiEnts) { items.DoDelete(); } IList <string> DataList = RequestData.GetList <string>("data"); if (DataList.Count > 0) { qiEnts = DataList.Select(tent => JsonHelper.GetObject <QuestionAnswerItem>(tent) as QuestionAnswerItem).ToArray(); foreach (QuestionAnswerItem itms in qiEnts) { itms.DoCreate(); } } } }
private void DoBatchDelete() { IList <object> idList = RequestData.GetList <object>("IdList"); if (idList != null && idList.Count > 0) { // SurveyQuestion.DoBatchDelete(idList.ToArray()); for (var v = 0; v < idList.Count; v++) { // 人员 问卷 QuestionItem[] Qent = QuestionItem.FindAllByProperties(QuestionItem.Prop_SurveyId, idList[v].ToString()); QuestionAnswerItem[] Aent = QuestionAnswerItem.FindAllByProperties(QuestionAnswerItem.Prop_SurveyId, idList[v].ToString()); SurveyFinallyUsr[] FuEnt = SurveyFinallyUsr.FindAllByProperties(SurveyFinallyUsr.Prop_SurveyId, idList[v].ToString()); SurveyCanReaderUsr[] Ruent = SurveyCanReaderUsr.FindAllByProperties(SurveyCanReaderUsr.Prop_SurveyId, idList[v].ToString()); SurveyedObj[] SoEnt = SurveyedObj.FindAllByProperties(SurveyedObj.Prop_SurveyId, idList[v].ToString()); SurveyReaderObj[] RoEnt = SurveyReaderObj.FindAllByProperties(SurveyReaderObj.Prop_SurveyId, idList[v].ToString()); foreach (var ent in Qent) { ent.DoDelete(); } foreach (var ent in Aent) { ent.DoDelete(); } foreach (var ent in FuEnt) { ent.DoDelete(); } foreach (var ent in Ruent) { ent.DoDelete(); } foreach (var ent in SoEnt) { ent.DoDelete(); } foreach (var ent in RoEnt) { ent.DoDelete(); } } SurveyQuestion.DoBatchDelete(idList.ToArray()); } }
/// <summary> /// 撤销模板 /// </summary> private void CancelTpl() { string SurveyId = RequestData.Get("SurveyId") + ""; var Ent = SurveyQuestion.Find(SurveyId); Ent.TemplateId = ""; //TemplateId Ent.DoUpdate(); var ItemEnts = QuestionItem.FindAllByProperties(QuestionItem.Prop_SurveyId, SurveyId, QuestionItem.Prop_Ext2, "imp"); if (ItemEnts.Length > 0) { //撤销模板 'imp' 导入标志 string SQL = @"delete from FL_Culture..QuestionItem where SurveyId='{0}' and Ext2='imp' ; delete from FL_Culture..QuestionAnswerItem where SurveyId='{0}' and Ext1='imp' "; SQL = string.Format(SQL, SurveyId); DataHelper.ExecSql(SQL); IList <QuestionItem> items = QuestionItem.FindAll(Expression.Sql(" SurveyId='" + SurveyId + "' order by SortIndex ")); this.PageState.Add("QItem", items); } }
private void RendSurveryView(string Id) { IList <QuestionContent> qcEnts = QuestionContent.FindAllByProperties(0, QuestionContent.Prop_SortIndex, QuestionContent.Prop_SurveyQuestionId, Id); if (qcEnts.Count > 0) { StringBuilder Stb = new StringBuilder(); for (int i = 0; i < qcEnts.Count; i++) { StringBuilder SubStb = new StringBuilder(); IList <QuestionItem> qiEnts = QuestionItem.FindAllByProperties(0, QuestionItem.Prop_SortIndex, QuestionItem.Prop_QuestionContentId, qcEnts[i].Id); for (int k = 0; k < qiEnts.Count; k++) { if (k > 0) { SubStb.Append(","); } SubStb.Append(JsonHelper.GetJsonString(qiEnts[k])); } qcEnts[i].QuestionItems = "[" + SubStb.ToString() + "]"; if (i > 0) { Stb.Append(","); } Stb.Append(JsonHelper.GetJsonString(qcEnts[i])); } this.PageState.Add("ItemList", "[" + Stb.ToString() + "]"); } //string sql = @"select * from BJKY_IntegratedManage..SurveyQuestion where Id='{0}' "; SurveyQuestion ent = null; if (!string.IsNullOrEmpty(Id)) { ent = SurveyQuestion.Find(Id); this.PageState.Add("Survey", ent); } }