예제 #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        nguoidungBLL bs = new nguoidungBLL();
        bool         tf = false;
        int          id = Convert.ToInt32(Request.QueryString["id"]);

        if (bs.uniqueEmailtt(txtEmail.Text, id) == true)
        {
            lbEmail.Text = "Địa chỉ email này đã có người sử dụng.";
        }
        else
        {
            tf = bs.suanguoidung(id, txtHoTen.Text.Trim(), txtSDT.Text, txtDiaChi.Text, Convert.ToInt32(ddlRole.SelectedValue), txtEmail.Text);
            if (tf == true)
            {
                Response.Redirect("nguoidung.aspx?edit=t");
            }
            else
            {
                lbError.Text = "<div class='error'> " +
                               " <div class='tl'></div><div class='tr'></div>"
                               + "<div class='desc'>"
                               + "	<p>Sửa người dùng không thành công!</p>"
                               + "</div>"
                               + "<div class='bl'></div><div class='br'></div>"
                               + "</div>";
            }
        }
    }
예제 #2
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        string               tk  = txtUserName.Text;
        string               mk  = txtPassWord.Text;
        nguoidungBLL         dn  = new nguoidungBLL();
        List <nguoidungDAL>  ds  = dn.dangNhap(tk, mk);
        List <userpublicDAL> usp = new List <userpublicDAL>();

        if (ds.Count == 1)
        {
            userpublicDAL us = new userpublicDAL();
            us.id_user  = ds[0].id_user;
            us.username = ds[0].username;
            us.hoten    = ds[0].hoten;
            us.sdt      = ds[0].sdt;
            us.diachi   = ds[0].diachi;
            us.role     = ds[0].role;
            us.email    = ds[0].email;

            usp.Add(us);
            Session["userpublic"] = usp;
            Response.Redirect("/");
        }
        else
        {
            lbResult.Text = "Sai tài khoản hoặc mật khẩu!";
        }
    }
예제 #3
0
    protected void btnDangKy_Click(object sender, EventArgs e)
    {
        nguoidungBLL bs = new nguoidungBLL();

        if (bs.uniqueTK(txtTK.Text) == true)
        {
            lbError.Text = "Tài khoản này đã có người sử dụng !";
        }
        else if (bs.uniqueEmail(txtEmail.Text) == true)
        {
            lbError.Text = "Email này đã có người sử dụng !";
        }
        else
        {
            bool tf = bs.dangKy(txtTK.Text, txtMK2.Text, txtHoTen.Text, txtDT.Text, txtDiaChi.Text, txtEmail.Text);
            if (tf == true)
            {
                lbError.Text = "Đăng ký thành công !";
                Response.Redirect("dkthanhcong.aspx");
            }
            else
            {
                lbError.Text = "Đăng ký thất bại !";
            }
        }
    }
예제 #4
0
    protected void btndoimatkhau_Click(object sender, EventArgs e)
    {
        nguoidungBLL         bs = new nguoidungBLL();
        List <userpublicDAL> ds = (List <userpublicDAL>)Session["userpublic"];

        if (bs.xacthuc(txtmk.Text, ds[0].id_user) == true)
        {
            bool tf = bs.qenMatKhau_doiMatKhau(txtmk2.Text, ds[0].id_user);

            if (tf == true)
            {
                lbError.Text = "Đổi mật khẩu thành công !";
                txtmk.Text   = "";
                txtmk1.Text  = "";
                txtmk2.Text  = "";
            }
            else
            {
                lbError.Text = "Đổi mật khẩu thất bại !";
            }
        }
        else
        {
            lbError.Text = "Mật khẩu cũ không chính xác !";
        }
    }
예제 #5
0
    private void loadNguoiDungT(string noidung, string danhmuc)
    {
        int row  = 10;
        int hide = 0;

        if (Request.QueryString["p"] != null)
        {
            hide = Convert.ToInt32(Request.QueryString["p"]);
        }
        nguoidungBLL        bs = new nguoidungBLL();
        List <nguoidungDAL> ds = bs.getNguoiDungT(row, hide, noidung, danhmuc);

        rpNguoiDung.DataSource = ds;
        rpNguoiDung.DataBind();

        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbSTT = rpNguoiDung.Items[i].FindControl("lbSTT") as Label;
            lbSTT.Text += (i + 1 + hide).ToString();
        }
        string pa = "&tval=" + noidung + "&tkey=" + danhmuc;

        // phan trang:
        int       current = Convert.ToInt32(Request.QueryString["p"]);
        phantrang pt      = new phantrang();

        lbPage.Text = pt.paging(bs.countT(noidung, danhmuc), row, pa, current);
    }
예제 #6
0
    private void loadNguoiDungV(string role)
    {
        int row  = 10;
        int hide = 0;

        if (Request.QueryString["p"] != null)
        {
            hide = Convert.ToInt32(Request.QueryString["p"]);
        }
        nguoidungBLL        bs = new nguoidungBLL();
        List <nguoidungDAL> ds = bs.getNguoiDungV(row, hide, role);

        rpNguoiDung.DataSource = ds;
        rpNguoiDung.DataBind();

        for (int i = 0; i <= ds.Count - 1; i++)
        {
            Label lbSTT = rpNguoiDung.Items[i].FindControl("lbSTT") as Label;
            lbSTT.Text += (i + 1 + hide).ToString();
        }
        // phan trang:
        int       current = Convert.ToInt32(Request.QueryString["p"]);
        phantrang pt      = new phantrang();

        lbPage.Text = pt.paging(bs.countV(ddlRole.Text), row, "", current);
    }
예제 #7
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        roleBLL              ro   = new roleBLL();
        nguoidungBLL         bs   = new nguoidungBLL();
        List <nguoidungDAL>  list = bs.dangNhap(txtTK.Text, txtMK.Text);
        List <userpublicDAL> user = new List <userpublicDAL>();
        userpublicDAL        u    = new userpublicDAL();

        if (list.Count == 1)
        {
            List <roleDAL> r = ro.getRolebyId(list[0].role);
            if (r[0].truycap_cms == true && r[0].special == false)
            {
                u.id_user = list[0].id_user;
                u.hoten   = list[0].hoten;
                u.special = false;
                user.Add(u);
                Session["adminuser"] = user;
                Response.Redirect("/admin/");
            }
            else if (r[0].truycap_cms == true && r[0].special == true)
            {
                u.id_user = list[0].id_user;
                u.hoten   = list[0].hoten;
                u.special = true;
                user.Add(u);
                Session["adminuser"] = user;
                Response.Redirect("/admin/");
            }
            else
            {
                lbError.Text = "<div class='notice'>"
                               + "<div class='tl'></div><div class='tr'></div>"
                               + "<div class='desc'>"
                               + "<p>Bạn bị giới hạn quyền truy cập !</p>"
                               + "</div>"
                               + "<div class='bl'></div><div class='br'></div>"
                               + "</div>";
            }
        }
        else
        {
            lbError.Text = "<div class='error'>"
                           + "<div class='tl'></div><div class='tr'></div>"
                           + "<div class='desc'>"
                           + "<p>Sai mật khẩu hoặc tài khoản !</p>"
                           + "</div>"
                           + "<div class='bl'></div><div class='br'></div>"
                           + "</div>";
        }
    }
예제 #8
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        nguoidungBLL bs = new nguoidungBLL();
        int          id = bs.quenMatKhau(txtTK.Text, txtEmail.Text);

        if (id > 0)
        {
            Session["quenmatkhau"] = id;
            Response.Redirect("quenmatkhau-matkhaumoi.aspx");
        }
        else
        {
            lbError.Text = "Tài khoản hoặc email không đúng!";
        }
    }
예제 #9
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        nguoidungBLL bs = new nguoidungBLL();
        int          id = Convert.ToInt32(Session["quenmatkhau"]);
        bool         tf = bs.qenMatKhau_doiMatKhau(txtmk1.Text, Convert.ToInt32(txtmk2.Text));

        if (tf == true)
        {
            lbError.Text = "Đổi mật khẩu thành công !";
            Session.Remove("quenmatkhau");
        }
        else
        {
            lbError.Text = "Đổi mật khẩu thất bại !";
        }
    }
예제 #10
0
    protected void btnCapNhat_Click(object sender, EventArgs e)
    {
        List <userpublicDAL> list = (List <userpublicDAL>)Session["userpublic"];
        nguoidungBLL         bs   = new nguoidungBLL();
        bool tf = bs.updateTTcaNhan(list[0].id_user, txtHoTen.Text, txtSDT.Text, txtDiaChi.Text, txtEmail.Text);

        if (tf == true)
        {
            lbError.Text   = "Cập nhật thông tin thành công!";
            list[0].hoten  = txtHoTen.Text;
            list[0].sdt    = txtSDT.Text;
            list[0].diachi = txtDiaChi.Text;
            list[0].email  = txtEmail.Text;
        }
        else
        {
            lbError.Text = "Có lỗi xảy ra!";
        }
    }
예제 #11
0
    // load thoong tin nguoi dung:

    private void loadNguoiDung(int id)
    {
        nguoidungBLL        bs = new nguoidungBLL();
        List <nguoidungDAL> ds = bs.getNguoiDungbyId(id);

        if (ds.Count == 1)
        {
            txtDiaChi.Text        = ds[0].diachi;
            txtEmail.Text         = ds[0].email;
            txtHoTen.Text         = ds[0].hoten;
            txtSDT.Text           = ds[0].sdt;
            ddlRole.SelectedValue = ds[0].role.ToString();
            lbTK.Text             = ds[0].username;
        }
        else
        {
            Response.Redirect("error.aspx");
        }
    }
예제 #12
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        nguoidungBLL bs = new nguoidungBLL();

        if (bs.uniqueTK(txtTK.Text) == true)
        {
            lbTK.Text = "Tài khoản này đã có người sử dụng.";
        }
        else if (bs.uniqueEmail(txtEmail.Text) == true)
        {
            lbEmail.Text = "Email này đã có người sử dụng.";
        }
        else if (txtMK1.Text == txtMK2.Text)
        {
            bool tf = bs.add(txtTK.Text.Trim(), txtMK2.Text, txtHoTen.Text, txtSDT.Text, txtDiaChi.Text, txtEmail.Text, Convert.ToInt32(ddlRole.SelectedValue));
            if (tf == true)
            {
                Response.Redirect("nguoidung.aspx?add=t");
            }
            else
            {
                lbError.Text = "<div class='error'>"
                               + "<div class='tl'></div><div class='tr'></div>"
                               + "<div class='desc'>"
                               + "<p>Thêm người dùng bị lỗi !</p>"
                               + "</div>"
                               + "<div class='bl'></div><div class='br'></div>"
                               + "</div>";
            }
        }
        else
        {
            lbError.Text = "<div class='error'>"
                           + "<div class='tl'></div><div class='tr'></div>"
                           + "<div class='desc'>"
                           + "<p>Mật khẩu không chính xác !</p>"
                           + "</div>"
                           + "<div class='bl'></div><div class='br'></div>"
                           + "</div>";
        }
    }
예제 #13
0
    protected void btnUpDate_Click(object sender, EventArgs e)
    {
        nguoidungBLL bs    = new nguoidungBLL();
        bool         check = false;
        string       id    = "";
        int          lengh = 0;
        bool         tf    = false;

        for (int i = 0; i <= rpNguoiDung.Items.Count - 1; i++)
        {
            CheckBox cbDell = rpNguoiDung.Items[i].FindControl("cbDell") as CheckBox;

            if (cbDell.Checked)
            {
                id   += cbDell.ToolTip + ",";
                check = true;
            }
        }
        lengh = id.Length;

        if (check == true)
        {
            string hid = id.Remove(lengh - 1);
            tf = bs.del(hid);
            if (tf == true)
            {
                Response.Redirect("nguoidung.aspx?up=t");
            }
            else
            {
                lbError.Text = "<div class='error'> " +
                               " <div class='tl'></div><div class='tr'></div>"
                               + "<div class='desc'>"
                               + "	<p>Cập nhật thất bại!</p>"
                               + "</div>"
                               + "<div class='bl'></div><div class='br'></div>"
                               + "</div>";
            }
        }
    }
예제 #14
0
    private bool doimatkhau(int id)
    {
        bool         t  = false;
        nguoidungBLL bs = new nguoidungBLL();

        if (txtMK1.Text == txtMK2.Text)
        {
            bool tf = bs.qenMatKhau_doiMatKhau(txtMK2.Text, id);
            t = tf;
        }
        else
        {
            lbError.Text = "<div class='error'>"
                           + "<div class='tl'></div><div class='tr'></div>"
                           + "<div class='desc'>"
                           + "<p>Mật khẩu mới không chính xác !</p>"
                           + "</div>"
                           + "<div class='bl'></div><div class='br'></div>"
                           + "</div>";
        }


        return(t);
    }
예제 #15
0
    // load dat hang
    private void loadDatHang(string v)
    {
        int row  = 10;
        int hide = 0;

        if (Request.QueryString["p"] != null)
        {
            hide = Convert.ToInt32(Request.QueryString["p"]);
        }
        dathangBLL             bs      = new dathangBLL();
        phuongthucthanhtoanBLL pt_bs   = new phuongthucthanhtoanBLL();
        dathangdetailBLL       dhdt_bs = new dathangdetailBLL();
        nguoidungBLL           nd_bs   = new nguoidungBLL();
        khuyenmaiBLL           km      = new khuyenmaiBLL();
        List <dathangDAL>      ds      = bs.getDathangP(row, hide, v);

        rpDatHang.DataSource = ds;
        rpDatHang.DataBind();
        for (int i = 0; i <= ds.Count - 1; i++)
        {
            List <nguoidungDAL>           nd_ds   = nd_bs.getNguoiDungbyId(ds[i].id_user);
            List <phuongthucthanhtoanDAL> pt_ds   = pt_bs.getPhuongThucById(ds[i].id_pt);
            List <dathangdetail>          dhdt_ds = dhdt_bs.getdathangDetail(ds[i].id_dathang);
            Label lbNguoiDung = rpDatHang.Items[i].FindControl("lbNguoiDung") as Label;
            lbNguoiDung.Text = nd_ds[0].hoten;
            Label lbThanhToan = rpDatHang.Items[i].FindControl("lbThanhToan") as Label;
            lbThanhToan.Text = pt_ds[0].ten_phuongthuc;
            Label   lbTongTien = rpDatHang.Items[i].FindControl("lbTongTien") as Label;
            decimal tongTien   = 0;
            for (int j = 0; j <= dhdt_ds.Count - 1; j++)
            {
                if (dhdt_ds[j].khuyenmai == true)
                {
                    tongTien += (dhdt_ds[j].gia - (dhdt_ds[j].gia * km.getKhuyenMaibyId(1) / 100)) * dhdt_ds[j].soluong;
                }
                else
                {
                    tongTien += (dhdt_ds[j].gia * dhdt_ds[j].soluong);
                }
            }
            lbTongTien.Text = String.Format("{0:0,0 VNĐ}", tongTien);
            Label lbHinh = rpDatHang.Items[i].FindControl("lbHinh") as Label;
            if (ds[i].trangthai == true)
            {
                lbHinh.Text = "<img src=\"../images/admin/dathutien.jpg\" alt=\"Đã thu tiền\">";
            }

            Label lbSTT = rpDatHang.Items[i].FindControl("lbSTT") as Label;
            lbSTT.Text += (i + 1 + hide).ToString();
        }
        string view = "";

        if (v != "")
        {
            view = "&v=" + Request.QueryString["v"];
        }

        // phan trang:
        int       current = Convert.ToInt32(Request.QueryString["p"]);
        phantrang pt      = new phantrang();

        lbPage.Text = pt.paging(bs.countP(v), row, view, current);
    }