private void AddCriteriaToSessionVar() { //individual selection criteria foreach (LoanInquiryCriteria criteria in this.listCriteria) { LoanInquiryCriteria inqCriteria = new LoanInquiryCriteria(); List <Control> ctrlvalues = inqCriteria.FindControls(new[] { "loaninquiry", "temp" }, criteria.Controls); if (ctrlvalues.Count > 0) { ComboBoxData dataName = criteria.DataName; string[] values = new string[3]; int i = 0; //get all non-loaninquiry* objects - these have the values foreach (Control ctrl in ctrlvalues) { switch (ctrl.GetType().Name) { case "State": ComboBox states = (ComboBox)ctrl.Controls[0]; USState state = (USState)states.SelectedItem; values[i++] = state.ShortName; break; case "Country": ComboBox countries = (ComboBox)ctrl.Controls[0]; CountryData country = (CountryData)countries.SelectedItem; values[i++] = country.Name; break; case "Gender": case "Race": case "Haircolor": case "EyeColor": ComboBox list = (ComboBox)ctrl.Controls[0]; ComboBoxData item = (ComboBoxData)list.SelectedItem; values[i++] = item.Description; break; case "Zipcode": case "Date": values[i++] = ctrl.Controls[0].Text; break; case "TextBox": case "ComboBox": values[i++] = ctrl.Text; break; } } InquirySelectedCriteria selCriteria = new InquirySelectedCriteria(criteria.loaninquiryDataTypeCombobox.SelectedItem.ToString(), dataName.Description, dataName.Code, criteria.SearchType, values, false); GlobalDataAccessor.Instance.DesktopSession.InquirySelectionCriteria.SelectedCriteria.Add(selCriteria); } } }
// //for adding LoanInquiryCriteria public void AddCriteria(int intAndButtonNumber) { //only add another criteria if the "And" was the last And in the collection if (intAndButtonNumber == listCriteria.Count) { LoanInquiryCriteria criteriaList = new LoanInquiryCriteria(); AddCriteriaCommon(criteriaList, listCriteria.Count); listCriteria.Add(criteriaList); } }
//common code for AddCriteria private void AddCriteriaCommon(LoanInquiryCriteria loanCriteria, int intInCriteria) { if (intInCriteria == 0) { loanCriteria.Location = new System.Drawing.Point(10, 10); } else { loanCriteria.Location = new System.Drawing.Point(10, listCriteria[intInCriteria - 1].Top + listCriteria[intInCriteria - 1].Height); } loanCriteria.Index = intInCriteria + 1; loanCriteria.Name = "LoanInquiryCriteria" + intInCriteria.ToString(); this.panelCriteriaListPanel.Controls.Add(loanCriteria); //move instruction label labelMessageLabel.Top = loanCriteria.Top + loanCriteria.Height + 20; }
//for re-adding LoanInquiryCriteria after a remove has been done public LoanInquiryCriteria AddCriteria(LoanInquiryCriteria loanCriteria, int intInCriteria) { AddCriteriaCommon(loanCriteria, intInCriteria); return(loanCriteria); }