private void button1_Click(object sender, EventArgs e)
 {
     var unitofwork = new UnitOfWork();
     unitofwork.EmployeeAvailabilityRepository.Insert(GetFields(new EmployeeAvailabilityDay()));
     unitofwork.Save();
     DialogResult = DialogResult.OK;
 }
        private void AddEditBooking_Load(object sender, EventArgs e)
        {
            var unitOfWork = new UnitOfWork();

            cbType.DataSource = unitOfWork.BookingClassificationRepository.Get().ToList();
            cbType.DisplayMember = "ClassificationName";
            cbType.ValueMember = "Id";
            var startDate = DateTime.Today;
            startDate.AddSeconds(-startDate.Second);
            startDate.AddMinutes(-startDate.Minute);
            dtpBookingTime.Value = startDate;

            if (currentBookingID != null)
            {
                currentBooking = unitOfWork.BookingRepository.Get(null, null, "Employee,BookingClasification,BookingNotes").Where(x => x.Id == currentBookingID).FirstOrDefault();
                btnSave.Text = "Save Changes";
                dtpBookingTime.Value = currentBooking.BookingDate;
                tbName.Text = currentBooking.Name;
                tbContactNumber.Text = currentBooking.ContactNumber;
                tbEmail.Text = currentBooking.Email;

                cbType.SelectedValue = currentBooking.BookingClasification.Id;
                newbookingNotes = currentBooking.BookingNotes.Where(x => x.DateInactive == null).ToList();
            }
            RebindNotes();
        }
 private void ManageRestaurantEmployees_Load(object sender, EventArgs e)
 {
     unitOfWork = new UnitOfWork();
     accessLevel = unitOfWork.AccessLevelRepository.Get(x => x.Id == AccessLevelID,null,"Employees").FirstOrDefault();
     lblRestaurantName.Text = accessLevel.Name;
     Rebind();
 }
        public void BookingLockoutsForDate(RichTextBox rtb, DateTime date)
        {
            rtb.Text = "";
            var unitOfWork = new UnitOfWork();
            var today = date.Date;
            var notes = unitOfWork.LockedOutDateRepository.Get(x => today < x.EndDate && today > x.StartDate,includeProperties:"LockOutTimes");

            notes = notes.OrderBy(x => x.DateCreated);
            if (notes.Count() > 0)
            {

                rtb.AppendBoldColoredLine("Locked:", System.Drawing.Color.Red);
                int i = 1;
                foreach (var note in notes)
                {
                    rtb.AppendBoldColoredLine(i + ". " + note.Name, System.Drawing.Color.Red);
                    string reason = note.Reason;

                    rtb.AppendLine(reason);
                    if (note.LockOutTimes.Count>0)
                    {
                        foreach(var v in note.LockOutTimes)
                        {
                            rtb.AppendText(v.StartTime.ToShortTimeString() + " - "+ v.EndTime.ToShortTimeString()+", " );

                        }
                    }
                }

            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                InitService.Initialize();
                var unitofwork = new UnitOfWork();

                int userID = int.Parse(tbUserId.Text);
                var user = unitofwork.EmployeeRepository.Get(x => x.Id == userID).FirstOrDefault();
                if (user == null)
                {
                    throw new NullReferenceException();
                }
                NavigationMenu v = new NavigationMenu();
                v.User = user;
                v.ShowDialog();

            }
            catch (FormatException ex)
            {
                MessageBox.Show("Incorrect Format, Please input an integer number");
            }
            catch (NullReferenceException ex2)
            {
                MessageBox.Show("User Not Found");

            }
            catch (System.Data.Entity.Validation.DbEntityValidationException ex4)
            {
                MessageBox.Show(ex4.Message + " " + string.Join(", ", ex4.EntityValidationErrors.SelectMany(x => x.ValidationErrors.SelectMany(y => y.ErrorMessage))));
            }
        }
 public void RebindNotes()
 {
     var unitOfWork = new UnitOfWork();
     if(currentBooking!=null)
     existingbookingnotes = unitOfWork.BookingNotesRepository.Get(y => y.Booking_Id == currentBooking.Id, null, "Employee").ToList();
     allbookingnotes = existingbookingnotes.Union(newbookingNotes).Where(x=> x.DateInactive== null).ToList();
     dataGridView1.DataSource = allbookingnotes.Select(x => new { Severity = x.Severity, Note = x.Note }).ToList();
 }
 public void Rebind()
 {
     var unitofwork = new UnitOfWork();
     EmployeeList = unitofwork.EmployeeRepository.Get(Filter, x => x.OrderBy(y => y.FirstName)).ToList();
     ddlUsers.DisplayMember = "FullName";
     ddlUsers.ValueMember = "Id";
     ddlUsers.DataSource = EmployeeList;
 }
 private void AddCommendationClassificationSkillCategory_Load(object sender, EventArgs e)
 {
     var unitofwork = new UnitOfWork();
     var listofusedIDs = classification.EmployeeCommendationSkillCategories.Select(x => x.SkillCategory.Id);
     availableskills = unitofwork.SkillCategoryRepository.Get(y => !(listofusedIDs.Contains(y.Id))).ToList();
     comboBox1.DisplayMember = "Name";
     comboBox1.DataSource = availableskills;
 }
 private void button2_Click(object sender, EventArgs e)
 {
     if (dgvLocked.SelectedRows.Count > 0)
     {
         var unitOfWork = new UnitOfWork();
         int workingIndex = dgvLocked.SelectedRows[0].Index;
         unitOfWork.LockedOutDateRepository.Delete(DateLockouts[workingIndex]);
         RebindDateLockouts();
     }
 }
 private void button3_Click(object sender, EventArgs e)
 {
     if (dgvPresetNotes.SelectedRows.Count > 0)
     {
         var unitofwork = new UnitOfWork();
         unitofwork.BookingClassificationRepository.Delete(accessLevels[dgvPresetNotes.SelectedRows[0].Index].Id);
         unitofwork.Save();
         Rebind();
     }
 }
        private void button3_Click(object sender, EventArgs e)
        {
            if (dgvNAs.SelectedRows.Count > 0)
            {
                var unitofwork = new UnitOfWork();
                unitofwork.EmployeeNARepository.Delete(EmployeeNAs[dgvNAs.SelectedRows[0].Index]);
                unitofwork.Save();
                RebindEmployeeNAs();

            }
        }
        private void AddEditAccessLevel_Load(object sender, EventArgs e)
        {
            if (AccessLevelId != null)
            {
                var unitOfWork = new UnitOfWork();

                WorkingLevel = unitOfWork.AccessLevelRepository.GetByID(AccessLevelId);
                textBox1.Text = WorkingLevel.Name;
                numericUpDown1.Value = WorkingLevel.Level;
            }
        }
        public EmployeeAvailabilityDay AvailabilityForDay(int userID, int DayOfTheWeek, DateTime? d = null)
        {
            if (d == null)
                d = DateTime.Now;

            var unitOfWork = new UnitOfWork();
            var alldays = unitOfWork.EmployeeAvailabilityRepository.Get(x => x.Employee.Id == userID && x.StartDate < d && (x.EndDate == null || x.EndDate > d), includeProperties: "Employee").ToList();

            var item = alldays.Where(x => x.DayOfWeek == DayOfTheWeek).OrderByDescending(x => x.DateAdded).FirstOrDefault();
            return item;
        }
 private void AddEditLockedDate_Load(object sender, EventArgs e)
 {
     if(LockedDateID.HasValue)
     {
         var unitofwork = new UnitOfWork();
         workinglockedDate = unitofwork.LockedOutDateRepository.Get(x => x.Id == LockedDateID.Value, includeProperties:"LockOutTimes").FirstOrDefault();
         tbTitle.Text = workinglockedDate.Name;
         tbDescription.Text = workinglockedDate.Reason;
         dtpStart.Value = workinglockedDate.StartDate;
         dtpEnd.Value = workinglockedDate.EndDate;
     }
 }
 private void AddEditDateNote_Load(object sender, EventArgs e)
 {
     if(DateNoteID.HasValue)
     {
         var unitOfWork = new UnitOfWork();
         workingnote = unitOfWork.DateNoteRepository.GetByID(DateNoteID);
         dtpStart.Value = workingnote.StartDate;
         dtpEnd.Value = workingnote.EndDate;
         cbAppearOnBooking.Checked = workingnote.AppearOnAddingBooking;
         cbAppearOnRoster.Checked = workingnote.AppearOnRoster;
         tbNote.Text = workingnote.Note;
     }
 }
        private void button3_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                var unitofwork = new UnitOfWork();
                for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
                {
                    unitofwork.SkillCategoryRepository.Delete(Categories[dataGridView1.SelectedRows[i].Index]);
                }
                unitofwork.Save();
                Rebind();

            }
        }
        public static void Initialize()
        {
            var unitofwork = new UnitOfWork();

            if (unitofwork.EmployeeRepository.Get().Count() == 0)
            {
                unitofwork.BookingClassificationRepository.Insert(new BookingClasification() { ClassificationName = "Class 1", DisplayOrder = 1 });
                unitofwork.BookingClassificationRepository.Insert(new BookingClasification() { ClassificationName = "Class 2", DisplayOrder = 1 });
                unitofwork.BookingClassificationRepository.Insert(new BookingClasification() { ClassificationName = "Class 3", DisplayOrder = 1 });
                unitofwork.BookingClassificationRepository.Insert(new BookingClasification() { ClassificationName = "Class 4", DisplayOrder = 1 });
                unitofwork.BookingClassificationRepository.Insert(new BookingClasification() { ClassificationName = "Class 5", DisplayOrder = 1 });
                var added = unitofwork.AccessLevelRepository.Insert(new AccessLevel { Name = "Level 1", Level = 1 });
                var newRestaurant = new Restaurant() { Capacity = 100, Name = "Rebellion", Location = "Sydney", RosteringStartDay = (int)DayOfWeek.Monday, RosteringWeekDuration = 1, RosteringWeekOffset = 0 };
                var newemployee = new Employee() { Id = 111, FirstName = "Scott", LastName = "Becker", AccessLevel = added, Email = "*****@*****.**", PhoneNumber = "999999999" };
                var availabilities = new List<EmployeeAvailabilityDay>();
                availabilities.Add(new EmployeeAvailabilityDay() { DayOfWeek = (int)DayOfWeek.Monday, StartDate = new DateTime(2014, 1, 1), Notes = "Initial Availability", StartTime = new DateTime(2014, 10, 10, 16, 30, 0),DateAdded= DateTime.Now });
                availabilities.Add(new EmployeeAvailabilityDay() { DayOfWeek = (int)DayOfWeek.Tuesday, StartDate = new DateTime(2014, 1, 1), Notes = "Initial Availability", StartTime = new DateTime(2014, 10, 10, 18, 30, 0), DateAdded = DateTime.Now });
                availabilities.Add(new EmployeeAvailabilityDay() { DayOfWeek = (int)DayOfWeek.Wednesday, StartDate = new DateTime(2014, 1, 1), Notes = "Initial Availability", StartTime = new DateTime(2014, 10, 10, 12, 30, 0), DateAdded = DateTime.Now });
                availabilities.Add(new EmployeeAvailabilityDay() { DayOfWeek = (int)DayOfWeek.Thursday, StartDate = new DateTime(2014, 1, 1), Notes = "Initial Availability", StartTime = new DateTime(2014, 10, 10, 15, 30, 0), DateAdded = DateTime.Now });
                availabilities.Add(new EmployeeAvailabilityDay() { DayOfWeek = (int)DayOfWeek.Friday, StartDate = new DateTime(2014, 1, 1), Notes = "Initial Availability", StartTime = new DateTime(2014, 10, 10, 13, 30, 0), DateAdded = DateTime.Now });
                availabilities.Add(new EmployeeAvailabilityDay() { DayOfWeek = (int)DayOfWeek.Saturday, StartDate = new DateTime(2014, 1, 1), Notes = "Initial Availability", StartTime = new DateTime(2014, 10, 10, 16, 30, 0), DateAdded = DateTime.Now });
                availabilities.Add(new EmployeeAvailabilityDay() { DayOfWeek = (int)DayOfWeek.Sunday, StartDate = new DateTime(2014, 1, 1), Notes = "Initial Availability", StartTime = new DateTime(2014, 10, 10, 14, 30, 0), DateAdded = DateTime.Now });
                newemployee.EmployeeAvailabilityDays = availabilities;
                newemployee.EmployeeNAs.Add(new EmployeeNA() { StartDate = DateTime.Now.AddDays(-7), EndDate = DateTime.Now.AddDays(-6), Notes = "Visiting Grandma", SubmittedBy = newemployee ,SubmittedDate=DateTime.Now});
                newemployee.EmployeeNAs.Add(new EmployeeNA() { StartDate = DateTime.Now.AddDays(6), EndDate = DateTime.Now.AddDays(7), Notes = "Visiting Grandma Again", SubmittedBy = newemployee, SubmittedDate = DateTime.Now });
                newemployee.EmployeeNAs.Add(new EmployeeNA() { StartDate = DateTime.Now.AddDays(9), EndDate = DateTime.Now.AddDays(10), Notes = "Visiting Grandma", SubmittedBy = newemployee, SubmittedDate = DateTime.Now });

                newemployee.EmployeeAvailabilityHoursRequests.Add(new EmployeeAvailabilityHoursRequest() { StartDate = new DateTime(2014, 1, 1), RequestedMinimumHours = 8, RequestedMaximumHours = 30 });
                unitofwork.AccessLevelRepository.Insert(new AccessLevel() { Name = "Level 2", Level = 2 });
                unitofwork.AccessLevelRepository.Insert(new AccessLevel() { Name = "Level 3", Level = 3 });
                unitofwork.AccessLevelRepository.Insert(new AccessLevel() { Name = "Level 4", Level = 4 });
                unitofwork.EmployeeRepository.Insert(newemployee);
                unitofwork.PresetNoteRepository.Insert(new PresetNote() { Name = "Gluten Free", Severity = 5 });
                unitofwork.PresetNoteRepository.Insert(new PresetNote() { Name = "Dairy Free", Severity = 5 });
                unitofwork.PresetNoteRepository.Insert(new PresetNote() { Name = "Window Seat", Severity = 2 });
                unitofwork.LockedOutDateRepository.Insert(new LockOutDate() { Name = "Locked Out Date 1", Reason = "Cause", StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), DateCreated = DateTime.Now, Restaurant = newRestaurant });
                unitofwork.LockedOutDateRepository.Insert(new LockOutDate() { Name = "Locked Out Date 2", Reason = "Cause", StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), DateCreated = DateTime.Now, Restaurant = newRestaurant });
                unitofwork.LockedOutDateRepository.Insert(new LockOutDate() { Name = "Locked Out Date 3", Reason = "Cause", StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), DateCreated = DateTime.Now, Restaurant = newRestaurant });
                unitofwork.LockedOutDateRepository.Insert(new LockOutDate() { Name = "Locked Out Date 4", Reason = "Cause", StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), DateCreated = DateTime.Now, Restaurant = newRestaurant });
                unitofwork.DateNoteRepository.Insert(new DateNote() { Note = "Note1", AppearOnAddingBooking = true, AppearOnRoster = true, StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), Restaurant = newRestaurant, DateCreated = DateTime.Now });
                unitofwork.DateNoteRepository.Insert(new DateNote() { Note = "Note2", AppearOnAddingBooking = false, AppearOnRoster = true, StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), DateCreated = DateTime.Now, Restaurant = newRestaurant });
                unitofwork.DateNoteRepository.Insert(new DateNote() { Note = "Note3", AppearOnAddingBooking = true, AppearOnRoster = false, StartDate = DateTime.Now, EndDate = DateTime.Now.AddYears(1), DateCreated = DateTime.Now, Restaurant = newRestaurant });
                unitofwork.ShiftCategoryRepository.Insert(new ShiftCategory() { CategoryName="Quiet Night" });
                unitofwork.ShiftCategoryRepository.Insert(new ShiftCategory() { CategoryName="Busy Week Night" });
                unitofwork.ShiftCategoryRepository.Insert(new ShiftCategory() { CategoryName="Saturday Night" });
                unitofwork.ShiftCategoryRepository.Insert(new ShiftCategory() { CategoryName= "Banquets < 100" });
                unitofwork.Save();
            }
        }
        private void button3_Click(object sender, EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count > 0)
            {
                var unitofwork = new UnitOfWork();
               for(int i=0; i<dataGridView1.SelectedRows.Count;i++)
                {
                    var comm = commendations[dataGridView1.SelectedRows[i].Index];
                  unitofwork.EmployeeCommendationClassificationRepository.Delete( comm);
                }
                unitofwork.Save();
                    Rebind();

            }
        }
        private void AddEditShiftRoster_Load(object sender, EventArgs e)
        {
            var unitofwork = new UnitOfWork();
            RebindPresets();
            WorkingShift = unitofwork.ShiftRepository.Get(x => x.DayOfTheWeek == DayOfWeek && x.RosterId == RosterId, includeProperties: "EmployeeShifts.EmployeeShiftAssignments").FirstOrDefault();

            if (WorkingShift != null)
            {
                ShiftSlots = WorkingShift.EmployeeShifts.ToList();
                txtNotes.Text = WorkingShift.Notes;
                RebindShiftSlots();

            }
            RebindBookingInformation();
        }
        private void AddEditStaffCommendation_Load(object sender, EventArgs e)
        {
            var unitOfWork = new UnitOfWork();

            cbClassification.DisplayMember = "Name";
            cbEmployee.Rebind();
            cbClassification.DataSource = unitOfWork.EmployeeCommendationClassificationRepository.Get(x=> x.AvailableOnUser).ToList();

            if (currentCommendationId!= null)
            {
                currentCommendation = unitOfWork.EmployeeCommendationRepository.Get(x => x.Id == currentCommendationId).FirstOrDefault();
                txtNotes.Text = currentCommendation.Notes;
                cbEmployee.SelectedEmployee = currentCommendation.RecievingEmployee;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var unitofwork = new UnitOfWork();

            if (LockedDateID.HasValue)
            {
                unitofwork.LockedOutDateRepository.Update(GetFields(workinglockedDate));
            }
            else
            {
                unitofwork.LockedOutDateRepository.Insert(GetFields(new LockOutDate()));
            }
            unitofwork.Save();
            this.DialogResult = DialogResult.OK;
        }
        private void AddEditBookingNote_Load(object sender, EventArgs e)
        {
            var unitOfWork = new UnitOfWork();

            if(presetID!=null)
            {
                WorkingNote = unitOfWork.BookingClassificationRepository.GetByID(presetID.Value);

            }
            if(WorkingNote !=null)
            {
                tbNote.Text = WorkingNote.ClassificationName;

            }
            //stylesSheetManager1.ApplyStyles();
        }
Example #23
0
        private void button1_Click(object sender, EventArgs e)
        {
            var unitOfWork = new UnitOfWork();

            if (NAID!= null)
            {
                unitOfWork.EmployeeNARepository.Update(GetFields(workingNA));

            }
            else
            {
                unitOfWork.EmployeeNARepository.Insert(GetFields(new EmployeeNA()));
            }
            unitOfWork.Save();
            this.DialogResult = DialogResult.OK;
        }
        private void AddEditBookingNote_Load(object sender, EventArgs e)
        {
            var unitOfWork = new UnitOfWork();

            if(presetID!=null)
            {
                WorkingNote = unitOfWork.PresetNoteRepository.GetByID(presetID.Value);

            }
            if(WorkingNote !=null)
            {
                tbNote.Text = WorkingNote.Name;
                nmudSeverity.Value = WorkingNote.Severity;

            }
            stylesSheetManager1.ApplyStyles();
        }
        private void AddEditEmployee_Load(object sender, EventArgs e)
        {
            var unitOfWork = new UnitOfWork();

            comboBox1.DisplayMember = "Name";
            comboBox1.ValueMember = "Id";
            comboBox1.DataSource = unitOfWork.AccessLevelRepository.Get();
            if (currentEmployeeId != null)
            {
                currentUser = unitOfWork.EmployeeRepository.Get(x => x.Id == currentEmployeeId.Value, null, "AccessLevel").FirstOrDefault();
                tbFirstName.Text = currentUser.FirstName;
                tbLastName.Text = currentUser.LastName;
                tbEmail.Text = currentUser.Email;
                tbPhoneNumber.Text = currentUser.PhoneNumber;
                tbID.Text = currentUser.Id.ToString();
                comboBox1.SelectedValue = currentUser.AccessLevel.Id;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var unitofwork = new UnitOfWork();
            SkillCategory parent=null;
            if(parentSkillCategoryId!= null)
                parent= unitofwork.SkillCategoryRepository.Get(x => x.Id == parentSkillCategoryId).FirstOrDefault();
            if (currentSkillCategoryId!=null)
            {
                unitofwork.SkillCategoryRepository.Update(GetFields(currentSkillCategory,parent));
            }
            else
            {
                unitofwork.SkillCategoryRepository.Insert(GetFields(new SkillCategory(),parent));

            }
            unitofwork.Save();
            this.DialogResult = DialogResult.OK;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            var unitOfWork = new UnitOfWork();
            if(RestaurantID== null)
            {
                unitOfWork.RestaurantRepository.Insert(new Restaurant() { Location = tbLocation.Text, Name = tbName.Text, Capacity = (int)tbCapacity.Value });

            }
            else
            {
                Restaurant.Name = tbName.Text;
                Restaurant.Capacity = (int)tbCapacity.Value;
                Restaurant.Location = tbLocation.Text;
                unitOfWork.RestaurantRepository.Update(Restaurant);
            }
            unitOfWork.Save();
            this.DialogResult = DialogResult.OK;
        }
        private void AddEditCommendationClassification_Load(object sender, EventArgs e)
        {
            var unitofwork = new UnitOfWork();
            if(workingClassificationID!=null)
            {
                workingClassification = unitofwork.EmployeeCommendationClassificationRepository.Get(x => x.Id == workingClassificationID,includeProperties: "EmployeeCommendationSkillCategories.SkillCategory").FirstOrDefault();
                textBox1.Name = workingClassification.Name;
                numericUpDown1.Value = workingClassification.Weighting;

                checkBox1.Checked= workingClassification.AvailableOnUser  ;
                checkBox2.Checked= workingClassification.AvailableOnTeam  ;
            }
            else
            {
                workingClassification = new EmployeeCommendationClassification();

            }
            RebindSkills();
        }
        private void ManagePermissions_Load(object sender, EventArgs e)
        {
            var unitOfWork = new UnitOfWork();

            WorkingLevel = unitOfWork.AccessLevelRepository.Get(x => x.Id == AccessLevelId, includeProperties: "Permissions").FirstOrDefault();
            label3.Text = WorkingLevel.Name;

            foreach (var v in AllPermissions.PermissionList())
            {
                checkedListBox1.Items.Add(v.PermissionName, v.PermissionValue);
            }
            for(int i = 0; i<WorkingLevel.Permissions.Count; i++)
            {
                if(checkedListBox1.Items.IndexOf(WorkingLevel.Permissions.ElementAt(i).PermissionName)!=-1)
                {
                    checkedListBox1.SetItemChecked(checkedListBox1.Items.IndexOf(WorkingLevel.Permissions.ElementAt(i).PermissionName), WorkingLevel.Permissions.ElementAt(i).PermissionValue);
                }
            }
        }
 private void AddEditRestaurant_Load(object sender, EventArgs e)
 {
     if(RestaurantID!=null)
     {
         var unitOfWork = new UnitOfWork();
         Restaurant = unitOfWork.RestaurantRepository.Get(x => x.Id == RestaurantID).FirstOrDefault();
         tbLocation.Text = Restaurant.Location;
         tbName.Text = Restaurant.Name;
         tbCapacity.Value = Restaurant.Capacity;
     }
 }