public static void DeleteAll(List <long> listStatementNums) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { Meth.GetVoid(MethodBase.GetCurrentMethod(), listStatementNums); return; } if (listStatementNums == null || listStatementNums.Count == 0) { return; } //Removed all linked dependencies from these statements. StmtLinks.DetachAllFromStatements(listStatementNums); string command = DbHelper.WhereIn("UPDATE procedurelog SET StatementNum=0 WHERE StatementNum IN ({0})", false, listStatementNums.Select(x => POut.Long(x)).ToList()); Db.NonQ(command); command = DbHelper.WhereIn("UPDATE adjustment SET StatementNum=0 WHERE StatementNum IN({0})", false, listStatementNums.Select(x => POut.Long(x)).ToList()); Db.NonQ(command); command = DbHelper.WhereIn("UPDATE payplancharge SET StatementNum=0 WHERE StatementNum IN({0})", false, listStatementNums.Select(x => POut.Long(x)).ToList()); Db.NonQ(command); command = DbHelper.WhereIn("DELETE FROM statement WHERE StatementNum IN ({0})", false, listStatementNums.Select(x => POut.Long(x)).ToList()); Db.NonQ(command); }
public static Statement CreateLimitedStatement(List <long> listPatNumsSelected, long patNum, List <long> listPayClaimNums, List <long> listAdjustments, List <long> listPayNums, List <long> listProcedures) { Statement stmt = new Statement(); if (listPatNumsSelected.Count == 1) { stmt.PatNum = listPatNumsSelected[0]; } else { stmt.PatNum = patNum; } stmt.DateSent = DateTimeOD.Today; stmt.IsSent = false; stmt.Mode_ = StatementMode.InPerson; stmt.HidePayment = false; stmt.SinglePatient = listPatNumsSelected.Count == 1; //SinglePatient determined by the selected transactions stmt.Intermingled = listPatNumsSelected.Count > 1 && PrefC.GetBool(PrefName.IntermingleFamilyDefault); stmt.IsReceipt = false; stmt.IsInvoice = false; stmt.StatementType = StmtType.LimitedStatement; stmt.DateRangeFrom = DateTime.MinValue; stmt.DateRangeTo = DateTimeOD.Today; stmt.Note = ""; stmt.NoteBold = ""; stmt.IsBalValid = true; stmt.BalTotal = 0; stmt.InsEst = 0; Statements.Insert(stmt); //we need stmt.StatementNum for attaching procs, adjustments, and paysplits to the statement foreach (long adjNum in listAdjustments) { StmtLinks.Insert(new StmtLink() { FKey = adjNum, StatementNum = stmt.StatementNum, StmtLinkType = StmtLinkTypes.Adj }); } foreach (long payNum in listPayNums) { Payment payment = Payments.GetPayment(payNum); PaySplits.GetForPayment(payNum) .FindAll(x => x.PatNum == payment.PatNum && x.ClinicNum == payment.ClinicNum) .ForEach(x => StmtLinks.Insert(new StmtLink() { FKey = x.SplitNum, StatementNum = stmt.StatementNum, StmtLinkType = StmtLinkTypes.PaySplit })); } foreach (long procNum in listProcedures) { StmtLinks.Insert(new StmtLink() { FKey = procNum, StatementNum = stmt.StatementNum, StmtLinkType = StmtLinkTypes.Proc }); } foreach (long claimNum in listPayClaimNums) { StmtLinks.Insert(new StmtLink() { FKey = claimNum, StatementNum = stmt.StatementNum, StmtLinkType = StmtLinkTypes.ClaimPay }); } //foreach(PayPlanCharge payPlanCharge in listPayPlanCharges) { // StmtLinks.Insert(new OpenDentBusiness.StmtLink() {FKey=payPlanCharge.PayPlanChargeNum,StatementNum=stmt.StatementNum,StmtLinkType=StmtLinkTypes.PayPlanCharge}); //} //set statement lists to null in order to force refresh the lists now that we've inserted all of the StmtAttaches stmt.ListAdjNums = null; stmt.ListPaySplitNums = null; stmt.ListProcNums = null; stmt.ListInsPayClaimNums = null; if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { //Currently when using MiddleTier null lists inside an object like above causes the deserialized statement to incorrectly set the null lists //to empty lists. //In the case of a Statement, the public property associated to list in question does not run queries to populate the list as expected because //it checks for a null list, but instead sees an empty list. //We may fix the underlying MiddleTier bug later, but this is an immediate patch to address this symptom. stmt.ListAdjNums = StmtLinks.GetForStatementAndType(stmt.StatementNum, StmtLinkTypes.Adj); stmt.ListPaySplitNums = StmtLinks.GetForStatementAndType(stmt.StatementNum, StmtLinkTypes.PaySplit); if (stmt.IsInvoice) { stmt.ListProcNums = Procedures.GetForInvoice(stmt.StatementNum); } else { stmt.ListProcNums = StmtLinks.GetForStatementAndType(stmt.StatementNum, StmtLinkTypes.Proc); } stmt.ListInsPayClaimNums = StmtLinks.GetForStatementAndType(stmt.StatementNum, StmtLinkTypes.ClaimPay); } return(stmt); }