Ejemplo n.º 1
0
    }/// <summary>

    /// 修改密码
    /// </summary>
    private void UPpwd()
    {
        SqlHelper mydata   = new SqlHelper();
        string    Username = Session["UserId"].ToString();

        try
        {
            string sql = "update [Users]  set [pwd] ='" + PwdEncrypt.MD5Encrypt64(txtpwd2.Text.ToString()) + "' where [id]='" + Username + "' ";
            mydata.RunSql(sql);



            LabelWarningMessage.Text = "修改成功!";
        }
        catch
        {
            LabelWarningMessage.Text = "修改失败!";
        }
    }
Ejemplo n.º 2
0
        public virtual string Register(User user)
        {
            string returnString = string.Empty;

            try
            {
                user.Password = PwdEncrypt.ComputeHash(user.Password, "SHA512", null);
                using (var ctx = new TTContext())
                {
                    ctx.Users.Add(user);
                    returnString = ctx.SaveChanges().ToString();
                }
            }
            catch (Exception ex)
            {
                throw;;
            }

            return(returnString);
        }
Ejemplo n.º 3
0
        public virtual bool Login(string username, string password)
        {
            bool isValid = false;

            try
            {
                using (var ctx = new TTContext())
                {
                    IQueryable <User> user = ctx.Users.Where(c => c.Username == username);
                    var dUser = user.FirstOrDefault();
                    isValid = PwdEncrypt.VerifyHash(password, "SHA512", dUser.Password);

                    ChangeStatus(username, "1");
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(isValid);
        }
Ejemplo n.º 4
0
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)

    {
        string ID        = GridView1.Rows[e.RowIndex].Cells[0].Text;
        string adminName = GridView1.Rows[e.RowIndex].Cells[1].Text;
        string adminRole = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[3].Controls[0])).Text;

        string adminPwd    = ((TextBox)(GridView1.Rows[e.RowIndex].Cells[2].Controls[0])).Text;
        string currentRole = Label3.Text;
        string currentName = Label2.Text;

        /*  GridView1.EditIndex = -1; //一定要设置,否则还处于编辑状态
         * showData();*/

        if (currentRole == "超级管理员" && adminRole == "普通管理员" || adminName == Session["admin"].ToString())

        {
            int n = SqlHelper.exexu("update   admin  set password='******',roleName='" + adminRole + "'where id='" + Convert.ToInt32(ID) + "'");
            if (n > 0)
            {
                Response.Write("<script>alert('更新成功')</script>");
            }

            else
            {
                Response.Write("<script>alert('更新失败')</script>");
                GridView1.DataBind();
            }
            GridView1.EditIndex = -1; //一定要设置,否则还处于编辑状态
            showData();
        }
        else
        {
            Response.Write("<script>alert('您的权限不足')</script>");
            GridView1.EditIndex = -1; //一定要设置,否则还处于编辑状态
            showData();
        }
    }
Ejemplo n.º 5
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (lblyanzheng.Text != txtyan.Text)
        {
            Response.Write("<script>alert('验证码错误!');history.go(-1);</script>");
            return;
        }

        else
        {
            SqlDataReader dr = data.GetDataReader("select * from Users where  UserName='******'");
            if (dr.Read())
            {
                Label1.Text = "已经存在账号了";
            }
            else
            {
                //data.RunSql("insert into Users(emal,UserName,Sex,pwd,XingMing,Tel,Address,ShengRi)values('" + txtemal.Text + "','" + txtname.Text + "','" + DropDownList1.SelectedItem.Text + "','" + PwdEncrypt.MD5Encrypt64(TextBox1.Text) + "','" + XingMing.Text + "','" + Tel.Text + "','" + Address.Text + "','" + txttime.Value + "')");
                data.RunSql("insert into Users(UserName,pwd,Tel)values('" + txtname.Text + "','" + PwdEncrypt.MD5Encrypt64(TextBox1.Text) + "','" + Tel.Text + "')");

                Alert.AlertAndRedirect("注册成功!", "UserLogin.aspx");
            }
        }
    }
Ejemplo n.º 6
0
    private void chkADmin()
    {
        if (TxtUserName.Text == "" && TxtPassword.Text == "")
        {
            Alert.AlertAndRedirect("没有输入账号和密码!", "Login.aspx");
        }
        else
        {
            dr = data.GetDataReader("select * from  admin where admin='" + TxtUserName.Text.Trim() + "'and password='******'    ");
            if (dr.Read())
            {
                Session["admin"] = dr["admin"].ToString();

                Response.Redirect("index.html");
            }
            else
            {
                Alert.AlertAndRedirect("管理员的账号或者密码不对请重新登陆!", "login.aspx");
            }
        }
    }
Ejemplo n.º 7
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        string mysql = "select count(*) from admin where admin='" + TextBox1.Text + "'";

        int n = SqlHelper.dd(mysql);

        if (n > 0)
        {
            TextBox1.Focus();
            Label1.Visible = true;
            Label1.Text    = "该用户已经存在!";
            return;
            //  Page.RegisterClientScriptBlock("e","<script language='javascript'>alert('该用户已经存在!')</script>");
        }
        else
        {
            string addAdmin = "insert into admin(admin,password,roleName)values('" + TextBox1.Text + "','" + PwdEncrypt.MD5Encrypt64(TextBox2.Text) + "','" + RadioButtonList2.SelectedItem.Text + "')";
            int    add      = SqlHelper.exexu(addAdmin);
            if (add > 0)
            {
                Label1.Visible = true;
                Label1.Text    = "添加管理员成功!";
                showData();
            }
            else
            {
                Label1.Visible = true;
                Label1.Text    = "添加管理员失败!";
            }
        }
    }
Ejemplo n.º 8
0
 private void chkADmin()
 {
     if (TxtUserName.Text == "" && TxtPassword.Text == "")
     {
         //  Alert.AlertAndRedirect("没有输入账号和密码!", "Default.aspx");
         Label1.Text = "没有输入账号和密码!";
     }
     else
     {
         SqlDataReader dr;
         dr = data.GetDataReader("select * from  Users where UserName='******'and pwd='" + PwdEncrypt.MD5Encrypt64(TxtPassword.Text.Trim()) + "'");
         if (dr.Read())
         {
             Session["UserId"]   = dr["id"].ToString();
             Session["UserName"] = dr["UserName"].ToString();
             Session["Photo"]    = dr["Photo"].ToString();
             Response.Redirect("Default.aspx?activeItem=0");
         }
         else
         {
             Label1.Text = "账号或者密码不对请重新登陆!";
             /*Alert.AlertAndRedirect("账号或者密码不对请重新登陆!", "Default.aspx");*/
         }
     }
 }
Ejemplo n.º 9
0
    /// <summary>
    /// 检验原来的密码
    /// </summary>
    private void chkpwd()
    {
        SqlDataReader dr;

        dr = data.GetDataReader("select * from  Users  where id='" + Session["UserId"].ToString() + "' and pwd='" + PwdEncrypt.MD5Encrypt64(txtpwd1.Text) + "'");
        if (dr.Read())
        {
            UPpwd();
        }
        else
        {
            LabelWarningMessage.Text = "原密码不正确!";
        }
    }