private void butCopy_Click(object sender, EventArgs e) { if (grid1.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select an internal sheet from the list above first."); return; } SheetDef sheetdef = grid1.SelectedTag <SheetDef>(); sheetdef.IsNew = true; SheetDefs.InsertOrUpdate(sheetdef); if (sheetdef.SheetType == SheetTypeEnum.MedicalHistory && (sheetdef.Description == "Medical History New Patient" || sheetdef.Description == "Medical History Update")) { MsgBox.Show(this, "This is just a template, it may contain allergies and problems that do not exist in your setup."); } grid1.SetSelected(false); FillGrid2(sheetdef.SheetDefNum); }
private void menuItemGoTo_Click(object sender, EventArgs e) { if (gridMain.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select a lab case first."); return; } DataRow row = gridMain.SelectedTag <DataRow>(); if (row["AptNum"].ToString() == "0") { MsgBox.Show(this, "There are no appointments for unattached lab cases."); return; } Appointment apt = Appointments.GetOneApt(PIn.Long(row["AptNum"].ToString())); if (apt.AptStatus == ApptStatus.UnschedList) { MsgBox.Show(this, "Cannot go to an unscheduled appointment"); return; } GoToAptNum = apt.AptNum; Close(); }
private void FillGrid(bool isPrinting = false, bool isResizing = false) { if (textDateFrom.errorProvider1.GetError(textDateFrom) != "" || textDateTo.errorProvider1.GetError(textDateTo) != "") { return; } ODGrid gridToFill = isPrinting?gridMainPrint:gridMain; long firstVisibleTransNum = 0; if (!isPrinting && gridToFill.VisibleRows.Count > 0) //don't scroll into view if printing { firstVisibleTransNum = (long)gridToFill.VisibleRows[0].Tag; } long selectedTransNum = 0; if (!isPrinting && gridToFill.GetSelectedIndex() > -1) //no need to reselect an index if printing { selectedTransNum = gridToFill.SelectedTag <long>(); } //Resize grid to fit, important for later resizing gridToFill.BeginUpdate(); gridToFill.Title = _acctCur.Description + " (" + Lan.g("enumAccountType", _acctCur.AcctType.ToString()) + ")"; FillColumns(isPrinting, isResizing); DateTime dateFrom = PIn.Date(textDateFrom.Text); DateTime dateTo = string.IsNullOrEmpty(textDateTo.Text)?DateTime.MaxValue:PIn.Date(textDateTo.Text); double filterAmt = string.IsNullOrEmpty(textAmt.errorProvider1.GetError(textAmt))?PIn.Double(textAmt.Text):0; if (!isResizing || _listJEntries == null || _dictTransUsers == null) { _listJEntries = JournalEntries.GetForAccount(_acctCur.AccountNum); _dictTransUsers = Transactions.GetManyTrans(_listJEntries.Select(x => x.TransactionNum).ToList()) .ToDictionary(x => x.TransactionNum, x => x.UserNum); } gridToFill.ListGridRows.Clear(); GridRow row; decimal bal = 0; int firstVisibleRowIndex = -1; int selectedIndex = -1; foreach (JournalEntry jeCur in _listJEntries) { if (jeCur.DateDisplayed > dateTo) { break; } if (new[] { AccountType.Income, AccountType.Expense }.Contains(_acctCur.AcctType) && jeCur.DateDisplayed < dateFrom) { continue; //for income and expense accounts, previous balances are not included. Only the current timespan. } //DebitIsPos=true for checking acct, bal+=DebitAmt-CreditAmt bal += (Accounts.DebitIsPos(_acctCur.AcctType)?1:-1) * ((decimal)jeCur.DebitAmt - (decimal)jeCur.CreditAmt); if (new[] { AccountType.Asset, AccountType.Liability, AccountType.Equity }.Contains(_acctCur.AcctType) && jeCur.DateDisplayed < dateFrom) { continue; //for asset, liability, and equity accounts, older entries do affect the current balance. } if (filterAmt != 0 && filterAmt != jeCur.CreditAmt && filterAmt != jeCur.DebitAmt) { continue; } if (textFindText.Text != "" && new[] { jeCur.Memo, jeCur.CheckNumber, jeCur.Splits }.All(x => !x.ToUpper().Contains(textFindText.Text.ToUpper()))) { continue; } row = new GridRow(); row.Cells.Add(jeCur.CheckNumber); row.Cells.Add(jeCur.DateDisplayed.ToShortDateString()); row.Cells.Add(jeCur.Memo); row.Cells.Add(jeCur.Splits); row.Cells.Add(jeCur.DebitAmt == 0?"":jeCur.DebitAmt.ToString("n")); row.Cells.Add(jeCur.CreditAmt == 0?"":jeCur.CreditAmt.ToString("n")); row.Cells.Add(bal.ToString("n")); long userNum; row.Cells.Add(Userods.GetName(_dictTransUsers.TryGetValue(jeCur.TransactionNum, out userNum)?userNum:0)); row.Cells.Add(Userods.GetName(jeCur.SecUserNumEdit)); row.Cells.Add(jeCur.ReconcileNum == 0?"":"X"); row.Tag = jeCur.TransactionNum; gridToFill.ListGridRows.Add(row); if (firstVisibleTransNum > 0 && jeCur.TransactionNum == firstVisibleTransNum) { firstVisibleRowIndex = gridToFill.ListGridRows.Count - 1; } if (selectedTransNum > 0 && jeCur.TransactionNum == selectedTransNum) { selectedIndex = gridToFill.ListGridRows.Count - 1; } } gridToFill.EndUpdate(); if (selectedIndex > -1) { gridToFill.SetSelected(selectedIndex, true); } if (firstVisibleRowIndex > -1) { gridToFill.ScrollToIndex(firstVisibleRowIndex); } else { gridToFill.ScrollToEnd(); } }