Esempio n. 1
0
 private void ShowInfo(int cid)
 {
     myhouse.BLL.ContractService bll   = new myhouse.BLL.ContractService();
     myhouse.Model.Contract      model = bll.GetModel(cid);
     this.lblcid.Text      = model.cid.ToString();
     this.lbluid.Text      = model.uid.ToString();
     this.lblhid.Text      = model.hid.ToString();
     this.lblcname.Text    = model.cname;
     this.lblccontent.Text = model.ccontent;
     this.lblcphoto.Text   = model.cphoto;
     this.lblcstatus.Text  = model.cstatus.ToString();
 }
Esempio n. 2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtuid.Text))
            {
                strErr += "uid格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txthid.Text))
            {
                strErr += "hid格式错误!\\n";
            }
            if (this.txtcname.Text.Trim().Length == 0)
            {
                strErr += "cname不能为空!\\n";
            }
            if (this.txtccontent.Text.Trim().Length == 0)
            {
                strErr += "ccontent不能为空!\\n";
            }
            if (this.txtcphoto.Text.Trim().Length == 0)
            {
                strErr += "cphoto不能为空!\\n";
            }
            if (!PageValidate.IsNumber(txtcstatus.Text))
            {
                strErr += "cstatus格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    uid      = int.Parse(this.txtuid.Text);
            int    hid      = int.Parse(this.txthid.Text);
            string cname    = this.txtcname.Text;
            string ccontent = this.txtccontent.Text;
            string cphoto   = this.txtcphoto.Text;
            int    cstatus  = int.Parse(this.txtcstatus.Text);

            myhouse.Model.Contract model = new myhouse.Model.Contract();
            model.uid      = uid;
            model.hid      = hid;
            model.cname    = cname;
            model.ccontent = ccontent;
            model.cphoto   = cphoto;
            model.cstatus  = cstatus;

            myhouse.BLL.ContractService bll = new myhouse.BLL.ContractService();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Esempio n. 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(myhouse.Model.Contract model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_contract set ");
            strSql.Append("cname=@cname,");
            strSql.Append("ccontent=@ccontent,");
            strSql.Append("cphoto=@cphoto,");
            strSql.Append("cstatus=@cstatus");
            strSql.Append(" where cid=@cid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@cname",    SqlDbType.VarChar,   30),
                new SqlParameter("@ccontent", SqlDbType.VarChar, 2000),
                new SqlParameter("@cphoto",   SqlDbType.VarChar,   50),
                new SqlParameter("@cstatus",  SqlDbType.Int,        4),
                new SqlParameter("@cid",      SqlDbType.Int,        4),
                new SqlParameter("@uid",      SqlDbType.Int,        4),
                new SqlParameter("@hid",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.cname;
            parameters[1].Value = model.ccontent;
            parameters[2].Value = model.cphoto;
            parameters[3].Value = model.cstatus;
            parameters[4].Value = model.cid;
            parameters[5].Value = model.uid;
            parameters[6].Value = model.hid;

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

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

            strSql.Append("insert into t_contract(");
            strSql.Append("uid,hid,cname,ccontent,cphoto,cstatus)");
            strSql.Append(" values (");
            strSql.Append("@uid,@hid,@cname,@ccontent,@cphoto,@cstatus)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@uid",      SqlDbType.Int,        4),
                new SqlParameter("@hid",      SqlDbType.Int,        4),
                new SqlParameter("@cname",    SqlDbType.VarChar,   30),
                new SqlParameter("@ccontent", SqlDbType.VarChar, 2000),
                new SqlParameter("@cphoto",   SqlDbType.VarChar,   50),
                new SqlParameter("@cstatus",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.uid;
            parameters[1].Value = model.hid;
            parameters[2].Value = model.cname;
            parameters[3].Value = model.ccontent;
            parameters[4].Value = model.cphoto;
            parameters[5].Value = model.cstatus;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public myhouse.Model.Contract DataRowToModel(DataRow row)
 {
     myhouse.Model.Contract model = new myhouse.Model.Contract();
     if (row != null)
     {
         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["hid"] != null && row["hid"].ToString() != "")
         {
             model.hid = int.Parse(row["hid"].ToString());
         }
         if (row["cname"] != null)
         {
             model.cname = row["cname"].ToString();
         }
         if (row["ccontent"] != null)
         {
             model.ccontent = row["ccontent"].ToString();
         }
         if (row["cphoto"] != null)
         {
             model.cphoto = row["cphoto"].ToString();
         }
         if (row["cstatus"] != null && row["cstatus"].ToString() != "")
         {
             model.cstatus = int.Parse(row["cstatus"].ToString());
         }
     }
     return(model);
 }
Esempio n. 6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public myhouse.Model.Contract GetModel(int cid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 cid,uid,hid,cname,ccontent,cphoto,cstatus from t_contract ");
            strSql.Append(" where cid=@cid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@cid", SqlDbType.Int, 4)
            };
            parameters[0].Value = cid;

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

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