Ejemplo n.º 1
0
        public bool ConditionDeleteOffice()
        {
            IEnumerable <ClassTerm> query =
                from elem in ClassSqlCalendar.ListOfTerms()
                where elem.Office.OfficeId == ((ClassOffice)DataGridListOfOffice.SelectedItem).OfficeId
                select elem;

            if (query.Any())
            {
                string data = "This office cannot be removed because at this days meetings are being hosted in said of it: \n";
                foreach (ClassTerm queryResult in query)
                {
                    data += queryResult.Date.ToShortDateString() + "\n";
                }
                MessageBox.Show(data);
                return(false);
            }

            IEnumerable <ClassDoctor> query2 =
                from elem in ClassSQLConnections.DoctorList()
                where elem.OfficeNumber == ((ClassOffice)DataGridListOfOffice.SelectedItem).OfficeId
                select elem;

            if (query2.Any())
            {
                MessageBox.Show("This Office is currently occupied by " + query2.First().Name + " " + query2.First().Surname);
                return(false);
            }
            return(true);
        }