Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ErroLogInfoModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update CORE.dbo.ErroLogInfo set ");

            strSql.Append(" ErroLogContent = @ErroLogContent , ");
            strSql.Append(" CreateTime = @CreateTime , ");
            strSql.Append(" MemberId = @MemberId , ");
            strSql.Append(" UserId = @UserId , ");
            strSql.Append(" Message = @Message  ");
            strSql.Append(" where ErroLogId=@ErroLogId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ErroLogId",      SqlDbType.Decimal,    9),
                new SqlParameter("@ErroLogContent", SqlDbType.NText),
                new SqlParameter("@CreateTime",     SqlDbType.DateTime),
                new SqlParameter("@MemberId",       SqlDbType.Decimal,    9),
                new SqlParameter("@UserId",         SqlDbType.VarChar,   50),
                new SqlParameter("@Message",        SqlDbType.VarChar, 500)
            };

            parameters[0].Value = model.ErroLogId;
            parameters[1].Value = model.ErroLogContent;
            parameters[2].Value = model.CreateTime;
            parameters[3].Value = model.MemberId;
            parameters[4].Value = model.UserId;
            parameters[5].Value = model.Message; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ErroLogInfoModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CORE.dbo.ErroLogInfo (");
            strSql.Append("ErroLogContent,CreateTime,MemberId,UserId,Message");
            strSql.Append(") values (");
            strSql.Append("@ErroLogContent,@CreateTime,@MemberId,@UserId,@Message");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ErroLogContent", SqlDbType.NText),
                new SqlParameter("@CreateTime",     SqlDbType.DateTime),
                new SqlParameter("@MemberId",       SqlDbType.Decimal,    9),
                new SqlParameter("@UserId",         SqlDbType.VarChar,   50),
                new SqlParameter("@Message",        SqlDbType.VarChar, 500)
            };

            parameters[0].Value = model.ErroLogContent;
            parameters[1].Value = model.CreateTime;
            parameters[2].Value = model.MemberId;
            parameters[3].Value = model.UserId;
            parameters[4].Value = model.Message;

            bool result = false;

            try
            {
                helper.ExecSqlReInt(strSql.ToString(), parameters);
                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
Example #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ErroLogInfoModel GetModel(decimal ErroLogId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ErroLogId, ErroLogContent, CreateTime, MemberId, UserId, Message  ");
            strSql.Append("  from CORE.dbo.ErroLogInfo ");
            strSql.Append(" where ErroLogId=@ErroLogId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ErroLogId", SqlDbType.Decimal)
            };
            parameters[0].Value = ErroLogId;


            ErroLogInfoModel model = new ErroLogInfoModel();
            DataSet          ds    = helper.ExecSqlReDs(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ErroLogId"].ToString() != "")
                {
                    model.ErroLogId = decimal.Parse(ds.Tables[0].Rows[0]["ErroLogId"].ToString());
                }
                model.ErroLogContent = ds.Tables[0].Rows[0]["ErroLogContent"].ToString();
                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MemberId"].ToString() != "")
                {
                    model.MemberId = decimal.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString());
                }
                model.UserId  = ds.Tables[0].Rows[0]["UserId"].ToString();
                model.Message = ds.Tables[0].Rows[0]["Message"].ToString();

                return(model);
            }
            else
            {
                return(model);
            }
        }