///<summary>Adds the passed in pat fields to the grid. Adds any fields that have been renamed at the end of the grid if the preference is ///enabled. The tag on the row will be the PatFieldDef or the PatField if the PatFieldDef has been renamed.</summary> public static void AddPatFieldsToGrid(ODGrid grid, List <PatField> listPatFields, FieldLocations fieldLocation, List <FieldDefLink> listFieldDefLinks = null) { List <PatFieldDef> listPatFieldDefs = PatFieldDefs.GetDeepCopy(true); listFieldDefLinks = listFieldDefLinks ?? FieldDefLinks.GetForLocation(fieldLocation) .FindAll(x => x.FieldDefType == FieldDefTypes.Patient); //Add a row for each existing PatFieldDef foreach (PatFieldDef patFieldDef in listPatFieldDefs) { if (listFieldDefLinks.Exists(x => x.FieldDefNum == patFieldDef.PatFieldDefNum)) { continue; } ODGridRow row = new ODGridRow(); PatField field = listPatFields.FirstOrDefault(x => x.FieldName == patFieldDef.FieldName); if (patFieldDef.FieldType.ToString() == "InCaseOfEmergency") { //Deprecated. Should never happen. continue; } row.Cells.Add(patFieldDef.FieldName); if (field == null) { row.Cells.Add(""); } else { if (patFieldDef.FieldType == PatFieldType.Checkbox) { row.Cells.Add("X"); } else if (patFieldDef.FieldType == PatFieldType.Currency) { row.Cells.Add(PIn.Double(field.FieldValue).ToString("c")); } else { row.Cells.Add(field.FieldValue); } } row.Tag = patFieldDef; grid.Rows.Add(row); } if (!PrefC.GetBool(PrefName.DisplayRenamedPatFields)) { return; } //Now loop through the PatFields that do not have a matching PatFieldDef. foreach (PatField patField in listPatFields.Where(x => !listPatFieldDefs.Any(y => y.FieldName == x.FieldName))) { ODGridRow row = new ODGridRow(); row.Cells.Add(patField.FieldName); row.Cells.Add(patField.FieldValue); row.Tag = patField; row.ColorText = Color.DarkSlateGray; grid.Rows.Add(row); } }
private void buttonDelete_Click(object sender, EventArgs e) { if (IsNew) { DialogResult = DialogResult.Cancel; return; } try{ ApptFieldDefs.Delete(FieldDef); //Throws if in use. FieldDefLinks.DeleteForFieldDefNum(FieldDef.ApptFieldDefNum, FieldDefTypes.Appointment); //Delete any FieldDefLinks to this ApptFieldDef DialogResult = DialogResult.OK; } catch (ApplicationException ex) { MessageBox.Show(ex.Message); } }
private void FormFieldDefLink_Load(object sender, EventArgs e) { string[] arrayFieldLocations = Enum.GetNames(typeof(FieldLocations)); for (int i = 0; i < arrayFieldLocations.Length; i++) { comboFieldLocation.Items.Add(Lan.g("enumFieldLocations", arrayFieldLocations[i])); if (i == (int)_fieldLocation) { comboFieldLocation.SelectedIndex = i; } } _listFieldDefLinks = FieldDefLinks.GetAll(); _listApptFieldDefs = ApptFieldDefs.GetDeepCopy(); _listPatFieldDefs = PatFieldDefs.GetDeepCopy(true); FillGridDisplayed(); FillGridHidden(); }
private void butOK_Click(object sender, EventArgs e) { FieldDefLinks.Sync(_listFieldDefLinks); DialogResult = DialogResult.OK; }