public CustomFieldRow(CustomField field)
        {
            Label cfNameLabel = new Label(string.Format("//label[text()='{0}']", field.NameOnForm), LocateBy.XPath);
            field.Id = Convert.ToInt32(cfNameLabel.GetAttribute("for"));

            if (field is CFCheckBox)
            {
                CustomFieldType = new CheckBox(string.Format(locator + "//input", field.Id.ToString()), LocateBy.XPath);
                CustomFieldLabel = new Label(string.Format(locator + "//label", field.Id.ToString()), LocateBy.XPath);
            }
        }
 public Input MerchInputField(DataCollection.MerchandiseItem merch)
 {
     Label merchNameLabel = new Label(string.Format("//label[text()='{0}']", merch.Name), LocateBy.XPath);
     merch.Id = Convert.ToInt32(merchNameLabel.GetAttribute("for"));
     return new Input(merch.Id.ToString(), LocateBy.Id);
 }
        public AgendaRow(DataCollection.AgendaItem agendaItem)
        {
            Label agendaNameTd = new Label(string.Format("//span[@class='bold'][text()='{0}']/..", agendaItem.NameOnForm), LocateBy.XPath);
            string agendaNameOnclickAttriText = agendaNameTd.GetAttribute("onclick");
            int agendaItemId = Convert.ToInt32(agendaNameOnclickAttriText.Split(new string[] { "'" }, StringSplitOptions.RemoveEmptyEntries)[1]);

            this.Agenda = new Clickable(string.Format("//*[@id='listGridTD{0}2']", agendaItemId), LocateBy.XPath);
            this.Delete = new Clickable(string.Format("//*[@id='listGridTD{0}5']//img[@title='Copy']/../../following-sibling::*//img", agendaItemId), LocateBy.XPath);
            this.Copy = new Clickable(string.Format("//*[@id='listGridTD{0}5']//img[@title='Copy']", agendaItemId), LocateBy.XPath);
        }
        public void PerformDefaultActions_Agenda(Registrant reg)
        {
            foreach (CustomFieldResponse responses in reg.CustomField_Responses)
            {
                if (responses is AgendaResponse)
                {
                    AgendaResponse response = responses as AgendaResponse;

                    switch (response.AgendaItem.Type)
                    {
                        case FormData.CustomFieldType.AlwaysSelected:
                            {
                                AgendaResponse_AlwaysSelected resp = response as AgendaResponse_AlwaysSelected;
                                AgendaRow row = PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(response.AgendaItem);

                                if (resp.Code != null)
                                {
                                    row.DiscountCodeInput.Type(resp.Code.CodeString);
                                }
                            }
                            break;

                        case FormData.CustomFieldType.CheckBox:
                            {
                                AgendaResponse_Checkbox resp = response as AgendaResponse_Checkbox;
                                AgendaRow row = PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(response.AgendaItem);
                                ((CheckBox)row.AgendaType).Set(resp.Checked.Value);

                                if (resp.Code != null)
                                {
                                    row.DiscountCodeInput.Type(resp.Code.CodeString);
                                }
                            }
                            break;

                        case FormData.CustomFieldType.RadioButton:
                            {
                                AgendaResponse_MultipleChoice_RadioButton resp = response as AgendaResponse_MultipleChoice_RadioButton;
                                Label choiceItemLabel = new Label(string.Format("//*[contains(text(),'{0}')]", resp.ChoiceItem.Name), LocateBy.XPath);
                                resp.ChoiceItem.Id = Convert.ToInt32(choiceItemLabel.GetAttribute("for"));
                                RadioButton radio = new RadioButton(resp.ChoiceItem.Id.ToString(), LocateBy.Id);
                                radio.Click();

                                AgendaRow row = PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(response.AgendaItem);

                                if (resp.Code != null)
                                {
                                    row.DiscountCodeInput.Type(resp.Code.CodeString);
                                }
                            }
                            break;

                        case FormData.CustomFieldType.Dropdown:
                            {
                                AgendaResponse_MultipleChoice_DropDown resp = response as AgendaResponse_MultipleChoice_DropDown;

                                AgendaRow row = PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(response.AgendaItem);

                                ((MultiChoiceDropdown)row.AgendaType).SelectWithText(resp.ChoiceItem.Name);

                                if (resp.Code != null)
                                {
                                    row.DiscountCodeInput.Type(resp.Code.CodeString);
                                }
                            }
                            break;

                        case FormData.CustomFieldType.Number:
                        case FormData.CustomFieldType.OneLineText:
                        case FormData.CustomFieldType.Paragraph:
                            {
                                AgendaResponse_TextInput resp = response as AgendaResponse_TextInput;
                                ((Input)PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(
                                    response.AgendaItem).AgendaType).Type(resp.CharToInput);
                            }
                            break;

                        case FormData.CustomFieldType.Contribution:
                            {
                                AgendaResponse_Contribution resp = response as AgendaResponse_Contribution;
                                ((Input)PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(
                                    response.AgendaItem).AgendaType).Type(resp.ContributionAmount);
                            }
                            break;

                        case FormData.CustomFieldType.Date:
                            {
                                AgendaResponse_Date resp = response as AgendaResponse_Date;
                                string date = string.Format("{0}/{1}/{2}", resp.Date.Value.Month, resp.Date.Value.Day, resp.Date.Value.Year);
                                ((Input)PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(
                                    response.AgendaItem).AgendaType).Type(date);
                            }
                            break;

                        case FormData.CustomFieldType.Time:
                            {
                                AgendaResponse_Time resp = response as AgendaResponse_Time;
                                string time = string.Format("{0}:{1}", resp.Time.Value.Hour, resp.Time.Value.Minute);
                                ((Input)PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(
                                    response.AgendaItem).AgendaType).Type(time);
                            }
                            break;

                        case FormData.CustomFieldType.FileUpload:
                            {
                                AgendaResponse_FileUpload resp = response as AgendaResponse_FileUpload;
                                ((Clickable)PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(
                                    response.AgendaItem).AgendaType).Click();
                                AutoIt.UploadFile.UploadAFile("File Upload", resp.FileSource);
                            }
                            break;

                        case FormData.CustomFieldType.Duration:
                            {
                                AgendaResponse_Duration resp = response as AgendaResponse_Duration;
                                ((Input)PageObject.PageObjectProvider.Register.RegistationSite.Agenda.GetAgendaItem(response.AgendaItem).AgendaType).Type(resp.Duration.ToString("c"));
                            }
                            break;

                        default:
                            throw new InvalidOperationException(string.Format("No action defined for specified type of agenda item: {0}", response.AgendaItem.Type.ToString()));
                    }
                }
            }
        }