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

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

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string wasc_name = this.txtwasc_name.Text;
            int    wasc_ID   = int.Parse(this.lblwasc_ID.Text);


            WalleProject.Model.t_wastecategory model = new WalleProject.Model.t_wastecategory();
            model.wasc_name = wasc_name;
            model.wasc_ID   = wasc_ID;

            WalleProject.BLL.t_wastecategory bll = new WalleProject.BLL.t_wastecategory();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
示例#2
0
 private void ShowInfo(int wasc_ID)
 {
     WalleProject.BLL.t_wastecategory   bll   = new WalleProject.BLL.t_wastecategory();
     WalleProject.Model.t_wastecategory model = bll.GetModel(wasc_ID);
     this.txtwasc_name.Text = model.wasc_name;
     this.lblwasc_ID.Text   = model.wasc_ID.ToString();
 }
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WalleProject.Model.t_wastecategory model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_wastecategory set ");
            strSql.Append("wasc_name=@wasc_name,");
            strSql.Append("wasc_c_id=@wasc_c_id");
            strSql.Append(" where wasc_ID=@wasc_ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@wasc_name", MySqlDbType.VarChar, 10),
                new MySqlParameter("@wasc_c_id", MySqlDbType.Int32,   10),
                new MySqlParameter("@wasc_ID",   MySqlDbType.Int32, 10)
            };
            parameters[0].Value = model.wasc_name;
            parameters[1].Value = model.wasc_c_id;
            parameters[2].Value = model.wasc_ID;

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

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

            strSql.Append("insert into t_wastecategory(");
            strSql.Append("wasc_name,wasc_c_id)");
            strSql.Append(" values (");
            strSql.Append("@wasc_name,@wasc_c_id)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@wasc_name", MySqlDbType.VarChar, 10),
                new MySqlParameter("@wasc_c_id", MySqlDbType.Int32, 10)
            };
            parameters[0].Value = model.wasc_name;
            parameters[1].Value = model.wasc_c_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public WalleProject.Model.t_wastecategory DataRowToModel(DataRow row)
 {
     WalleProject.Model.t_wastecategory model = new WalleProject.Model.t_wastecategory();
     if (row != null)
     {
         if (row["wasc_name"] != null)
         {
             model.wasc_name = row["wasc_name"].ToString();
         }
         if (row["wasc_ID"] != null && row["wasc_ID"].ToString() != "")
         {
             model.wasc_ID = int.Parse(row["wasc_ID"].ToString());
         }
         if (row["wasc_c_id"] != null && row["wasc_c_id"].ToString() != "")
         {
             model.wasc_c_id = int.Parse(row["wasc_c_id"].ToString());
         }
     }
     return(model);
 }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public WalleProject.Model.t_wastecategory GetModel(int wasc_ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select wasc_name,wasc_ID,wasc_c_id from t_wastecategory ");
            strSql.Append(" where wasc_ID=@wasc_ID");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@wasc_ID", MySqlDbType.Int32)
            };
            parameters[0].Value = wasc_ID;

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

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