示例#1
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();
                    }
                }
            }
        }