private void butDown_Click(object sender, EventArgs e) { if (gridMain.SelectedIndices.Length != 1) { MsgBox.Show(this, "Please select exactly one referral first."); return; } int selectedIdx = gridMain.GetSelectedIndex(); if (selectedIdx == gridMain.ListGridRows.Count - 1) //already at bottom { return; } RefAttach sourceAttach = ((RefAttach)gridMain.ListGridRows[selectedIdx].Tag); RefAttach destAttach = ((RefAttach)gridMain.ListGridRows[selectedIdx + 1].Tag); int sourceIdx = sourceAttach.ItemOrder; sourceAttach.ItemOrder = destAttach.ItemOrder; RefAttaches.Update(sourceAttach); destAttach.ItemOrder = sourceIdx; RefAttaches.Update(destAttach); if (!gridMain.SwapRows(selectedIdx, selectedIdx + 1)) { MsgBox.Show(this, "Unable to change order."); return; } gridMain.SetSelected(selectedIdx + 1, true); }
///<summary>Surround with try-catch.</summary> private void SaveData() { if (textOrder.errorProvider1.GetError(textOrder) != "" || textRefDate.errorProvider1.GetError(textRefDate) != "") { throw new ApplicationException(Lan.g(this, "Please fix data entry errors first.")); } if (radioFrom.Checked) { RefAttachCur.IsFrom = true; } else { RefAttachCur.IsFrom = false; } RefAttachCur.RefDate = PIn.PDate(textRefDate.Text); RefAttachCur.ItemOrder = PIn.PInt(textOrder.Text); RefAttachCur.RefToStatus = (ReferralToStatus)comboRefToStatus.SelectedIndex; RefAttachCur.Note = textNote.Text; if (IsNew) { RefAttaches.Insert(RefAttachCur); } else { RefAttaches.Update(RefAttachCur); } }
private void butOK_Click(object sender, System.EventArgs e) { //We want to help EHR users meet their summary of care measure. So all outgoing patient referrals should warn them if they didn't enter data correctly. if ((ReferralType)listRefType.SelectedIndex == ReferralType.RefTo && PrefC.GetBool(PrefName.ShowFeatureEhr)) { string warning = ""; if (comboProvNum.SelectedIndex < 0) { warning += Lans.g(this, "Selected patient referral does not have a referring provider set."); } if (!checkIsTransitionOfCare.Checked) { if (warning != "") { warning += "\r\n"; } warning += Lans.g(this, "Selected patient referral is not flagged as a transition of care."); } if (warning != "") { warning += "\r\n" + Lans.g(this, "It will not meet the EHR summary of care requirements.") + " " + Lans.g(this, "Continue anyway?"); if (MessageBox.Show(warning, Lans.g(this, "EHR Measure Warning"), MessageBoxButtons.OKCancel) == DialogResult.Cancel) { return; } } } //this is an old pattern try{ DataToCur(); if (IsNew) { RefAttaches.Insert(RefAttachCur); } else { RefAttaches.Update(RefAttachCur, _refAttachOld); } } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { //this is an old pattern try{ DataToCur(); if (IsNew) { RefAttaches.Insert(RefAttachCur); } else { RefAttaches.Update(RefAttachCur); } } catch (ApplicationException ex) { MessageBox.Show(ex.Message); return; } DialogResult = DialogResult.OK; }
private void butOK_Click(object sender, System.EventArgs e) { //Cur.IsFrom already handled if (textOrder.errorProvider1.GetError(textOrder) != "" || textRefDate.errorProvider1.GetError(textRefDate) != "" ) { MessageBox.Show(Lan.g(this, "Please fix data entry errors first.")); return; } RefAttachCur.RefDate = PIn.PDate(textRefDate.Text); RefAttachCur.ItemOrder = PIn.PInt(textOrder.Text); if (IsNew) { RefAttaches.Insert(RefAttachCur); } else { RefAttaches.Update(RefAttachCur); } DialogResult = DialogResult.OK; }