예제 #1
0
        /// <summary>
        /// Refreshes the fields.
        /// </summary>
        public void RefreshFields()
        {
            var drivers = this.driverLogic.GetDrivers();
            if (drivers.Successful)
            {
                this.DriverCbx.DisplayMember = "NAME";
                this.DriverCbx.ValueMember = "ID";
                driversList = new List<BaseIdNameDto>()
                {
                    new BaseIdNameDto()
                    {
                        ID = 0,
                        NAME = ""
                    }
                };

                driversList.AddRange(drivers.Objects);
                this.DriverCbx.DataSource = driversList;
            }
            else
            {
                MessageBox.Show(this, drivers.ErrorMessage, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            var vehicles = this.vehicleLogic.GetVehicles();
            if (vehicles.Successful)
            {
                this.VehicleCbx.DisplayMember = "NAME";
                this.VehicleCbx.ValueMember = "ID";
                vehiclesList = new List<BaseIdNameDto>()
                {
                    new BaseIdNameDto()
                    {
                        ID = 0,
                        NAME = ""
                    }
                };

                vehiclesList.AddRange(vehicles.Objects);
                this.VehicleCbx.DataSource = vehiclesList;
            }
            else
            {
                MessageBox.Show(this, vehicles.ErrorMessage, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.failureCbx.DisplayMember = "NAME";
            this.failureCbx.ValueMember = "ID";
            var failuresList = new List<BaseIdStringNameDto>()
            {
                new BaseIdStringNameDto()
                {
                    ID = "",
                    NAME = ""
                }
            };

            failuresList.AddRange(Mapper.Map<Dictionary<string, FailureReason>, IList<BaseIdStringNameDto>>(FailureReason.FailureReasonDictionary));
            this.failureCbx.DataSource = failuresList;

            var course = this.courseLogic.GetPlanCourse(this.courseId);
            if (course.Successful)
            {
                this.executeCourse = course.Object;

                this.Text = String.Format("Wykonujesz kurs");
                this.footerLbl.Text = this.Text;

                this.planDateTxb.Text = course.Object.PLANDATE;
                this.planHourTxb.Text = course.Object.PlanTime;

                this.executionDateTxb.Text = course.Object.PLANDATE;
                this.executionHourTxb.Text = course.Object.PlanTime;

                this.planDriverTxb.Text = course.Object.PlanDriverName;
                this.DriverCbx.SelectedValue = course.Object.EXECUTIONDRIVERID;

                this.planVehicleTxb.Text = course.Object.PlanVehicleName;
                this.VehicleCbx.SelectedValue = course.Object.EXECUTIONVEHICLEID;
            }
            else
            {
                MessageBox.Show(this, course.ErrorMessage, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
예제 #2
0
        /// <summary>
        /// Executes the plan course.
        /// </summary>
        /// <param name="planCourseList">The plan course list.</param>
        /// <returns></returns>
        public BaseOperationResponse ExecutePlanCourse(ExecuteCourseDto executeCourseDto)
        {
            var response = new BaseOperationResponse();

            try
            {
                var unitOfWork = SWKM.Setup.IoC.Resolve<UnitOfWork>();

                var planCourse = unitOfWork.PlanCourses.FindBy(u => u.ID == executeCourseDto.ID).FirstOrDefault();

                if (planCourse == null)
                {
                    response.Successful = false;
                    response.ErrorMessage = "Nie ma planowanego kursu o takim identyfikatorze.";
                    return response;
                }

                planCourse.EXECUTIONDATE = executeCourseDto.EXECUTIONDATE;
                planCourse.FAILUREKEY = executeCourseDto.FAILUREKEY;
                planCourse.DESCRIPTION = executeCourseDto.DESCRIPTION;
                planCourse.EXECUTIONDRIVERID = executeCourseDto.EXECUTIONDRIVERID;
                planCourse.EXECUTIONVEHICLEID = executeCourseDto.EXECUTIONVEHICLEID;

                unitOfWork.Save();
                response.Successful = true;
            }
            catch (Exception e)
            {
                SWKM.Setup.Logger.Instance.Log.Error("Error occurred!", e);
                response.Successful = false;
                response.ErrorMessage = "Wystapił nie oczekiwany błąd przy zapisywaniu planowanych kursów.";
            }

            return response;
        }