Exemple #1
0
 private void ShowInfo(int comc_ID)
 {
     WalleProject.BLL.t_commoditycategory   bll   = new WalleProject.BLL.t_commoditycategory();
     WalleProject.Model.t_commoditycategory model = bll.GetModel(comc_ID);
     this.txtcomc_name.Text = model.comc_name;
     this.lblcomc_ID.Text   = model.comc_ID.ToString();
 }
Exemple #2
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

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

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string comc_name = this.txtcomc_name.Text;
            int    comc_ID   = int.Parse(this.lblcomc_ID.Text);


            WalleProject.Model.t_commoditycategory model = new WalleProject.Model.t_commoditycategory();
            model.comc_name = comc_name;
            model.comc_ID   = comc_ID;

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

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

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

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

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

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

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

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

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

            WalleProject.Model.t_commoditycategory model = new WalleProject.Model.t_commoditycategory();
            model.comc_name = comc_name;

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

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

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

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