private void butOK_Click(object sender, System.EventArgs e) { if (textDate.errorProvider1.GetError(textDate) != "" || textInsUsed.errorProvider1.GetError(textInsUsed) != "" || textDedUsed.errorProvider1.GetError(textDedUsed) != "" ) { MessageBox.Show(Lan.g("All", "Please fix data entry errors first.")); return; } ClaimProcCur.ProcDate = PIn.Date(textDate.Text); ClaimProcCur.InsPayAmt = PIn.Double(textInsUsed.Text); ClaimProcCur.DedApplied = PIn.Double(textDedUsed.Text); if (IsNew) { ClaimProcs.Insert(ClaimProcCur); } else { ClaimProcs.Update(ClaimProcCur); } DialogResult = DialogResult.OK; }
public void butWriteOff_Click(object sender, System.EventArgs e) { DialogResult dresWriteoff = DialogResult.Cancel; if (CultureInfo.CurrentCulture.Name.EndsWith("CA")) //Canadian. en-CA or fr-CA { dresWriteoff = MessageBox.Show( Lan.g(this, "Write off unpaid amounts on labs and procedures?") + "\r\n" + Lan.g(this, "Choose Yes to write off unpaid amounts on both labs and procedures.") + "\r\n" + Lan.g(this, "Choose No to write off unpaid amounts on procedures only."), "", MessageBoxButtons.YesNoCancel); if (dresWriteoff != DialogResult.Yes && dresWriteoff != DialogResult.No) //Cancel { return; } } else //United States { if (MessageBox.Show(Lan.g(this, "Write off unpaid amount on each procedure?"), "", MessageBoxButtons.OKCancel) != DialogResult.OK) { return; } } if (!SaveGridChanges()) { return; } if (CultureInfo.CurrentCulture.Name.EndsWith("CA") && dresWriteoff == DialogResult.Yes) //Canadian. en-CA or fr-CA { Claim claim = Claims.GetClaim(ClaimProcsToEdit[0].ClaimNum); //There should be at least one, since a claim can only be created with one or more procedures. ClaimProc cpTotalLabs = new ClaimProc(); cpTotalLabs.ClaimNum = claim.ClaimNum; cpTotalLabs.PatNum = claim.PatNum; cpTotalLabs.ProvNum = claim.ProvTreat; cpTotalLabs.Status = ClaimProcStatus.Received; cpTotalLabs.PlanNum = claim.PlanNum; cpTotalLabs.InsSubNum = claim.InsSubNum; cpTotalLabs.DateCP = DateTimeOD.Today; cpTotalLabs.ProcDate = claim.DateService; cpTotalLabs.DateEntry = DateTime.Now; cpTotalLabs.ClinicNum = claim.ClinicNum; cpTotalLabs.WriteOff = 0; cpTotalLabs.InsPayAmt = 0; for (int i = 0; i < ClaimProcsToEdit.Length; i++) { ClaimProc claimProc = ClaimProcsToEdit[i]; double procLabInsPaid = 0; if (claimProc.InsPayAmt > claimProc.FeeBilled) { procLabInsPaid = claimProc.InsPayAmt - claimProc.FeeBilled; //The amount of exceess greater than the fee billed. claimProc.InsPayAmt = claimProc.FeeBilled; } List <Procedure> listProcLabs = Procedures.GetCanadianLabFees(claimProc.ProcNum); //0, 1 or 2 lab fees per procedure double procLabTotal = 0; for (int j = 0; j < listProcLabs.Count; j++) { procLabTotal += listProcLabs[j].ProcFee; } if (procLabInsPaid > procLabTotal) //Could happen if the user enters a payment amount greater than the fee billed and lab fees added together. { procLabInsPaid = procLabTotal; } cpTotalLabs.InsPayAmt += procLabInsPaid; cpTotalLabs.WriteOff += procLabTotal - procLabInsPaid; } if (cpTotalLabs.InsPayAmt > 0 || cpTotalLabs.WriteOff > 0) //These amounts will both be zero if there are no lab fees on any of the procedures. These amounts should never be negative. { ClaimProcs.Insert(cpTotalLabs); } } //fix later: does not take into account other payments. double unpaidAmt = 0; List <Procedure> ProcList = Procedures.Refresh(PatCur.PatNum); for (int i = 0; i < ClaimProcsToEdit.Length; i++) { //ClaimProcsToEdit guaranteed to only contain claimprocs for procedures before this form loads, payments are not in the list unpaidAmt = Procedures.GetProcFromList(ProcList, ClaimProcsToEdit[i].ProcNum).ProcFee //((Procedure)Procedures.HList[ClaimProcsToEdit[i].ProcNum]).ProcFee - ClaimProcsToEdit[i].DedApplied - ClaimProcsToEdit[i].InsPayAmt; if (unpaidAmt > 0) { ClaimProcsToEdit[i].WriteOff = unpaidAmt; } } FillGrid(); }