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