Esempio n. 1
0
        public Model.UserInfoPostModel GetModel(int postId)
        {
            string sql = "select postId,postName,orderId from UserInfo_Post where postId =" + postId;

            Model.UserInfoPostModel model = new Model.UserInfoPostModel();
            DataTable dt = SqlHelper.ExecuteDataTable(conn, CommandType.Text, sql);

            if (dt.Rows.Count > 0)
            {
                if (dt.Rows[0]["PostId"] != null && dt.Rows[0]["PostId"].ToString() != "")
                {
                    model.PostId = int.Parse(dt.Rows[0]["PostId"].ToString());
                }
                if (dt.Rows[0]["OrderId"] != null && dt.Rows[0]["OrderId"].ToString() != "")
                {
                    model.OrderId = int.Parse(dt.Rows[0]["OrderId"].ToString());
                }
                if (dt.Rows[0]["PostName"] != null && dt.Rows[0]["PostName"].ToString() != "")
                {
                    model.PostName = dt.Rows[0]["PostName"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public int Update(Model.UserInfoPostModel model)
        {
            int           obj    = 0;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update    UserInfo_Post set PostName='" + model.PostName + "',OrderId=" + model.OrderId + "  where PostId=" + model.PostId + "");
            obj = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString());
            return(obj);
        }
Esempio n. 3
0
        /// <summary>
        /// 添加组织
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public int Add(Model.UserInfoPostModel model)
        {
            int obj = 0;

            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserInfo_Post(PostName,OrderId) values('" + model.PostName + "'," + model.OrderId + ")");
            obj = SqlHelper.ExecuteNonQuery(conn, CommandType.Text, strSql.ToString());
            return(obj);
        }