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);
        }
Пример #2
0
        public ChiTietHoiNghiWindow(HOINGHI HoiNghi)
        {
            InitializeComponent();
            ChiTietHoiNghiViewModel viewModel = new ChiTietHoiNghiViewModel(HoiNghi, this);

            this.viewModel   = viewModel;
            this.DataContext = viewModel;
        }
        public CapQuyenHoiNghiWindow(HOINGHI HoiNghi, String type)
        {
            InitializeComponent();
            CapQuyenHoiNghiViewModel viewModel = new CapQuyenHoiNghiViewModel(HoiNghi, type);

            this.viewModel   = viewModel;
            this.DataContext = this.viewModel;
        }
 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);
 }
        public DanhSachDangKyHoiNghi(HOINGHI hoiNghi)
        {
            InitializeComponent();
            viewModel = new DanhSachDangKyHoiNghiViewModel(hoiNghi);
            int total = viewModel.ListDangKyUser.Count;

            viewModel.PagingInfo = new PagingInfo(NUMBER_USER_PER_PAGE, total);
            loadPage(1);
        }
        public ChinhSuaHoiNghiViewModel(HOINGHI hoiNghi, Window window)
        {
            this.Window  = window;
            this.HoiNghi = hoiNghi;

            LoadData();

            this.ChooseImageCommand = new RelayCommand(ChooseImage);
            this.SaveHoiNghiCommand = new RelayCommand(SaveHoiNghi);
            this.CapQuyenCommand    = new RelayCommand(CapQuyen);
        }
        private void chinhSuaBtn_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                int index = 0;
                index = lvDanhSachHoiNghiQL.SelectedIndex;

                HOINGHI hn = viewModel.ListHoiNghi[((viewModel.PagingInfo.CurrentPage - 1) * 4) + index];
                ChinhSuaHoiNghiWindow CSHN = new ChinhSuaHoiNghiWindow(hn);
                CSHN.Show();
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        private void CapQuyen()
        {
            if (!IsSaved)
            {
                MessageBox.Show("Hội nghị phải được lưu trước khi cấp quyền.");
                return;
            }

            using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities())
            {
                HOINGHI hoiNghi = (HOINGHI)db.HOINGHIs.Where(hn => hn.IDHN == SavedId).FirstOrDefault();
                CapQuyenHoiNghiWindow window = new CapQuyenHoiNghiWindow(hoiNghi, "0");
                //this.Window.Show();
                window.Show();
                this.Window.Close();
            }
        }
        private void AddHoiNghi()
        {
            if (!ValidateInput())
            {
                return;
            }

            try
            {
                using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities())
                {
                    int id = db.HOINGHIs.Max(hn => hn.IDHN) + 1;

                    HOINGHI HoiNghi = new HOINGHI();
                    HoiNghi.IDHN            = id;
                    HoiNghi.IDDD            = ListDiaDiem[IndexDiaDiem].IDDD;
                    HoiNghi.TENHN           = TenHoiNghi;
                    HoiNghi.MOTACHITIETHN   = NoiDungHoiNghi;
                    HoiNghi.THOIGIANBATDAU  = NgayBatDau;
                    HoiNghi.THOIGIANKETTHUC = NgayKetThuc;
                    String path = SaveImage(ImagePathHoiNghi);
                    HoiNghi.HINHANH    = path;
                    HoiNghi.MOTANGANHN = MoTa;
                    HoiNghi.SOLUONG    = int.Parse(SoLuong);

                    db.HOINGHIs.Add(HoiNghi);
                    db.SaveChanges();

                    CHITIETADMIN ChiTietAdmin = new CHITIETADMIN();
                    ChiTietAdmin.IDHN      = id;
                    ChiTietAdmin.IDUSER    = DangNhapViewModel.User.IDUSER;
                    ChiTietAdmin.LOAIADMIN = "0";
                    db.CHITIETADMINs.Add(ChiTietAdmin);
                    db.SaveChanges();

                    IsSaved = true;
                    SavedId = id;
                    MessageBox.Show("Đã thêm hội nghị.");
                }
            }
            catch
            {
                MessageBox.Show("Đã có lỗi xảy ra.");
                return;
            }
        }
Пример #10
0
        public CapQuyenHoiNghiViewModel(HOINGHI HoiNghi, String type)
        {
            this.HoiNghi   = HoiNghi;
            this.LoaiAdmin = type;
            this.PageIndex = 1;

            using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities())
            {
                float count = db.USERs.Where(u => u.LOAIUSER.Equals("1")).Count();
                LastPage   = (int)Math.Ceiling(count / USER_PER_PAGE);
                Pagination = PageIndex.ToString() + "/" + LastPage.ToString();
            }

            this.ListCapQuyenUser = new ObservableCollection <CapQuyenUser>();
            LoadData();

            PreviousPageCommand = new RelayCommand(GetPreviousPage);
            NextPageCommand     = new RelayCommand(GetNextPage);
        }
        private void SaveHoiNghi()
        {
            if (!ValidateInput())
            {
                LoadData();
                return;
            }

            try
            {
                using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities())
                {
                    HOINGHI hoiNghi = (from hn in db.HOINGHIs where hn.IDHN == this.HoiNghi.IDHN select hn).ToList().FirstOrDefault();

                    hoiNghi.TENHN           = TenHoiNghi;
                    hoiNghi.MOTACHITIETHN   = NoiDungHoiNghi;
                    hoiNghi.IDDD            = this.ListDiaDiem[IndexDiaDiem].IDDD;
                    hoiNghi.THOIGIANBATDAU  = NgayBatDau;
                    hoiNghi.THOIGIANKETTHUC = NgayKetThuc;

                    if (!ImagePathHoiNghi.Contains(hoiNghi.HINHANH))
                    {
                        String path    = SaveImage(ImagePathHoiNghi);
                        String oldPath = hoiNghi.HINHANH;
                        hoiNghi.HINHANH = path;
                    }


                    hoiNghi.MOTANGANHN = MoTa;
                    hoiNghi.SOLUONG    = int.Parse(SoLuong);

                    db.SaveChanges();

                    MessageBox.Show("Đã cập nhật thông tin hội nghị.");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Đã có lỗi xảy ra.");
            }
        }
        private void UnSignUp()
        {
            if (DangNhapViewModel.User == null)
            {
                DangNhapWindow dangNhapWindow = new DangNhapWindow();
                dangNhapWindow.Show();
                this.Window.Close();
            }
            else
            {
                try
                {
                    using (DBQuanLiHoiNghiEntities db = new DBQuanLiHoiNghiEntities())
                    {
                        var dky = from dk in db.DANGKITHAMGIAs
                                  where dk.IDHN == this.HoiNghi.IDHN && dk.IDUSER == DangNhapViewModel.User.IDUSER
                                  select dk;
                        if (dky.Count() > 0)
                        {
                            if (dky.First().TRANGTHAI == 2)
                            {
                                HOINGHI hn = db.HOINGHIs.Where(o => o.IDHN == this.HoiNghi.IDHN).FirstOrDefault();
                                hn.SOLUONG -= 1;
                            }
                            db.DANGKITHAMGIAs.Remove(dky.First());

                            db.SaveChanges();
                            Status        = 0;
                            SignUpCommand = new RelayCommand(SignUp);
                        }
                    }
                }
                catch
                {
                    MessageBox.Show("Đã có lỗi xảy ra.");
                }
            }
        }
 public DanhSachDangKyHoiNghiViewModel(HOINGHI HoiNghi)
 {
     this.HoiNghi        = HoiNghi;
     this.ListDangKyUser = new ObservableCollection <XacNhanDangKyUser>();
     LoadData();
 }