예제 #1
0
 private void SubjectCommand_Executed(object sender, ExecutedRoutedEventArgs e)
 {
     if (!ComputerCentre.SoftwareRepository.GetAll().ToList().Any())
     {
         MessageBox.Show("No softwares available,\nplease add at least one software first!");
     }
     else if (!ComputerCentre.CourseRepository.GetAll().ToList().Any())
     {
         MessageBox.Show("No courses available,\nplease add at least one course first!");
     }
     else
     {
         this.IsEnabled = false;
         var w = new View.SubjectsWindow();
         w.ShowDialog();
     }
     this.IsEnabled = true;
 }
예제 #2
0
        public void view()
        {
            classroomsList = ComputerCentre.context.Classrooms.Include(s => s.Softwares).ToList();
            dt             = new DataTable();
            dt.Columns.Add("Name");
            dt.Columns.Add("Code");
            dt.Columns.Add("Description");
            dt.Columns.Add("NumOfSeats");
            dt.Columns.Add("Projector");
            dt.Columns.Add("Table");
            dt.Columns.Add("SmartTable");
            dt.Columns.Add("OsType");
            dt.Columns.Add("Softwares");
            foreach (Classroom cr in classroomsList)
            {
                DataRow dr = dt.NewRow();
                if (cr.Description.Length > 40)
                {
                    dr["Description"] = cr.Description.Substring(1, 40) + "...";
                }
                else
                {
                    dr["Description"] = cr.Description;
                }
                dr["Name"]       = cr.Name;
                dr["Code"]       = cr.Code;
                dr["NumOfSeats"] = cr.NumOfSeats;
                if (cr.Projector)
                {
                    dr["Projector"] = "YES";
                }
                else
                {
                    dr["Projector"] = "NO";
                }
                if (cr.Table)
                {
                    dr["Table"] = "YES";
                }
                else
                {
                    dr["Table"] = "NO";
                }
                dr["OsType"] = cr.OsType;
                if (cr.SmartTable)
                {
                    dr["SmartTable"] = "YES";
                }
                else
                {
                    dr["SmartTable"] = "NO";
                }
                dr["Softwares"] = SubjectsWindow.SoftwaresToString(cr.Softwares);
                dt.Rows.Add(dr);
            }
            gvData.ItemsSource = dt.AsDataView();

            if (dt.Rows.Count > 0)
            {
                noClassrooms.Visibility = System.Windows.Visibility.Hidden;
                gvData.Visibility       = System.Windows.Visibility.Visible;
            }
            else
            {
                noClassrooms.Visibility = System.Windows.Visibility.Visible;
                gvData.Visibility       = System.Windows.Visibility.Hidden;
            }
        }