/// <summary>
 /// Save in the database the workingshfits
 /// </summary>
 /// <param name="wsList">List of WorkingShift</param>
 /// <param name="bd">database</param>
 public static void PersistWorkingShiftDataBase(List <WorkingShift> wsList, bd_easyplannerEntities bd)
 {
     foreach (WorkingShift ws in wsList)
     {
         bd.WorkingShifts.Add(ws);
     }
     bd.SaveChanges();
 }
Example #2
0
 public AddUser()
 {
     InitializeComponent();
     bdModel                   = bd_easyplannerEntities.OpenWithFallback();
     cbxRole.ItemsSource       = bdModel.Roles.ToList();
     cbxRole.DisplayMemberPath = "roleName";
     cbxRole.SelectedValuePath = "idRole";
     modify = false;
 }
        public static List <AbsencePreference> GetAbsPreferenceSlots(DateTime d, bd_easyplannerEntities bd)
        {
            DateTime lastMonday = GetMondayBefore(d);
            DateTime nextSunday = GetSundayAfter(d);

            // return all slot between monday and sunday
            //return bd.AbsencePreferences.Where(a => a.lastDate >= lastMonday && a.lastDate <= nextSunday).ToList();
            return(bd.AbsencePreferences.ToList());
        }
Example #4
0
        public MainWindow(Person user, Boolean isAdmin)
        {
            InitializeComponent();
            bdModel      = bd_easyplannerEntities.OpenWithFallback();
            this.isAdmin = isAdmin;
            this.user    = user;
            mainScheduler.OnEventDoubleClick    += MainScheduler_OnEventDoubleClick;
            mainScheduler.OnScheduleDoubleClick += MainScheduler_OnScheduleDoubleClick;

            //sécurise l'interface
            userAccess();
        }
 // <summary>
 /// create a ScheduleSlot
 /// Populate an enum with days of week
 /// </summary>
 /// <param>None</param>
 public AddPlotWindow()
 {
     InitializeComponent();
     current  = new ScheduleSlot();
     bdModel  = bd_easyplannerEntities.OpenWithFallback();
     modified = false;
     foreach (DayOfWeek day in Enum.GetValues(typeof(DayOfWeek)))
     {
         cbxDayOfWeek.Items.Add(DateTimeFormatInfo.CurrentInfo.GetDayName(day));
     }
     cbxDayOfWeek.SelectedIndex = 1;
     dpFirstDay.SelectedDate    = DateTime.Today;
     dpLastDay.SelectedDate     = DateTime.Today;
 }
Example #6
0
        /// <summary>
        /// Construtor for the week generation Windows
        /// </summary>
        /// <param name="bd">Entity framework datbase</param>
        public WeekGenerationWindow(bd_easyplannerEntities bd)
        {
            InitializeComponent();

            this.bdModel       = bd;
            totalWorkingShifts = new List <WorkingShift>();
            weekGenerationScheduler.SelectedDate = DateTime.Today;
            weekGenerationScheduler.StartJourney = new TimeSpan(7, 0, 0);
            weekGenerationScheduler.EndJourney   = new TimeSpan(19, 0, 0);
            weekGenerationScheduler.Mode         = Mode.Week;

            btnSaveInDB.IsEnabled = false;
            //weekGenerationScheduler.OnEventDoubleClick += weekGenerationScheduler_OnEventDoubleClick;
            //weekGenerationScheduler.OnScheduleDoubleClick += weekGenerationScheduler_OnScheduleDoubleClick;
        }
        /// <summary>
        /// Remove from database the workingshifts listed in the paramater.
        /// (if the workingShif id is in the list then it is removed)
        /// </summary>
        /// <param name="wsList">List of WorkingShift to remove</param>
        /// <param name="bd">database</param>
        public static void RemoveWorkingShiftDataBase(List <WorkingShift> wsList, bd_easyplannerEntities bd)
        {
            WorkingShift wsRemove = null;

            foreach (WorkingShift ws in wsList)
            {
                wsRemove = bd.WorkingShifts.Find(ws.idShift);
                if (wsRemove != null)
                {
                    bd.WorkingShifts.Remove(wsRemove);
                }
            }

            bd.SaveChanges();
        }
        public LoginFormWindow()
        {
            InitializeComponent();
            try {
                bdModel = bd_easyplannerEntities.OpenWithFallback();
            }
            catch (NoDataBaseUsableException e)
            {
                MessageBox.Show(e.Message);
                this.Close();
            }

/*            if (bdModel == null)
 *          {
 *              //afficher erreur
 *              this.Close();
 *          }*/
        }
Example #9
0
        public AddUser(Person current, bd_easyplannerEntities bd)
        {
            InitializeComponent();

            bdModel                   = bd;
            modify                    = true;
            this.current              = current;
            txtName.Text              = current.name;
            txtFirstname.Text         = current.firstName;
            txtAvs.Text               = current.numberAVS;
            txtOccupencyrate.Text     = current.occupancyRate.ToString();
            txtDescription.Text       = current.description;
            cbxRole.ItemsSource       = bdModel.Roles.ToList();
            cbxRole.DisplayMemberPath = "roleName";
            cbxRole.SelectedValuePath = "idRole";
            cbxRole.SelectedValue     = current.idRole;
            btnSave.Content           = "Modifier";
        }
Example #10
0
        /// <summary>
        /// Construtor for the week generation Windows
        /// </summary>
        /// <param name="bd">Entity framework datbase</param>
        public SlotGenerationWindow(bd_easyplannerEntities bd)
        {
            InitializeComponent();
            this.bdModel            = bd;
            bdModel                 = bd_easyplannerEntities.OpenWithFallback();
            NextPrevButtonVisibity  = false;
            this.btnNext.Visibility = Visibility.Hidden;
            this.btnPrev.Visibility = Visibility.Hidden;

            //Scheduler settings
            slotGenerationScheduler.SelectedDate = DateTime.Today;
            slotGenerationScheduler.StartJourney = new TimeSpan(7, 0, 0);
            slotGenerationScheduler.EndJourney   = new TimeSpan(19, 0, 0);
            slotGenerationScheduler.Mode         = Mode.Week;

            //Activate double-click on the scheduler
            slotGenerationScheduler.OnEventDoubleClick    += slotGenerationScheduler_OnEventDoubleClick;
            slotGenerationScheduler.OnScheduleDoubleClick += slotGenerationScheduler_OnScheduleDoubleClick;
        }
        public static bd_easyplannerEntities OpenWithFallback()
        {
            bd_easyplannerEntities bd = new bd_easyplannerEntities("name=bd_easyplannerEntities");

            try
            {
                bd.Database.Connection.Open();
            }
            catch
            {
                bd = new bd_easyplannerEntities("name=bd_easyplannerEntitiesFB");
                try
                {
                    bd.Database.Connection.Open();
                }
                catch
                {
                    throw new NoDataBaseUsableException();
                }
            }
            return(bd);
        }
Example #12
0
 public ManageUser()
 {
     InitializeComponent();
     bdModel = bd_easyplannerEntities.OpenWithFallback();
     dgPeople.ItemsSource = bdModel.People.ToList();
 }