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

            strSql.Append("update DBLOG.dbo.StMsg set ");

            strSql.Append(" Invalid = @Invalid , ");
            strSql.Append(" Ip = @Ip , ");
            strSql.Append(" StMsgCode = @StMsgCode , ");
            strSql.Append(" StMsgTypeId = @StMsgTypeId , ");
            strSql.Append(" StMsgClassId = @StMsgClassId , ");
            strSql.Append(" StMsgContent = @StMsgContent , ");
            strSql.Append(" PhoneNo = @PhoneNo , ");
            strSql.Append(" CreateTime = @CreateTime , ");
            strSql.Append(" ReKey = @ReKey , ");
            strSql.Append(" MerId = @MerId  ");
            strSql.Append(" where StMsgId=@StMsgId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@StMsgId",      SqlDbType.Decimal,     9),
                new SqlParameter("@Invalid",      SqlDbType.Bit,         1),
                new SqlParameter("@Ip",           SqlDbType.VarChar,    50),
                new SqlParameter("@StMsgCode",    SqlDbType.VarChar,    20),
                new SqlParameter("@StMsgTypeId",  SqlDbType.Decimal,     9),
                new SqlParameter("@StMsgClassId", SqlDbType.Decimal,     9),
                new SqlParameter("@StMsgContent", SqlDbType.VarChar,   500),
                new SqlParameter("@PhoneNo",      SqlDbType.VarChar,    50),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@ReKey",        SqlDbType.VarChar,    50),
                new SqlParameter("@MerId",        SqlDbType.Decimal, 9)
            };

            parameters[0].Value  = model.StMsgId;
            parameters[1].Value  = model.Invalid;
            parameters[2].Value  = model.Ip;
            parameters[3].Value  = model.StMsgCode;
            parameters[4].Value  = model.StMsgTypeId;
            parameters[5].Value  = model.StMsgClassId;
            parameters[6].Value  = model.StMsgContent;
            parameters[7].Value  = model.PhoneNo;
            parameters[8].Value  = model.CreateTime;
            parameters[9].Value  = model.ReKey;
            parameters[10].Value = model.MerId; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(StMsgModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into DBLOG.dbo.StMsg (");
            strSql.Append("Invalid,Ip,StMsgCode,StMsgTypeId,StMsgClassId,StMsgContent,PhoneNo,CreateTime,ReKey,MerId");
            strSql.Append(") values (");
            strSql.Append("@Invalid,@Ip,@StMsgCode,@StMsgTypeId,@StMsgClassId,@StMsgContent,@PhoneNo,@CreateTime,@ReKey,@MerId");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Invalid",      SqlDbType.Bit,         1),
                new SqlParameter("@Ip",           SqlDbType.VarChar,    50),
                new SqlParameter("@StMsgCode",    SqlDbType.VarChar,    20),
                new SqlParameter("@StMsgTypeId",  SqlDbType.Decimal,     9),
                new SqlParameter("@StMsgClassId", SqlDbType.Decimal,     9),
                new SqlParameter("@StMsgContent", SqlDbType.VarChar,   500),
                new SqlParameter("@PhoneNo",      SqlDbType.VarChar,    50),
                new SqlParameter("@CreateTime",   SqlDbType.DateTime),
                new SqlParameter("@ReKey",        SqlDbType.VarChar,    50),
                new SqlParameter("@MerId",        SqlDbType.Decimal, 9)
            };

            parameters[0].Value = model.Invalid;
            parameters[1].Value = model.Ip;
            parameters[2].Value = model.StMsgCode;
            parameters[3].Value = model.StMsgTypeId;
            parameters[4].Value = model.StMsgClassId;
            parameters[5].Value = model.StMsgContent;
            parameters[6].Value = model.PhoneNo;
            parameters[7].Value = model.CreateTime;
            parameters[8].Value = model.ReKey;
            parameters[9].Value = model.MerId;

            bool result = false;

            try
            {
                model.StMsgId = decimal.Parse(helper.ExecuteNonQueryBackId(strSql.ToString(), "StMsgId", parameters));
                result        = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public StMsgModel GetModel(decimal StMsgId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select StMsgId, Invalid, Ip, StMsgCode, StMsgTypeId, StMsgClassId, StMsgContent, PhoneNo, CreateTime, ReKey, MerId  ");
            strSql.Append("  from DBLOG.dbo.StMsg ");
            strSql.Append(" where StMsgId=@StMsgId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StMsgId", SqlDbType.Decimal)
            };
            parameters[0].Value = StMsgId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["StMsgId"].ToString() != "")
                {
                    model.StMsgId = decimal.Parse(ds.Tables[0].Rows[0]["StMsgId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Invalid"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Invalid"].ToString() == "1") || (ds.Tables[0].Rows[0]["Invalid"].ToString().ToLower() == "true"))
                    {
                        model.Invalid = true;
                    }
                    else
                    {
                        model.Invalid = false;
                    }
                }
                model.Ip        = ds.Tables[0].Rows[0]["Ip"].ToString();
                model.StMsgCode = ds.Tables[0].Rows[0]["StMsgCode"].ToString();
                if (ds.Tables[0].Rows[0]["StMsgTypeId"].ToString() != "")
                {
                    model.StMsgTypeId = decimal.Parse(ds.Tables[0].Rows[0]["StMsgTypeId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["StMsgClassId"].ToString() != "")
                {
                    model.StMsgClassId = decimal.Parse(ds.Tables[0].Rows[0]["StMsgClassId"].ToString());
                }
                model.StMsgContent = ds.Tables[0].Rows[0]["StMsgContent"].ToString();
                model.PhoneNo      = ds.Tables[0].Rows[0]["PhoneNo"].ToString();
                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                model.ReKey = ds.Tables[0].Rows[0]["ReKey"].ToString();
                if (ds.Tables[0].Rows[0]["MerId"].ToString() != "")
                {
                    model.MerId = decimal.Parse(ds.Tables[0].Rows[0]["MerId"].ToString());
                }

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