Example #1
0
 private void ShowInfo(int id)
 {
     Movie.BLL.users   bll   = new Movie.BLL.users();
     Movie.Model.users model = bll.GetModel(id);
     this.lblid.Text       = model.id.ToString();
     this.lbluname.Text    = model.uname;
     this.lblpwd.Text      = model.pwd;
     this.lblrealname.Text = model.realname;
     this.lblsex.Text      = model.sex;
     this.lblbirthday.Text = model.birthday;
     this.lblcontact.Text  = model.contact;
     this.lblemail.Text    = model.email;
 }
Example #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            dtCate = dalCate.GetList("").Tables[0];

            dtTop = dalArticle.GetList("").Tables[0];
            dtImg = dalArticle.GetList("").Tables[0];
            if (HttpContext.Current.Session["User"] != null)
            {
                try
                {
                    user = (Model.users)(HttpContext.Current.Session["User"]);
                }
                catch { }
                finally { }
            }
        }
Example #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Movie.Model.users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update users set ");
            strSql.Append("uname=@SQL2012uname,");
            strSql.Append("pwd=@SQL2012pwd,");
            strSql.Append("realname=@SQL2012realname,");
            strSql.Append("sex=@SQL2012sex,");
            strSql.Append("birthday=@SQL2012birthday,");
            strSql.Append("contact=@SQL2012contact,");
            strSql.Append("email=@SQL2012email");
            strSql.Append(" where id=@SQL2012id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SQL2012uname",    SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012pwd",      SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012realname", SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012sex",      SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012birthday", SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012contact",  SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012email",    SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012id",       SqlDbType.Int, 4)
            };
            parameters[0].Value = model.uname;
            parameters[1].Value = model.pwd;
            parameters[2].Value = model.realname;
            parameters[3].Value = model.sex;
            parameters[4].Value = model.birthday;
            parameters[5].Value = model.contact;
            parameters[6].Value = model.email;
            parameters[7].Value = model.id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Movie.Model.users DataRowToModel(DataRow row)
 {
     Movie.Model.users model = new Movie.Model.users();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["uname"] != null)
         {
             model.uname = row["uname"].ToString();
         }
         if (row["pwd"] != null)
         {
             model.pwd = row["pwd"].ToString();
         }
         if (row["realname"] != null)
         {
             model.realname = row["realname"].ToString();
         }
         if (row["sex"] != null)
         {
             model.sex = row["sex"].ToString();
         }
         if (row["birthday"] != null)
         {
             model.birthday = row["birthday"].ToString();
         }
         if (row["contact"] != null)
         {
             model.contact = row["contact"].ToString();
         }
         if (row["email"] != null)
         {
             model.email = row["email"].ToString();
         }
     }
     return(model);
 }
Example #5
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Movie.Model.users model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into users(");
            strSql.Append("id,uname,pwd,realname,sex,birthday,contact,email)");
            strSql.Append(" values (");
            strSql.Append("@SQL2012id,@SQL2012uname,@SQL2012pwd,@SQL2012realname,@SQL2012sex,@SQL2012birthday,@SQL2012contact,@SQL2012email)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SQL2012id",       SqlDbType.Int,       4),
                new SqlParameter("@SQL2012uname",    SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012pwd",      SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012realname", SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012sex",      SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012birthday", SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012contact",  SqlDbType.VarChar, 255),
                new SqlParameter("@SQL2012email",    SqlDbType.VarChar, 255)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.uname;
            parameters[2].Value = model.pwd;
            parameters[3].Value = model.realname;
            parameters[4].Value = model.sex;
            parameters[5].Value = model.birthday;
            parameters[6].Value = model.contact;
            parameters[7].Value = model.email;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #6
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Movie.Model.users GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,uname,pwd,realname,sex,birthday,contact,email from users ");
            strSql.Append(" where id=@SQL2012id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@SQL2012id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #7
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txtid.Text))
            {
                strErr += "id格式错误!\\n";
            }
            if (this.txtuname.Text.Trim().Length == 0)
            {
                strErr += "uname不能为空!\\n";
            }
            if (this.txtpwd.Text.Trim().Length == 0)
            {
                strErr += "pwd不能为空!\\n";
            }
            if (this.txtrealname.Text.Trim().Length == 0)
            {
                strErr += "realname不能为空!\\n";
            }
            if (this.txtsex.Text.Trim().Length == 0)
            {
                strErr += "sex不能为空!\\n";
            }
            if (this.txtbirthday.Text.Trim().Length == 0)
            {
                strErr += "birthday不能为空!\\n";
            }
            if (this.txtcontact.Text.Trim().Length == 0)
            {
                strErr += "contact不能为空!\\n";
            }
            if (this.txtemail.Text.Trim().Length == 0)
            {
                strErr += "email不能为空!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int    id       = int.Parse(this.txtid.Text);
            string uname    = this.txtuname.Text;
            string pwd      = this.txtpwd.Text;
            string realname = this.txtrealname.Text;
            string sex      = this.txtsex.Text;
            string birthday = this.txtbirthday.Text;
            string contact  = this.txtcontact.Text;
            string email    = this.txtemail.Text;

            Movie.Model.users model = new Movie.Model.users();
            model.id       = id;
            model.uname    = uname;
            model.pwd      = pwd;
            model.realname = realname;
            model.sex      = sex;
            model.birthday = birthday;
            model.contact  = contact;
            model.email    = email;

            Movie.BLL.users bll = new Movie.BLL.users();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }