예제 #1
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtwastecate_name.Text.Trim().Length == 0)
            {
                strErr += "wastecate_name不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtwastecate_cid.Text))
            {
                strErr += "wastecate_cid格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string wastecate_name = this.txtwastecate_name.Text;
            int    wastecate_id   = int.Parse(this.lblwastecate_id.Text);
            int    wastecate_cid  = int.Parse(this.txtwastecate_cid.Text);


            WalleProject.Model.t_wastesmailcate model = new WalleProject.Model.t_wastesmailcate();
            model.wastecate_name = wastecate_name;
            model.wastecate_id   = wastecate_id;
            model.wastecate_cid  = wastecate_cid;

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

            strSql.Append("update t_wastesmailcate set ");
            strSql.Append("wastecate_name=@wastecate_name,");
            strSql.Append("wastecate_cid=@wastecate_cid");
            strSql.Append(" where wastecate_id=@wastecate_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@wastecate_name", MySqlDbType.VarChar, 20),
                new MySqlParameter("@wastecate_cid",  MySqlDbType.Int32,   10),
                new MySqlParameter("@wastecate_id",   MySqlDbType.Int32, 10)
            };
            parameters[0].Value = model.wastecate_name;
            parameters[1].Value = model.wastecate_cid;
            parameters[2].Value = model.wastecate_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
 private void ShowInfo(int wastecate_id)
 {
     WalleProject.BLL.t_wastesmailcate   bll   = new WalleProject.BLL.t_wastesmailcate();
     WalleProject.Model.t_wastesmailcate model = bll.GetModel(wastecate_id);
     this.txtwastecate_name.Text = model.wastecate_name;
     this.lblwastecate_id.Text   = model.wastecate_id.ToString();
     this.txtwastecate_cid.Text  = model.wastecate_cid.ToString();
 }
예제 #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WalleProject.Model.t_wastesmailcate DataRowToModel(DataRow row)
 {
     WalleProject.Model.t_wastesmailcate model = new WalleProject.Model.t_wastesmailcate();
     if (row != null)
     {
         if (row["wastecate_name"] != null)
         {
             model.wastecate_name = row["wastecate_name"].ToString();
         }
         if (row["wastecate_id"] != null && row["wastecate_id"].ToString() != "")
         {
             model.wastecate_id = int.Parse(row["wastecate_id"].ToString());
         }
         if (row["wastecate_cid"] != null && row["wastecate_cid"].ToString() != "")
         {
             model.wastecate_cid = int.Parse(row["wastecate_cid"].ToString());
         }
     }
     return(model);
 }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WalleProject.Model.t_wastesmailcate GetModel(int wastecate_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select wastecate_name,wastecate_id,wastecate_cid from t_wastesmailcate ");
            strSql.Append(" where wastecate_id=@wastecate_id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@wastecate_id", MySqlDbType.Int32)
            };
            parameters[0].Value = wastecate_id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(WalleProject.Model.t_wastesmailcate model)
 {
     return(dal.Update(model));
 }
예제 #7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(WalleProject.Model.t_wastesmailcate model)
 {
     return(dal.Add(model));
 }