Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try         //--判断是否具有权限,若无权限回退到上一页
            {
                char[] AuthorityKey = Session["roleValue"].ToString().ToCharArray();
                if (AuthorityKey[50] == '0')
                {
                    Response.Write("<script>alert('无此权限');document.execCommand('stop');window.stop();window.history.back();</script>");
                }
            }
            catch
            {
                Response.Write("<script>alert('无此权限');document.execCommand('stop');window.stop();window.history.back();</script>");
            }           //--END


            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                UID              = (Convert.ToInt32(Request.Params["id"]));
                model            = bll.GetModel(UID);
                lblUserName.Text = model.RealName;
            }

            if (!IsPostBack)
            {
                ShowRole();
            }
        }
Exemple #2
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string RealName = this.txtRealName.Text;
            string UserName = this.txtUserName.Text;
            string Password = FormsAuthentication.HashPasswordForStoringInConfigFile(this.txtPassword.Text, "MD5");   //对密码进行MD5加密
            string Gender   = Request.Form["gender"].ToString();
            string BornDate = this.txtBornDate.Text;
            string Phone    = this.txtPhone.Text;
            string Address  = this.txtAddress.Text;
            string IDNumber = this.txtIDNumber.Text;
            int    RID      = 2008; //int.Parse(this.txtRID.Text);
            string AddDate  = DateTime.Now.ToString();

            CHSS.Model.CUser model = new CHSS.Model.CUser();
            model.RealName = RealName;
            model.UserName = UserName;
            model.Password = Password;
            model.Gender   = Gender;
            model.BornDate = BornDate;
            model.Phone    = Phone;
            model.Address  = Address;
            model.IDNumber = IDNumber;
            model.RID      = RID;
            model.AddDate  = AddDate;

            CHSS.BLL.CUser bll = new CHSS.BLL.CUser();
            bll.Add(model);
            Response.Redirect("Show.aspx?id=" + (bll.GetMaxId() - 1));
        }
Exemple #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(CHSS.Model.CUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CUser set ");
            strSql.Append("RealName=@RealName,");
            strSql.Append("UserName=@UserName,");
            strSql.Append("Password=@Password,");
            strSql.Append("Gender=@Gender,");
            strSql.Append("BornDate=@BornDate,");
            strSql.Append("Phone=@Phone,");
            strSql.Append("Address=@Address,");
            strSql.Append("IDNumber=@IDNumber,");
            //strSql.Append("AddDate=@AddDate,");
            strSql.Append("RID=@RID");
            strSql.Append(" where UID=@UID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RealName", SqlDbType.NVarChar, 20),
                new SqlParameter("@UserName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Password", SqlDbType.NVarChar, 50),
                new SqlParameter("@Gender",   SqlDbType.Char,      2),
                new SqlParameter("@BornDate", SqlDbType.VarChar,  20),
                new SqlParameter("@Phone",    SqlDbType.Char,     11),
                new SqlParameter("@Address",  SqlDbType.NVarChar, 50),
                new SqlParameter("@IDNumber", SqlDbType.VarChar,  18),
                //new SqlParameter("@AddDate", SqlDbType.NVarChar,20),
                new SqlParameter("@RID",      SqlDbType.Int,       4),
                new SqlParameter("@UID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RealName;
            parameters[1].Value = model.UserName;
            parameters[2].Value = model.Password;
            parameters[3].Value = model.Gender;
            parameters[4].Value = model.BornDate;
            parameters[5].Value = model.Phone;
            parameters[6].Value = model.Address;
            parameters[7].Value = model.IDNumber;
            //parameters[8].Value = model.AddDate;
            parameters[8].Value = model.RID;
            parameters[9].Value = model.UID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public CHSS.Model.CUser DataRowToModel(DataRow row)
 {
     CHSS.Model.CUser model = new CHSS.Model.CUser();
     if (row != null)
     {
         if (row["UID"] != null && row["UID"].ToString() != "")
         {
             model.UID = int.Parse(row["UID"].ToString());
         }
         if (row["RealName"] != null)
         {
             model.RealName = row["RealName"].ToString();
         }
         if (row["UserName"] != null)
         {
             model.UserName = row["UserName"].ToString();
         }
         if (row["Password"] != null)
         {
             model.Password = row["Password"].ToString();
         }
         if (row["Gender"] != null)
         {
             model.Gender = row["Gender"].ToString();
         }
         if (row["BornDate"] != null)
         {
             model.BornDate = row["BornDate"].ToString();
         }
         if (row["Phone"] != null)
         {
             model.Phone = row["Phone"].ToString();
         }
         if (row["Address"] != null)
         {
             model.Address = row["Address"].ToString();
         }
         if (row["IDNumber"] != null)
         {
             model.IDNumber = row["IDNumber"].ToString();
         }
         if (row["AddDate"] != null)
         {
             model.AddDate = row["AddDate"].ToString();
         }
         if (row["RID"] != null && row["RID"].ToString() != "")
         {
             model.RID = int.Parse(row["RID"].ToString());
         }
     }
     return(model);
 }
Exemple #5
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            foreach (ListItem li in MyRadioButtonList.Items)
            {
                if (li.Selected)
                {
                    model     = bll.GetModel(UID);
                    model.RID = Convert.ToInt32(li.Value);

                    bll.Update(model);
                    Response.Redirect("UserList.aspx?txtKeyword=" + model.UserName);
                }
            }
        }
Exemple #6
0
 private void ShowInfo(int UID)
 {
     CHSS.BLL.CUser   bll   = new CHSS.BLL.CUser();
     CHSS.Model.CUser model = bll.GetModel(UID);
     this.UID.Text         = model.UID.ToString();
     this.txtRealName.Text = model.RealName;
     this.txtUserName.Text = model.UserName;
     this.txtPassword.Text = model.Password + " (加密)";
     this.txtGender.Text   = model.Gender;
     this.txtBornDate.Text = model.BornDate;
     this.txtPhone.Text    = model.Phone;
     this.txtAddress.Text  = model.Address;
     this.txtIDNumber.Text = model.IDNumber;
     //this.txtRID.Text = model.RID.ToString();
 }
Exemple #7
0
 private void ShowInfo(int UID)
 {
     CHSS.BLL.CUser   bll   = new CHSS.BLL.CUser();
     CHSS.Model.CUser model = bll.GetModel(UID);
     this.UID.Text      = model.UID.ToString();
     this.RealName.Text = model.RealName;
     this.UserName.Text = model.UserName;
     this.Password.Text = model.Password + " (加密)";
     this.Gender.Text   = model.Gender;
     this.BornDate.Text = model.BornDate;
     this.Phone.Text    = model.Phone;
     this.Address.Text  = model.Address;
     this.IDNumber.Text = model.IDNumber;
     this.RoleName.Text = bll.GetList("UID=" + UID.ToString()).Tables[0].Rows[0]["RoleName"].ToString();
 }
Exemple #8
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(CHSS.Model.CUser model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CUser(");
            strSql.Append("RealName,UserName,Password,Gender,BornDate,Phone,Address,IDNumber,AddDate,RID)");
            strSql.Append(" values (");
            strSql.Append("@RealName,@UserName,@Password,@Gender,@BornDate,@Phone,@Address,@IDNumber,@AddDate,@RID)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RealName", SqlDbType.NVarChar, 20),
                new SqlParameter("@UserName", SqlDbType.NVarChar, 50),
                new SqlParameter("@Password", SqlDbType.NVarChar, 50),
                new SqlParameter("@Gender",   SqlDbType.Char,      2),
                new SqlParameter("@BornDate", SqlDbType.VarChar,  20),
                new SqlParameter("@Phone",    SqlDbType.Char,     11),
                new SqlParameter("@Address",  SqlDbType.NVarChar, 50),
                new SqlParameter("@IDNumber", SqlDbType.VarChar,  18),
                new SqlParameter("@AddDate",  SqlDbType.NVarChar, 20),
                new SqlParameter("@RID",      SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RealName;
            parameters[1].Value = model.UserName;
            parameters[2].Value = model.Password;
            parameters[3].Value = model.Gender;
            parameters[4].Value = model.BornDate;
            parameters[5].Value = model.Phone;
            parameters[6].Value = model.Address;
            parameters[7].Value = model.IDNumber;
            parameters[8].Value = model.AddDate;
            parameters[9].Value = model.RID;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #9
0
        public void btnSave_Click(object sender, EventArgs e)
        {
            int    UID      = int.Parse(this.UID.Text);
            string RealName = this.txtRealName.Text;
            string UserName = this.txtUserName.Text;
            //string Password = this.txtPassword.Text;
            string BornDate = this.txtBornDate.Text;
            string Phone    = this.txtPhone.Text;
            string Address  = this.txtAddress.Text;
            string IDNumber = this.txtIDNumber.Text;
            //int RID = int.Parse(this.txtRID.Text);
            string Gender = String.Empty;

            try
            {
                Gender = Request.Form["gender"].ToString();
            }
            catch
            {
                Gender = this.txtGender.Text;
            }


            if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
            {
                int              RequestUID = (Convert.ToInt32(Request.Params["id"]));
                CHSS.BLL.CUser   bll        = new CHSS.BLL.CUser();
                CHSS.Model.CUser model      = bll.GetModel(RequestUID);

                model.UID      = UID;
                model.RealName = RealName;
                model.UserName = UserName;
                //model.Password = Password;
                model.Gender   = Gender;
                model.BornDate = BornDate;
                model.Phone    = Phone;
                model.Address  = Address;
                model.IDNumber = IDNumber;
                //model.RID = RID;

                bll.Update(model);
            }
            Response.Redirect("Show.aspx?id=" + UID);
        }
Exemple #10
0
        protected void submit_Click(object sender, EventArgs e)
        {
            CHSS.Model.CUser model = new CHSS.Model.CUser();
            model.UserName = username.Text;
            model.Password = FormsAuthentication.HashPasswordForStoringInConfigFile(password.Text, "MD5");   //对密码进行MD5加密
            model.BornDate = birthday.Text;
            model.Phone    = phonenumber.Text;
            model.Address  = address.Text;
            model.IDNumber = idcard.Text;
            //-----
            model.AddDate  = DateTime.Now.ToString();
            model.RealName = "某某";
            model.Gender   = Request.Form["gender"].ToString();
            model.RID      = 2008;

            CHSS.BLL.CUser bll = new CHSS.BLL.CUser();
            bll.Add(model);
            Response.Redirect("Login.aspx?userName="******"&msg=恭喜注册成功,请登录!");
        }
Exemple #11
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public CHSS.Model.CUser GetModel(int UID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 UID,RealName,UserName,Password,Gender,BornDate,Phone,Address,IDNumber,AddDate,RID from CUser ");
            strSql.Append(" where UID=@UID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@UID", SqlDbType.Int, 4)
            };
            parameters[0].Value = UID;

            CHSS.Model.CUser model = new CHSS.Model.CUser();
            DataSet          ds    = DBHelper.Query(strSql.ToString(), parameters);

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