Example #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(myhouse.Model.Housetype model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_housetype set ");
            strSql.Append("ttype=@ttype,");
            strSql.Append("tcontent=@tcontent");
            strSql.Append(" where tid=@tid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ttype",    SqlDbType.Char,    20),
                new SqlParameter("@tcontent", SqlDbType.VarChar, 30),
                new SqlParameter("@tid",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.ttype;
            parameters[1].Value = model.tcontent;
            parameters[2].Value = model.tid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(myhouse.Model.Housetype model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_housetype(");
            strSql.Append("ttype,tcontent)");
            strSql.Append(" values (");
            strSql.Append("@ttype,@tcontent)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ttype",    SqlDbType.Char,    20),
                new SqlParameter("@tcontent", SqlDbType.VarChar, 30)
            };
            parameters[0].Value = model.ttype;
            parameters[1].Value = model.tcontent;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Example #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtttype.Text))
            {
                strErr += "ttype格式错误!\\n";
            }
            if (this.txttcontent.Text.Trim().Length == 0)
            {
                strErr += "tcontent不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    ttype    = int.Parse(this.txtttype.Text);
            string tcontent = this.txttcontent.Text;

            myhouse.Model.Housetype model = new myhouse.Model.Housetype();
            model.ttype    = ttype;
            model.tcontent = tcontent;

            myhouse.BLL.HousetypeService bll = new myhouse.BLL.HousetypeService();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Example #4
0
 private void ShowInfo(int tid)
 {
     myhouse.BLL.HousetypeService bll   = new myhouse.BLL.HousetypeService();
     myhouse.Model.Housetype      model = bll.GetModel(tid);
     this.lbltid.Text      = model.tid.ToString();
     this.lblttype.Text    = model.ttype.ToString();
     this.lbltcontent.Text = model.tcontent;
 }
Example #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public myhouse.Model.Housetype DataRowToModel(DataRow row)
 {
     myhouse.Model.Housetype model = new myhouse.Model.Housetype();
     if (row != null)
     {
         if (row["tid"] != null && row["tid"].ToString() != "")
         {
             model.tid = int.Parse(row["tid"].ToString());
         }
         if (row["ttype"] != null && row["ttype"].ToString() != "")
         {
             model.ttype = row["ttype"].ToString();
         }
         if (row["tcontent"] != null)
         {
             model.tcontent = row["tcontent"].ToString();
         }
     }
     return(model);
 }
Example #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public myhouse.Model.Housetype GetModel(int tid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 tid,ttype,tcontent from t_housetype ");
            strSql.Append(" where tid=@tid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@tid", SqlDbType.Int, 4)
            };
            parameters[0].Value = tid;

            myhouse.Model.Housetype model = new myhouse.Model.Housetype();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

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