示例#1
0
 /// <summary>
 /// 根据session判断是否登录
 /// </summary>
 /// <returns></returns>
 public bool IsUserLogin()
 {
     if (HttpContext.Current.Session[Keys.SESSION_USER_INFO] != null)
     {
         user = HttpContext.Current.Session[Keys.SESSION_USER_INFO] as UserInfo;
         return true;
     }
     return false;
 }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (!IsUserLogin())
         {
             user = GetUserInfo();
         }
         Bind();
     }
 }
示例#3
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            string user_name = txt_user_name.Text.Trim().ToString();
            string password = txt_user_pwd.Text.Trim().ToString();
            UserInfo user = new UserInfo();
            user = UserBLL.GetUserInfo(user_name, password);
            if (user != null)
            {
                HttpContext.Current.Session[Keys.SESSION_USER_INFO] = user;
                HttpContext.Current.Session.Timeout = 45;

                //写入cookie,时间为1周
                if (cb_check.Checked == true)
                {
                    Utils.WriteCookie(Keys.COOKIE_USER_NAME_REMEMBER, "BDUser", user.User_Name, 10080);
                    Utils.WriteCookie(Keys.COOKIE_USER_PWD_REMEMBER, "BDUser", user.Password, 10080);
                }

                Session["user_id"] = user.Id.ToString();
                Session["status"] = user.Status.ToString();
                if (Session["status"].ToString() == "Y")
                {
                    if (Session["status"].ToString() == "N")
                    {
                        Session["error_message"] = "该账号未激活,请登录你的注册邮箱激活";
                        this.lab_mess.Text = "该账号未激活,请登录你的注册邮箱激活";

                        //WebCom.ShowAlert(this.Page, "系统提示!", "error", "该账号未激活,请登录你的注册邮箱激活");
                    }
                    else
                    {
                        if (HttpContext.Current.Session[Keys.COOKIE_URL_REFERRER] != null)
                        {
                            Response.Redirect(HttpContext.Current.Session[Keys.COOKIE_URL_REFERRER].ToString());
                        }
                        Response.Redirect("Index.aspx");
                    }
                }
                else
                {
                    Session["error_message"] = "请输入正确的用户名和密码";
                    this.lab_mess.Text = "请输入正确的用户名和密码";
                    return;
                }
                //HttpContext.Current.Response.Redirect(preUrl);//跳转到登录前页面
            }
            else
            {
                Session["error_message"] = "请输入正确的用户名和密码";
                this.lab_mess.Text = "请输入正确的用户名和密码";
                return;
            }
        }
示例#4
0
 protected void btn_submit_Click(object sender, EventArgs e)
 {
     string user_name = txt_user_name.Text.ToString();
     string password = txt_password.Text.ToString();
     string email = txt_email.Text.ToString();
     UserInfo u = new UserInfo();
     u.User_Name = user_name;
     u.Password = password;
     u.E_Mail = email;
     bool result = UserBLL.Register(u);
     if (result)
     {
         UserInfo user = new UserInfo();
         //user = UserBLL.GetUser(u);
         Session["user_id"] = user.Id;
         Response.Redirect("Success.aspx");
     }
 }
示例#5
0
 /// <summary>
 /// 根据Id获取实体
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public UserInfo GetById(int id)
 {
     UserInfo user = new UserInfo();
     StringBuilder sql = new StringBuilder();
     sql.Append("select Id,User_Name,Password,Nick_Name,Real_Name,Score,User_Photo_Url,Birthday,Income,Marry_Status,");
     sql.Append(" E_Mail,Phone_Number,User_Type,Hobby,Address,School_Type,School,Department,Enrolled_Date,Company_Name,");
     sql.Append(" Worked_Begin_Date,Status from BigDog_User where Id='" + id + "'");
     DataTable dt = new DataTable();
     dt = SQLHelper.GetDs(sql.ToString()).Tables[0];
     if (dt.Rows.Count > 0)
     {
         user.Id = Convert.ToInt32(dt.Rows[0]["Id"].ToString());
         user.User_Name = dt.Rows[0][1].ToString();
         user.Password = dt.Rows[0][2].ToString();
         user.Nick_Name = dt.Rows[0][3].ToString();
         user.Real_Name = dt.Rows[0][4].ToString();
         user.Score = Convert.ToInt32(dt.Rows[0][5].ToString());
         user.User_Photo_Url = dt.Rows[0][6].ToString();
         //user.Birthday =  Convert.ToDateTime(dt.Rows[0][7]) == null ? null : dt.Rows[0][7];
         user.Income = dt.Rows[0][8].ToString();
         user.Marry_Status = dt.Rows[0][9].ToString();
         user.E_Mail = dt.Rows[0][10].ToString();
         user.Phone_Number = dt.Rows[0][11].ToString();
         //user.User_Type =dt.Rows[0][12]==null? 0 : Convert.ToInt32( dt.Rows[0][12].ToString());
         user.Hobby = dt.Rows[0][13].ToString();
         user.Address = dt.Rows[0][14].ToString();
         user.School_Type = dt.Rows[0][15].ToString();
         user.School = dt.Rows[0][16].ToString();
         user.Department = dt.Rows[0][17].ToString();
         user.Enrolled_Date = dt.Rows[0][18].ToString();
         user.Company_Name = dt.Rows[0][19].ToString();
         user.Worked_Begin_Time = dt.Rows[0][20].ToString();
         user.Status = dt.Rows[0][21].ToString();
         return user;
     }
     else
     {
         return null;
     }
 }
示例#6
0
        /// <summary>
        /// 根据userId获取user实体对象
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public UserInfo GetById(int userId)
        {
            UserInfo user = new UserInfo();
            StringBuilder sql = new StringBuilder();
            sql.Append("select Id,User_Name,Password,Nick_Name,Real_Name,Score,User_Photo_Url,Birthday,Income,Marry_Status,");
            sql.Append(" E_Mail,Phone_Number,User_Type,Hobby,Address,School_Type,School,Department,Enrolled_Date,Company_Name,");
            sql.Append(" Worked_Time_Begin,Worked_Time_End,Status from BigDog_User where Id='" + userId + "'");
            DataTable dt = OracleHelper.GetDS(sql.ToString()).Tables[0];
            try
            {
                if (dt.Rows.Count > 0)
                {
                    user.Id = Convert.ToInt32(dt.Rows[0][0].ToString());
                    user.User_Name = dt.Rows[0][1].ToString();
                    user.Password = dt.Rows[0][2].ToString();
                    user.Nick_Name = dt.Rows[0][3].ToString();
                    user.Real_Name = dt.Rows[0][4].ToString();
                    user.User_Photo_Url = dt.Rows[0][5].ToString();
                    //user.Birthday = Convert.ToDateTime( dt.Rows[0][6].ToString());
                    user.Income = dt.Rows[0][7].ToString();
                    user.Score = Convert.ToInt32(dt.Rows[0][8].ToString());
                    user.Income = dt.Rows[0][9].ToString();
                    user.E_Mail = dt.Rows[0][10].ToString();
                    user.Phone_Number = dt.Rows[0][11].ToString();
                    //user.Birthday = Convert.ToDateTime( dt.Rows[0][12].ToString());
                    user.User_Type = Convert.ToInt32(dt.Rows[0][12].ToString());
                    user.School = dt.Rows[0][14].ToString();
                    user.Address = dt.Rows[0][15].ToString();
                    user.School_Type = dt.Rows[0][16].ToString();
                    user.School = dt.Rows[0][17].ToString();
                    user.Department = dt.Rows[0][18].ToString();
                    //user.Enrolled_Date = dt.Rows[0][27].ToString();
                    user.Company_Name = dt.Rows[0][20].ToString();

                    user.Status = dt.Rows[0][21].ToString();
                }
            }
            catch (OleDbException ex)
            {
                user = null;
                throw new Exception(ex.Message);
            }
            return user;
        }
示例#7
0
 /// <summary>
 /// 修改密码
 /// </summary>
 /// <param name="user"></param>
 /// <param name="emailCode">E_Mail密码</param>
 /// <returns></returns>
 public bool UpdatePwd(UserInfo user)
 {
     StringBuilder sqlStr = new StringBuilder();
     sqlStr.Append("update BigDog_User set Password='******' where Id='" + user.Id + "'");
     return OracleHelper.ExeSQL(sqlStr.ToString()) > 0;
 }
示例#8
0
 /// <summary>
 /// 更新user对象
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool Update(UserInfo user)
 {
     try
     {
         StringBuilder sql = new StringBuilder();
         string[] param = new string[] { user.Password, user.Nick_Name, user.User_Photo_Url, user.Hobby, user.E_Mail, user.Phone_Number, user.Address, user.Hobby };
         sql.AppendFormat("update BigDog_User set user_name='{0}',nick_name='{1}',real_name='{2}',hobby='{3}',E_Mail='{4}',Phone_Number='{5}',address='{6}',updated_date=sysdate,Hobby='{7}' where Id='" + user.Id + "'", param);
         return OracleHelper.ExeSQL(sql.ToString()) > 0;
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
 }
示例#9
0
        /// <summary>
        /// 用户注册
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public bool Register(UserInfo user)
        {
            using (OleDbConnection conn = new OleDbConnection(OracleHelper.ConnString))
            {

                conn.Open();
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection = conn;
                OleDbTransaction trans = conn.BeginTransaction();
                cmd.Transaction = trans;
                try
                {
                    StringBuilder sql = new StringBuilder();
                    sql.Append("insert into BigDog_User(Id,E_Mail,user_name,Password) values(BigDog_User_seq.nextval,'" + user.E_Mail + "','" + user.Password + "','" + user.Real_Name + "')");
                    cmd.Parameters.Clear();
                    cmd.CommandText = sql.ToString();
                    int n1 = cmd.ExecuteNonQuery();

                    string key = Guid.NewGuid().ToString();
                    string param2 = string.Format("{0}|||{0}|{1}", user.E_Mail, key);
                    StringBuilder mailSql = new StringBuilder();
                    mailSql.Append("insert into common_mail_notice(mail_id,mail_info_id,params,mailed,mailed_date,creator,creation_date)");
                    mailSql.AppendFormat(" values(common_mail_notice_seq.nextval,'3','{0}','N',sysdate,'sys',sysdate)", param2);//3,用户注册,4修改密码
                    cmd.Parameters.Clear();
                    cmd.CommandText = mailSql.ToString();
                    int n2 = cmd.ExecuteNonQuery();
                    if (n1 > 0 && n2 > 0)
                    {
                        trans.Commit();
                        return true;
                    }
                    else
                    {
                        trans.Rollback();
                        return false;
                    }
                }
                catch (Exception ex)
                {
                    return false;
                    throw new Exception(ex.Message);
                }
            }
        }
示例#10
0
 /// <summary>
 /// 根据用户名密码获取用户信息
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public UserInfo GetUserInfo(string user_name, string password)
 {
     UserInfo user = new UserInfo();
     StringBuilder sql = new StringBuilder();
     sql.Append("select Id,User_Name,Password,Nick_Name,Real_Name,Score,User_Photo_Url,Birthday,Income,Marry_Status,");
     sql.Append(" E_Mail,Phone_Number,User_Type,Hobby,Address,School_Type,School,Department,EnrollDate,Company_Name,");
     sql.Append(" WorkingTime,Status from Users where user_name='" + user_name + "' and password='******'");
     DataTable dt = OracleHelper.GetDS(sql.ToString()).Tables[0];
     try
     {
         if (dt.Rows.Count > 0)
         {
             user.Id = Convert.ToInt32(dt.Rows[0]["Id"].ToString());
             user.User_Name = dt.Rows[0]["User_Name"].ToString();
             user.E_Mail = dt.Rows[0]["E_Mail"].ToString();
             user.Hobby = dt.Rows[0]["Hobby"].ToString();
             user.Nick_Name = dt.Rows[0]["Nick_Name"].ToString();
             user.User_Photo_Url = dt.Rows[0]["User_Photo_Url"].ToString();
             user.Phone_Number = dt.Rows[0]["Phone_Number"].ToString();
             user.Address = dt.Rows[0]["Address"].ToString();
             user.Score = Convert.ToInt32(dt.Rows[0]["Score"].ToString());
             user.Income = dt.Rows[0]["Income"].ToString();
             user.Birthday = Convert.ToDateTime(dt.Rows[0]["Birthday"].ToString());
             user.User_Name = dt.Rows[0][""].ToString();
             user.School = dt.Rows[0][""].ToString();
             user.User_Type = Convert.ToInt32(dt.Rows[0][""].ToString());
             user.Real_Name = dt.Rows[0][""].ToString();
             user.Status = dt.Rows[0][""].ToString();
         }
         else
         {
             user = null;
             return user;
         }
     }
     catch (OleDbException ex)
     {
         user = null;
         throw new Exception(ex.Message);
     }
     return user;
 }
示例#11
0
 /// <summary>
 /// 密码找回
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool GetPassword(UserInfo user)
 {
     return true;
 }
示例#12
0
 /// <summary>
 /// 用户註冊
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool Register(UserInfo user)
 {
     return Dal.Register(user);
 }
示例#13
0
 /// <summary>
 /// 更新用户
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public static bool Update(UserInfo user)
 {
     return Dal.Update(user);
 }
示例#14
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool Update(UserInfo user)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("update BigDog_User set Nick_Name=@Nick_Name,Password=@Password,Real_Name=@Real_Name,Score=@Score,User_Photo_Url=@User_Photo_Url,");
     sql.Append("Birthday=@Birthday,Income=@Income,Marry_Status=@Marry_Status,E_Mail=@E_Mail,Phone_Number=@Phone_Number,Hobby=@Hobby,");
     sql.Append("Address=@Address,School_Type=@School_Type,School=@School,Department=@Department,Enrolled_Date=@Enrolled_Date,");
     sql.Append("Company_Name=@Company_Name,Worked_Begin_Date=@Worked_Begin_Date,Status=@Status ");
     sql.Append("where Id=@Id");
     SqlParameter[] parms = new SqlParameter[] {
             new SqlParameter("@Nick_Name",SqlDbType.NVarChar,20),
             new SqlParameter("@Password",SqlDbType.NVarChar,20),
             new SqlParameter("@Real_Name",SqlDbType.NVarChar,20),
             new SqlParameter("@Score",SqlDbType.Int),
             new SqlParameter("@User_Photo_Url",SqlDbType.NVarChar,50),
             new SqlParameter("@Birthday",SqlDbType.DateTime),
             new SqlParameter("@Income",SqlDbType.NVarChar,20),
             new SqlParameter("@Marry_Status",SqlDbType.NVarChar,20),
             new SqlParameter("@E_Mail",SqlDbType.NVarChar,20),
             new SqlParameter("@Phone_Number",SqlDbType.NVarChar,20),
             new SqlParameter("@Hobby",SqlDbType.NVarChar,20),
             new SqlParameter("@Address",SqlDbType.NVarChar,20),
             new SqlParameter("@School_Type",SqlDbType.NVarChar,20),
             new SqlParameter("@School",SqlDbType.NVarChar,20),
             new SqlParameter("@Department",SqlDbType.NVarChar,20),
             new SqlParameter("@Enrolled_Date",SqlDbType.NVarChar,20),
             new SqlParameter("@Company_Name",SqlDbType.NVarChar,20),
             new SqlParameter("@Worked_Begin_Date",SqlDbType.NVarChar,20),
             new SqlParameter("@Status",SqlDbType.NVarChar,20),
             new SqlParameter("@Id",SqlDbType.Int)
     };
     parms[0].Value = user.Nick_Name;
     parms[1].Value = user.Password;
     parms[2].Value = user.Real_Name;
     parms[3].Value = user.Score;
     parms[4].Value = user.User_Photo_Url;
     parms[5].Value = user.Birthday;
     parms[6].Value = user.Income;
     parms[7].Value = user.Marry_Status;
     parms[8].Value = user.E_Mail;
     parms[9].Value = user.Phone_Number;
     parms[10].Value = user.Hobby;
     parms[11].Value = user.Address;
     parms[12].Value = user.School_Type;
     parms[13].Value = user.School;
     parms[14].Value = user.Department;
     parms[15].Value = user.Enrolled_Date;
     parms[16].Value = user.Company_Name;
     parms[17].Value = user.Worked_Begin_Time;
     parms[19].Value = user.Status;
     parms[20].Value = user.Id;
     return SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms) > 0;
 }
示例#15
0
 /// <summary>
 /// 用户注册
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public bool Register(UserInfo user)
 {
     StringBuilder sql = new StringBuilder();
     sql.Append("insert into BigDog_User (User_Name,Password,E_Mail,User_Type,CreatedDate,Creator)values(@User_Name,@Password,@E_Mail,@User_Type,@CreatedDate,@Creator)");
     SqlParameter[] parms = new SqlParameter[] {
         new SqlParameter("@User_Name",SqlDbType.NVarChar,20),
         new SqlParameter("@Password",SqlDbType.NVarChar,20),
         new SqlParameter("@E_Mail",SqlDbType.NVarChar,20),
         new SqlParameter("@User_Type",SqlDbType.Int),
         new SqlParameter("@CreatedDate",SqlDbType.DateTime),
         new SqlParameter("@Creator",SqlDbType.NVarChar,20)
     };
     parms[0].Value = user.User_Name;
     parms[1].Value = user.Password;
     parms[2].Value = user.E_Mail;
     parms[3].Value = user.User_Type;
     parms[4].Value = user.Created_Date;
     parms[5].Value = user.Created_By;
     return SQLHelper.ExecuteNonQuery(CommandType.Text, sql.ToString(), parms) > 0;
 }