コード例 #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(CSLG.CTalk.Model.DICT_messageState model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into DICT_messageState(");
            strSql.Append("messageStateID,messageStateName)");
            strSql.Append(" values (");
            strSql.Append("@messageStateID,@messageStateName)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@messageStateID",   SqlDbType.TinyInt,  1),
                new SqlParameter("@messageStateName", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.messageStateID;
            parameters[1].Value = model.messageStateName;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CSLG.CTalk.Model.DICT_messageState model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update DICT_messageState set ");
            strSql.Append("messageStateName=@messageStateName");
            strSql.Append(" where messageStateID=@messageStateID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@messageStateName", SqlDbType.NVarChar, 50),
                new SqlParameter("@messageStateID",   SqlDbType.TinyInt, 1)
            };
            parameters[0].Value = model.messageStateName;
            parameters[1].Value = model.messageStateID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CSLG.CTalk.Model.DICT_messageState GetModel(int messageStateID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 messageStateID,messageStateName from DICT_messageState ");
            strSql.Append(" where messageStateID=@messageStateID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@messageStateID", SqlDbType.TinyInt, 1)
            };
            parameters[0].Value = messageStateID;

            CSLG.CTalk.Model.DICT_messageState model = new CSLG.CTalk.Model.DICT_messageState();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["messageStateID"] != null && ds.Tables[0].Rows[0]["messageStateID"].ToString() != "")
                {
                    model.messageStateID = int.Parse(ds.Tables[0].Rows[0]["messageStateID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["messageStateName"] != null && ds.Tables[0].Rows[0]["messageStateName"].ToString() != "")
                {
                    model.messageStateName = ds.Tables[0].Rows[0]["messageStateName"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }