//导入模板 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); } }
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); } } }
/// <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); } }