private void processReturnToolStripMenuItem_Click(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.PaymentCreate)) { return; } if (gridMain.SelectedIndices.Length < 1) { return; } if (IsXWebTransaction(gridMain.SelectedIndices[0])) { long patNum = PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PatNum"].ToString()); string alias = _tableTrans.Rows[gridMain.SelectedIndices[0]]["Alias"].ToString(); List <CreditCard> listCards = CreditCards.GetCardsByToken(alias, new List <CreditCardSource> { CreditCardSource.XWeb, CreditCardSource.XWebPortalLogin }); if (listCards.Count == 0) { MsgBox.Show(this, "This credit card is no longer stored in the database. Return cannot be processed."); return; } if (listCards.Count > 1) { MsgBox.Show(this, "There is more than one card in the database with this token. Return cannot be processed due to the risk of charging the " + "incorrect card."); return; } FormXWeb FormXW = new FormXWeb(patNum, listCards.FirstOrDefault(), XWebTransactionType.CreditReturnTransaction, createPayment: true); FormXW.LockCardInfo = true; if (FormXW.ShowDialog() == DialogResult.OK) { FillGrid(); } } else { Payment payment = Payments.GetPayment(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PaymentNum"].ToString())); PayConnectResponseWeb pcResponseWeb = PayConnectResponseWebs.GetOne(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["ResponseNum"].ToString())); decimal amt = PIn.Decimal(_tableTrans.Rows[gridMain.SelectedIndices[0]]["Amount"].ToString()); string refNum = _tableTrans.Rows[gridMain.SelectedIndices[0]]["TransactionID"].ToString(); //This is actually PayConnectResponseWeb.RefNumber, it's just stored in the TransactionID column if (!PayConnectL.VoidOrRefundPayConnectPortalTransaction(pcResponseWeb, payment, PayConnectService.transType.RETURN, refNum, amt)) { return; } MsgBox.Show("Return successful."); FillGrid(); } }
private void voidPaymentToolStripMenuItem_Click(object sender, EventArgs e) { if (!Security.IsAuthorized(Permissions.PaymentCreate)) { return; } if (gridMain.SelectedIndices.Length < 1 || !MsgBox.Show(this, MsgBoxButtons.YesNo, "Void this payment?")) { return; } try { Cursor = Cursors.WaitCursor; if (IsXWebTransaction(gridMain.SelectedIndices[0])) { long patNum = PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PatNum"].ToString()); long responseNum = PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["ResponseNum"].ToString()); string payNote = Lan.g(this, "Void XWeb payment made from within Open Dental") + "\r\n" + Lan.g(this, "Amount:") + " " + PIn.Double(_tableTrans.Rows[gridMain.SelectedIndices[0]]["Amount"].ToString()).ToString("f") + "\r\n" + Lan.g(this, "Transaction ID:") + " " + _tableTrans.Rows[gridMain.SelectedIndices[0]]["TransactionID"].ToString() + "\r\n" + Lan.g(this, "Card Number:") + " " + _tableTrans.Rows[gridMain.SelectedIndices[0]]["MaskedAcctNum"].ToString() + "\r\n" + Lan.g(this, "Processed:") + " " + DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToShortTimeString(); XWebs.VoidPayment(patNum, payNote, responseNum); } else { Payment payment = Payments.GetPayment(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PaymentNum"].ToString())); PayConnectResponseWeb pcResponseWeb = PayConnectResponseWebs.GetOne(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["ResponseNum"].ToString())); decimal amt = PIn.Decimal(_tableTrans.Rows[gridMain.SelectedIndices[0]]["Amount"].ToString()); string refNum = _tableTrans.Rows[gridMain.SelectedIndices[0]]["TransactionID"].ToString(); //This is actually PayConnectResponseWeb.RefNumber, it's just stored in the TransactionID column if (!PayConnectL.VoidOrRefundPayConnectPortalTransaction(pcResponseWeb, payment, PayConnectService.transType.VOID, refNum, amt)) { Cursor = Cursors.Default; return; } } Cursor = Cursors.Default; MsgBox.Show(this, "Void successful"); FillGrid(); } catch (ODException ex) { Cursor = Cursors.Default; MessageBox.Show(ex.Message); } }
private void openPaymentToolStripMenuItem_Click(object sender, EventArgs e) { if (gridMain.SelectedIndices.Length < 1) { return; } Payment pay = Payments.GetPayment(PIn.Long(_tableTrans.Rows[gridMain.SelectedIndices[0]]["PaymentNum"].ToString())); if (pay == null) //The payment has been deleted { MsgBox.Show(this, "This payment no longer exists."); return; } Patient pat = Patients.GetPat(pay.PatNum); Family fam = Patients.GetFamily(pat.PatNum); FormPayment FormP = new FormPayment(pat, fam, pay, false); FormP.ShowDialog(); FillGrid(); }
private void menuItemOpenPayment_Click(object sender, EventArgs e) { RecurringCharge charge = gridMain.SelectedTag <RecurringCharge>(); if (charge == null || charge.PayNum == 0) { return; } Payment pay = Payments.GetPayment(charge.PayNum); if (pay == null) //The payment has been deleted { MsgBox.Show(this, "This payment no longer exists."); return; } Patient pat = Patients.GetPat(pay.PatNum); Family fam = Patients.GetFamily(pat.PatNum); FormPayment FormP = new FormPayment(pat, fam, pay, false); FormP.ShowDialog(); }
private void butOK_Click(object sender, System.EventArgs e) { bool isDiscountPlanAdj = (Defs.GetValue(DefCat.AdjTypes, _adjustmentCur.AdjType) == "dp"); if (textAdjDate.errorProvider1.GetError(textAdjDate) != "" || textProcDate.errorProvider1.GetError(textProcDate) != "" || textAmount.errorProvider1.GetError(textAmount) != "") { MsgBox.Show(this, "Please fix data entry errors first."); return; } if (PIn.Date(textAdjDate.Text).Date > DateTime.Today.Date && !PrefC.GetBool(PrefName.FutureTransDatesAllowed)) { MsgBox.Show(this, "Adjustment date can not be in the future."); return; } if (textAmount.Text == "") { MessageBox.Show(Lan.g(this, "Please enter an amount.")); return; } if (!isDiscountPlanAdj && listTypeNeg.SelectedIndex == -1 && listTypePos.SelectedIndex == -1) { MsgBox.Show(this, "Please select a type first."); return; } if (IsNew && AvaTax.IsEnabled() && listTypePos.SelectedIndex > -1 && (_listAdjPosCats[listTypePos.SelectedIndex].DefNum == AvaTax.SalesTaxAdjType || _listAdjPosCats[listTypePos.SelectedIndex].DefNum == AvaTax.SalesTaxReturnAdjType) && !Security.IsAuthorized(Permissions.SalesTaxAdjEdit)) { return; } if (PrefC.GetInt(PrefName.RigorousAdjustments) == 0 && _adjustmentCur.ProcNum == 0) { MsgBox.Show(this, "You must attach a procedure to the adjustment."); return; } if (_adjRemAmt < 0) { if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Remaining amount is negative. Continue?", "Overpaid Procedure Warning")) { return; } } bool changeAdjSplit = false; List <PaySplit> listPaySplitsForAdjust = new List <PaySplit>(); if (IsNew) { //prevents backdating of initial adjustment if (!Security.IsAuthorized(Permissions.AdjustmentCreate, PIn.Date(textAdjDate.Text), true)) //Give message later. { if (!_checkZeroAmount) //Let user create as long as Amount is zero and has edit zero permissions. This was checked on load. { MessageBox.Show(Lans.g("Security", "Not authorized for") + "\r\n" + GroupPermissions.GetDesc(Permissions.AdjustmentCreate)); return; } } } else { //Editing an old entry will already be blocked if the date was too old, and user will not be able to click OK button //This catches it if user changed the date to be older. if (!Security.IsAuthorized(Permissions.AdjustmentEdit, PIn.Date(textAdjDate.Text))) { return; } if (_adjustmentCur.ProvNum != comboProv.GetSelectedProvNum()) { listPaySplitsForAdjust = PaySplits.GetForAdjustments(new List <long>() { _adjustmentCur.AdjNum }); foreach (PaySplit paySplit in listPaySplitsForAdjust) { if (!Security.IsAuthorized(Permissions.PaymentEdit, Payments.GetPayment(paySplit.PayNum).PayDate)) { return; } if (comboProv.GetSelectedProvNum() != paySplit.ProvNum && PrefC.GetInt(PrefName.RigorousAccounting) == (int)RigorousAdjustments.EnforceFully) { changeAdjSplit = true; break; } } if (changeAdjSplit && !MsgBox.Show(this, MsgBoxButtons.OKCancel, "The provider for the associated payment splits will be changed to match the provider on the " + "adjustment.")) { return; } } } //DateEntry not allowed to change DateTime datePreviousChange = _adjustmentCur.SecDateTEdit; _adjustmentCur.AdjDate = PIn.Date(textAdjDate.Text); _adjustmentCur.ProcDate = PIn.Date(textProcDate.Text); _adjustmentCur.ProvNum = comboProv.GetSelectedProvNum(); _adjustmentCur.ClinicNum = comboClinic.SelectedClinicNum; if (listTypePos.SelectedIndex != -1) { _adjustmentCur.AdjType = _listAdjPosCats[listTypePos.SelectedIndex].DefNum; _adjustmentCur.AdjAmt = PIn.Double(textAmount.Text); } if (listTypeNeg.SelectedIndex != -1) { _adjustmentCur.AdjType = _listAdjNegCats[listTypeNeg.SelectedIndex].DefNum; _adjustmentCur.AdjAmt = -PIn.Double(textAmount.Text); } if (isDiscountPlanAdj) { //AdjustmentCur.AdjType is already set to a "discount plan" adj type. _adjustmentCur.AdjAmt = -PIn.Double(textAmount.Text); } if (_checkZeroAmount && _adjustmentCur.AdjAmt != 0) { MsgBox.Show(this, "Amount has to be 0.00 due to security permission."); return; } _adjustmentCur.AdjNote = textNote.Text; try{ if (IsNew) { Adjustments.Insert(_adjustmentCur); SecurityLogs.MakeLogEntry(Permissions.AdjustmentCreate, _adjustmentCur.PatNum, _patCur.GetNameLF() + ", " + _adjustmentCur.AdjAmt.ToString("c")); TsiTransLogs.CheckAndInsertLogsIfAdjTypeExcluded(_adjustmentCur, _isTsiAdj); } else { Adjustments.Update(_adjustmentCur); SecurityLogs.MakeLogEntry(Permissions.AdjustmentEdit, _adjustmentCur.PatNum, _patCur.GetNameLF() + ", " + _adjustmentCur.AdjAmt.ToString("c"), 0 , datePreviousChange); } } catch (Exception ex) { //even though it doesn't currently throw any exceptions MessageBox.Show(ex.Message); return; } if (changeAdjSplit) { PaySplits.UpdateProvForAdjust(_adjustmentCur, listPaySplitsForAdjust); } DialogResult = DialogResult.OK; }