Exemple #1
0
        public async Task <ActionResult> login(taikhoan tk)
        {
            var account = db.taikhoans.FirstOrDefault(x => x.Tentk == tk.Tentk.Trim());

            if (ModelState.IsValid)
            {
                if (account != null)
                {
                    var person = db.taikhoans.FirstOrDefault(x => x.Tentk == tk.Tentk.Trim() && x.matkhau == tk.matkhau.Trim());
                    if (person != null)
                    {
                        //FormsAuthentication.SetAuthCookie(tk.Tentk,Convert.ToBoolean(tk.Tentk));
                        return(RedirectToAction("HienThiDS", "QuanLiPhim"));
                    }
                    else
                    {
                        ModelState.AddModelError("matkhau", "Sai mật khẩu!");
                        return(View(tk));
                    }
                }
                else
                {
                    ModelState.AddModelError("Tentk", "Sai tên tài khoản!");
                    return(View(tk));
                }
            }
            return(View());
        }
 private void iconButton1_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có chắc muốn đổi mật khẩu?", "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
     {
         AccountDAO1 accountDAO1 = new AccountDAO1();
         try
         {
             StaffDAO1 staff = new StaffDAO1();
             taikhoan  tk    = new taikhoan();
             tk.manv        = staff.getIDbyUsername(Program.idLoged);
             tk.tentaikhoan = Program.idLoged;
             tk.matkhau     = Script.MD5Hash(txtPass.Text);
             if (accountDAO1.Edit(tk) == 1)
             {
                 MessageBox.Show("Cập nhập mật khẩu thành công");
                 LoadData();
             }
             else
             {
                 MessageBox.Show("Đổi mật khẩu thất bại");
             }
         }
         catch
         {
             MessageBox.Show("Có lỗi xảy ra!!!");
         }
     }
 }
Exemple #3
0
        private void btnThem_Click(object sender, EventArgs e)
        {
            nhanvien nv = new nhanvien();
            taikhoan tk = new taikhoan();

            nv.manhanvien  = Convert.ToInt32(txtMaNhanVien.Text);
            nv.tennhanvien = txtHoTen.Text;
            if (rdbtnNam.Checked == true)
            {
                nv.gioitinh = "Nam";
            }
            if (rdbtnNu.Checked == true)
            {
                nv.gioitinh = "Nữ";
            }
            nv.sdt         = txtSoDienThoai.Text;
            nv.cmnd        = txtSoCMND.Text;
            nv.ngaysinh    = dtpNgaySinh.Value;
            nv.machucvu    = ((CBBItem)cbxChucvu.SelectedItem).Value;
            tk.manhanvien  = Convert.ToInt32(txtMaNhanVien.Text);
            tk.tendangnhap = txtTenDangNhap.Text;
            tk.matkhau     = txtMatKhau.Text;

            if (nv_BLL.Add_NV(nv) == true && tk_BLL.Add_TK(tk) == true)
            {
                MessageBox.Show("Thêm thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DSNV();
            }
            else
            {
                MessageBox.Show("Thêm thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void UserInformation_Load(object sender, EventArgs e)
        {
            taikhoan    tk         = new taikhoan();
            nhanvien    nv         = new nhanvien();
            AccountDAO1 accountDAO = new AccountDAO1();
            StaffDAO1   staffDAO   = new StaffDAO1();

            tk                  = accountDAO.getAccountLogedin();
            nv                  = staffDAO.getStaffLogedin();
            txtName.Text        = nv.hoten;
            txtCMND.Text        = nv.cnmd;
            txtPhoneNumber.Text = nv.sdt;
            txtPermission.Text  = nv.chucvu;
            current_gender      = (int)nv.gioitinh;
            if (nv.gioitinh == 1)
            {
                cbFemale.Checked = true;
            }
            else
            {
                cbMale.Checked = true;
            }
            txtUsername.Text = tk.tentaikhoan;
            txtBirth.Text    = nv.ngaysinh.ToString();
        }
Exemple #5
0
        public ActionResult DangKy(FormCollection collection, taikhoan tk)
        {
            string stendangnhap = collection["username"];
            string shoten       = collection["fullname"];
            string smatkhau     = collection["password"];
            string ssdt         = collection["telNumber"];
            string sdiachi      = collection["address"];
            int    irole        = 0;

            if (collection["role"] == null)
            {
                irole = 0;
            }
            else
            {
                irole = int.Parse(collection["role"]);
            }
            //gan du lieu vao model
            tk.tendangnhap = stendangnhap;
            tk.hoten       = shoten;
            tk.matkhau     = smatkhau;
            tk.sdt         = ssdt;
            tk.diachi      = sdiachi;
            tk.role        = irole;

            DB.taikhoans.Add(tk);
            DB.SaveChanges();
            return(RedirectToAction("DangNhap"));
        }
 public Form_Dichvu(taikhoan tk)
 {
     InitializeComponent();
     this.tk = tk;
     HienThiDanhSachHoaDon();
     LoadCbxThoiGian();
     LoadCbxTimKiem();
 }
        public ActionResult DeleteConfirmed(int id)
        {
            taikhoan taikhoan = db.taikhoans.Find(id);

            db.taikhoans.Remove(taikhoan);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #8
0
        private void btndoi_Click(object sender, EventArgs e)
        {
            foreach (var pi in txtmkmoi.Text)
            {
                if (pi.Equals(' '))
                {
                    MessageBox.Show("Mật khẩu mới không hợp lệ", "", MessageBoxButtons.OK);
                    return;
                }
            }

            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://localhost:44326/");
            HttpResponseMessage response = client.GetAsync("api/login").Result;
            var tk1 = response.Content.ReadAsAsync <IEnumerable <taikhoan> >().Result;
            var nv  = tk1.FirstOrDefault(a => a.Taikhoan1.Equals(Program.taikhoan) && a.Matkhau.Equals(txtmkcu.Text));

            try
            {
                if (nv == null)
                {
                    MessageBox.Show("Bạn nhập sai thông tin tài khoản cũ.Vui lòng nhập lại", "", MessageBoxButtons.OK);
                    return;
                }

                else if (txtxnmkmoi.Text.Equals(txtmkmoi.Text) != true)
                {
                    MessageBox.Show("Mật khẩu xác nhận bị sai.Vui lòng kiểm tra lại", "", MessageBoxButtons.OK);
                    return;
                }
                else
                {
                    manv = nv.MaNV;
                    taikhoan tk = new taikhoan();
                    // em.Taikhoan = txttkmoi.Text;
                    tk.Matkhau = txtmkmoi.Text.Trim();

                    HttpClient client1 = new HttpClient();
                    client1.BaseAddress = new Uri("https://localhost:44326/");
                    HttpResponseMessage response1 = client1.PutAsJsonAsync <taikhoan>("api/doimk?manv=" + nv.MaNV + "", tk).Result;
                    if (response1.IsSuccessStatusCode == true)
                    {
                        MessageBox.Show("Đổi thành công", "", MessageBoxButtons.OK);
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Đổi thất bại", "", MessageBoxButtons.OK);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi", "", MessageBoxButtons.OK);
            }
        }
Exemple #9
0
        private void button1_Click(object sender, EventArgs e)
        {
            foreach (var pi in txtmk.Text)
            {
                if (pi.Equals(' '))
                {
                    MessageBox.Show("Mật khẩu mới không hợp lệ", "", MessageBoxButtons.OK);
                    return;
                }
            }
            if (txttk.Text.Length < 6)
            {
                MessageBox.Show("Tài khoản không hợp lệ", "", MessageBoxButtons.OK);
                return;
            }
            if (txttk.Text == "" || txtmk.Text == "" || cmbnhom.Text == "" || cmbmanv.Text == "")
            {
                MessageBox.Show("Vui lòng điền đầy đủ thông tin", "", MessageBoxButtons.OK);
                return;
            }
            HttpClient clienta = new HttpClient();

            clienta.BaseAddress = new Uri("https://localhost:44326/");
            HttpResponseMessage responsea = clienta.GetAsync("api/login").Result;
            var kt      = responsea.Content.ReadAsAsync <IEnumerable <taikhoan> >().Result;
            var kiemtra = from t in kt where t.Taikhoan1 == txttk.Text || t.MaNV == cmbmanv.Text select t;

            if (kiemtra.ToList().Count != 0)
            {
                MessageBox.Show("Tài khoản đã có sẵn.Vui lòng thay đổi tài khoản", "", MessageBoxButtons.OK);
                return;
            }
            taikhoan tk = new taikhoan();

            tk.MaNV      = cmbmanv.Text;
            tk.Taikhoan1 = txttk.Text;
            tk.Matkhau   = txtmk.Text;
            tk.Nhom      = cmbnhom.Text;
            tk.Ngaylap   = DateTime.Now;
            HttpClient client = new HttpClient();

            client.BaseAddress = new Uri("https://localhost:44326/");
            HttpResponseMessage response = client.PostAsJsonAsync <taikhoan>("api/Taotk", tk).Result;

            if (response.IsSuccessStatusCode == true)
            {
                MessageBox.Show("Tạo thành công", "", MessageBoxButtons.OK);

                this.Close();
                return;
            }
            else
            {
                MessageBox.Show("Tạo thất bại", "", MessageBoxButtons.OK);
                return;
            }
        }
 public ActionResult Edit([Bind(Include = "id,username,name,password,address,email")] taikhoan taikhoan)
 {
     if (ModelState.IsValid)
     {
         db.Entry(taikhoan).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(taikhoan));
 }
Exemple #11
0
        public ActionResult DangKi(taikhoan tk)
        {
            var data = new TaikhoanController().InsertElement(tk);

            if (data == true)
            {
                return(RedirectToAction("Index"));
            }

            return(RedirectToAction("Index"));
        }
        public ActionResult Create([Bind(Include = "id,username,name,password,address,email")] taikhoan taikhoan)
        {
            if (ModelState.IsValid)
            {
                db.taikhoans.Add(taikhoan);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(taikhoan));
        }
Exemple #13
0
 public Form_QuanLy(taikhoan tk)
 {
     InitializeComponent();
     this.tk = tk;
     Form_ChoThue  ChoThue  = new Form_ChoThue();
     Form_Dichvu   Dichvu   = new Form_Dichvu(this.tk);
     Form_Hopdong  Hopdong  = new Form_Hopdong();
     Form_Nhanvien Nhanvien = new Form_Nhanvien();
     Form_Canho    Canho    = new Form_Canho();
     Form_Thongtin Thongtin = new Form_Thongtin();
 }
Exemple #14
0
        public JsonResult UpdateMatKhau(taikhoan tk)
        {
            tk.id = ((taikhoan)Session[CommonConstants.SESSION_ACCOUNT]).id;
            bool kq = new TaikhoanController().UpdateMatKhau(tk);

            if (kq == true)
            {
                return(Json("Cap Nhap Thanh cong", JsonRequestBehavior.AllowGet));
            }

            return(Json("Cap nhat khong thanh cong", JsonRequestBehavior.AllowGet));
        }
Exemple #15
0
        /// <summary>
        /// /AuthCallback/IndexAsync
        /// </summary>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>

        public async Task <ActionResult> IndexAsync(CancellationToken cancellationToken)
        {
            var result = await new AuthorizationCodeMvcApp(this, new AppFlowMetadata()).
                         AuthorizeAsync(cancellationToken);

            if (result.Credential != null)
            {
                var service = new PlusService(new BaseClientService.Initializer
                {
                    HttpClientInitializer = result.Credential,
                    ApplicationName       = "ASP.NET MVC Sample"
                });

                // YOUR CODE SHOULD BE HERE..
                // SAMPLE CODE:
                Person me = service.People.Get("me").Execute();
                if (me != null)
                {
                    taikhoan taik = new TaikhoanController().CheckGoole(me.Id);
                    if (taik == null)
                    {
                        taikhoan taikhoan = new taikhoan()
                        {
                            email    = me.Emails.ElementAt(0).Value,
                            GoogleID = me.Id,
                            hinhanh  = me.Image.Url,
                        };
                        bool resutl = new TaikhoanController().DangNhapGoogle(taikhoan);
                        Session.Add(CommonConstants.SESSION_ACCOUNT, taikhoan);


                        if (Session["CurrentUrl"] != null)
                        {
                            return(Redirect((string)Session["CurrentUrl"]));
                        }
                        return(RedirectToAction("Index", "QuanLy"));
                    }

                    Session.Add(CommonConstants.SESSION_ACCOUNT, taik);
                    return(RedirectToAction("Index", "QuanLy"));
                }



                //    ViewBag.Message = "FILE COUNT IS: " + list.Items.Count();
                return(RedirectToAction("Index"));
            }
            else
            {
                return(new RedirectResult(result.RedirectUri));
            }
        }
Exemple #16
0
 public ActionResult SuaTK(taikhoan Sanpham)
 {
     try
     {
         DB.Entry(Sanpham).State = EntityState.Modified;
         DB.SaveChanges();
         return(RedirectToAction("QuanLyTaiKhoan", "TaiKhoan"));
     }
     catch
     {
         return(View());
     }
 }
 public taikhoan GetTaikhoan(string tentaikhoan)
 {
     try
     {
         CSDL     db = new CSDL();
         taikhoan l  = db.taikhoans.Find(tentaikhoan);
         return(l);
     }
     catch (Exception e)
     {
         return(null);
     }
 }
Exemple #18
0
        public int create(taikhoan tk)
        {
            //kiểm tra duplicate
            var result = db.taikhoans.Where(x => x.tentaikhoan.Equals(tk.tentaikhoan)).SingleOrDefault();

            if (result == null)
            {
                db.taikhoans.Add(tk);
                db.SaveChanges();
                return(1);
            }
            return(0);
        }
Exemple #19
0
 public ActionResult CapNhatTaiKhoan(taikhoan TaiKhoan)
 {
     try
     {
         DB.Entry(TaiKhoan).State = EntityState.Modified;
         DB.SaveChanges();
         return(RedirectToAction("DanhSachTK", "TaiKhoan"));
     }
     catch
     {
         return(View());
     }
 }
Exemple #20
0
        public ActionResult SPSach()
        {
            taikhoan tk = (taikhoan)Session[CommonConstants.SESSION_ACCOUNT];

            DonHangValue Dh = new GioHangController().KiemTraTkTrongDonHang(tk.id);

            List <ThongTinGioHang> DanhsachSP = new GioHangController().DanhSachSpTrongGio(Dh.IdDonHang);

            decimal?TongTien = new GioHangController().TongTien(Dh.IdDonHang);

            ViewBag.TongTien = TongTien;

            return(View(DanhsachSP));
        }
        // GET: taikhoans/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            taikhoan taikhoan = db.taikhoans.Find(id);

            if (taikhoan == null)
            {
                return(HttpNotFound());
            }
            return(View(taikhoan));
        }
        // GET: LoginUser

        #region Đăng Nhập
        public JsonResult DangNhap(taikhoan tk)
        {
            if (ModelState.IsValid)
            {
                taikhoan user = new TaikhoanController().CheckElement(tk);
                if (user != null)
                {
                    Session.Add(CommonConstants.SESSION_ACCOUNT, user);
                    FormsAuthentication.SetAuthCookie(tk.nguoidung, true);
                    return(Json(true, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(false, JsonRequestBehavior.AllowGet));
        }
Exemple #23
0
 private void iconbtnAccept_Click(object sender, EventArgs e)
 {
     if (txtOldPass.TextLength == 0 || txtConfirmPass.TextLength == 0 || txtNewpass.TextLength == 0)
     {
         MessageBox.Show("Vẫn còn thông tin bị bỏ sót");
     }
     else if (txtNewpass.Text != txtConfirmPass.Text)
     {
         MessageBox.Show("Mật khẩu không khớp với nhau");
     }
     else if (txtNewpass.TextLength < 6)
     {
         MessageBox.Show("Mật khẩu quá ngắn");
     }
     else
     {
         if (MessageBox.Show("Bạn có chắc muốn đổi mật khẩu?", "Thông báo", MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.OK)
         {
             AccountDAO1 accountDAO1 = new AccountDAO1();
             if (accountDAO1.getAccountLogedin().matkhau != Script.MD5Hash(txtOldPass.Text))
             {
                 MessageBox.Show("mật khẩu cũ không đúng");
             }
             else
             {
                 try
                 {
                     StaffDAO1 staff = new StaffDAO1();
                     taikhoan  tk    = new taikhoan();
                     tk.manv        = staff.getIDbyUsername(Program.idLoged);
                     tk.tentaikhoan = Program.idLoged;
                     tk.matkhau     = Script.MD5Hash(txtNewpass.Text);
                     if (accountDAO1.Edit(tk) == 1)
                     {
                         MessageBox.Show("Thêm thành công");
                     }
                     else
                     {
                         MessageBox.Show("Đổi mật khẩu thất bại");
                     }
                 }
                 catch
                 {
                     MessageBox.Show("Có lỗi xảy ra!!!");
                 }
             }
         }
     }
 }
Exemple #24
0
        public int Edit(taikhoan tk)
        {
            var result = db.taikhoans.Find(tk.tentaikhoan);

            if (result != null)
            {
                //code update db

                result.manv        = tk.manv;
                result.tentaikhoan = tk.tentaikhoan;
                result.matkhau     = tk.matkhau;
                db.SaveChanges();
                return(1);
            }
            return(0);
        }
Exemple #25
0
        public ActionResult DangNhap(taikhoan tk)
        {
            var data = new TaikhoanController().CheckElement(tk);

            if (ModelState.IsValid)
            {
                if (data != null)
                {
                    Session.Add(CommonConstants.SESSION_ACCOUNT, data);
                    FormsAuthentication.SetAuthCookie(data.nguoidung, true);
                    return(RedirectToAction("Index", "QuanLy"));
                }
            }

            return(RedirectToAction("Index"));
        }
 public bool Login(string tentaikhoan, string matkhau)
 {
     try
     {
         CSDL     db = new CSDL();
         taikhoan l  = db.taikhoans.Find(tentaikhoan);
         if (l != null && l.matkhau.CompareTo(matkhau) == 0)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemple #27
0
        private void iconbtnAdd_Click(object sender, EventArgs e)
        {
            AccountDAO1 accountDAO1 = new AccountDAO1();
            taikhoan    tk          = new taikhoan();

            tk.tentaikhoan = txt_tk.Text;
            tk.matkhau     = Script.MD5Hash(txt_mk.Text);
            tk.manv        = txt_manv.Text;
            if (accountDAO1.create(tk) == 1)
            {
                MessageBox.Show("Thêm thành công");
            }
            else
            {
                MessageBox.Show("Thêm thất bại");
            }
        }
      private void btdangnhap_Click(object sender, EventArgs e)
      {
          taikhoan tk = new taikhoan();
          var      r  = tk.Select("USERNAME='******'and MATKHAU='" + tbxmatkhau.Text + "'");

          if (r.Count() > 0)

          {
              f.Text = "Xin Chào " + r[0]["TENNV"].ToString();
              f.enablebutton((int)r[0]["MAPHANQUYEN"]);
              this.OnClosed(e);
          }
          else
          {
              MessageBox.Show("Sai tên đăng nhập hoặc mật khẩu");
          }
      }
Exemple #29
0
 public ActionResult SignUp(string ten, DateTime nsinh, string dchi, string gtinh, string username, string password, string password1, string sdt)
 {
     if (password != password1)
     {
         ViewData["thongbao"] = "error";
         return(View());
     }
     else
     {
         KhachhangDao khdao = new KhachhangDao();
         khachhang    kh    = new khachhang();
         kh.HOTEN    = ten;
         kh.NGSINH   = nsinh.Date;
         kh.GIOITINH = gtinh;
         kh.DCHI     = dchi;
         kh.NGDK     = DateTime.Now.Date;
         kh.SODT     = sdt;
         int check = khdao.ThemKhachHang(kh);
         if (check != 0)
         {
             taikhoan tk = new taikhoan();
             tk.USERNAME = username;
             tk.PASSWORD = password;
             tk.MAKH     = kh.MAKH;
             tk.LOAITK   = 1;
             context.taikhoans.Add(tk);
             int check2 = context.SaveChanges();
             if (check2 != 0)
             {
                 Response.Redirect("/Register/Login");
             }
             else
             {
                 ViewData["thongbao"] = "error";
                 return(View());
             }
         }
         else
         {
             ViewData["thongbao"] = "error";
             return(View());
         }
         return(View());
     }
 }
Exemple #30
0
        private void btnSua_Click(object sender, EventArgs e)
        {
            if (dgvDanhSachNhanVien.SelectedRows.Count != 1)
            {
                MessageBox.Show("Vui lòng chỉ chọn 1 nhân viên", "Cảnh báo");
            }
            else
            {
                if (txtMaNhanVien.Text == "" || txtTenDangNhap.Text == "")
                {
                    MessageBox.Show("Vui lòng không được sửa mã nhân viên và tên đăng nhập!", "Cảnh báo");
                }
                else
                {
                    nhanvien nv = new nhanvien();
                    taikhoan tk = new taikhoan();
                    nv.manhanvien  = Convert.ToInt32(txtMaNhanVien.Text);
                    nv.tennhanvien = txtHoTen.Text;
                    if (rdbtnNam.Checked == true)
                    {
                        nv.gioitinh = "Nam";
                    }
                    if (rdbtnNu.Checked == true)
                    {
                        nv.gioitinh = "Nữ";
                    }
                    nv.sdt         = txtSoDienThoai.Text;
                    nv.cmnd        = txtSoCMND.Text;
                    nv.ngaysinh    = dtpNgaySinh.Value;
                    nv.machucvu    = ((CBBItem)cbxChucvu.SelectedItem).Value;
                    tk.tendangnhap = txtTenDangNhap.Text;
                    tk.matkhau     = txtMatKhau.Text;

                    if (BLL_Nhanvien.Instance.Edit_NV(nv) == true && BLL_TaiKhoan.Instance.Edit_TK(tk) == true)
                    {
                        MessageBox.Show("Sửa thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        DSNV();
                    }
                    else
                    {
                        MessageBox.Show("Sửa thất bại!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
        }