Exemplo n.º 1
0
 private void AddMotherButton_Click(object sender, RoutedEventArgs e)
 {
     if (!(AddMotherButton.Content.ToString() == "update mother"))
     {
         try
         {
             mother = new Mother();
             SetTime(mother.serviseNeededTimeTable[0], startSundayTime, endSundayTime);
             SetTime(mother.serviseNeededTimeTable[1], startMondayTime, endMondayTime);
             SetTime(mother.serviseNeededTimeTable[2], startTuesdayTime, endTuesdayTime);
             SetTime(mother.serviseNeededTimeTable[3], startWednesdayTime, endWednesdayTime);
             SetTime(mother.serviseNeededTimeTable[4], startThursdayTime, endThursdayTime);
             SetTime(mother.serviseNeededTimeTable[5], startFridayTime, endFridayTime);
             bl.addMother(mother);
             System.Windows.MessageBox.Show("mother added succesfuly:", mother.ToString());
             Close();
         }
         catch (Exception x)
         {
             System.Windows.MessageBox.Show(x.Message);
         }
     }
     else
     {
         try
         {
             SetTime(mother.serviseNeededTimeTable[0], startSundayTime, endSundayTime);
             SetTime(mother.serviseNeededTimeTable[1], startMondayTime, endMondayTime);
             SetTime(mother.serviseNeededTimeTable[2], startTuesdayTime, endTuesdayTime);
             SetTime(mother.serviseNeededTimeTable[3], startWednesdayTime, endWednesdayTime);
             SetTime(mother.serviseNeededTimeTable[4], startThursdayTime, endThursdayTime);
             SetTime(mother.serviseNeededTimeTable[5], startFridayTime, endFridayTime);
             bl.addMother(mother);
             System.Windows.MessageBox.Show("mother added succesfuly:", mother.ToString());
             Close();
             bl.updateMotherDetalis(mother);
             System.Windows.MessageBox.Show("mother succesfuly updated :", mother.ToString());
             Close();
         }
         catch (Exception x)
         {
             System.Windows.MessageBox.Show(x.Message);
         }
     }
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {//delete button
            try
            {
                switch (flag)
                {
                // selectedMother;
                // selectedNanny;
                // selectedChild;
                // selectedContract;
                case 1:
                case 5:
                    var result = MessageBox.Show(selectedNanny.ToString(), "Are you sure you want to remove this Nanny?", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result == MessageBoxResult.Yes)
                    {
                        TheBL.deleteNanny(selectedNanny.ToString());
                        Close();
                    }
                    //WMPLib.WindowsMediaPlayer player = new WMPLib.WindowsMediaPlayer();
                    //player.URL = @"track.mp3";
                    //player.controls.play();
                    break;

                case 2:
                case 6:
                    var result2 = MessageBox.Show(selectedMother.ToString(), "Are you sure you want to remove this Mother?", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result2 == MessageBoxResult.Yes)
                    {
                        TheBL.deleteMother(selectedMother.ToString());
                        Close();
                    }
                    break;

                case 3:
                case 7:
                    var result3 = MessageBox.Show(selectedChild.ToString(), "Are you sure you want to remove this child?", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result3 == MessageBoxResult.Yes)
                    {
                        TheBL.deleteChild(selectedChild.ToString());
                        Close();
                    }
                    break;

                case 4:
                case 8:
                    var result4 = MessageBox.Show(selectedContract.ToString(), "Are you sure you want to remove this contract?", MessageBoxButton.YesNo, MessageBoxImage.Question);
                    if (result4 == MessageBoxResult.Yes)
                    {
                        TheBL.deleteChild(selectedContract.ToString());
                        Close();
                    }
                    break;

                default:    //for numbers 5-8
                    break;
                }
            }
            catch (Exception x)
            {
                MessageBox.Show(x.Message);
            }
        }