예제 #1
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            login_user = new User();
            db         = new ExamWatchesDBContext();

            string name = username.Text;
            string pw   = password.Password;



            int num = db.Users.Where(x => x.Username == name && x.Password == pw).Count();

            if (num == 1)
            {
                login_user = db.Users.Where(x => x.Username == name && x.Password == pw).FirstOrDefault();

                App.Current.Properties["user_id"] = login_user.Id;

                user_id = login_user.Id;
                MessageBox.Show("أهلا بك " + login_user.FirstName);
                mainui = new MainUI(user_id);
                mainui.Show();
                this.Close();
            }
            else
            {
                MessageBox.Show("اسم المستخدم أو كلمة المرور غير صالحة");
            }
            //  db.Users.Select(x => x);
        }
예제 #2
0
        public Scheduling3()
        {
            //EXAM_ID= ExamInit.examID;
            FirstDataGramData  = new ObservableCollection <fillFirstDataGridmodel>();
            SecondDataGramData = new ObservableCollection <Scheduling3ViewModel>();
            BaseList           = new ObservableCollection <Scheduling3ViewModel>();


            periodList = new ObservableCollection <int> {
                1, 2, 3
            };
            periodDurationList = new ObservableCollection <decimal> {
                60, 90, 120, 150, 180, 210, 240
            };

            InitializeComponent();
            Periods.ItemsSource  = FirstDataGramData;
            Periods2.ItemsSource = SecondDataGramData;
            db = new ExamWatchesDBContext();

            int userid = Int32.Parse(App.Current.Properties["user_id"].ToString());

            CurrentUser      = db.Users.Find(userid);
            UserWorkLocation = db.WorkLocations.Find(CurrentUser.WorkLocationId);
            WORK_LOCATION_ID = UserWorkLocation.Id;
            //ComboBox cb= Periods.Columns[1].GetCellContent(Periods.Items[0]) as ComboBox;
        }
예제 #3
0
        public MainUI(int userid) : this()
        {
            User         user;
            WorkLocation location;

            using (ExamWatchesDBContext db = new ExamWatchesDBContext())
            {
                //db.WorkLocations.Include(loc => loc.Users);

                user            = db.Users.Find(userid);
                location        = db.WorkLocations.Find(user.WorkLocationId);
                CurrentUserName = user.FirstName + " " + user.LastName;
            }
            //MessageBox.Show(CurrentUserName);
            UserName.Content = "تم تسجيل الدخول باسم: " + CurrentUserName + " - " + location.Name;
        }
예제 #4
0
        public SchedulingFinalViewModel()

        {
            CurrentExamId = Views.ExamInit.examID;
            db            = new ExamWatchesDBContext();
            int userid = Int32.Parse(App.Current.Properties["user_id"].ToString());

            CurrentUser      = db.Users.Find(userid);
            UserWorkLocation = db.WorkLocations.Find(CurrentUser.WorkLocationId);
            CollegeName      = CurrentUser.WorkLocation.Name;
            WatchDates       = new ObservableCollection <DateTime?>();
            PeriodValues     = new ObservableCollection <short?>();
            WatchesList      = new ObservableCollection <WatchTableViewModel>();

            Initialization();

            WatchesListView     = CollectionViewSource.GetDefaultView(WatchesList);
            SelectedWatchDate   = WatchDates.FirstOrDefault();
            SelectedWatchPeriod = PeriodValues.FirstOrDefault();
        }
예제 #5
0
        public WatchersInitViewModel()
        {
            Classes = new List <string>()
            {
                "أولى", "ثانية", "ثالثة", "رابعة", "خامسة"
            };
            Titles = new List <string>()
            {
                "", "د.", "م.", "قا.", "أ.د."
            };



            IsEditModeOn  = false;
            IsEditModeOff = true;

            db = new ExamWatchesDBContext();

            int userid = Int32.Parse(App.Current.Properties["user_id"].ToString());

            CurrentUser      = db.Users.Find(userid);
            UserWorkLocation = db.WorkLocations.Find(CurrentUser.WorkLocationId);
            CollegeName      = CurrentUser.WorkLocation.Name;

            CurrentItem = new WatcherManageViewModel();

            Watchers  = db.Watchers.Where(w => w.WorkLocationId.Equals(CurrentUser.WorkLocationId)).ToList();
            ItemsList = new ObservableCollection <WatcherManageViewModel>();
            foreach (Watcher w in Watchers)
            {
                ItemsList.Add(new WatcherManageViewModel(w));
            }

            ItemsList.CollectionChanged += ItemsList_CollectionChanged;

            SelectedItemChangedCommand = new RelayCommand(SelectedItemChangedAction);
            SaveCommand      = new RelayCommand(SaveAction, null);
            StartEditCommand = new RelayCommand(StartEditAction, null);
            CancelCommand    = new RelayCommand(StopEditAction, null);
            DeleteCommand    = new RelayCommand(DeleteAction, null);
        }
예제 #6
0
        //private ObservableCollection<Room> _roomsList;

        //public event PropertyChangedEventHandler PropertyChanged;

        //public ObservableCollection<Room> RoomsList
        //{
        //    get { return _roomsList; }
        //    set { _roomsList = value; OnPropertyChanaged("RoomsList"); }
        //}



        public RoomsInitViewModel()
        {
            IsEditModeOn  = false;
            IsEditModeOff = true;

            db = new ExamWatchesDBContext();

            int userid = Int32.Parse(App.Current.Properties["user_id"].ToString());

            CurrentUser      = db.Users.Find(userid);
            UserWorkLocation = db.WorkLocations.Find(CurrentUser.WorkLocationId);
            CollegeName      = CurrentUser.WorkLocation.Name;
            CurrentItem      = new RoomViewModel();

            //CollegeName = db.WorkLocations.Find();
            //db.Rooms.Load();
            //RoomsList = db.Rooms.Local.ToObservableCollection();

            Rooms     = db.Rooms.Where(s => s.WorkLocationId.Equals(CurrentUser.WorkLocationId)).ToList();
            ItemsList = new ObservableCollection <RoomViewModel>();
            foreach (Room r in Rooms)
            {
                ItemsList.Add(new RoomViewModel(r));
            }

            ItemsList.CollectionChanged += ItemsList_CollectionChanged;


            Types = new List <string>()
            {
                "صغيرة", "متوسطة", "كبيرة", "مدرج"
            };

            SelectedItemChangedCommand = new RelayCommand(SelectedItemChangedAction);
            SaveCommand      = new RelayCommand(SaveAction, null);
            StartEditCommand = new RelayCommand(StartEditAction, null);
            CancelCommand    = new RelayCommand(StopEditAction, null);
            DeleteCommand    = new RelayCommand(DeleteAction, null);
        }
        public WatcherSchedulingViewModel()
        {
            db = new ExamWatchesDBContext();
            int userid = Int32.Parse(App.Current.Properties["user_id"].ToString());

            CurrentUser      = db.Users.Find(userid);
            UserWorkLocation = db.WorkLocations.Find(CurrentUser.WorkLocationId);
            CollegeName      = CurrentUser.WorkLocation.Name;

            CurrentExamId = Views.ExamInit.examID;

            WatcherWatches = db.WatcherWatches.Include(x => x.Watcher).Include(ww => ww.Room).ThenInclude(x => x.WorkLocation).Include(x => x.Watch)
                             //.ThenInclude(x => x.Room)
                             .Where(x => x.Watch.ExamId.Equals(CurrentExamId)).ToList();

            Watchers = WatcherWatches.Select(w => w.Watcher).Distinct().ToList();


            WatchesList = new ObservableCollection <WatcherWatchTableViewModel>();

            WatcherWatchTableViewModel row;
            List <string> demoList;

            foreach (WatcherWatch ww in WatcherWatches)
            {
                demoList            = new List <string>();
                WatchesList.Add(row = new WatcherWatchTableViewModel()
                {
                    Watch     = ww.Watch,
                    Watcher   = ww.Watcher,
                    WatchRoom = ww.Room,
                    //WatchType = ww.WatcherType,
                    //WatchDate = ww.Watch.WatchDate,
                    //WatchPeriodId = ww.Watch.PeriodId,
                    Attendence = ww.Attendence
                });

                if (ww.WatcherType.Equals("1"))
                {
                    row.WatchType = "رئيس قاعة";
                }
                else if (ww.WatcherType.Equals("2"))
                {
                    row.WatchType = "أمين سر";
                }
                else if (ww.WatcherType.Equals("3"))
                {
                    row.WatchType = "مراقب";
                }


                foreach (WatcherWatch x in db.WatcherWatches.Where(w => w.WatchId.Equals(ww.WatchId) && w.RoomId.Equals(ww.RoomId)).Include(x => x.Watcher).ToList())
                {
                    if (x.WatcherType.Equals("1"))
                    {
                        demoList.Add(x.Watcher.FullName);
                    }

                    //if(w.Id.Equals(ww.WatchId)&& ww.WatcherType.Equals("1"))
                    //{
                    //    row.RoomChief= w.
                    //}
                }

                row.RoomChief = string.Join(", ", demoList.ToArray());
            }

            WatchesListView = CollectionViewSource.GetDefaultView(WatchesList);
            SelectedWatcher = Watchers.FirstOrDefault();
            //db.WatcherWatches.Where()
        }