private void ActionButton_Click(object sender, EventArgs e) { Button btn = (Button)sender; DataElementRowControl deletedRow = (DataElementRowControl)btn.Parent; char deletedChar = deletedRow.ElementID[2]; foreach (Control ctrl in _panelDataElements.Controls) { if (ctrl is DataElementRowControl) { DataElementRowControl row = (DataElementRowControl)ctrl; char rowChar = row.ElementID[2]; if (rowChar > deletedChar) { row.ElementID = "Z" + _jurisdiction.ToString()[0] + ((char)(rowChar - 1)); } } } _panelDataElements.Controls.Remove(deletedRow); _btnAddDataElement.Enabled = true; _currentChar--; if (_currentChar == ASCII_A) { _btnSubmit.Enabled = false; } }
private void InternalAddDataElement(string optionalElementID, string optionalValue) { if (_currentChar <= ASCII_Z) { DataElementRowControl row = new DataElementRowControl(); row.Jurisdiction = _jurisdiction; row.ElementID = optionalElementID != null ? optionalElementID : "Z" + _jurisdiction.ToString()[0] + _currentChar.ToString(); if (optionalValue != null) { row.TextBox.Text = optionalValue; } row.Dock = DockStyle.Top; row.SubfileType = AAMVASubfileType.JurisdictionSpecific; row.ActionButton.Click += ActionButton_Click; _panelDataElements.Controls.Add(row); _panelDataElements.Controls.SetChildIndex(row, 0); _currentChar++; if (_currentChar > ASCII_Z) { _btnAddDataElement.Enabled = false; } _panelDataElements.ScrollControlIntoView(row); _btnSubmit.Enabled = true; } }
private void RepopulateDataElements() { AAMVARegion rgn = AAMVAID.LookupRegion(_jurisdiction); string dateFormat = ""; if (rgn == AAMVARegion.UnitedStates) { dateFormat = "MMddyyyy"; } else { dateFormat = "yyyyMMdd"; } foreach (TabPage tabPage in _tabControl.TabPages) { foreach (Control ctrl in tabPage.Controls) { if (ctrl is DataElementRowControl) { DataElementRowControl row = (DataElementRowControl)ctrl; AAMVADataElement dataElement = null; try { dataElement = _subfileSkeleton.DataElements[row.ElementID]; } catch { continue; } if (dataElement != null) { if (!row.CheckBox.Checked) { row.CheckBox.Checked = true; } switch (row.ViewMode) { case DataElementRowControl.Mode.ComboBox: row.ComboBox.SelectedValue = dataElement.Value; break; case DataElementRowControl.Mode.DatePicker: DateTime dateTime; DateTime.TryParseExact(dataElement.Value, dateFormat, null, System.Globalization.DateTimeStyles.None, out dateTime); row.DateTimePicker.Value = dateTime; break; case DataElementRowControl.Mode.TextBox: row.TextBox.Text = dataElement.Value; break; } } } } } }
private void _btnSubmit_Click(object sender, EventArgs e) { IDictionary <string, AAMVADataElement> dataElements = new Dictionary <string, AAMVADataElement>(); //Get values foreach (Control ctrl in _panelDataElements.Controls) { if (ctrl is DataElementRowControl) { DataElementRowControl row = (DataElementRowControl)ctrl; if (row.CheckBox.Checked) { AAMVADataElement dataElement = new AAMVADataElement(); dataElement.ElementID = row.ElementID; dataElement.Value = row.TextBox.Text; dataElements.Add(dataElement.ElementID, dataElement); } } } _parent.SubmitEditSubfile(_subfileIndex, dataElements); _closeAction = EditSubfileDialog.CloseAction.Submit; Close(); }
private void _btnSubmit_Click(object sender, EventArgs e) { //loop over all dataelementrowctrls bool allValid = true; //Check values for (int i = 0; i < 2; i++) { foreach (Control ctrl in _tabControl.TabPages[i].Controls) { if (ctrl is DataElementRowControl) { DataElementRowControl row = (DataElementRowControl)ctrl; if (row.ViewMode == DataElementRowControl.Mode.TextBox && row.CheckBox.Checked) { row.RaiseBeforeSubmitTextEvent(); bool rowValid = row.RaiseValidateOnSubmitTextEvent(); if (!rowValid) { allValid = false; } } } } } if (!allValid) { System.Media.SystemSounds.Beep.Play(); return; } IDictionary <string, AAMVADataElement> dataElements = new Dictionary <string, AAMVADataElement>(); //Get values for (int i = 0; i < 2; i++) { foreach (Control ctrl in _tabControl.TabPages[i].Controls) { if (ctrl is DataElementRowControl) { DataElementRowControl row = (DataElementRowControl)ctrl; if (row.CheckBox.Checked) { if (row.ViewMode == DataElementRowControl.Mode.TextBox) { AAMVADataElement dataElement = new AAMVADataElement(); dataElement.ElementID = row.ElementID; dataElement.Value = row.TextBox.Text; dataElements.Add(dataElement.ElementID, dataElement); } if (row.ViewMode == DataElementRowControl.Mode.DatePicker) { AAMVARegion rgn = AAMVAID.LookupRegion(_jurisdiction); string dateFormat = ""; if (rgn == AAMVARegion.UnitedStates) { dateFormat = "MMddyyyy"; } else { dateFormat = "yyyyMMdd"; } string dateString = row.DateTimePicker.Value.ToString(dateFormat); AAMVADataElement dataElement = new AAMVADataElement(); dataElement.ElementID = row.ElementID; dataElement.Value = dateString; dataElements.Add(dataElement.ElementID, dataElement); } if (row.ViewMode == DataElementRowControl.Mode.ComboBox) { AAMVADataElement dataElement = new AAMVADataElement(); dataElement.ElementID = row.ElementID; dataElement.Value = (string)(row.ComboBox.SelectedValue); dataElements.Add(dataElement.ElementID, dataElement); } } } } } _parent.SubmitEditSubfile(_subfileIndex, dataElements); _closeAction = CloseAction.Submit; Close(); }
private void AddDataElementRows(HashSet <string> values, int tabIndex) { _dataElementInfo = AAMVADataElementInfo.RetrieveAll(AAMVAVersion.Version2016); if (tabIndex == 0) { Label label = new Label(); label.Text = "Per AAMVA CDS 2016 §D.12.5, mandatory data elements that call for variable length, alphabetical values will be filled with \"NONE\" if no value is provided."; label.Dock = DockStyle.Top; _tabControl.TabPages[tabIndex].Controls.Add(label); _tabControl.TabPages[tabIndex].Controls.SetChildIndex(label, 0); } if (tabIndex == 1) { _cbDHS = new CheckBox(); _cbDHS.Text = "DHS (REAL ID) Required Data Elements"; _cbDHS.Dock = DockStyle.Top; _cbDHS.CheckedChanged += (s, e) => { if (_cbDHS.Checked) { foreach (Control ctrl in _tabControl.TabPages[tabIndex].Controls) { if (ctrl is DataElementRowControl) { DataElementRowControl rowInner = (DataElementRowControl)ctrl; if (DHSDataElements.Contains(rowInner.ElementID)) { rowInner.CheckBox.Checked = true; } } } } else { bool shouldUncheckAll = true; foreach (Control ctrl in _tabControl.TabPages[tabIndex].Controls) { if (ctrl is DataElementRowControl) { DataElementRowControl rowInner = (DataElementRowControl)ctrl; if (DHSDataElements.Contains(rowInner.ElementID) && !rowInner.CheckBox.Checked) { shouldUncheckAll = false; } } } if (shouldUncheckAll) { foreach (Control ctrl in _tabControl.TabPages[tabIndex].Controls) { if (ctrl is DataElementRowControl) { DataElementRowControl rowInner = (DataElementRowControl)ctrl; if (DHSDataElements.Contains(rowInner.ElementID)) { rowInner.CheckBox.Checked = false; } } } } } }; _tabControl.TabPages[tabIndex].Controls.Add(_cbDHS); _tabControl.TabPages[tabIndex].Controls.SetChildIndex(_cbDHS, 0); } foreach (string elementID in values) { AAMVADataElementInfo info = _dataElementInfo[elementID]; if ((info.ValidSubfileTypes & (int)_subfileSkeleton.SubfileType) == (int)_subfileSkeleton.SubfileType) { DataElementRowControl row = new DataElementRowControl(); row.DataElementInfo = _dataElementInfo; row.Jurisdiction = _jurisdiction; row.ElementID = elementID; row.Dock = DockStyle.Top; row.CheckBox.CheckedChanged += (s, e) => { CheckBox cb = (CheckBox)s; if (!cb.Checked && DHSDataElements.Contains(row.ElementID)) { _cbDHS.Checked = false; } }; if (tabIndex == 1) //optional { row.CheckBox.Enabled = true; row.CheckBox.Checked = false; } _tabControl.TabPages[tabIndex].Controls.Add(row); _tabControl.TabPages[tabIndex].Controls.SetChildIndex(row, 0); } } }