120 likes | 250 Views
This project outlines the development of a Generic Storage and Validation (GSV) system designed for .NET applications. The GSV system facilitates the storage of screen data, control elements, and their associated values. Key features include automated retrieval and filling of form values, customizable presentation controls, and robust data validation methods. It integrates various validator controls to ensure data integrity and offers flexibility in deployment. The system leverages a thorough understanding of control loops and data management to enhance user interaction and data handling efficiency.
E N D
GSV – Generic Storage and Validation Hovedprosjekt 2004/2005Oppgave 10E Trond Smaavik13.05.05
GSV – Generic Storage and Validation • Oppgaven: • Min motivasjon:
GSV – Generic Storage and Validation • Fundator:
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.
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; }}
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); }
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;}
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);}
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; } }}
GSV – Validering • Valideringskontroller • Integrert i Visual Studio • Tjener- og klient-sidevalidering • Tilbakemelding til bruker • Fleksibilitet • .NET validatorkontroller • RequiredFieldValidator • RegularExpressionValidator • CustomValidator • RangeValidator • CompareValidator • CheckBoxListValidator • PersonnrValidator
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;}