/// <summary>
        /// Initializes a new instance of the <see cref="EditSchedulePeriodForm"/> class.
        /// </summary>
        /// <param name="form">The form.</param>
        public EditSchedulePeriodForm(SchedulePeriodsForm form)
        {
            this.schedulePeriodLogic = SWKM.Setup.IoC.Resolve<SchedulePeriodLogic>();
            this.dayTypeTemplateLogic = SWKM.Setup.IoC.Resolve<DayTypeTemplateLogic>();
            this.schedulePeriodsForm = form;

            InitializeComponent();
            this.Text = this.footerLbl.Text = "Dodaj nowy okres rozkładu jazdy";
            this.validFromDtp.Value = DateTime.Now;
            this.validToDtp.Value = this.validFromDtp.Value.AddDays(validToDayInterval);
            this.validToDtp.Enabled = this.isValidTo.Checked;

            var response = this.dayTypeTemplateLogic.GetDayTypeTemplates();

            if (response.Successful == true)
            {
                this.dayTypeTemplateCbx.DataSource = response.Objects;
                this.dayTypeTemplateCbx.DisplayMember = "NAME";
                this.dayTypeTemplateCbx.ValueMember = "ID";
            }
            else
            {
                MessageBox.Show(this, response.ErrorMessage, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="EditSchedulePeriodForm"/> class.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="id">The id.</param>
        public EditSchedulePeriodForm(SchedulePeriodsForm form, int id)
            : this(form)
        {
            var schedulePeriod = this.schedulePeriodLogic.GetSchedulePeriod(id);
            this.schedulePeriodId = id;

            if (schedulePeriod != null)
            {
                this.Text = String.Format("Edytuj okres rozkładu jazdy w wersji: {0}", schedulePeriod.Object.ID);
                this.footerLbl.Text = this.Text;
                this.validFromDtp.Value = schedulePeriod.Object.VALIDFROM;
                this.validToDtp.Value = this.validFromDtp.Value.AddDays(validToDayInterval);

                if(schedulePeriod.Object.VALIDTO.HasValue)
                {
                    this.validToDtp.Enabled = this.isValidTo.Checked = true;
                    this.validToDtp.Value = schedulePeriod.Object.VALIDTO.Value;
                }
                this.periodNrc.Text = schedulePeriod.Object.PLANNINGPERIOD.ToString();
                this.dayTypeTemplateCbx.SelectedValue = schedulePeriod.Object.DAYTYPETEMPLATEID;
            }
        }