public void SaveAction(object selectedItem) { //Edit Action if (!CurrentItem.Id.Equals(0)) { SelectedItem.Name = CurrentItem.Name; SelectedItem.Type = CurrentItem.Type; SelectedItem.Capacity = CurrentItem.Capacity; db.SaveChanges(); } else { //Room r = db.Rooms.Add(new Room() { Name = CurrentRoom.Name, Capacity = CurrentRoom.Capacity , Type = CurrentRoom.Room.Type, WorkLocationId = location.Id}).Entity; RoomViewModel room = new RoomViewModel() { Name = CurrentItem.Name, Capacity = CurrentItem.Capacity, Type = CurrentItem.Type, WorkLocationId = UserWorkLocation.Id }; ItemsList.Add(room); db.Rooms.Add(room.Model); db.SaveChanges(); //StudentsListView.Refresh(); SelectedItem = null; } IsEditModeOff = true; IsEditModeOn = false; }
private void Print_Click(object sender, RoutedEventArgs e) { List <Final> flist = new List <Final>(); flist = db.Finals.ToList <Final>(); foreach (Final i in flist) { db.Finals.Remove(i); db.SaveChanges(); } foreach (WatchTableViewModel wtvm in WatchesSchedule.Items) { Final f = new Final(); DateTime dtt = (DateTime)date.SelectedValue; f.Date = dtt.ToString("dd/MM/yyyy"); f.Period = period.Text; f.Roomname = wtvm.Room.Name; f.RoomChief = wtvm.RoomChiefs; f.RoomSecretarie = wtvm.RoomSecretaries; f.RoomWatcher = wtvm.RoomWatchers; f.StartTime = time.Text; f.dean = ExamInit.deanName; f.manager = ExamInit.wl; db.Finals.Add(f); db.SaveChanges(); } report1 r = new report1(); r.Show(); }
public void SaveAction(object selectedItem) { //Edit Action if (!CurrentItem.Id.Equals(0)) { SelectedItem.Id = CurrentItem.Id; SelectedItem.FirstName = CurrentItem.FirstName; SelectedItem.MiddleName = CurrentItem.MiddleName; SelectedItem.LastName = CurrentItem.LastName; SelectedItem.Title = CurrentItem.Title; SelectedItem.FullName = CurrentItem.FullName; SelectedItem.Job = CurrentItem.Job; SelectedItem.Class = CurrentItem.Class; SelectedItem.Certificate = CurrentItem.Certificate; //SelectedItem.WorkLocationId = CurrentItem.WorkLocationId; db.SaveChanges(); } else { WatcherManageViewModel watcher = new WatcherManageViewModel() { FirstName = CurrentItem.FirstName, MiddleName = CurrentItem.MiddleName, LastName = CurrentItem.LastName, Title = CurrentItem.Title, //FullName = CurrentItem.FullName, Job = CurrentItem.Job, Class = CurrentItem.Class, Certificate = CurrentItem.Certificate, WorkLocationId = UserWorkLocation.Id }; ItemsList.Add(watcher); db.Watchers.Add(watcher.Model); //ItemsList.Add(new WatcherManageViewModel(watcher)); db.SaveChanges(); //StudentsListView.Refresh(); SelectedItem = null; } IsEditModeOff = true; IsEditModeOn = false; }
private void ManagerNameSaveChanges_Click(object sender, RoutedEventArgs e) { work_locationl.Manager = manager_name.Text; db.WorkLocations.Update(work_locationl); db.SaveChanges(); //ManagerNameCancel.IsEnabled = false; //ManagerNameSaveChanges.IsEnabled = false; //ManagerNameStartEdit.IsEnabled = true; ManagerNameCancel.Visibility = Visibility.Hidden; ManagerNameSaveChanges.Visibility = Visibility.Hidden; ManagerNameStartEdit.Visibility = Visibility.Visible; manager_name.IsEnabled = false; }
private void Print_Click(object sender, RoutedEventArgs e) { List <Print> flist = new List <Print>(); flist = db.Prints.ToList <Print>(); foreach (Print i in flist) { db.Prints.Remove(i); db.SaveChanges(); } foreach (WatcherWatchTableViewModel wtvm in WatcherSchedule.Items) { Print f = new Print(); f.FullName = WatcherName.Text; f.worklocation = worloc.Text; DateTime dttt = (DateTime)wtvm.Watch.WatchDate; f.WatchDate = dttt.ToString("dd/MM/yyyy"); f.PeriodId = wtvm.Watch.PeriodId.ToString(); f.Name = wtvm.WatchRoom.Name; f.WatchType = wtvm.WatchType; f.RoomChief = wtvm.RoomChief; f.attendence = wtvm.Attendence; f.dean = ExamInit.deanName; f.manager = ExamInit.wl; db.Prints.Add(f); db.SaveChanges(); } report2 r = new report2(); r.Show(); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (FirstDataGramData.Count() == 0) { MessageBox.Show("لم يتم تحديد أيام للتوزيع"); return; } List <Watch> Watches = new List <Watch>(); Watch watch; int NumberOfRooms = Scheduling1.SelectedRooms.Count(); int NumberOfCheifs = Scheduling2.BossWatcherList.Count(); int NumberOfSecretaries = Scheduling2.SecretaryWatchersList.Count(); int NumberOfWatchers = Scheduling2.OrdinaryWatchersList.Count(); if (NumberOfRooms == 0) { MessageBox.Show("لم يتم اختيار أي قاعة للتوزيع"); return; } //if (NumberOfCheifs < NumberOfRooms) { MessageBox.Show("عدد رؤساء القاعات أقل من عدد القاعات"); return; } if (NumberOfSecretaries < NumberOfRooms) { MessageBox.Show("عدد أمناء السر أقل من عدد القاعات"); return; } //if (NumberOfWatchers < NumberOfRooms) { MessageBox.Show("عدد المراقبين أقل من عدد القاعات"); return; } foreach (Scheduling3ViewModel s in BaseList) { watch = new Watch() { Duration = s.PD, ExamId = ExamInit.examID, PeriodId = s.periodID, StartTime = s.startTime, WorkLocationId = WORK_LOCATION_ID, WatchDate = s.day, WatcherWatches = new List <WatcherWatch>() }; Watches.Add(watch); //} } foreach (Watch w in Watches) { Queue <Watcher> RoomChiefs = new Queue <Watcher>(); Queue <Watcher> RoomSecretaries = new Queue <Watcher>(); Queue <Watcher> RoomWatchers = new Queue <Watcher>(); foreach (WatcherViewModel wv in Scheduling2.BossWatcherList) { RoomChiefs.Enqueue(db.Watchers.Find(wv.Id)); } foreach (WatcherViewModel wv in Scheduling2.SecretaryWatchersList) { RoomSecretaries.Enqueue(db.Watchers.Find(wv.Id)); } foreach (WatcherViewModel wv in Scheduling2.OrdinaryWatchersList) { RoomWatchers.Enqueue(db.Watchers.Find(wv.Id)); } while (!(RoomChiefs.Count == 0 && RoomSecretaries.Count == 0 && RoomWatchers.Count == 0)) { foreach (RoomView roomView in Scheduling1.SelectedRooms) { //foreach(WatcherViewModel wvm in Scheduling2.BossWatcherList) //{ if (!RoomChiefs.Count.Equals(0)) { w.WatcherWatches.Add( new WatcherWatch() { WatchId = w.Id, WatcherId = RoomChiefs.Dequeue().Id, //WatcherId = wvm.Id, WatcherType = "1", RoomId = roomView.Id } ); } //} //foreach (WatcherViewModel wvm in Scheduling2.SecretaryWatchersList) //{ if (!RoomSecretaries.Count.Equals(0)) { w.WatcherWatches.Add( new WatcherWatch() { WatchId = w.Id, WatcherId = RoomSecretaries.Dequeue().Id, //WatcherId = wvm.Id, WatcherType = "2", RoomId = roomView.Id } ); } //} //foreach (WatcherViewModel wvm in Scheduling2.OrdinaryWatchersList) //{ if (!RoomWatchers.Count.Equals(0)) { w.WatcherWatches.Add( new WatcherWatch() { WatchId = w.Id, WatcherId = RoomWatchers.Dequeue().Id, //WatcherId = wvm.Id, WatcherType = "3", RoomId = roomView.Id } ); } } } } foreach (Watch w in Watches) { db.Watches.Add(w); } db.SaveChanges(); MessageBox.Show("تم التوزيع بنجاح"); MessageBox.Show("تم توزيع: " + NumberOfSecretaries + "أمين سر، " + NumberOfWatchers + " مراقب، " + NumberOfCheifs + " رئيس قاعة . على " + NumberOfRooms + " قاعة"); BaseList.Clear(); Watches.Clear(); FirstDataGramData.Clear(); }