Пример #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(myhouse.Model.User model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into t_user(");
            strSql.Append("unickname,uname,usex,uphoto,ucard,ucardphoto,upassword,utel,uqq,uemail,uregtime,ucredit,utype)");
            strSql.Append(" values (");
            strSql.Append("@unickname,@uname,@usex,@uphoto,@ucard,@ucardphoto,@upassword,@utel,@uqq,@uemail,@uregtime,@ucredit,@utype)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@unickname",  SqlDbType.VarChar,    20),
                new SqlParameter("@uname",      SqlDbType.Char,       16),
                new SqlParameter("@usex",       SqlDbType.Char,        2),
                new SqlParameter("@uphoto",     SqlDbType.VarChar,   100),
                new SqlParameter("@ucard",      SqlDbType.Char,       18),
                new SqlParameter("@ucardphoto", SqlDbType.VarChar,    50),
                new SqlParameter("@upassword",  SqlDbType.VarChar,    50),
                new SqlParameter("@utel",       SqlDbType.Char,       13),
                new SqlParameter("@uqq",        SqlDbType.Char,       15),
                new SqlParameter("@uemail",     SqlDbType.VarChar,    30),
                new SqlParameter("@uregtime",   SqlDbType.DateTime),
                new SqlParameter("@ucredit",    SqlDbType.Char,        8),
                new SqlParameter("@utype",      SqlDbType.Char, 4)
            };
            parameters[0].Value  = model.unickname;
            parameters[1].Value  = model.uname;
            parameters[2].Value  = model.usex;
            parameters[3].Value  = model.uphoto;
            parameters[4].Value  = model.ucard;
            parameters[5].Value  = model.ucardphoto;
            parameters[6].Value  = model.upassword;
            parameters[7].Value  = model.utel;
            parameters[8].Value  = model.uqq;
            parameters[9].Value  = model.uemail;
            parameters[10].Value = model.uregtime;
            parameters[11].Value = model.ucredit;
            parameters[12].Value = model.utype;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Пример #2
0
 private void ShowInfo(int uid)
 {
     myhouse.BLL.UserService bll   = new myhouse.BLL.UserService();
     myhouse.Model.User      model = bll.GetModel(uid);
     this.lbluid.Text        = model.uid.ToString();
     this.lblunickname.Text  = model.unickname;
     this.lbluname.Text      = model.uname;
     this.lblusex.Text       = model.usex;
     this.lbluphoto.Text     = model.uphoto;
     this.lblucard.Text      = model.ucard;
     this.lblucardphoto.Text = model.ucardphoto;
     this.lblupassword.Text  = model.upassword;
     this.lblutel.Text       = model.utel;
     this.lbluqq.Text        = model.uqq;
     this.lbluemail.Text     = model.uemail;
     this.lbluregtime.Text   = model.uregtime.ToString();
     this.lblucredit.Text    = model.ucredit;
     this.lblutype.Text      = model.utype;
 }
Пример #3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public myhouse.Model.User GetModel(int uid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 uid,unickname,uname,usex,uphoto,ucard,ucardphoto,upassword,utel,uqq,uemail,uregtime,ucredit,utype from t_user ");
            strSql.Append(" where uid=@uid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@uid", SqlDbType.Int, 4)
            };
            parameters[0].Value = uid;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (this.txtunickname.Text.Trim().Length == 0)
            {
                strErr += "unickname不能为空!\\n";
            }
            if (this.txtuname.Text.Trim().Length == 0)
            {
                strErr += "uname不能为空!\\n";
            }
            if (this.txtusex.Text.Trim().Length == 0)
            {
                strErr += "usex不能为空!\\n";
            }
            if (this.txtuphoto.Text.Trim().Length == 0)
            {
                strErr += "uphoto不能为空!\\n";
            }
            if (this.txtucardphoto.Text.Trim().Length == 0)
            {
                strErr += "ucardphoto不能为空!\\n";
            }
            if (this.txtupassword.Text.Trim().Length == 0)
            {
                strErr += "upassword不能为空!\\n";
            }
            if (this.txtutel.Text.Trim().Length == 0)
            {
                strErr += "utel不能为空!\\n";
            }
            if (this.txtuqq.Text.Trim().Length == 0)
            {
                strErr += "uqq不能为空!\\n";
            }
            if (this.txtuemail.Text.Trim().Length == 0)
            {
                strErr += "uemail不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txturegtime.Text))
            {
                strErr += "uregtime格式错误!\\n";
            }
            if (this.txtucredit.Text.Trim().Length == 0)
            {
                strErr += "ucredit不能为空!\\n";
            }
            if (this.txtutype.Text.Trim().Length == 0)
            {
                strErr += "utype不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      uid        = int.Parse(this.lbluid.Text);
            string   unickname  = this.txtunickname.Text;
            string   uname      = this.txtuname.Text;
            string   usex       = this.txtusex.Text;
            string   uphoto     = this.txtuphoto.Text;
            string   ucard      = this.lblucard.Text;
            string   ucardphoto = this.txtucardphoto.Text;
            string   upassword  = this.txtupassword.Text;
            string   utel       = this.txtutel.Text;
            string   uqq        = this.txtuqq.Text;
            string   uemail     = this.txtuemail.Text;
            DateTime uregtime   = DateTime.Parse(this.txturegtime.Text);
            string   ucredit    = this.txtucredit.Text;
            string   utype      = this.txtutype.Text;


            myhouse.Model.User model = new myhouse.Model.User();
            model.uid        = uid;
            model.unickname  = unickname;
            model.uname      = uname;
            model.usex       = usex;
            model.uphoto     = uphoto;
            model.ucard      = ucard;
            model.ucardphoto = ucardphoto;
            model.upassword  = upassword;
            model.utel       = utel;
            model.uqq        = uqq;
            model.uemail     = uemail;
            model.uregtime   = uregtime;
            model.ucredit    = ucredit;
            model.utype      = utype;

            myhouse.BLL.UserService bll = new myhouse.BLL.UserService();
            bll.Update(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "list.aspx");
        }
Пример #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public myhouse.Model.User DataRowToModel(DataRow row)
 {
     myhouse.Model.User model = new myhouse.Model.User();
     if (row != null)
     {
         if (row["uid"] != null && row["uid"].ToString() != "")
         {
             model.uid = int.Parse(row["uid"].ToString());
         }
         if (row["unickname"] != null)
         {
             model.unickname = row["unickname"].ToString();
         }
         if (row["uname"] != null)
         {
             model.uname = row["uname"].ToString();
         }
         if (row["usex"] != null)
         {
             model.usex = row["usex"].ToString();
         }
         if (row["uphoto"] != null)
         {
             model.uphoto = row["uphoto"].ToString();
         }
         if (row["ucard"] != null)
         {
             model.ucard = row["ucard"].ToString();
         }
         if (row["ucardphoto"] != null)
         {
             model.ucardphoto = row["ucardphoto"].ToString();
         }
         if (row["upassword"] != null)
         {
             model.upassword = row["upassword"].ToString();
         }
         if (row["utel"] != null)
         {
             model.utel = row["utel"].ToString();
         }
         if (row["uqq"] != null)
         {
             model.uqq = row["uqq"].ToString();
         }
         if (row["uemail"] != null)
         {
             model.uemail = row["uemail"].ToString();
         }
         if (row["uregtime"] != null && row["uregtime"].ToString() != "")
         {
             model.uregtime = DateTime.Parse(row["uregtime"].ToString());
         }
         if (row["ucredit"] != null)
         {
             model.ucredit = row["ucredit"].ToString();
         }
         if (row["utype"] != null)
         {
             model.utype = row["utype"].ToString();
         }
     }
     return(model);
 }
Пример #6
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(myhouse.Model.User model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update t_user set ");
            strSql.Append("unickname=@unickname,");
            strSql.Append("uname=@uname,");
            strSql.Append("usex=@usex,");
            strSql.Append("uphoto=@uphoto,");
            strSql.Append("ucard=@ucard,");
            strSql.Append("ucardphoto=@ucardphoto,");
            strSql.Append("upassword=@upassword,");
            strSql.Append("utel=@utel,");
            strSql.Append("uqq=@uqq,");
            strSql.Append("uemail=@uemail,");
            strSql.Append("uregtime=@uregtime,");
            strSql.Append("ucredit=@ucredit,");
            strSql.Append("utype=@utype");
            strSql.Append(" where uid=@uid");
            SqlParameter[] parameters =
            {
                new SqlParameter("@unickname",  SqlDbType.VarChar,    20),
                new SqlParameter("@uname",      SqlDbType.Char,       16),
                new SqlParameter("@usex",       SqlDbType.Char,        2),
                new SqlParameter("@uphoto",     SqlDbType.VarChar,   100),
                new SqlParameter("@ucardphoto", SqlDbType.VarChar,    50),
                new SqlParameter("@upassword",  SqlDbType.VarChar,    50),
                new SqlParameter("@utel",       SqlDbType.Char,       13),
                new SqlParameter("@uqq",        SqlDbType.Char,       15),
                new SqlParameter("@uemail",     SqlDbType.VarChar,    30),
                new SqlParameter("@uregtime",   SqlDbType.DateTime),
                new SqlParameter("@ucredit",    SqlDbType.Char,        8),
                new SqlParameter("@utype",      SqlDbType.Char,        4),
                new SqlParameter("@uid",        SqlDbType.Int,         4),
                new SqlParameter("@ucard",      SqlDbType.Char, 18)
            };
            parameters[0].Value  = model.unickname;
            parameters[1].Value  = model.uname;
            parameters[2].Value  = model.usex;
            parameters[3].Value  = model.uphoto;
            parameters[4].Value  = model.ucardphoto;
            parameters[5].Value  = model.upassword;
            parameters[6].Value  = model.utel;
            parameters[7].Value  = model.uqq;
            parameters[8].Value  = model.uemail;
            parameters[9].Value  = model.uregtime;
            parameters[10].Value = model.ucredit;
            parameters[11].Value = model.utype;
            parameters[12].Value = model.uid;
            parameters[13].Value = model.ucard;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }