コード例 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Jium.Model.userevent model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update userevent set ");
            strSql.Append("userid=@userid,");
            strSql.Append("eventid=@eventid,");
            strSql.Append("eventtime=@eventtime,");
            strSql.Append("remark=@remark");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@userid",    MySqlDbType.Int32,    11),
                new MySqlParameter("@eventid",   MySqlDbType.bigint,   20),
                new MySqlParameter("@eventtime", MySqlDbType.VarChar,  20),
                new MySqlParameter("@remark",    MySqlDbType.VarChar, 100),
                new MySqlParameter("@id",        MySqlDbType.bigint, 20)
            };
            parameters[0].Value = model.userid;
            parameters[1].Value = model.eventid;
            parameters[2].Value = model.eventtime;
            parameters[3].Value = model.remark;
            parameters[4].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Jium.Model.userevent model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into userevent(");
            strSql.Append("userid,eventid,eventtime,remark)");
            strSql.Append(" values (");
            strSql.Append("@userid,@eventid,@eventtime,@remark)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@userid",    MySqlDbType.Int32,   11),
                new MySqlParameter("@eventid",   MySqlDbType.bigint,  20),
                new MySqlParameter("@eventtime", MySqlDbType.VarChar, 20),
                new MySqlParameter("@remark",    MySqlDbType.VarChar, 100)
            };
            parameters[0].Value = model.userid;
            parameters[1].Value = model.eventid;
            parameters[2].Value = model.eventtime;
            parameters[3].Value = model.remark;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Jium.Model.userevent DataRowToModel(DataRow row)
 {
     Jium.Model.userevent model = new Jium.Model.userevent();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = long.Parse(row["id"].ToString());
         }
         if (row["userid"] != null && row["userid"].ToString() != "")
         {
             model.userid = int.Parse(row["userid"].ToString());
         }
         if (row["eventid"] != null && row["eventid"].ToString() != "")
         {
             model.eventid = long.Parse(row["eventid"].ToString());
         }
         if (row["eventtime"] != null)
         {
             model.eventtime = row["eventtime"].ToString();
         }
         if (row["remark"] != null)
         {
             model.remark = row["remark"].ToString();
         }
     }
     return(model);
 }
コード例 #4
0
 private void ShowInfo(long id)
 {
     Jium.BLL.userevent   bll   = new Jium.BLL.userevent();
     Jium.Model.userevent model = bll.GetModel(id);
     this.lblid.Text        = model.id.ToString();
     this.lbluserid.Text    = model.userid.ToString();
     this.lbleventid.Text   = model.eventid.ToString();
     this.lbleventtime.Text = model.eventtime;
     this.lblremark.Text    = model.remark;
 }
コード例 #5
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtuserid.Text))
            {
                strErr += "userid格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txteventid.Text))
            {
                strErr += "eventid格式错误!\\n";
            }
            if (this.txteventtime.Text.Trim().Length == 0)
            {
                strErr += "eventtime不能为空!\\n";
            }
            if (this.txtremark.Text.Trim().Length == 0)
            {
                strErr += "remark不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            long   id        = long.Parse(this.lblid.Text);
            int    userid    = int.Parse(this.txtuserid.Text);
            long   eventid   = long.Parse(this.txteventid.Text);
            string eventtime = this.txteventtime.Text;
            string remark    = this.txtremark.Text;


            Jium.Model.userevent model = new Jium.Model.userevent();
            model.id        = id;
            model.userid    = userid;
            model.eventid   = eventid;
            model.eventtime = eventtime;
            model.remark    = remark;

            Jium.BLL.userevent bll = new Jium.BLL.userevent();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
コード例 #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Jium.Model.userevent GetModel(long id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,userid,eventid,eventtime,remark from userevent ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.bigint)
            };
            parameters[0].Value = id;

            Jium.Model.userevent model = new Jium.Model.userevent();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }