示例#1
0
        /// <summary>
        /// Creates TaskModel based on data gathered in form.
        /// </summary>
        /// <returns>TaskModel object with values given in form.</returns>
        private TaskModel CreateTaskFromFields()
        {
            TaskModel taskData = new TaskModel();

            taskData.FirstName        = tbFirstName.Text;
            taskData.LastName         = tbLastName.Text;
            taskData.PhoneNumber      = tbPhone.Text;
            taskData.Email            = tbEmail.Text;
            taskData.BikeManufacturer = tbManufacturer.Text;
            taskData.BikeModel        = tbModel.Text;
            taskData.FrameNumber      = tbFrameNo.Text;
            taskData.AdditionalInfo   = tbAdditionalInfo.Text;
            taskData.StartDate        = dtpStartDate.Value.Date;
            if (dtpEndDate.Checked)
            {
                taskData.EndDate = dtpEndDate.Value.Date;
            }
            if (ValidatorHelper.CostCheckAndSetErrors(tbCost.Text, epCost, labelCost, tbCost) && !string.IsNullOrWhiteSpace(tbCost.Text))
            {
                taskData.Cost = decimal.Parse(tbCost.Text, CultureInfo.InvariantCulture);
            }
            taskData.TaskDescription = tbDescription.Text;
            taskData.Status          = statuses.FirstOrDefault(x => x.Id == (int)cbStatus.SelectedValue);
            //taskData.Status = cbStatus.SelectedValue;

            return(taskData);
        }
示例#2
0
        /// <summary>
        /// Checks if fields, containg mandatory and compulsory data, has been filled with valid data.
        /// </summary>
        /// <returns>Bool telling if fields contains valid data.</returns>
        private bool ValidateControls()
        {
            bool validationResult = true;

            if (!ValidatorHelper.FirstNameCheckAndSetErrors(tbFirstName.Text, epFirstName, labelFirstName))
            {
                validationResult = false;
            }
            if (!ValidatorHelper.LastNameCheckAndSetErrors(tbLastName.Text, epLastName, labelLastName))
            {
                validationResult = false;
            }
            if (!ValidatorHelper.PhoneCheckAndSetErrors(tbPhone.Text, epPhone, labelPhone))
            {
                validationResult = false;
            }
            if (!ValidatorHelper.EmailCheckAndSetErrors(tbEmail.Text, epEmail, labelEmail))
            {
                validationResult = false;
            }
            if (!ValidatorHelper.ManufacturerCheckAndSetErrors(tbManufacturer.Text, epManufacturer, labelManufacturer))
            {
                validationResult = false;
            }
            if (!ValidatorHelper.ModelCheckAndSetErrors(tbModel.Text, epModel, labelModel))
            {
                validationResult = false;
            }
            if (!ValidatorHelper.FrameNoCheckAndSetErrors(tbFrameNo.Text, epFrameNo, labelFrameNo))
            {
                validationResult = false;
            }
            //if (!ValidatorHelper.AdditionalInfoValidation(tbAdditionalInfo.Text, epAddidtionalInfo, labelAdditionalInfo)) validationResult = false;
            if (!ValidatorHelper.DatesCheckAndSetErrors(dtpStartDate.Value, dtpEndDate.Value, epStartDate, epEndDate, labelStartDate, labelEndDate))
            {
                validationResult = false;
            }

            if (!ValidatorHelper.CostCheckAndSetErrors(tbCost.Text, epCost, labelCost, tbCost))
            {
                validationResult = false;
            }
            if (!ValidatorHelper.DescriptionCheckAndSetErrors(tbDescription.Text, epDescription, labelDescription))
            {
                validationResult = false;
            }

            return(validationResult);
        }