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

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

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string newc_name = this.txtnewc_name.Text;
            int    newc_ID   = int.Parse(this.lblnewc_ID.Text);


            WalleProject.Model.t_newscategory model = new WalleProject.Model.t_newscategory();
            model.newc_name = newc_name;
            model.newc_ID   = newc_ID;

            WalleProject.BLL.t_newscategory bll = new WalleProject.BLL.t_newscategory();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
예제 #2
0
 private void ShowInfo(int newc_ID)
 {
     WalleProject.BLL.t_newscategory   bll   = new WalleProject.BLL.t_newscategory();
     WalleProject.Model.t_newscategory model = bll.GetModel(newc_ID);
     this.txtnewc_name.Text = model.newc_name;
     this.lblnewc_ID.Text   = model.newc_ID.ToString();
 }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(WalleProject.Model.t_newscategory model)
        {
            StringBuilder strSql = new StringBuilder();

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

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

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

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

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

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

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

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

            WalleProject.Model.t_newscategory model = new WalleProject.Model.t_newscategory();
            model.newc_name = newc_name;

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

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

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

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