///<summary></summary> public static long Insert(XChargeTransaction xChargeTransaction) { if(RemotingClient.RemotingRole==RemotingRole.ClientWeb) { xChargeTransaction.XChargeTransactionNum=Meth.GetLong(MethodBase.GetCurrentMethod(),xChargeTransaction); return xChargeTransaction.XChargeTransactionNum; } return Crud.XChargeTransactionCrud.Insert(xChargeTransaction); }
public static DataTable GetMissingPaymentsTable(DateTime dateStart, DateTime dateEnd) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { return(Meth.GetTable(MethodBase.GetCurrentMethod(), dateStart, dateEnd)); } string command = "SELECT xchargetransaction.* " + "FROM xchargetransaction " + "WHERE " + DbHelper.BetweenDates("TransactionDateTime", dateStart, dateEnd) + " " + "AND xchargetransaction.ResultCode=0"; //Valid entries to count have result code 0 List <XChargeTransaction> listTrans = Crud.XChargeTransactionCrud.SelectMany(command); command = "SELECT payment.* " + "FROM payment " //only payments with the same PaymentType as the X-Charge PaymentType for the clinic + "INNER JOIN (" + "SELECT ClinicNum,PropertyValue PaymentType FROM programproperty " + "WHERE ProgramNum=" + POut.Long(Programs.GetProgramNum(ProgramName.Xcharge)) + " AND PropertyDesc='PaymentType'" + ") paytypes ON paytypes.ClinicNum=payment.ClinicNum AND paytypes.PaymentType=payment.PayType " + "WHERE DateEntry BETWEEN " + POut.Date(dateStart) + " AND " + POut.Date(dateEnd); List <Payment> listPays = Crud.PaymentCrud.SelectMany(command); for (int i = listTrans.Count - 1; i >= 0; i--) //Looping backwards in order to remove items { XChargeTransaction tran = listTrans[i]; Payment pay = listPays.Where(x => x.PatNum == tran.PatNum) .Where(x => x.DateEntry.Date == tran.TransactionDateTime.Date) .Where(x => x.PayAmt.Equals(tran.Amount)) .FirstOrDefault(); if (pay == null) //The XCharge transaction does not have a corresponding payment. { continue; } listTrans.RemoveAt(i); listPays.Remove(pay); //So that the same payment does not get counted for more than one XCharge transaction. } DataTable table = Crud.XChargeTransactionCrud.ListToTable(listTrans); List <string> listColumnsToKeep = new List <string> { "TransactionDateTime", "TransType", "ClerkID", "ItemNum", "PatNum", "CreditCardNum", "Expiration", "Result", "Amount" }; //Remove columns we don't want. for (int i = table.Columns.Count - 1; i >= 0; i--) { if (table.Columns[i].ColumnName.In(listColumnsToKeep)) { continue; } table.Columns.RemoveAt(i); } //Reorder the column in the order we want them. for (int i = 0; i < listColumnsToKeep.Count; i++) { table.Columns[listColumnsToKeep[i]].SetOrdinal(i); } return(table); }
///<summary></summary> public static long Insert(XChargeTransaction xChargeTransaction) { if (RemotingClient.RemotingRole == RemotingRole.ClientWeb) { xChargeTransaction.XChargeTransactionNum = Meth.GetLong(MethodBase.GetCurrentMethod(), xChargeTransaction); return(xChargeTransaction.XChargeTransactionNum); } return(Crud.XChargeTransactionCrud.Insert(xChargeTransaction)); }
private void butImport_Click(object sender,EventArgs e) { Cursor=Cursors.WaitCursor; OpenFileDialog Dlg=new OpenFileDialog(); if(Directory.Exists(@"C:\X-Charge\")) { Dlg.InitialDirectory=@"C:\X-Charge\"; } else if(Directory.Exists(@"C:\")) { Dlg.InitialDirectory=@"C:\"; } if(Dlg.ShowDialog()!=DialogResult.OK) { Cursor=Cursors.Default; return; } if(!File.Exists(Dlg.FileName)) { Cursor=Cursors.Default; MsgBox.Show(this,"File not found"); return; } XChargeTransaction trans=new XChargeTransaction(); string[] fields; XChargeTransaction transCheck; using(StreamReader sr=new StreamReader(Dlg.FileName)) { Cursor=Cursors.WaitCursor; string line=sr.ReadLine(); while(line!=null) { fields=line.Split(new string[1] { "," },StringSplitOptions.None); if(fields.Length<16){ continue; } trans.TransType=fields[0]; fields[1]=fields[1].Replace("$",""); if(fields[1].Contains("(")) { fields[1]=fields[1].TrimStart('('); fields[1]=fields[1].TrimEnd(')'); fields[1]=fields[1].Insert(0,"-"); } trans.Amount=PIn.Double(fields[1]); trans.CCEntry=fields[2]; trans.PatNum=0; if(!String.IsNullOrWhiteSpace(fields[3])) { trans.PatNum=PIn.Long(fields[3].Substring(3));//remove "PAT" from the beginning of the string } trans.Result=fields[4]; trans.ClerkID=fields[5]; trans.ResultCode=fields[7]; trans.Expiration=fields[8]; trans.CCType=fields[9]; trans.CreditCardNum=fields[10]; trans.BatchNum=fields[11]; trans.ItemNum=fields[12]; trans.ApprCode=fields[13]; trans.TransactionDateTime=PIn.Date(fields[14]).AddHours(PIn.Double(fields[15].Substring(0,2))).AddMinutes(PIn.Double(fields[15].Substring(3,2))); //Code removed in 14.2 so all transactions are allowed historically. //if(trans.BatchNum=="" || trans.ItemNum=="") { // line=sr.ReadLine(); // continue; //} transCheck=XChargeTransactions.GetOneByBatchItem(trans.BatchNum,trans.ItemNum); if(transCheck!=null && trans.Result!="AP DUPE") { XChargeTransactions.Delete(transCheck.XChargeTransactionNum); XChargeTransactions.Insert(trans); } else { XChargeTransactions.Insert(trans); } line=sr.ReadLine(); } } Cursor=Cursors.Default; MsgBox.Show(this,"Done."); }