示例#1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Admins vcontroller = new Admins();
                Entities.KhachHang vusers = new Entities.KhachHang();
                string errMsg = string.Empty;
                int result = vcontroller.Login_khachhang(true, txtUserName.Text, txtPassword.Text, ref errMsg);

                if (result > 0)
                {
                    vusers = vcontroller.getby_tk_khachhang(txtUserName.Text, ref errMsg);

                    if (vusers != null)
                    {
                        Session.Add("UserID", Convert.ToInt32(vusers.MaKH));
                        Session.Add("FullName", Convert.ToString(vusers.Hoten));
                        Response.Redirect("~/Admin/users.aspx");
                    }
                }
                else
                {
                    if (result == -1) { throw new Exception("Sai tên tài khoản hoặc mật khẩu!"); }
                    else { throw new Exception("Hệ thống gặp sự cố trong quá trình xác thực tài khoản!"); }
                }

            }
            catch (Exception ex)
            {
                AlertNotification.Visible = true;
                lblAlert.Text = ex.Message;
            }
        }
示例#2
0
        protected void btndangnhap_Click(object sender, EventArgs e)
        {
            try
            {
                EndUser vcontroller_enduser = new EndUser();
                Admins vcontroller_admin = new Admins();
                Entities.KhachHang vkhachhang = new Entities.KhachHang();
                string errMsg = string.Empty;
                int result = vcontroller_admin.Login_khachhang(false, txtusername.Text, txtmakhau.Text, ref errMsg);

                if (result > 0)
                {
                    vkhachhang = vcontroller_admin.getby_tk_khachhang(txtusername.Text, ref errMsg);

                    if (vkhachhang != null)
                    {
                        Session.Add("KhachhangID", Convert.ToInt32(vkhachhang.MaKH));
                        Session.Add("FullName_KH", Convert.ToString(vkhachhang.Hoten));
                        Response.Redirect("~/Default.aspx");
                    }
                }
                else
                {
                    if (result == -1) { throw new Exception("Sai tên tài khoản hoặc mật khẩu!"); }
                    else { throw new Exception("Hệ thống gặp sự cố trong quá trình xác thực tài khoản!"); }
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void ucConfirmDialog_Yes(object sender)
        {
            ucConfirmDialog.Hide();
            string errMsg = string.Empty;
            Admins vcontroller = new Admins();
            Entities.KhachHang vusers = new Entities.KhachHang();
            vusers = vcontroller.getby_tk_khachhang(Convert.ToString(ucConfirmDialog.Key), ref errMsg);
            if (vusers.Trangthai == true)
            {
                vusers.Trangthai = false;
            }
            else
            {
                vusers.Trangthai = true;
            }
            int result = vcontroller.capnhap_tt_khachhang(vusers.Tendangnhap, vusers.Trangthai, ref errMsg);
            if (result > 0)
            {
                ucNotificationDialog.MessageContent = "cập nhập trạng thái thành công!";
                ucNotificationDialog.MessageType = 1;
                ucNotificationDialog.RedirectUrl = "~/Admin/users.aspx";
                ucNotificationDialog.Show();
            }
            else
            {
                if (result == -1) { ucNotificationDialog.MessageContent = "Bản ghi không tồn tại!<br/>Vui lòng kiểm tra lại."; }
                else { ucNotificationDialog.MessageContent = "Hệ thống gặp sự cố!<br/>Vui lòng liên hệ @ để được hỗ trợ."; }

                ucNotificationDialog.MessageType = 0;
                ucNotificationDialog.Show();
            }
        }