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); } }