Ejemplo n.º 1
0
        public MainViewModel()
        {
            instance = this;

            this.dayDataService = new DayDataService();

            this.CurrentDay = dayDataService.GetCurrentDay();
            this.WeekDays   = this.dayDataService.GetCurrentWeekDays();

            this.Fichada = new FichadaViewModel();
            this.Semana  = new SemanaViewModel();

            this.InitializeTimer();
        }
Ejemplo n.º 2
0
        public MainViewModel()
        {
            instance = this;

            dayDataService = new DayDataService();

            CurrentDay = dayDataService.GetCurrentDay();
            WeekDays   = dayDataService.GetCurrentWeekDays();

            Fichada = new FichadaViewModel();
            Semana  = new SemanaViewModel();

            InitializeTimer();
        }
Ejemplo n.º 3
0
        public Tab_Main_Days()
        {
            InitializeComponent();

            stackPanelBorderCreated = false;

            //retrieving the DaysAndHours data from the DB if exists
            try
            {
                //setting the selected Days list to an ObservableCollection so it could be bound to the view
                theDaysList      = new ObservableCollection <Day>(timetableManagerDbContext.Days);
                selectedDaysList = new ObservableCollection <string>();

                //the DataService for Days table
                DayDataService dayDataService = new DayDataService(new EntityFramework.TimetableManagerDbContext());

                //setting the rest of the saved data
                daysAndHours = timetableManagerDbContext.DaysAndHours.FirstOrDefault <DaysAndHours>();

                if (daysAndHours != null)
                {
                    noOfDays = daysAndHours.NoOfDays;
                    hours    = daysAndHours.Hours;
                    mins     = daysAndHours.Mins;
                    timeSlot = daysAndHours.TimeSlot;

                    //setting data to the view
                    comboBoxNoOfDays.SelectedIndex = noOfDays;
                    comboBoxHours.SelectedIndex    = hours;

                    if (mins.Equals(30))
                    {
                        comboBoxMinutes.Text = "30";
                    }
                    else if (mins.Equals(60))
                    {
                        comboBoxMinutes.Text = "00";
                    }

                    if (timeSlot.Equals(30))
                    {
                        comboBoxDuration.Text = "30 mins";
                    }
                    else if (timeSlot.Equals(60))
                    {
                        comboBoxDuration.Text = "1 hour";
                    }
                }
                if (theDaysList != null)
                {
                    foreach (Day day in theDaysList)
                    {
                        if (day.IsSelected == true)
                        {
                            createStackPanelBorder();
                            createStackPanel(day.DayName, day.IsSelected, day.startHour, day.startMin, day.endHour, day.endMin);
                        }
                    }
                }
                this.DataContext = this;
            }
            catch (Exception e)
            {
                //in case if the connection to the DB is lost
                MessageBox.Show("first error " + e.Message);
            }
        }