예제 #1
0
 private void ShowInfo(int state_id)
 {
     Auction.BLL.state   bll   = new Auction.BLL.state();
     Auction.Model.state model = bll.GetModel(state_id);
     this.lblstate_id.Text   = model.state_id.ToString();
     this.txtstate_name.Text = model.state_name;
 }
예제 #2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtstate_name.Text.Trim().Length == 0)
            {
                strErr += "state_name不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    state_id   = int.Parse(this.lblstate_id.Text);
            string state_name = this.txtstate_name.Text;


            Auction.Model.state model = new Auction.Model.state();
            model.state_id   = state_id;
            model.state_name = state_name;

            Auction.BLL.state bll = new Auction.BLL.state();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Auction.Model.state model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update state set ");
            strSql.Append("state_name=@state_name");
            strSql.Append(" where state_id=@state_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@state_name", MySqlDbType.VarChar, 10),
                new MySqlParameter("@state_id",   MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.state_name;
            parameters[1].Value = model.state_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #4
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Auction.Model.state model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into state(");
            strSql.Append("state_name)");
            strSql.Append(" values (");
            strSql.Append("@state_name)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@state_name", MySqlDbType.VarChar, 10)
            };
            parameters[0].Value = model.state_name;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Auction.Model.state DataRowToModel(DataRow row)
 {
     Auction.Model.state model = new Auction.Model.state();
     if (row != null)
     {
         if (row["state_id"] != null && row["state_id"].ToString() != "")
         {
             model.state_id = int.Parse(row["state_id"].ToString());
         }
         if (row["state_name"] != null)
         {
             model.state_name = row["state_name"].ToString();
         }
     }
     return(model);
 }
예제 #6
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtstate_name.Text.Trim().Length == 0)
            {
                strErr += "state_name不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string state_name = this.txtstate_name.Text;

            Auction.Model.state model = new Auction.Model.state();
            model.state_name = state_name;

            Auction.BLL.state bll = new Auction.BLL.state();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
예제 #7
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Auction.Model.state GetModel(int state_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select state_id,state_name from state ");
            strSql.Append(" where state_id=@state_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@state_id", MySqlDbType.Int32)
            };
            parameters[0].Value = state_id;

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

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