override public decimal GetAccountBalance(string accountNumber) { if (!_isExistingCustomer) { throw new Exception("Account Balance may only be obtained for an existing customer"); } if (string.IsNullOrEmpty(accountNumber)) { throw new ArgumentNullException("accountNumber"); } // call up the WBGB transaction _Handler.SendKey("WBGB@E"); TraceScreen(); // wait for the F9=Add Acct _Handler.WaitForContent("F9=Add Acct", 5000); TraceScreen(); // The cursor is at the right place _Handler.CurrentField.Data = _name; // now, next input field _Handler.MoveNextField(new ScreenFieldAttributeData(ScreenFieldAttribute.Normal)).Data = accountNumber; _Handler.SendKey("@E"); TraceScreen(); // wait for the ". sign" or name is invalid ScreenPartialFieldCollection fields = new ScreenPartialFieldCollection(3); fields.Add(new ScreenPartialField("Customer name not found", 21, 2)); fields.Add(new ScreenPartialField("Name / account could not be found", 21, 2)); fields.Add(new ScreenPartialField(".", 5, 31)); int indexOfField = _Handler.WaitForContent(fields, 5000); TraceScreen(); if (indexOfField == 0) { throw new ArgumentException("Customer Name incorrect", _name); } if (indexOfField == 1) { throw new ArgumentException("Account Name incorrect", accountNumber); } // get the amount field, by using a partial field string amountString = _Handler.GetField(5, 20)[2].Data; // go to the blank screen ClearScreenAndWait(); return(decimal.Parse(amountString)); }
override public void CreateNewCustomer() { if (_isExistingCustomer) { throw new Exception("Create New Customer may only be called for a new customer"); } // call up the WBGB transaction _Handler.SendKey("WBAC@E"); TraceScreen(); // wait for the F9=Add Acct _Handler.WaitForContent("F9=Add Acct", 5000); TraceScreen(); // The cursor is at the right place _Handler.SendKey(_name + ((_name.Length != MaximumNameLength) ? "@T" : "")); // All of the values set by the client, first SSN _Handler.SendKey(_ssn); // no tab needed // Street _Handler.SendKey(_street + ((_street.Length != MaximumStreetLength) ? "@T" : "")); //City _Handler.SendKey(_city + ((_city.Length != MaximumCityLength) ? "@T" : "")); // State _Handler.SendKey(_state); // no tab needed // ZIP _Handler.SendKey(_zip); // no tab needed // Phone, this comes in as 10 digits, the field is however 13 digits long _Handler.SendKey(_phone + "@T"); // create a random 4 digit PIN Random r = new Random(); string randomPIN = r.Next(1000, 11000).ToString(); _Handler.SendKey(randomPIN + randomPIN + "@E"); TraceScreen(); // Customer Successfully Added // wait for the Initial Balance ScreenPartialFieldCollection fields = new ScreenPartialFieldCollection(3); fields.Add(new ScreenPartialField("Customer name already defined", 21, 2)); fields.Add(new ScreenPartialField("Duplicate SSN found", 21, 2)); fields.Add(new ScreenPartialField("Customer successfully added", 21, 2)); int indexOfField = _Handler.WaitForContent(fields, 5000); TraceScreen(); if (indexOfField == 0) { throw new Exception("Customer Name incorrect"); } if (indexOfField == 1) { throw new ArgumentException("Duplicate SSN found", _ssn); } // set the PIN _pin = randomPIN; // go to the blank screen ClearScreenAndWait(); // say this is now an existing customer _isExistingCustomer = true; }
override public void CreateNewAccount(AccountType accountType) { if (!_isExistingCustomer) { throw new Exception("New Accounts may only be created for an existing customer"); } // call up the WBGB transaction _Handler.SendKey("WBAA@E"); TraceScreen(); // wait for the F8=Add Cust _Handler.WaitForContent("F8=Add Cust", 5000); TraceScreen(); // The cursor is at the right place _Handler.CurrentField.Data = _name; // now, next input field _Handler.MoveNextField(new ScreenFieldAttributeData(ScreenFieldAttribute.Normal)).Data = (accountType == AccountType.Checking ? "C" : "S"); _Handler.SendKey("@E"); TraceScreen(); // wait for the Initial Balance ScreenPartialFieldCollection fields = new ScreenPartialFieldCollection(2); fields.Add(new ScreenPartialField("Initial Balance", (short)(accountType == AccountType.Savings ? 9 : 10), 2)); fields.Add(new ScreenPartialField("Account add failed", 21, 2)); int indexOfField = _Handler.WaitForContent(fields, 5000); TraceScreen(); if (indexOfField == 1) { throw new ArgumentException("Customer Name incorrect", _name); } // pick up the new Number string newNumber = _Handler.GetField(5, 11).Data; // if this is savings if (accountType == AccountType.Savings) { // Interest Rate _Handler.SendKey("2.5@T"); // Service Charge _Handler.SendKey("1.0@T"); // Initial Balance _Handler.SendKey("0.00@E"); TraceScreen(); fields.Clear(); fields.Add(new ScreenPartialField("Account successfully added", 21, 2)); fields.Add(new ScreenPartialField("Account add failed", 21, 2)); indexOfField = _Handler.WaitForContent(fields, 5000); TraceScreen(); if (indexOfField == 1) { throw new Exception("Could not add Account"); } } else { // Overdraft Charge _Handler.SendKey("1@T"); // Overdraft Limit _Handler.SendKey("1000@T"); // no Linked Savings Account, Initial Balance _Handler.SendKey("@T0.00@E"); fields.Clear(); fields.Add(new ScreenPartialField("Account successfully added", 21, 2)); fields.Add(new ScreenPartialField("Account add failed", 21, 2)); indexOfField = _Handler.WaitForContent(fields, 5000); if (indexOfField == 1) { throw new Exception("Could not add Account"); } } // add the new Number to the list of Accounts if (_accountNumbers == null) { _accountNumbers = new string[1]; } else { Array.Resize(ref _accountNumbers, _accountNumbers.Length + 1); } _accountNumbers[_accountNumbers.Length - 1] = newNumber; // go to the blank screen ClearScreenAndWait(); }
override public string[] GetStatements() { if (!_isExistingCustomer) { throw new Exception("Statements may only be obtained for an existing customer"); } // call up the WBGB transaction _Handler.SendKey("WBGD@E"); TraceScreen(); // wait for the F9=Add Acct _Handler.WaitForContent("F9=Add Acct", 5000); TraceScreen(); // The cursor is at the right place _Handler.SendKey(_name + "@E"); TraceScreen(); // wait for the "paging commands" or name is invalid ScreenPartialFieldCollection fields = new ScreenPartialFieldCollection(2); fields.Add(new ScreenPartialField("Customer name not found", 21, 2)); fields.Add(new ScreenPartialField("Press <Enter> and follow with paging commands", 1, 2)); int indexOfField = _Handler.WaitForContent(fields, 5000); TraceScreen(); if (indexOfField == 0) { throw new ArgumentException("Customer Name incorrect", _name); } // hit enter _Handler.SendKey("@E"); TraceScreen(); // statement lines ArrayList alLines = new ArrayList(); // look for the end of paging or more fields.Clear(); fields.Add(new ScreenPartialField("End of Report", 24, 2)); fields.Add(new ScreenPartialField("Press Clear and type P/N to see page N", 24, 2)); // for each page bool morePages = true; int pageNumber = 1; while (morePages) { // do we have more statements indexOfField = _Handler.WaitForContent(fields, 5000); TraceScreen(); // get hold of all of the statement lines // the last Amount spreads over the rest of the screen, so the column // does no longer start at 2..thus ending the get fields ScreenFieldCollection sfcNumbers = _Handler.GetFieldsByColumn(2, 4); foreach (ScreenField numberField in sfcNumbers) { // get the Account Number string line = numberField.Data; // reference the transaction type field ScreenField valueField = numberField + 3; // add the rest of the info line += valueField.Data + (++valueField).Data; // just in case the last field is humogously long, use the partial field line += (++valueField)[1, 13].Data; alLines.Add(line); } // more? if (indexOfField == 1) { // go to the blank screen ClearScreenAndWait(); // next page pageNumber++; _Handler.SendKey("P/" + pageNumber.ToString() + "@E"); } else { morePages = false; } } // go to the blank screen ClearScreenAndWait(); string [] returnLines = new string[alLines.Count]; for (int index = 0; index < alLines.Count; index++) { returnLines[index] = (string)alLines[index]; } return(returnLines); }
override public void ValidateCustomer(string customerName) { if (string.IsNullOrEmpty(customerName)) { throw new ArgumentNullException("customerName"); } // save the name come what may _name = customerName; // call up the WBGA transaction _Handler.SendKey("WBGA@E"); TraceScreen(); // wait for the F9=Add Acct _Handler.WaitForContent("F9=Add Acct", 5000); TraceScreen(); // The cursor is at the right place _Handler.SendKey(customerName + "@E"); TraceScreen(); // wait for the "paging commands" or name is invalid ScreenPartialFieldCollection fields = new ScreenPartialFieldCollection(2); fields.Add(new ScreenPartialField("Customer name not found", 21, 2)); fields.Add(new ScreenPartialField("Press <Enter> and follow with paging commands", 1, 2)); int indexOfField = _Handler.WaitForContent(fields, 5000); TraceScreen(); // if we can't find the customer if (indexOfField == 0) { _isExistingCustomer = false; // go to the blank screen ClearScreenAndWait(); } else { _isExistingCustomer = true; // hit enter _Handler.SendKey("@E"); TraceScreen(); // wait for "End of Report" _Handler.WaitForContent("End of Report", 5000); TraceScreen(); // get all the accounts available ScreenFieldCollection sfcAccountNumbers = _Handler.GetFieldsByColumn(2, 4); _accountNumbers = new string[sfcAccountNumbers.Length]; for (int index = 0; index < sfcAccountNumbers.Length; index++) { _accountNumbers[index] = (string)sfcAccountNumbers[index].Data; } // go to the blank screen ClearScreenAndWait(); // get the customers address data RetrieveCustomerInfo(); } }