public ChiTietHoiNghiViewModel(HOINGHI hoiNghi, Window window)
        {
            this.Window = window;
            using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities())
            {
                this.HoiNghi = hoiNghi;
                DIADIEMTOCHUC diaDiem = (from dd in db.DIADIEMTOCHUCs
                                         where dd.IDDD == hoiNghi.IDDD
                                         select dd).ToList().FirstOrDefault();

                this.DiaDiem = diaDiem.TENDD + ", " + diaDiem.DIACHI;
                this.SucChua = diaDiem.SUCCHUA;

                if (DangNhapViewModel.User == null)
                {
                    this.Status        = 0;
                    this.SignUpCommand = new RelayCommand(SignUp);
                }
                else
                {
                    DANGKITHAMGIA dktg = (from dk in db.DANGKITHAMGIAs
                                          where dk.IDUSER == DangNhapViewModel.User.IDUSER && dk.IDHN == hoiNghi.IDHN
                                          select dk).FirstOrDefault();

                    this.Status        = dktg != null ? (dktg.TRANGTHAI == 1 ? -1 : 1) : 0;
                    this.SignUpCommand = Status == 0 ? new RelayCommand(SignUp) : new RelayCommand(UnSignUp);
                }
            }

            this.NgayBatDau       = this.HoiNghi.THOIGIANBATDAU.ToString("dd/MM/yyyy hh:mm");
            this.NgayKetThuc      = this.HoiNghi.THOIGIANKETTHUC.ToString("dd/MM/yyyy hh:mm");
            this.ImagePathHoiNghi = Path.Combine(Environment.CurrentDirectory, this.HoiNghi.HINHANH);
        }
 public XacNhanDangKyUser(USER user, DANGKITHAMGIA dangKy, HOINGHI hoiNghi, int sucChua)
 {
     this.User                 = user;
     this.DangKiThamGia        = dangKy;
     this.HoiNghi              = hoiNghi;
     this.SucChua              = sucChua;
     this.XacNhanDangKyCommand = new RelayCommand(xachNhanDangKy);
     this.ChanNguoiDungCommand = new RelayCommand(chanNguoiDung);
 }
        private void SignUp()
        {
            if (DangNhapViewModel.User == null)
            {
                DangNhapWindow dangNhapWindow = new DangNhapWindow();
                dangNhapWindow.Show();
                this.Window.Close();
            }
            else
            {
                if (this.HoiNghi.SOLUONG >= this.SucChua)
                {
                    MessageBox.Show("Số lượng tham gia hội nghị đã đạt giới hạn.");
                    return;
                }

                try
                {
                    using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities())
                    {
                        DANGKITHAMGIA dktg = (from dk in db.DANGKITHAMGIAs
                                              where dk.IDUSER == DangNhapViewModel.User.IDUSER && dk.IDHN == this.HoiNghi.IDHN
                                              select dk).FirstOrDefault();

                        if (dktg != null && dktg.TRANGTHAI == 1)
                        {
                            MessageBox.Show("Bạn đã bị chặn.");
                            return;
                        }

                        DANGKITHAMGIA dangky = new DANGKITHAMGIA();
                        dangky.IDHN       = this.HoiNghi.IDHN;
                        dangky.IDUSER     = DangNhapViewModel.User.IDUSER;
                        dangky.TRANGTHAI  = 0;
                        dangky.THOIGIANDK = DateTime.Now;
                        db.DANGKITHAMGIAs.Add(dangky);

                        db.SaveChanges();
                    }

                    Status        = 1;
                    SignUpCommand = new RelayCommand(UnSignUp);
                }
                catch
                {
                    MessageBox.Show("Đã có lỗi xảy ra.");
                }
            }
        }