コード例 #1
0
        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();
                    }
                }
            }
        }