public void SetInfant(InterJetPassangerInfant infant) { ComboBox nationalityComboBox = this.GetComboBoxByName("Nationality"); nationalityComboBox.SelectedValue = infant.Nationality; ComboBox genderComboBox = this.GetComboBoxByName("Gender"); genderComboBox.SelectedValue = infant.Sex; ComboBox titleComboBox = this.GetComboBoxByName("Title"); titleComboBox.SelectedValue = infant.Title; TextBox nameTextBox = this.GetTextBoxByName("Name_"); nameTextBox.Text = infant.Name; TextBox lastNameTextBox = this.GetTextBoxByName("LastName"); lastNameTextBox.Text = infant.LastName; ComboBox travelWithComboBox = this.GetComboBoxByName("TravelWith"); travelWithComboBox.SelectedItem = infant.AssignedPassanger; }
private void AsignInfantToPasanger(string idOfPassangerAssigned, InterJetPassangerInfant infant, ComboBox selectedPassangerID) { var passangers = (InterJetPassangers)this.Session["Passangers"]; InterJetPassanger passanger = passangers.FindPassanger(idOfPassangerAssigned); if (passanger is InterJetAdultPassanger) { var adultPassanger = (InterJetAdultPassanger)passanger; if (!adultPassanger.HasAlreadyAInfant) { adultPassanger.AssignedInfant = infant; infant.AssignedPassanger = adultPassanger; } else { selectedPassangerID.Focus(); throw new Exception(string.Format("POR FAVOR INDIQUE OTRO PASAJERO QUE ACOMPAÑE AL INFANTE {0}.", infant.Name)); } } else { var seniorPassanger = (InterJetSeniorAdultPassanger)passanger; if (!seniorPassanger.HasAlreadyAInfant) { seniorPassanger.AssignedInfant = infant; infant.AssignedPassanger = seniorPassanger; } else { selectedPassangerID.Focus(); throw new Exception(string.Format("POR FAVOR INDIQUE OTRO PASAJERO QUE ACOMPAÑE AL INFANTE {0}.", infant.Name)); } } }
//private List<InterJetPassangerInfant> GetInfants() //{ // InterJetAvailabilityUserInput userInput = (InterJetAvailabilityUserInput)this.Session["UserInput"]; // List<InterJetPassangerInfant> infants = new List<InterJetPassangerInfant>(); // if (userInput != null) // { // int numberOfInfants = userInput.InfantsPassangers; // for (int infantPaxIndex = 0; infantPaxIndex < numberOfInfants; infantPaxIndex++) // { // InterJetPassangerInfant infant = new InterJetPassangerInfant(); // Panel infantPanel = this.FindPanel(string.Format("Infant{0}", infantPaxIndex)); // GroupBox infantGroupBox = this.FindGroupBox(infantPanel, string.Format("InfantGroup{0}", infantPaxIndex)); // ComboBox genderComboBox = this.FindComboBox(infantGroupBox, string.Format("Gender{0}", infantPaxIndex)); // infant.Sex = genderComboBox.SelectedItem.ToString(); // this.ValidComboBox(genderComboBox, "SEXO", infantPaxIndex.ToString()); // ComboBox daysComboBox = this.FindComboBox(infantGroupBox, string.Format("dayOfBirth{0}", infantPaxIndex)); // this.ValidComboBox(daysComboBox, "DIA", infantPaxIndex.ToString()); // ComboBox monthComboBox = this.FindComboBox(infantGroupBox, string.Format("monthOfBirth{0}", infantPaxIndex)); // this.ValidComboBox(monthComboBox, "MES", infantPaxIndex.ToString()); // ComboBox yearComboBox = this.FindComboBox(infantGroupBox, string.Format("yearOfBirth{0}", infantPaxIndex)); // this.ValidComboBox(yearComboBox, "AÑO", infantPaxIndex.ToString()); // string dateOfBirthString = string.Format("{0}/{1}/{2}", daysComboBox.SelectedItem.ToString(), monthComboBox.SelectedItem.ToString(), yearComboBox.SelectedItem.ToString()); // infant.DateOfBirth = DateTime.Parse(dateOfBirthString); // ComboBox countryComboBox = this.FindComboBox(infantGroupBox, string.Format("Country{0}", infantPaxIndex)); // infant.Country = countryComboBox.SelectedItem != null ? countryComboBox.SelectedValue.ToString() : ""; // ComboBox nacionalityComboBox = this.FindComboBox(infantGroupBox, string.Format("Nacionality{0}", infantPaxIndex)); // infant.Nationality = nacionalityComboBox.SelectedItem != null ? nacionalityComboBox.SelectedValue.ToString() : ""; // TextBox nameTextBox = this.FindTextBox(infantGroupBox, string.Format("Name{0}", infantPaxIndex)); // this.ValidateTextBox(nameTextBox, "NOMBRE", infantPaxIndex.ToString()); // infant.Name = nameTextBox.Text; // TextBox lastNameTextBox = this.FindTextBox(infantGroupBox, string.Format("LastName{0}", infantPaxIndex)); // this.ValidateTextBox(lastNameTextBox, "APELLIDO", infantPaxIndex.ToString()); // infant.LastName = lastNameTextBox.Text; // ComboBox selectedPassangerID = this.FindComboBox(infantGroupBox, string.Format("PassangerID{0}", infantPaxIndex)); // string idOfPassangerAssigned = (selectedPassangerID.SelectedItem as InterJetPassanger).ID; // this.AsignInfantToPasanger(idOfPassangerAssigned, infant, selectedPassangerID); // infants.Add(infant); // } // } // return infants; //} /// <summary> /// Gets the infants. /// </summary> /// <returns></returns> private IEnumerable <InterJetPassangerInfant> GetInfants() { this.ClearAssignation(); var infants = new List <InterJetPassangerInfant>(); List <Panel> panels = this.InfantMainGroupBox.Controls.OfType <Panel>().ToList(); var userControls = new List <ucInterJetInfantCapture>(); if (panels.Count > 0) { userControls = panels.Where(panel => panel.Controls.OfType <ucInterJetInfantCapture>().FirstOrDefault() != null) .Select(panel => panel.Controls.OfType <ucInterJetInfantCapture>().FirstOrDefault()).ToList(); if (userControls.Count > 0) { foreach (ucInterJetInfantCapture userControl in userControls) { infants.Add(userControl.Infant); } } } foreach (InterJetPassangerInfant infantToCompare in infants) { InterJetPassangerInfant infantWithSamePassanger = infants.FirstOrDefault(infant => !infant.Name.Equals(infantToCompare.Name) && !infant.LastName.Equals(infantToCompare.LastName) && infant.AssignedPassanger.ID == infantToCompare.AssignedPassanger.ID); bool passangerIsAlreadyAssigned = infantWithSamePassanger != null; if (passangerIsAlreadyAssigned) { infants.Clear(); if (userControls.Any()) { var controlToWarn = userControls.FirstOrDefault( c => c.Infant.Name.Equals(infantToCompare.Name) && c.Infant.LastName.Equals(infantToCompare.LastName)); if (controlToWarn != null) { var msg = string.Format("POR FAVOR INDIQUE OTRO PASAJERO QUE ACOMPAÑE AL INFANTE {0}.", infantWithSamePassanger.Name); controlToWarn.WarnAboutPassangerSelected(msg); } } throw new Exception(string.Format("POR FAVOR INDIQUE OTRO PASAJERO QUE ACOMPAÑE AL INFANTE {0}.", infantWithSamePassanger.Name)); } } return(infants); }
//TODO: Validar seleccion. private InterJetPassangerInfant GetInfant() { var infant = new InterJetPassangerInfant(); ComboBox nationalityComboBox = this.GetComboBoxByName("Nationality"); infant.Nationality = nationalityComboBox.SelectedValue.ToString(); TextBox nameTextBox = this.GetTextBoxByName("Name_"); ValidateTextBox(nameTextBox, "NOMBRE"); infant.Name = nameTextBox.Text; TextBox lastNameTextBox = this.GetTextBoxByName("LastName"); ValidateTextBox(lastNameTextBox, "APELLIDO"); infant.LastName = lastNameTextBox.Text; ComboBox titleComboBox = this.GetComboBoxByName("Title"); ValidateInfateAge(this.CurrentUserControl.InfantDateOfBirth); infant.DateOfBirth = this.CurrentUserControl.InfantDateOfBirth; ComboBox genderComboBox = this.GetComboBoxByName("Gender"); infant.Sex = genderComboBox.SelectedValue.ToString(); ComboBox travelWithComboBox = this.GetComboBoxByName("TravelWith"); var passangerAssigned = travelWithComboBox.SelectedItem as InterJetPassanger; if (passangerAssigned != null && passangerAssigned.CanBeInfantAssigned) { if (passangerAssigned is InterJetAdultPassanger) { var adultPassanger = (InterJetAdultPassanger)passangerAssigned; adultPassanger.AssignedInfant = infant; infant.AssignedPassanger = adultPassanger; } if (passangerAssigned is InterJetSeniorAdultPassanger) { var adultPassanger = (InterJetSeniorAdultPassanger)passangerAssigned; adultPassanger.AssignedInfant = infant; infant.AssignedPassanger = adultPassanger; } } return(infant); }