private void FormAccountPick_Load(object sender, EventArgs e) { if (Security.IsAuthorized(Permissions.Setup, true)) { butPhoneComps.Visible = true; } FillGrid(); gridMain.SortForced(1, true); }
private void FillGridAllMedications(bool shouldRetainSelection = true) { Medication medSelected = null; if (shouldRetainSelection && gridAllMedications.GetSelectedIndex() != -1) { medSelected = (Medication)gridAllMedications.Rows[gridAllMedications.GetSelectedIndex()].Tag; } List <long> listInUseMedicationNums = Medications.GetAllInUseMedicationNums(); int sortColIndex = gridAllMedications.SortedByColumnIdx; bool isSortAscending = gridAllMedications.SortedIsAscending; gridAllMedications.BeginUpdate(); gridAllMedications.Columns.Clear(); //The order of these columns is important. See gridAllMedications_CellClick() ODGridColumn col = new ODGridColumn(Lan.g(this, "Drug Name"), 120, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "Generic Name"), 120, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); col = new ODGridColumn(Lan.g(this, "InUse"), 55, HorizontalAlignment.Center, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); if (CultureInfo.CurrentCulture.Name.EndsWith("US")) //United States { col = new ODGridColumn(Lan.g(this, "RxNorm"), 70, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); } col = new ODGridColumn(Lan.g(this, "Notes for Generic"), 250, GridSortingStrategy.StringCompare); gridAllMedications.Columns.Add(col); gridAllMedications.Rows.Clear(); List <Medication> listMeds = Medications.GetList(textSearch.Text); foreach (Medication med in listMeds) { ODGridRow row = new ODGridRow(); row.Tag = med; if (med.MedicationNum == med.GenericNum) //isGeneric { row.Cells.Add(med.MedName); row.Cells.Add(""); } else { row.Cells.Add(med.MedName); row.Cells.Add(Medications.GetGenericName(med.GenericNum)); } if (listInUseMedicationNums.Contains(med.MedicationNum)) { row.Cells.Add("X"); //InUse } else { row.Cells.Add(""); //InUse } if (CultureInfo.CurrentCulture.Name.EndsWith("US")) //United States { if (med.RxCui == 0) { row.Cells.Add(Lan.g(this, "(select)")); row.Cells[row.Cells.Count - 1].Bold = YN.Yes; } else { row.Cells.Add(med.RxCui.ToString()); } } row.Cells.Add(med.Notes); gridAllMedications.Rows.Add(row); } gridAllMedications.EndUpdate(); gridAllMedications.SortForced(sortColIndex, isSortAscending); if (medSelected != null) //Will be null if nothing is selected. { for (int i = 0; i < gridAllMedications.Rows.Count; i++) { Medication medCur = (Medication)gridAllMedications.Rows[i].Tag; if (medCur.MedicationNum == medSelected.MedicationNum) { gridAllMedications.SetSelected(i, true); break; } } } }