Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SurveyId = RequestData.Get <string>("id") + "";

            switch (this.RequestAction)
            {
            case RequestActionEnum.Update:
                DoSave();
                break;

            case RequestActionEnum.Delete:
                ent = this.GetTargetData <SurveyQuestion>();
                ent.DoDelete();
                return;

            default:
                if (RequestActionString == "GetId")
                {
                    QuestionItem qItem = new QuestionItem();
                    qItem.SubItemId = Guid.NewGuid().ToString();
                    qItem.DoCreate();
                    this.PageState.Add("SubItemId", qItem.Id + "|" + qItem.SubItemId);
                }
                else if (RequestActionString == "Close")
                {
                    DoClose();
                }
                else
                {
                    DoSelect();
                }
                break;
            }
        }
Exemplo n.º 2
0
        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);
                }
            }
        }
Exemplo n.º 3
0
        //导入模板
        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);
            }
        }
Exemplo n.º 4
0
        /// <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();
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 复制题目选择项
        /// </summary>
        private void CopyItems()
        {
            string LastItem = RequestData.Get("LastItem") + "";

            if (!string.IsNullOrEmpty(LastItem))
            {
                string gid = Guid.NewGuid().ToString();

                var LastEnt = QuestionItem.FindFirstByProperties(QuestionItem.Prop_SubItemId, LastItem);
                var Ents    = QuestionAnswerItem.FindAllByProperty("QuestionItemId", LastItem);
                foreach (var v in Ents)
                {
                    QuestionAnswerItem item = new QuestionAnswerItem();
                    item.Answer         = v.Answer;
                    item.IsExplanation  = v.IsExplanation;
                    item.IsShowScore    = v.IsShowScore;
                    item.QuestionItemId = gid;    //*
                    item.SurveyId       = v.SurveyId;
                    item.SortIndex      = v.SortIndex;
                    item.Score          = v.Score;
                    item.DoCreate();
                }

                QuestionItem QiEnt = new QuestionItem();
                QiEnt           = LastEnt;
                QiEnt.SubItemId = gid;   //*
                QiEnt.Content   = string.Empty;
                QiEnt.SortIndex = LastEnt.SortIndex + 1;

                //QiEnt.IsComment = LastEnt.IsComment;
                //QiEnt.IsMustAnswer = LastEnt.IsMustAnswer;
                //QiEnt.IsShowScore = LastEnt.IsShowScore;
                //QiEnt.QuestionType = LastEnt.QuestionType;
                //QiEnt.SurveyId = LastEnt.SurveyId;
                //QiEnt.SubItems = LastEnt.SubItems;
                //QiEnt.Ext1 = LastEnt.Ext1;
                QiEnt.DoCreate();


                this.PageState.Add("SubItemId", gid + "|" + QiEnt.Id);
            }
            else
            {
                this.PageState.Add("SubItemId", "");
            }
        }
Exemplo n.º 6
0
        string SurveyId = String.Empty;     // SurveyId

        protected void Page_Load(object sender, EventArgs e)
        {
            SurveyId = RequestData.Get <string>("SurveyId") + "";

            switch (this.RequestActionString)
            {
            case "GetId":
                QuestionItem qItem = new QuestionItem();
                qItem.SubItemId = Guid.NewGuid().ToString();
                qItem.DoCreate();
                this.PageState.Add("SubItemId", qItem.Id + "|" + qItem.SubItemId);
                break;

            case "Save":
                DoSave();
                break;

            default:
                DoSelect();
                break;
            }
        }
Exemplo n.º 7
0
        //子项的添加
        private void AddQuestionItem()
        {
            QuestionItem qItem = new QuestionItem();

            qItem.SubItemId = Guid.NewGuid().ToString();

            qItem.IsMustAnswer = "是";
            qItem.QuestionType = "单选项";
            qItem.IsShowScore  = "否";
            qItem.IsComment    = "否";
            var SortIndex = this.RequestData.Get("SortIndex") + "";
            var SurveyId  = RequestData.Get("SurveyId") + "";

            if (String.IsNullOrEmpty(SortIndex))
            {
                SortIndex = "0";
            }
            qItem.SortIndex = int.Parse(SortIndex);

            qItem.SurveyId = SurveyId;
            qItem.DoCreate();
            this.PageState.Add("SubItemId", qItem.Id + "|" + qItem.SubItemId);
        }