コード例 #1
0
ファイル: EditCourseForm.cs プロジェクト: kkrzaczkowski/SWKM
        /// <summary>
        /// Initializes a new instance of the <see cref="EditCourseForm"/> class.
        /// </summary>
        /// <param name="form">The form.</param>
        public EditCourseForm(CoursesForm form)
        {
            this.courseLogic = SWKM.Setup.IoC.Resolve<CourseLogic>();
            this.lineLogic = SWKM.Setup.IoC.Resolve<LineLogic>();
            this.schedulePeriodLogic = SWKM.Setup.IoC.Resolve<SchedulePeriodLogic>();
            this.dayTypeLogic = SWKM.Setup.IoC.Resolve<DayTypeLogic>();
            this.exceptionLogic = SWKM.Setup.IoC.Resolve<ExceptionLogic>();
            this.coursesForm = form;

            InitializeComponent();
            this.Text = this.footerLbl.Text = "Dodaj nowy kurs";

            this.RefreshComboBoxes();
        }
コード例 #2
0
ファイル: EditCourseForm.cs プロジェクト: kkrzaczkowski/SWKM
        /// <summary>
        /// Initializes a new instance of the <see cref="EditCourseForm"/> class.
        /// </summary>
        /// <param name="form">The form.</param>
        /// <param name="courseId">The course id.</param>
        public EditCourseForm(CoursesForm form, int courseId)
            : this(form)
        {
            this.courseId = courseId;
            this.Text = String.Format("Edytujesz kurs");
            this.footerLbl.Text = this.Text;

            // Wyłączmy ponieważ edytować mozna tylko godziny odjazdów
            this.schedulePeriodCbx.Enabled = false;
            this.lineCbx.Enabled = false;
            this.exceptionCbx.Enabled = false;
            this.dayTypeCbx.Enabled = false;

            var course = this.courseLogic.GetCourse(courseId);

            if (course.Successful)
            {
                this.schedulePeriodCbx.SelectedValue = course.Object.SCHEDULEPERIODID;
                this.lineCbx.SelectedValue = course.Object.LINEID;
                this.exceptionCbx.SelectedValue = course.Object.EXCEPTIONID ?? 0;
                this.dayTypeCbx.SelectedValue = course.Object.DAYTYPEID ?? 0;
                this.RefreshGrids(course.Object.LINEID, course.Object.SCHEDULEPERIODID);

                // zablokowanie mozliwości edycji
                if (course.Object.ReadOnly)
                {
                    this.schedulePeriodCbx.Enabled = false;
                    this.lineCbx.Enabled = false;
                    this.exceptionCbx.Enabled = false;
                    this.dayTypeCbx.Enabled = false;
                    this.deparaturesGrid.Enabled = false;
                    this.saveBtn.Enabled = false;
                }
            }
            else
            {
                MessageBox.Show(this, course.ErrorMessage, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }