Beispiel #1
0
        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);
        }
Beispiel #2
0
        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();
            }
        }