Ejemplo n.º 1
0
        /**
         * Methods saves the absence if correct data provided
         *
         * @param abcence Absence model
         * @return result of saving
         */
        private bool saveAbsence(AbsenceModel absence)
        {
            AbsenceRepo repo = new AbsenceRepo();

            if (String.IsNullOrEmpty(absence.startTime))
            {
                absence.startTime = "NULL";
            }
            if (String.IsNullOrEmpty(absence.endTime))
            {
                absence.endTime = "NULL";
            }
            if (String.IsNullOrEmpty(absence.endTime))
            {
                absence.endTime = "NULL";
            }
            if (String.IsNullOrEmpty(absence.reason))
            {
                absence.reason = "NULL";
            }
            if (String.IsNullOrEmpty(absence.endDate))
            {
                absence.endDate = "NULL";
            }
            if (Validator.validateAbsenceForSaving(absence).Count == 0)
            {
                return(repo.saveAbsence(absence));
            }
            return(false);
        }
Ejemplo n.º 2
0
        /** Method generates boxes containing number of appointments and day */
        private void generateDayBoxes()
        {
            AbsenceRepo absenceRepo = new AbsenceRepo();

            monthLabel.Text = date.ToString("MMMM").ToUpper();
            yearLabel.Text  = date.ToString("yyyy").ToUpper();
            appointmentDaysPanel.Visible = false;
            foreach (int dayNo in this.getWorkingDays(this.date.Year, this.date.Month))
            {
                string        dateToBeAdded = new DateTime(this.date.Year, this.date.Month, dayNo).ToString("yyyy-MM-dd");
                List <IModel> absences      = absenceRepo.getSurgeryAbsencesPerDate(dateToBeAdded);
                if (absences == null)
                {
                    dayOfaWeekBox dayBox = new dayOfaWeekBox(new DateTime(this.date.Year, this.date.Month, dayNo));
                    appointmentDaysPanel.Controls.Add(dayBox);
                    this.dayBoxes.Add(dayBox);
                }
            }
            appointmentDaysPanel.Visible = true;
        }