/// <summary>Returns the text box control corresponding to the given procType</summary> private void FillDates() { List <Pref> listInsHistPref = Prefs.GetInsHistPrefs(); string text = NO_INSHIST; foreach (PrefName prefName in Prefs.GetInsHistPrefNames()) { Procedure proc = _dictInsHistProcs[prefName]; ClaimProc claimProc = null; if (proc != null) { claimProc = _listClaimProcsForInsHistProcs.Find(x => x.InsSubNum == _insSubCur.InsSubNum && x.Status.In(ClaimProcStatus.InsHist, ClaimProcStatus.Received) && x.ProcNum == proc.ProcNum); } text = ((claimProc != null && proc != null && proc.ProcDate.Year > 1880) ? proc.ProcDate.ToShortDateString() : NO_INSHIST); bool isPrefSet = listInsHistPref.Exists(x => x.PrefName == prefName.ToString() && !string.IsNullOrWhiteSpace(x.ValueString)); TextBox textBoxCur = GetControlForPrefName(prefName); if (!isPrefSet) { text = NO_INSHISTSET; textBoxCur.Enabled = false; } textBoxCur.Text = text; } }
///<summary></summary> private bool IsValid() { DateTime dateEntry; foreach (PrefName prefName in Prefs.GetInsHistPrefNames()) { TextBox textBox = GetControlForPrefName(prefName); //Continue if no date is entered or the date entered is valid. if (!textBox.Enabled || string.IsNullOrEmpty(textBox.Text) || textBox.Text.Trim() == NO_INSHIST) { continue; } if (!DateTime.TryParse(textBox.Text, out dateEntry)) { //Invalid date entered. MsgBox.Show(this, "Invalid date"); return(false); } if (dateEntry.Year < 1880 || dateEntry.Year > 2100) { MsgBox.Show("Invalid date. Valid dates between 1880 and 2100"); return(false); } } return(true); }
private void butOK_Click(object sender, EventArgs e) { if (!IsValid()) { return; } List <Procedure> listProcsForDelete = new List <Procedure>(); foreach (PrefName prefName in Prefs.GetInsHistPrefNames()) { TextBox textBox = GetControlForPrefName(prefName); if (!textBox.Enabled || textBox.Text.Trim() == NO_INSHIST) { continue; } Procedure proc = _dictInsHistProcs[prefName]; if (string.IsNullOrWhiteSpace(textBox.Text)) { if (proc != null && proc.ProcStatus == ProcStat.EO) //Only delete EO procedures { listProcsForDelete.Add(proc); //Delete proc if user deleted procedure date from textbox. } continue; } DateTime dateEntered = PIn.Date(textBox.Text); List <ClaimProc> listClaimProcsForProc = new List <ClaimProc>(); if (proc != null) { //Get all of the claimprocs for this procedure. listClaimProcsForProc = _listClaimProcsForInsHistProcs.FindAll(x => x.ProcNum == proc.ProcNum); } Procedures.InsertOrUpdateInsHistProcedure(_patCur, prefName, dateEntered, _insSubCur.PlanNum, _insSubCur.InsSubNum, proc, listClaimProcsForProc); } if (listProcsForDelete.Count > 0 && !MsgBox.Show(this, MsgBoxButtons.YesNo, "Deleting the last procedure date for a category will delete the Existing Other procedure with that date for this patient. Continue?")) { return; } foreach (Procedure proc in listProcsForDelete) { try { Procedures.Delete(proc.ProcNum); } catch (Exception ex) { //Tried deleting the procedure. Do nothing. ex.DoNothing(); } } DialogResult = DialogResult.OK; }