Пример #1
0
        public override void SetContainer <S, V>(FormSelector <S, V> container)
        {
            if (container != null && !(container is FormRadioGroup))
            {
                throw new ArgumentException();
            }

            this.formRadioGroup = container as FormRadioGroup;
        }
Пример #2
0
        public virtual void Visit(FormRadioGroup formRadioGroup)
        {
            foreach (var c in formRadioGroup.Content)
            {
                if (c.IsHidden)
                {
                    continue;
                }

                if (c.IsDisabled)
                {
                    continue;
                }

                c.IsSelected = c.Value == values[formRadioGroup.Path];
            }
        }
Пример #3
0
        public virtual void Visit(FormRadioGroup formRadioGroup, HtmlContainer htmlContainer)
        {
            HtmlDiv htmlDiv = verbose ? new HtmlDiv(formRadioGroup.Path) : new HtmlDiv();

            htmlDiv.Class.Add("formRadioGroup");

            if (!string.IsNullOrWhiteSpace(formRadioGroup.CssClass))
            {
                htmlDiv.Class.AddRange(formRadioGroup.CssClass.Split(' ').Where(s => s != string.Empty));
            }

            if (!string.IsNullOrWhiteSpace(formRadioGroup.Path))
            {
                htmlDiv.Class.Add(string.Format("{0}{1}", "formId", formRadioGroup.Path));
            }

            htmlDiv.Class.Add("formField");

            if (initialize)
            {
                htmlDiv.Class.Add(formRadioGroup.IsRequired ? "formRequired" : "formOptional");
            }
            else
            {
                if (!formRadioGroup.IsRequired || formRadioGroup.HasValue)
                {
                    htmlDiv.Class.Add("formValid");
                }
                else
                {
                    htmlDiv.Class.Add(formRadioGroup.IsRequired ? "formNotEntered" : "formOptional");
                }
            }

            htmlDiv.Hidden.Value = formRadioGroup.IsHidden;

            htmlContainer.Add(htmlDiv);

            HtmlRadioGroup htmlRadioGroup = new HtmlRadioGroup(formRadioGroup.Path, verbose, formRadioGroup.Update);

            htmlRadioGroup.Disabled.Value = formRadioGroup.IsDisabled;

            if (!initialize && firstInvalidId == null)
            {
                if (formRadioGroup.IsRequired && !formRadioGroup.HasValue || !formRadioGroup.IsValid)
                {
                    firstInvalidId = htmlRadioGroup.Id.Value;
                }
            }

            switch (formRadioGroup.OrderElements)
            {
            case OrderElements.LabelMarkInput:

                AddLabelMark(formRadioGroup, htmlRadioGroup, htmlDiv);
                htmlDiv.Add(htmlRadioGroup);

                break;

            case OrderElements.MarkLabelInput:

                AddMarkLabel(formRadioGroup, htmlRadioGroup, htmlDiv);
                htmlDiv.Add(htmlRadioGroup);

                break;

            case OrderElements.InputLabelMark:

                htmlDiv.Add(htmlRadioGroup);
                AddLabelMark(formRadioGroup, htmlRadioGroup, htmlDiv);

                break;

            case OrderElements.InputMarkLabel:

                htmlDiv.Add(htmlRadioGroup);
                AddMarkLabel(formRadioGroup, htmlRadioGroup, htmlDiv);

                break;

            case OrderElements.LabelInputMark:

                AddLabel(formRadioGroup, htmlRadioGroup, htmlDiv);
                htmlDiv.Add(htmlRadioGroup);
                AddMark(formRadioGroup, htmlRadioGroup, htmlDiv);

                break;

            case OrderElements.MarkInputLabel:

                AddMark(formRadioGroup, htmlRadioGroup, htmlDiv);
                htmlDiv.Add(htmlRadioGroup);
                AddLabel(formRadioGroup, htmlRadioGroup, htmlDiv);

                break;

            default:
            case OrderElements.NotSet:

                break;
            }

            foreach (var formRadioButton in formRadioGroup.Content)
            {
                Visit(formRadioButton, htmlRadioGroup);
            }

            if (initialize)
            {
                return;
            }

            string message = null;

            if (formRadioGroup.UseLastMessage)
            {
                if (!string.IsNullOrEmpty(formRadioGroup.LastMessage))
                {
                    message = formRadioGroup.LastMessage;
                }
            }
            else if (formRadioGroup.IsRequired && !formRadioGroup.HasValue)
            {
                message = formRadioGroup.RequiredMessage;
            }
            else if (!formRadioGroup.IsValid)
            {
                message = formRadioGroup.ValidationMessage;
            }

            if (message == null)
            {
                return;
            }

            HtmlLabel htmlLabelMessage = new HtmlLabel(verbose ? string.Format("{0}{1}", formRadioGroup.Path, "Message") : "");

            htmlLabelMessage.Class.Add("formValidationMessage");
            htmlLabelMessage.For.Value = htmlRadioGroup.Id.Value;
            htmlLabelMessage.Add(new HtmlText(message));
            htmlDiv.Add(htmlLabelMessage);
        }
Пример #4
0
 public virtual void Visit(FormRadioGroup formRadioGroup)
 {
     sb.AppendLine(string.Format("{0}{1}: {2}", formRadioGroup.Label, Mark(formRadioGroup), formRadioGroup.Value != null ? formRadioGroup.Value.Text : ""));
 }
Пример #5
0
            protected override void CreateForm()
            {
                OpenGroup("Container");

                #region Defaults

                OrderElements = OrderElements.LabelMarkInput;

                Required = true;

                RequiredMessage = resFieldRequired;

                #endregion


                #region Title

                AddItem(new FormTitle("Title")
                {
                    Content = resAdults,
                });

                #endregion


                #region DateOfBirth

                AddItem(dtpDateOfBirth = new FormDatePicker("DateOfBirth", "dd/mm/yyyy")
                {
                    Label = resDateOfBirth,

                    Placeholder = resDateOfBirth,

                    Validator = (v) =>
                    {
                        if (v > DateTime.Now)
                        {
                            return(resDateInvalid);
                        }

                        return(null);
                    }
                });

                #endregion


                #region EmploymentStatus

                AddItem(rdgEmploymentStatus = new FormRadioGroup("EmploymentStatus")
                {
                    Label = resEmploymentStatus,

                    Required = true,

                    Update = true,

                    Content = tblEmploymentStatus.ListAll().Select(s => new FormRadioButton(s.id, s.descr))
                });

                #endregion


                #region EmploymentDuration

                AddItem(selEmploymentDuration = new FormSelect("EmploymentDuration", false)
                {
                    Label = resEmploymentDuration,

                    Header = new FormOption(resChoose),

                    Hidden = true,

                    Content = tblEmploymentDuration.ListAll().Select(d => new FormOption(d.id, d.descr))
                });

                #endregion


                #region EducationalLevel

                AddItem(selEducationalLevel = new FormSelect("EducationalLevel", false)
                {
                    Label = resEducationalLevel,

                    Header = new FormOption(resChoose),

                    Content = tblEducationalLevel.ListAll().Select(l => new FormOption(l.id, l.name))
                });

                #endregion


                #region Population

                AddItem(selPopulation = new FormSelect("Population", false)
                {
                    Label = resCity,

                    Header = new FormOption(resChoose),

                    Content = tblPopulation.ListAll().Select(p => new FormOption(p.id, p.descr))
                });

                #endregion


                #region City

                AddItem(selCity = new FormSelect("City", false)
                {
                    Label = resAreaOfResidence,

                    Header = new FormOption(resChoose),

                    Update = true,

                    Content = tblCity.ListAll().OrderBy(c => c.name).Select(c => new FormOption(c.id, c.name))
                });

                #endregion


                #region Municipality

                AddItem(selMunicipality = new FormSelect("MunicipalitySelect", false)
                {
                    Label = resMunicipality,

                    Header = new FormOption(resChoose),

                    Hidden = true,
                });


                AddItem(txtMunicipality = new FormTextBox("MunicipalityTextBox")
                {
                    Label = resMunicipality,

                    Hidden = true,
                });

                #endregion


                #region Submit

                AddItem(new FormButton("Submit")
                {
                    Content = resSend,

                    Submit = true
                });

                #endregion

                CloseGroup("Container");
            }
            protected override void CreateForm()
            {
                OpenGroup("Container");

                #region Defaults

                OrderElements = OrderElements.LabelMarkInput;

                Required = true;

                RequiredMessage = resFieldRequired;

                #endregion


                #region Title

                AddItem(new FormTitle("Title")
                {
                    Content = resStudents,
                });

                #endregion


                #region DateOfBirth

                AddItem(dtpDateOfBirth = new FormDatePicker("DateOfBirth", "dd/mm/yyyy")
                {
                    Label = resDateOfBirth,

                    Placeholder = resDateOfBirth,

                    Validator = (v) =>
                    {
                        if (v > DateTime.Now)
                        {
                            return(resDateInvalid);
                        }

                        return(null);
                    }
                });

                #endregion


                #region Population

                AddItem(selPopulation = new FormSelect("Population", false)
                {
                    Label = resCity,

                    Header = new FormOption(resChoose),

                    Content = tblPopulation.ListAll().Select(p => new FormOption(p.id, p.descr))
                });

                #endregion


                #region City

                AddItem(selCity = new FormSelect("City", false)
                {
                    Label = resAreaOfResidence,

                    Header = new FormOption(resChoose),

                    Update = true,

                    Content = tblCity.ListAll().OrderBy(c => c.name).Select(c => new FormOption(c.id, c.name))
                });

                #endregion


                #region Municipality

                AddItem(selMunicipality = new FormSelect("MunicipalitySelect", false)
                {
                    Label = resMunicipality,

                    Header = new FormOption(resChoose),

                    Hidden = true,
                });


                AddItem(txtMunicipality = new FormTextBox("MunicipalityTextBox")
                {
                    Label = resMunicipality,

                    Hidden = true,
                });

                #endregion


                #region Email

                AddItem(txtEmail = new FormTextBox("Email")
                {
                    Label = resEmail.ToLower(),

                    Validator = (v) =>
                    {
                        if (!new Regex(@"^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]*$").IsMatch(v.Trim()))
                        {
                            return(resEmailInvalid);
                        }

                        return(null);
                    },
                });

                #endregion


                #region EducationalStage

                AddItem(selEducationalStage = new FormSelect("EducationalStage", false)
                {
                    Label = resEducationalStage,

                    Header = new FormOption(resChoose),

                    Update = true,

                    Content = tblEducationalStage.ListAll().Select(s => new FormOption(s.id, s.name))
                });

                #endregion


                #region EducationalGrade

                AddItem(selEducationalGrade = new FormSelect("EducationalGrade", false)
                {
                    Label = resEducationalGrade,

                    Header = new FormOption(resChoose),

                    Hidden = true,

                    Update = true,
                });

                #endregion


                #region OrientationGroup

                AddItem(selOrientationGroup = new FormSelect("OrientationGroup", false)
                {
                    Label = resOrientationGroup,

                    Header = new FormOption(resChoose),

                    Hidden = true,

                    Content = tblOrientationGroup.ListAll().Select(o => new FormOption(o.id, o.name))
                });

                #endregion


                #region CoachingSchool

                AddItem(txtCoachingSchool = new FormTextBox("CoachingSchool")
                {
                    Label = resCoachingSchool,

                    Required = false,
                });

                #endregion


                #region PrivateLessons

                AddItem(rdgPrivateLessons = new FormRadioGroup("PrivateLessons")
                {
                    Label = resPrivateLessons,

                    Required = false,

                    Content = new FormRadioButton[]
                    {
                        new FormRadioButton(0, resYes)
                        {
                            IsSelected = false
                        },
                        new FormRadioButton(1, resNo)
                        {
                            IsSelected = false
                        },
                    }
                });

                #endregion

                AddItem(new FormNumberSpinner("NumberSpinner")
                {
                    Label = "Number",

                    OrderNumberSpinner = OrderNumberSpinner.DecrIncrNumber,

                    Content = "0",

                    DirectInput = false,

                    Min = 0,
                });

                #region Submit

                AddItem(new FormButton("Submit")
                {
                    Content = resSend,

                    Submit = true
                });

                #endregion

                CloseGroup("Container");
            }