コード例 #1
0
ファイル: Modify.aspx.cs プロジェクト: Pengxiaoxi/HouseRent
 private void ShowInfo(int hid)
 {
     myhouse.BLL.HouseService bll   = new myhouse.BLL.HouseService();
     myhouse.Model.House      model = bll.GetModel(hid);
     this.lblhid.Text          = model.hid.ToString();
     this.lblcid.Text          = model.cid.ToString();
     this.lbluid.Text          = model.uid.ToString();
     this.lblsid.Text          = model.sid.ToString();
     this.txthname.Text        = model.hname;
     this.txthdescription.Text = model.hdescription;
     this.txthmoney.Text       = model.hmoney;
     this.txthtype.Text        = model.htype.ToString();
     this.txthphotoone.Text    = model.hphotoone;
     this.txthphototwo.Text    = model.hphototwo;
     this.txthphotothree.Text  = model.hphotothree;
     this.txthphotofour.Text   = model.hphotofour;
     this.txthfloor.Text       = model.hfloor;
     this.txthsize.Text        = model.hsize;
     this.txtharea.Text        = model.harea.ToString();
     this.txthcommunity.Text   = model.hcommunity;
     this.txthadress.Text      = model.hadress;
     this.txthtime.Text        = model.htime.ToString();
     this.txthmode.Text        = model.hmode.ToString();
     this.txthstatus.Text      = model.hstatus.ToString();
 }
コード例 #2
0
ファイル: HouseDao.cs プロジェクト: Pengxiaoxi/HouseRent
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public myhouse.Model.House GetModel(int hid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 hid,cid,uid,sid,hname,hdescription,hmoney,htype,hphotoone,hphototwo,hphotothree,hphotofour,hfloor,hsize,harea,hcommunity,hadress,htime,hmode,hstatus from t_house ");
            strSql.Append(" where hid=@hid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@hid", SqlDbType.Int, 4)
            };
            parameters[0].Value = hid;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
ファイル: HouseDao.cs プロジェクト: Pengxiaoxi/HouseRent
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(myhouse.Model.House model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_house(");
            strSql.Append("cid,uid,sid,hname,hdescription,hmoney,htype,hphotoone,hphototwo,hphotothree,hphotofour,hfloor,hsize,harea,hcommunity,hadress,htime,hmode,hstatus)");
            strSql.Append(" values (");
            strSql.Append("@cid,@uid,@sid,@hname,@hdescription,@hmoney,@htype,@hphotoone,@hphototwo,@hphotothree,@hphotofour,@hfloor,@hsize,@harea,@hcommunity,@hadress,@htime,@hmode,@hstatus)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@cid",          SqlDbType.Int,         4),
                new SqlParameter("@uid",          SqlDbType.Int,         4),
                new SqlParameter("@sid",          SqlDbType.Int,         4),
                new SqlParameter("@hname",        SqlDbType.VarChar,    30),
                new SqlParameter("@hdescription", SqlDbType.VarChar,   200),
                new SqlParameter("@hmoney",       SqlDbType.VarChar,    10),
                new SqlParameter("@htype",        SqlDbType.Int,         4),
                new SqlParameter("@hphotoone",    SqlDbType.VarChar,   200),
                new SqlParameter("@hphototwo",    SqlDbType.VarChar,   200),
                new SqlParameter("@hphotothree",  SqlDbType.VarChar,   200),
                new SqlParameter("@hphotofour",   SqlDbType.VarChar,   200),
                new SqlParameter("@hfloor",       SqlDbType.Char,        4),
                new SqlParameter("@hsize",        SqlDbType.Char,        4),
                new SqlParameter("@harea",        SqlDbType.Int,         4),
                new SqlParameter("@hcommunity",   SqlDbType.VarChar,   100),
                new SqlParameter("@hadress",      SqlDbType.VarChar,   200),
                new SqlParameter("@htime",        SqlDbType.DateTime),
                new SqlParameter("@hmode",        SqlDbType.Int,         4),
                new SqlParameter("@hstatus",      SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.cid;
            parameters[1].Value  = model.uid;
            parameters[2].Value  = model.sid;
            parameters[3].Value  = model.hname;
            parameters[4].Value  = model.hdescription;
            parameters[5].Value  = model.hmoney;
            parameters[6].Value  = model.htype;
            parameters[7].Value  = model.hphotoone;
            parameters[8].Value  = model.hphototwo;
            parameters[9].Value  = model.hphotothree;
            parameters[10].Value = model.hphotofour;
            parameters[11].Value = model.hfloor;
            parameters[12].Value = model.hsize;
            parameters[13].Value = model.harea;
            parameters[14].Value = model.hcommunity;
            parameters[15].Value = model.hadress;
            parameters[16].Value = model.htime;
            parameters[17].Value = model.hmode;
            parameters[18].Value = model.hstatus;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
コード例 #4
0
ファイル: HouseDao.cs プロジェクト: Pengxiaoxi/HouseRent
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public myhouse.Model.House DataRowToModel(DataRow row)
 {
     myhouse.Model.House model = new myhouse.Model.House();
     if (row != null)
     {
         if (row["hid"] != null && row["hid"].ToString() != "")
         {
             model.hid = int.Parse(row["hid"].ToString());
         }
         if (row["cid"] != null && row["cid"].ToString() != "")
         {
             model.cid = int.Parse(row["cid"].ToString());
         }
         if (row["uid"] != null && row["uid"].ToString() != "")
         {
             model.uid = int.Parse(row["uid"].ToString());
         }
         if (row["sid"] != null && row["sid"].ToString() != "")
         {
             model.sid = int.Parse(row["sid"].ToString());
         }
         if (row["hname"] != null)
         {
             model.hname = row["hname"].ToString();
         }
         if (row["hdescription"] != null)
         {
             model.hdescription = row["hdescription"].ToString();
         }
         if (row["hmoney"] != null)
         {
             model.hmoney = row["hmoney"].ToString();
         }
         if (row["htype"] != null && row["htype"].ToString() != "")
         {
             model.htype = int.Parse(row["htype"].ToString());
         }
         if (row["hphotoone"] != null)
         {
             model.hphotoone = row["hphotoone"].ToString();
         }
         if (row["hphototwo"] != null)
         {
             model.hphototwo = row["hphototwo"].ToString();
         }
         if (row["hphotothree"] != null)
         {
             model.hphotothree = row["hphotothree"].ToString();
         }
         if (row["hphotofour"] != null)
         {
             model.hphotofour = row["hphotofour"].ToString();
         }
         if (row["hfloor"] != null)
         {
             model.hfloor = row["hfloor"].ToString();
         }
         if (row["hsize"] != null)
         {
             model.hsize = row["hsize"].ToString();
         }
         if (row["harea"] != null && row["harea"].ToString() != "")
         {
             model.harea = int.Parse(row["harea"].ToString());
         }
         if (row["hcommunity"] != null)
         {
             model.hcommunity = row["hcommunity"].ToString();
         }
         if (row["hadress"] != null)
         {
             model.hadress = row["hadress"].ToString();
         }
         if (row["htime"] != null && row["htime"].ToString() != "")
         {
             model.htime = DateTime.Parse(row["htime"].ToString());
         }
         if (row["hmode"] != null && row["hmode"].ToString() != "")
         {
             model.hmode = int.Parse(row["hmode"].ToString());
         }
         if (row["hstatus"] != null && row["hstatus"].ToString() != "")
         {
             model.hstatus = int.Parse(row["hstatus"].ToString());
         }
     }
     return(model);
 }
コード例 #5
0
ファイル: HouseDao.cs プロジェクト: Pengxiaoxi/HouseRent
        //UpdateAll 包含外键更新
        public bool UpdateAll(myhouse.Model.House model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_house set ");
            strSql.Append("hname=@hname,");
            strSql.Append("hdescription=@hdescription,");
            strSql.Append("hmoney=@hmoney,");
            strSql.Append("htype=@htype,");
            strSql.Append("hphotoone=@hphotoone,");
            strSql.Append("hphototwo=@hphototwo,");
            strSql.Append("hphotothree=@hphotothree,");
            strSql.Append("hphotofour=@hphotofour,");
            strSql.Append("hfloor=@hfloor,");
            strSql.Append("hsize=@hsize,");
            strSql.Append("harea=@harea,");
            strSql.Append("hcommunity=@hcommunity,");
            strSql.Append("hadress=@hadress,");
            strSql.Append("htime=@htime,");
            strSql.Append("hmode=@hmode,");
            strSql.Append("hstatus=@hstatus,");
            strSql.Append("sid=@sid");           /*外键sid更新*/
            strSql.Append(" where hid=@hid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@hname",        SqlDbType.VarChar,    30),
                new SqlParameter("@hdescription", SqlDbType.VarChar,   200),
                new SqlParameter("@hmoney",       SqlDbType.VarChar,    10),
                new SqlParameter("@htype",        SqlDbType.Int,         4),
                new SqlParameter("@hphotoone",    SqlDbType.VarChar,   200),
                new SqlParameter("@hphototwo",    SqlDbType.VarChar,   200),
                new SqlParameter("@hphotothree",  SqlDbType.VarChar,   200),
                new SqlParameter("@hphotofour",   SqlDbType.VarChar,   200),
                new SqlParameter("@hfloor",       SqlDbType.Char,        4),
                new SqlParameter("@hsize",        SqlDbType.Char,        4),
                new SqlParameter("@harea",        SqlDbType.Int,         4),
                new SqlParameter("@hcommunity",   SqlDbType.VarChar,   100),
                new SqlParameter("@hadress",      SqlDbType.VarChar,   200),
                new SqlParameter("@htime",        SqlDbType.DateTime),
                new SqlParameter("@hmode",        SqlDbType.Int,         4),
                new SqlParameter("@hstatus",      SqlDbType.Int,         4),
                new SqlParameter("@hid",          SqlDbType.Int,         4),
                new SqlParameter("@cid",          SqlDbType.Int,         4),
                new SqlParameter("@uid",          SqlDbType.Int,         4),
                new SqlParameter("@sid",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.hname;
            parameters[1].Value  = model.hdescription;
            parameters[2].Value  = model.hmoney;
            parameters[3].Value  = model.htype;
            parameters[4].Value  = model.hphotoone;
            parameters[5].Value  = model.hphototwo;
            parameters[6].Value  = model.hphotothree;
            parameters[7].Value  = model.hphotofour;
            parameters[8].Value  = model.hfloor;
            parameters[9].Value  = model.hsize;
            parameters[10].Value = model.harea;
            parameters[11].Value = model.hcommunity;
            parameters[12].Value = model.hadress;
            parameters[13].Value = model.htime;
            parameters[14].Value = model.hmode;
            parameters[15].Value = model.hstatus;
            parameters[16].Value = model.hid;
            parameters[17].Value = model.cid;
            parameters[18].Value = model.uid;
            parameters[19].Value = model.sid;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #6
0
ファイル: Modify.aspx.cs プロジェクト: Pengxiaoxi/HouseRent
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txthname.Text.Trim().Length == 0)
            {
                strErr += "hname不能为空!\\n";
            }
            if (this.txthdescription.Text.Trim().Length == 0)
            {
                strErr += "hdescription不能为空!\\n";
            }
            if (this.txthmoney.Text.Trim().Length == 0)
            {
                strErr += "hmoney不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txthtype.Text))
            {
                strErr += "htype格式错误!\\n";
            }
            if (this.txthphotoone.Text.Trim().Length == 0)
            {
                strErr += "hphotoone不能为空!\\n";
            }
            if (this.txthphototwo.Text.Trim().Length == 0)
            {
                strErr += "hphototwo不能为空!\\n";
            }
            if (this.txthphotothree.Text.Trim().Length == 0)
            {
                strErr += "hphotothree不能为空!\\n";
            }
            if (this.txthphotofour.Text.Trim().Length == 0)
            {
                strErr += "hphotofour不能为空!\\n";
            }
            if (this.txthfloor.Text.Trim().Length == 0)
            {
                strErr += "hfloor不能为空!\\n";
            }
            if (this.txthsize.Text.Trim().Length == 0)
            {
                strErr += "hsize不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtharea.Text))
            {
                strErr += "harea格式错误!\\n";
            }
            if (this.txthcommunity.Text.Trim().Length == 0)
            {
                strErr += "hcommunity不能为空!\\n";
            }
            if (this.txthadress.Text.Trim().Length == 0)
            {
                strErr += "hadress不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txthtime.Text))
            {
                strErr += "htime格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txthmode.Text))
            {
                strErr += "hmode格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txthstatus.Text))
            {
                strErr += "hstatus格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      hid          = int.Parse(this.lblhid.Text);
            int      cid          = int.Parse(this.lblcid.Text);
            int      uid          = int.Parse(this.lbluid.Text);
            int      sid          = int.Parse(this.lblsid.Text);
            string   hname        = this.txthname.Text;
            string   hdescription = this.txthdescription.Text;
            string   hmoney       = this.txthmoney.Text;
            int      htype        = int.Parse(this.txthtype.Text);
            string   hphotoone    = this.txthphotoone.Text;
            string   hphototwo    = this.txthphototwo.Text;
            string   hphotothree  = this.txthphotothree.Text;
            string   hphotofour   = this.txthphotofour.Text;
            string   hfloor       = this.txthfloor.Text;
            string   hsize        = this.txthsize.Text;
            int      harea        = int.Parse(this.txtharea.Text);
            string   hcommunity   = this.txthcommunity.Text;
            string   hadress      = this.txthadress.Text;
            DateTime htime        = DateTime.Parse(this.txthtime.Text);
            int      hmode        = int.Parse(this.txthmode.Text);
            int      hstatus      = int.Parse(this.txthstatus.Text);


            myhouse.Model.House model = new myhouse.Model.House();
            model.hid          = hid;
            model.cid          = cid;
            model.uid          = uid;
            model.sid          = sid;
            model.hname        = hname;
            model.hdescription = hdescription;
            model.hmoney       = hmoney;
            model.htype        = htype;
            model.hphotoone    = hphotoone;
            model.hphototwo    = hphototwo;
            model.hphotothree  = hphotothree;
            model.hphotofour   = hphotofour;
            model.hfloor       = hfloor;
            model.hsize        = hsize;
            model.harea        = harea;
            model.hcommunity   = hcommunity;
            model.hadress      = hadress;
            model.htime        = htime;
            model.hmode        = hmode;
            model.hstatus      = hstatus;

            myhouse.BLL.HouseService bll = new myhouse.BLL.HouseService();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }