示例#1
0
    protected void btn_kichhoat_Click(object sender, EventArgs e)
    {
        string key;

        try
        {
            key = Request.QueryString["key"];
        }
        catch (Exception)
        {
            Response.Write("<script>alert('Liên kết không đúng')</script>");
            return;
        }
        if (key == "")
        {
            Response.Redirect("~/trang-chu.aspx");
        }
        else
        {
            try
            {
                ThanhvienBUS.Thanhvien_Active(Request.QueryString["key"].ToString());
                Response.Write("<script>alert('Kích hoạt tài khoản thành công. Bạn có thể đăng nhập')</script>");
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Mã kích hoạt không đúng')</script>");
            }
        }
    }
示例#2
0
    protected void btn_chinhsua_submit_Click(object sender, EventArgs e)
    {
        if (txt_matkhau.Value.Length < 8)
        {
            check_matkhau.Visible = true;
        }

        if (Regex.IsMatch(txt_hoten.Value.ToString(), @"[`1234567890-=;',./~!@#$%^&*()_+{}:|<>?]") || txt_hoten.Value == "")
        {
            check_hoten.Visible = true;
        }

        if (!Regex.IsMatch(txt_sdt.Value, @"^[0-9]+$") || txt_sdt.Value == "")
        {
            if (txt_sdt.Value.Length == 10 || txt_sdt.Value.Length == 11)
            {
                check_sdt.Visible = false;
            }
            else
            {
                check_sdt.Visible = true;
            }
        }

        if (txt_diachi.Value == "")
        {
            check_diachi.Visible = true;
        }

        if (check_matkhau.Visible == false && check_hoten.Visible == false && check_sdt.Visible == false && check_diachi.Visible == false)
        {
            Thanhvien tv = new Thanhvien();
            tv.Email   = function.email;
            tv.Matkhau = function.Mahoa(txt_matkhau.Value);
            tv.Hoten   = txt_hoten.Value;
            tv.Diachi  = txt_diachi.Value;
            tv.Sdt     = txt_sdt.Value;

            try
            {
                ThanhvienBUS.Thanhvien_Update(tv);
                Response.Write("<script>alert('Cập nhật tài khoản thành công')</script>");
                function.hoten  = txt_hoten.Value;
                function.diachi = txt_diachi.Value;
                function.sdt    = txt_sdt.Value;
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Cập nhật tài khoản thất bại')</script>");
            }
        }
    }
示例#3
0
    protected void btn_thanhtoan_Click(object sender, EventArgs e)
    {
        if (Session["giohang"] != null)
        {
            try
            {
                create_insert_giohang();
                Session["giohang"] = null;
                //Response.Redirect(Request.Url.AbsoluteUri);
                if (double.Parse(txt_khautru.Text) == 0)
                {
                    ThanhvienBUS.Thanhvien_Set0DiemTichLuy(function.email);
                    function.diemtichluy = 0;
                }
                double tongtien = double.Parse(lbl_tongtien.InnerText);
                if (tongtien > 500000)
                {
                    ThanhvienBUS.Thanhvien_SumDiemTichLuy(function.email, "50000");
                    function.diemtichluy = function.diemtichluy + 50000;
                    Response.Write("<script>alert('Bạn đã được cộng 50000 VNĐ và điểm tích lũy')</script>");
                }
                else if (tongtien > 300000)
                {
                    ThanhvienBUS.Thanhvien_SumDiemTichLuy(function.email, "30000");
                    Response.Write("<script>alert('Bạn đã được cộng 30000 VNĐ và điểm tích lũy')</script>");
                    function.diemtichluy = function.diemtichluy + 30000;
                }
                else if (tongtien > 150000)
                {
                    ThanhvienBUS.Thanhvien_SumDiemTichLuy(function.email, "15000");
                    function.diemtichluy = function.diemtichluy + 15000;
                    Response.Write("<script>alert('Bạn đã được cộng 15000 VNĐ và điểm tích lũy')</script>");
                }
                else
                {
                }

                Response.Write("<script>alert('Bạn đã đặt hàng thành công! Chúng tôi sẽ giao hàng sớm cho bạn.')</script>");
            }
            catch (Exception)
            {
            }
        }
        //else
        //{
        //    Session["giohang"] = null;
        //    Response.Redirect(Request.Url.AbsoluteUri);
        //}
    }
示例#4
0
    protected void btn_dangnhap_submit_Click(object sender, EventArgs e)
    {
        string    email   = txt_email.Value;
        string    matkhau = function.Mahoa(txt_matkhau.Value);
        DataTable dt      = new DataTable();

        dt = ThanhvienBUS.Thanhvien_Login(email, matkhau);
        try
        {
            if (dt.Rows.Count != 0)
            {
                if (dt.Rows[0][0].ToString() == "mens")
                {
                    Session["login"] = "******";

                    function.email       = dt.Rows[0][0].ToString();
                    function.hoten       = dt.Rows[0][2].ToString();
                    function.diachi      = dt.Rows[0][3].ToString();
                    function.sdt         = dt.Rows[0][4].ToString();
                    function.diemtichluy = decimal.Parse(dt.Rows[0][5].ToString());

                    Response.Redirect("~/trang-chu.aspx");
                }
                else
                {
                    Session["login"] = "******";

                    function.email       = dt.Rows[0][0].ToString();
                    function.hoten       = dt.Rows[0][2].ToString();
                    function.diachi      = dt.Rows[0][3].ToString();
                    function.sdt         = dt.Rows[0][4].ToString();
                    function.diemtichluy = decimal.Parse(dt.Rows[0][5].ToString());

                    Response.Redirect("~/trang-chu.aspx");
                }
            }
            else
            {
                Response.Write("<script>alert('Đăng nhập thất bại')</script>");
            }
        }
        catch (Exception)
        {
            Response.Write("<script>alert('Đăng nhập thất bại')</script>");
        }
    }
示例#5
0
    protected void grv_thanhvien_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        string email = grv_thanhvien.DataKeys[e.RowIndex].Value.ToString();

        try
        {
            if (email == "mens")
            {
                Response.Write("<script>alert('Không thể Khóa tài khoản quản trị')</script>");
            }
            else
            {
                ThanhvienBUS.Thanhvien_Lock(email);
                Response.Write("<script>alert('Khóa tài khoản thành công')</script>");
                Thanhvien_Show();
            }
        }
        catch (Exception)
        {
            Response.Write("<script>alert('Xóa tài khoản thất bại')</script>");
        }
    }
示例#6
0
    protected void btn_phuchoitaikhoan_Click(object sender, EventArgs e)
    {
        string[] abc = { "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M" };

        string email     = txt_email.Value;
        string email_phu = email;
        Random rr        = new Random();
        string matkhau   = abc[rr.Next(0, 25)] + abc[rr.Next(0, 25)] + abc[rr.Next(0, 25)] + abc[rr.Next(0, 25)] + abc[rr.Next(0, 25)] + abc[rr.Next(0, 25)] + abc[rr.Next(0, 25)] + abc[rr.Next(0, 25)];

        if (email_phu == "mens")
        {
            email_phu = email_phu + "@gmail.com";
        }


        if (!Regex.IsMatch(email_phu, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"))
        {
            check_email.Visible = true;
        }


        if (check_email.Visible == false)
        {
            try
            {
                ThanhvienBUS.Thanhvien_UpdatePassword(email, function.Mahoa(matkhau));
                function.SendMail_2(email_phu, matkhau);

                Response.Write("<script>alert('Cấp lại mật khẩu thành công. Truy cập và Mail của bạn để lấy mật khẩu mới')</script>");
            }
            catch (Exception)
            {
                Response.Write("<script>alert('Cấp lại mật khẩu thất bại')</script>");
            }
        }
    }
示例#7
0
 //-----------------------------THÀNH VIÊN----------------------------------------
 public void Thanhvien_Show()
 {
     grv_thanhvien.DataSource = ThanhvienBUS.Thanhvien_Get();
     grv_thanhvien.DataBind();
 }
示例#8
0
    protected void btn_dangki_submit_Click(object sender, EventArgs e)
    {
        if (Regex.IsMatch(txt_hoten.Value.ToString(), @"[`1234567890-=;',./~!@#$%^&*()_+{}:|<>?]") || txt_hoten.Value == "")
        {
            check_hoten.Visible = true;
        }
        if (!Regex.IsMatch(txt_email.Value, @"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"))
        {
            check_email.Visible = true;
        }
        if (txt_matkhau.Value.Length < 8)
        {
            check_matkhau.Visible = true;
        }
        if (txt_nhaplaimatkhau.Value.Equals(txt_matkhau.Value) == false)
        {
            check_nhaplaimatkhau.Visible = true;
        }
        if (!Regex.IsMatch(txt_sdt.Value, @"^[0-9]+$") || txt_sdt.Value == "")
        {
            if (txt_sdt.Value.Length == 10 || txt_sdt.Value.Length == 11)
            {
                check_sdt.Visible = false;
            }
            else
            {
                check_sdt.Visible = true;
            }
        }
        if (txt_diachi.Value == "")
        {
            check_diachi.Visible = true;
        }

        if (check_email.Visible == false && check_hoten.Visible == false && check_matkhau.Visible == false && check_nhaplaimatkhau.Visible == false && check_sdt.Visible == false && check_diachi.Visible == false)
        {
            Thanhvien tv = new Thanhvien();
            tv.Email       = txt_email.Value;
            tv.Matkhau     = function.Mahoa(txt_matkhau.Value).ToString();
            tv.Hoten       = txt_hoten.Value;
            tv.Diachi      = txt_diachi.Value;
            tv.Sdt         = txt_sdt.Value;
            tv.Kichhoat    = "chua kich hoat";
            tv.Makichhoat  = function.Mahoa(txt_email.Value);
            tv.Diemtichluy = 0;

            try
            {
                int check = ThanhvienBUS.Thanhvien_Insert(tv);
                if (check == 0)
                {
                    function.SendMail(tv);
                    Response.Write("<script>alert('Đăng kí thành công. Bạn cần truy cập và mail để kích hoạt tài khoản và sử dụng')</script>");
                }
                else
                {
                    Response.Write("<script>alert('Email này đã có người sử dụng')</script>");
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>" + ex.Message + "</script>");
            }
        }
    }