1 / 12

GSV – Generic Storage and Validation

GSV – Generic Storage and Validation. Hovedprosjekt 2004/2005 Oppgave 10E Trond Smaavik 13.05.05. GSV – Generic Storage and Validation. Oppgaven:. Min motivasjon:. GSV – Generic Storage and Validation. Fundator:. GSV – Datalagring.

lavi
Download Presentation

GSV – Generic Storage and Validation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GSV – Generic Storage and Validation Hovedprosjekt 2004/2005Oppgave 10E Trond Smaavik13.05.05

  2. GSV – Generic Storage and Validation • Oppgaven: • Min motivasjon:

  3. GSV – Generic Storage and Validation • Fundator:

  4. GSV – Datalagring • Generisk lagring av skjermbilder, kontroller og innhold i kontroller. • Gjennfinning av verdier og innfylling i skjermbilder. • Enkel referering til lagrede verdier. • Egen kontroll for presentasjon i TextBox. • Egen kontroll for presentasjon i Label.

  5. GSV – Datamodell

  6. GSV – Gjennomløper aller kontroller i skjermbildet • private ArrayList ControlLoop(Control ctrl, ArrayList al) {if(ctrl.Controls.Count > 0) {foreach(Control c in ctrl.Controls) {if(c is CheckBoxList) { al.Add(c); } else {ControlLoop(c, al); } }return al; } else { WebControl wc = ctrl as WebControl; string storable = (wc != null) ? wc.Attributes["storable"] : null; bool store = (storable == null) ? true : !storable.Equals("false"); bool storeOnlyVisible = (wc != null && wc.Visible) ? true : false; if(store && storeOnlyVisible) al.Add(ctrl);return al; }}

  7. GSV – Finner støttede inputkontroller og henter verdi • foreach(Control c in controls) { InputControlVO icvo = null; • if(c is TextBox) { TextBox txt = c as TextBox; icvo = newInputControlVO(txt.UniqueID, txt.Text); }

  8. GSV – Finner støttede inputkontroller og henter verdi forts • if(c is CheckBoxList) { CheckBoxList cbl = c as CheckBoxList; ArrayList al = new ArrayList(); foreach(ListItem li in cbl.Items) {if(li.Selected) { icvo = new InputControlVO(cbl.UniqueID, li.Value); al.Add(ifvo); } }if(formId != 0) {da.DeleteValues(cbl.UniqueID,formId); FormVO f = new FormVO(); f.FormId = formId; f.ControlValues = al;da.InsertValues(f); } else { vos.AddRange(al); } icvo = null;}

  9. GSV – Lagrer kontroller og verdier i databasen • public IdsVO StoreData(FormVO form) { string insertStr = "InsertValues"; string updateStr = "UpdateValues"; • int suiteId = form.SuiteId; int formId = form.FormId; • if(suiteId == 0) suiteId = CreateFormSuite();if(formId == 0) { form.FormId = CreateForm(suiteId, form.FormTypeId);StoreValues(form, insertStr); } else {StoreValues(form, updateStr); formId = GetNextFormId(suiteId, formId); }return new IdsVO(suiteId, formId, form.FormTypeId);}

  10. GSV – Tilsvarende for gjennfinning av data • TextBox txt = c as TextBox;if(txt != null) txt.Text = icvo.ControlValue; • CheckBoxList cbl = c as CheckBoxList;if(cbl != null) { foreach(ListItem li in cbl.Items) { if(li.Text.Equals(icvo.ControlValue)) { li.Selected = true; break; } }}

  11. GSV – Validering • Valideringskontroller • Integrert i Visual Studio • Tjener- og klient-sidevalidering • Tilbakemelding til bruker • Fleksibilitet • .NET validatorkontroller • RequiredFieldValidator • RegularExpressionValidator • CustomValidator • RangeValidator • CompareValidator • CheckBoxListValidator • PersonnrValidator

  12. GSV – Validering, BaseValidator • protected override bool EvaluateIsValid() { int numSel = 0;foreach(ListItem li in _listctrl.Items) {if(li.Selected)numSel++; }if(_maxSelections < 0) { if(numSel >= _minSelections) return true; } else {if(numSel >= _minSelections && numSel <= _maxSelections) { return true; } } return false;}

More Related