示例#1
0
 public void LoadEntity(User userInfo, DataRow row)
 {
     userInfo.ID = Convert.ToInt64(row["ID"]);
       userInfo.email= row["email"].ToString();
       userInfo.nickname = row["nickname"].ToString();
       userInfo.phone= row["phone"].ToString();
       userInfo.sex = row["sex"].ToString();
       userInfo.belongs=row["belongs"].ToString();
       userInfo.position = row["position"].ToString();
       userInfo.type = row["type"].ToString();
 }
示例#2
0
 public User GetUserInfo(string name,string pass)
 {
     string sql = "select * from [UserInfo] where ID=@username and pwd=@pwd;";
       SqlParameter[] pars ={
                          new SqlParameter("@username",SqlDbType.NVarChar,32),
                          new SqlParameter("@pwd",SqlDbType.NVarChar,32),
                          };
       pars[0].Value = name;
       pars[1].Value = pass;
       DataTable da = SqlHelper.GetTable(sql, CommandType.Text, pars);
       User userInfo = null;
       if (da.Rows.Count > 0)
       {
       userInfo = new User();
       LoadEntity(userInfo, da.Rows[0]);
       }
       return userInfo;
 }
示例#3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string username = UserName.Value.Trim();
            string password = Password.Value;

            Model.User u = DAL.UserRule.Get(username);
            if (u.Password == St.GetMd5(username + password) && u.Status == 1)
            {
                Session["user"] = u;
                St.SetCookie("user", u.UserName, DateTime.Now.AddYears(1));
                St.SetCookie("user2", u.Password, DateTime.Now.AddYears(1));
                Response.Redirect("Default.aspx");
            }
            else
            {
                divError.Visible = true;
            }
        }