private void DisplayFailed(ArrayList failedTransactions) { try { DataTable dt = bll.GetFailedReconTable(); Recontran recontran = new Recontran(); for (int i = 0; i < failedTransactions.Count; i++) { recontran = (Recontran)failedTransactions[i]; DataRow dr = dt.NewRow(); dr["No."] = i + 1; dr["VendorRef"] = recontran.VendorRef; dr["PayDate"] = recontran.PayDate; dr["TransactionAmount"] = recontran.TransAmount.ToString("#,##0"); dr["Reason"] = recontran.Reason; dt.Rows.Add(dr); dt.AcceptChanges(); } LoadFailedGrid(dt); } catch (Exception ex) { ShowMessage(ex.Message, true); } }
public bool ReconcileTrans(Recontran tran, ArrayList failedBankTransactions, int Reconcode) { bool output; string source = "RECEIVED"; string reason = ""; dTable = datapay.GetTransactionforReconciliation(tran.VendorRef, tran.VendorCode); if (dTable.Rows.Count > 0) { datatable = datapay.GetReconciledTransaction(tran.VendorRef, tran.VendorCode); if (datatable.Rows.Count > 0) { int ReconId = int.Parse(datatable.Rows[0]["ReconciliationCode"].ToString()); if (ReconId.Equals(Reconcode)) { reason = "Duplicate transaction with (" + datatable.Rows[0]["TranId"].ToString() + ")"; tran.Reason = reason; failedBankTransactions.Add(tran); output = false; } else { DateTime recondate = DateTime.Parse(datatable.Rows[0]["ReconciledDate"].ToString()); string recondatestr = recondate.ToString("dd/MM/yyyy : HH:MM:ss"); reason = "Transaction already reconciled on " + recondatestr; tran.Reason = reason; failedBankTransactions.Add(tran); output = false; } } else { int recordid = int.Parse(dTable.Rows[0]["TranId"].ToString()); double interamount = double.Parse(dTable.Rows[0]["TranAmount"].ToString()); DateTime interDate = DateTime.Parse(dTable.Rows[0]["PaymentDate"].ToString()); string strInterDate = interDate.ToString("dd/MM/yyyy"); string strStateDate = tran.PayDate; if (interamount.Equals(tran.TransAmount)) { if (strInterDate.Equals(strStateDate)) { datapay.ReconcileTransaction(recordid, Reconcode, source, tran.ReconType, tran.ReconciledBy); output = true; } else { reason = "Payment Dates dont match"; tran.Reason = reason; failedBankTransactions.Add(tran); output = false; } } else { reason = "Amount in Umeme Database does not match with that on the Statement"; tran.Reason = reason; failedBankTransactions.Add(tran); output = false; } } } else { datatable = datapay.GetReconciledTransaction(tran.VendorRef, tran.VendorCode); if (datatable.Rows.Count > 0) { DateTime recondate = DateTime.Parse(datatable.Rows[0]["ReconciledDate"].ToString()); string recondatestr = recondate.ToString("dd/MM/yyyy : HH:MM:ss"); reason = "Transaction already reconciled on " + recondatestr; tran.Reason = reason; failedBankTransactions.Add(tran); output = false; } else { reason = "Not found in the System database"; tran.Reason = reason; failedBankTransactions.Add(tran); output = false; } } return(output); }
private void ReadFileToRecon(string vendorcode) { string filename = Path.GetFileName(FileUpload1.FileName); string extension = Path.GetExtension(filename); if (extension.ToUpper().Equals(".CSV") || extension.ToUpper().Equals(".TXT")) { string filePath = bll.ReconFilePath(vendorcode, filename); FileUpload1.SaveAs(filePath); ArrayList failedBankTransactions = new ArrayList(); bool Status; int count = 0; int failedRecon = 0; int Reconciled = 0; string user = Session["Username"].ToString(); dfile = new DataFileProcess(); fileContents = dfile.readFile(filePath); int Reconcode = CreateReconCode(); Recontran tran; for (int i = 0; i < fileContents.Count; i++) { count++; string line = fileContents[i].ToString(); string[] sLine = line.Split(','); { tran = new Recontran(); if (sLine.Length == 3) { string vendorref = sLine[0].Trim(); string amountstr = sLine[1].Trim(); string datestr = GetPayDate(sLine[2].Trim()); double amt; DateTime dt; //if (!Double.TryParse(amountstr, out amt)) //{ // throw new Exception("Incorrect amount format at line " + count.ToString()); //} //else if (!DateTime.TryParse(datestr, out dt)) //{ // throw new Exception("Incorrect date format at line " + count.ToString()); //} //else { tran.VendorRef = vendorref; tran.VendorCode = vendorcode; tran.TransAmount = Double.Parse(amountstr); tran.PayDate = datestr; tran.ReconciledBy = user; tran.ReconType = "AR"; Status = Process.ReconcileTrans(tran, failedBankTransactions, Reconcode); if (Status) { Reconciled++; } else { failedRecon++; } } } else { CancelRecnBatch(Reconcode); throw new Exception("File Format is not OK, Columns must be 3... and not " + sLine.Length.ToString()); } } } int Total = Reconciled + failedRecon; if (failedRecon == 0) { ShowMessage("File of " + Total + " record(s) Reconciled Successfully", false); } else if (Reconciled == 0) { ShowMessage("File of " + Total + " record(s) Reconciliation failed", true); DisplayFailed(failedBankTransactions); } else { ShowMessage("File of " + Total + " record(s) Processed( Success -" + Reconciled + " Failed - " + failedRecon + ")", true); DisplayFailed(failedBankTransactions); } } else { ShowMessage("Please Browser CSV File, " + extension + " file not supported", true); } }