示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(lgk.Model.tb_wealth model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update tb_wealth set ");
            strSql.Append("WealthContent=@WealthContent");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WealthContent", SqlDbType.Text),
                new SqlParameter("@ID",            SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.WealthContent;
            parameters[1].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(lgk.Model.tb_wealth model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into tb_wealth(");
            strSql.Append("WealthContent)");
            strSql.Append(" values (");
            strSql.Append("@WealthContent)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@WealthContent", SqlDbType.Text)
            };
            parameters[0].Value = model.WealthContent;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.tb_wealth GetModel()
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,WealthContent from tb_wealth ");

            lgk.Model.tb_wealth model = new lgk.Model.tb_wealth();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString(), null);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WealthContent"] != null && ds.Tables[0].Rows[0]["WealthContent"].ToString() != "")
                {
                    model.WealthContent = ds.Tables[0].Rows[0]["WealthContent"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public lgk.Model.tb_wealth GetModel(long ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 ID,WealthContent from tb_wealth ");
            strSql.Append(" where ID=@ID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ID", SqlDbType.BigInt)
            };
            parameters[0].Value = ID;

            lgk.Model.tb_wealth model = new lgk.Model.tb_wealth();
            DataSet             ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ID"] != null && ds.Tables[0].Rows[0]["ID"].ToString() != "")
                {
                    model.ID = long.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                if (ds.Tables[0].Rows[0]["WealthContent"] != null && ds.Tables[0].Rows[0]["WealthContent"].ToString() != "")
                {
                    model.WealthContent = ds.Tables[0].Rows[0]["WealthContent"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
示例#5
0
 /// <summary>
 /// 填充按钮
 /// </summary>
 protected void BindData()
 {
     lgk.Model.tb_wealth wealth = wealthBLL.GetModel();
     if (wealth != null)
     {
         textPubContext.Text = wealth.WealthContent;
     }
 }
示例#6
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string t = textPubContext.Text.ToString().Trim().Replace("&nbsp;", "");

            if (t.Length <= 7)
            {
                ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('财富计划内容不能为空!');", true);
                return;
            }
            lgk.Model.tb_wealth wealth = wealthBLL.GetModel();
            if (wealth != null)
            {
                wealth.WealthContent = textPubContext.Text;
                if (wealthBLL.Update(wealth))
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('修改成功!');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('修改失败!');", true);
                }
            }
            else
            {
                wealth = new lgk.Model.tb_wealth();
                wealth.WealthContent = textPubContext.Text;
                if (wealthBLL.Add(wealth) > 0)
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('添加成功!');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, typeof(Page), "info", "alert('添加失败!');", true);
                }
            }
        }