コード例 #1
0
        public IList <RiskTestQuestionInfo> GetList(string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,QuestionXml,LastUpdatedDate
                        from RiskTestQuestion ");
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }

            IList <RiskTestQuestionInfo> list = new List <RiskTestQuestionInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        RiskTestQuestionInfo model = new RiskTestQuestionInfo();
                        model.Id              = reader.GetGuid(0);
                        model.QuestionXml     = reader.GetString(1);
                        model.LastUpdatedDate = reader.GetDateTime(2);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #2
0
        public IList <RiskTestQuestionInfo> GetList()
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"select Id,QuestionXml,LastUpdatedDate 
			            from RiskTestQuestion
					    order by LastUpdatedDate desc "                    );

            IList <RiskTestQuestionInfo> list = new List <RiskTestQuestionInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString()))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        RiskTestQuestionInfo model = new RiskTestQuestionInfo();
                        model.Id              = reader.GetGuid(0);
                        model.QuestionXml     = reader.GetString(1);
                        model.LastUpdatedDate = reader.GetDateTime(2);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #3
0
        public IList <RiskTestQuestionInfo> GetList(int pageIndex, int pageSize, string sqlWhere, params SqlParameter[] cmdParms)
        {
            StringBuilder sb         = new StringBuilder(250);
            int           startIndex = (pageIndex - 1) * pageSize + 1;
            int           endIndex   = pageIndex * pageSize;

            sb.Append(@"select * from(select row_number() over(order by LastUpdatedDate desc) as RowNumber,
			           Id,QuestionXml,LastUpdatedDate
					   from RiskTestQuestion "                    );
            if (!string.IsNullOrEmpty(sqlWhere))
            {
                sb.AppendFormat(" where 1=1 {0} ", sqlWhere);
            }
            sb.AppendFormat(@")as objTable where RowNumber between {0} and {1} ", startIndex, endIndex);

            IList <RiskTestQuestionInfo> list = new List <RiskTestQuestionInfo>();

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), cmdParms))
            {
                if (reader != null && reader.HasRows)
                {
                    while (reader.Read())
                    {
                        RiskTestQuestionInfo model = new RiskTestQuestionInfo();
                        model.Id              = reader.GetGuid(1);
                        model.QuestionXml     = reader.GetString(2);
                        model.LastUpdatedDate = reader.GetDateTime(3);

                        list.Add(model);
                    }
                }
            }

            return(list);
        }
コード例 #4
0
        public RiskTestQuestionInfo GetModel(object Id)
        {
            RiskTestQuestionInfo model = null;

            StringBuilder sb = new StringBuilder(300);

            sb.Append(@"select top 1 Id,QuestionXml,LastUpdatedDate 
			            from RiskTestQuestion
						where Id = @Id "                        );
            SqlParameter parm = new SqlParameter("@Id", SqlDbType.UniqueIdentifier);

            parm.Value = Guid.Parse(Id.ToString());

            using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), parm))
            {
                if (reader != null)
                {
                    while (reader.Read())
                    {
                        model                 = new RiskTestQuestionInfo();
                        model.Id              = reader.GetGuid(0);
                        model.QuestionXml     = reader.GetString(1);
                        model.LastUpdatedDate = reader.GetDateTime(2);
                    }
                }
            }

            return(model);
        }
コード例 #5
0
        public string SaveRiskTestQuestion(string xml, string Id)
        {
            if (string.IsNullOrWhiteSpace(xml))
            {
                return("{\"success\": false,\"message\": \"未找到任何可提交的数据,请检查\"}");
            }

            try
            {
                xml = HttpUtility.HtmlDecode(xml);
                XElement root = XElement.Parse(xml);
            }
            catch
            {
                return("{\"success\": false,\"message\": \"参数值不符合xml格式的字符串,请检查\"}");
            }

            try
            {
                Guid gId = Guid.Empty;
                if (!string.IsNullOrWhiteSpace(Id))
                {
                    Guid.TryParse(Id, out gId);
                }
                RiskTestQuestionInfo model = new RiskTestQuestionInfo();
                model.Id              = gId;
                model.QuestionXml     = xml;
                model.LastUpdatedDate = DateTime.Now;

                RiskTestQuestion bll = new RiskTestQuestion();
                int effect           = 0;
                if (gId.Equals(Guid.Empty))
                {
                    gId      = Guid.NewGuid();
                    model.Id = gId;
                    effect   = bll.Insert(model);
                }
                else
                {
                    effect = bll.Update(model);
                }

                if (effect < 1)
                {
                    return("{\"success\": false,\"message\": \"数据库连接操作异常,请稍后再重试\"}");
                }

                return("{\"success\": true,\"message\": \"\",\"data\": \"" + gId.ToString() + "\"}");
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
コード例 #6
0
        public int Update(RiskTestQuestionInfo model)
        {
            StringBuilder sb = new StringBuilder(250);

            sb.Append(@"update RiskTestQuestion set QuestionXml = @QuestionXml,LastUpdatedDate = @LastUpdatedDate 
			            where Id = @Id
					    "                    );

            SqlParameter[] parms =
            {
                new SqlParameter("@Id",              SqlDbType.UniqueIdentifier),
                new SqlParameter("@QuestionXml",     SqlDbType.NVarChar, 3000),
                new SqlParameter("@LastUpdatedDate", SqlDbType.DateTime)
            };
            parms[0].Value = model.Id;
            parms[1].Value = model.QuestionXml;
            parms[2].Value = model.LastUpdatedDate;

            return(SqlHelper.ExecuteNonQuery(SqlHelper.GzxySiteDbConnString, CommandType.Text, sb.ToString(), parms));
        }
コード例 #7
0
 /// <summary>
 /// 修改数据
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Update(RiskTestQuestionInfo model)
 {
     return(dal.Update(model));
 }
コード例 #8
0
 /// <summary>
 /// 添加数据到数据库
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public int Insert(RiskTestQuestionInfo model)
 {
     return(dal.Insert(model));
 }