コード例 #1
0
        }//end method

        public override void ProcessFile()
        {
            ReadMasterFileRecord(ref ctMaster);
            ReadTransFileRecord(ref ctTrans);

            while (ctMaster != null)
            {
                while (ctTrans != null)
                {
                    if (ctMaster == ctTrans)//account nums match
                    {
                        ctMaster += ctTrans;
                    }
                    //don't read a trans record, wait for next master record
                    else if (ctMaster < ctTrans)
                    {
                        break;
                    }
                    //input appearing in the transaction file which doesn't have a corresponding account
                    else if (ctMaster > ctTrans)
                    {
                        Console.WriteLine("Transaction with no corresponding account line "
                                          + this.LineNum + " account number " + ctTrans.acctNum);
                    }

                    ReadTransFileRecord(ref ctTrans);
                }//end loop

                //write the new record
                writer.Write(ctMaster.acctNum);
                writer.Write(ctMaster.ctBal);
                writer.Write(ctMaster.name);

                ReadMasterFileRecord(ref ctMaster);
            }//end loop

            //could be mulitple unmatched transactions at the end of the list
            while (ctTrans != null)
            {
                Console.WriteLine("Transaction with no corresponding account line "
                                  + this.LineNum + " account number " + ctTrans.acctNum);
                ReadTransFileRecord(ref ctTrans);
            }

            writer.Flush();
            writer.Close();
            Console.WriteLine("The master file has been updated... ");
        } //end method
コード例 #2
0
        }//end method

        public override void ReadMasterFileRecord(ref MasterRecord ctMaster)
        {
            try {
                String   line = masterRecords.ReadLine();
                String[] toks = line.Split(' ');

                int offset = toks[0].Length + toks[1].Length + 1;

                ctMaster.acctNum = Convert.ToInt32(toks[0]);
                ctMaster.ctBal   = Convert.ToDecimal(toks[1]);
                ctMaster.name    = line.Substring(offset, line.Length - offset);
            }
            catch (ArgumentException) {
                ctMaster = null;
            }
            catch (NullReferenceException) {
                ctMaster = null;
            }
        }//end method
コード例 #3
0
        public override void ReadMasterFileRecord(ref MasterRecord ctMaster)
        {
            try {
                ctMaster.acctNum = masterRecords.ReadInt32();
                ctMaster.ctBal   = masterRecords.ReadDecimal();

                //apparently strings are prefixed with their length
                ctMaster.name = masterRecords.ReadString();

                this.LineNum++;
            }
            catch (ArgumentException) {
                ctMaster = null;
            }
            catch (NullReferenceException) {
                ctMaster = null;
            }
            catch (EndOfStreamException) {
                ctMaster = null;
            }
        }//end method
コード例 #4
0
        public override void ProcessFile()
        {
            ReadMasterFileRecord(ref ctMaster);
            ReadTransFileRecord(ref ctTrans);

            while (ctMaster != null) {
                while (ctTrans != null) {
                    if (ctMaster == ctTrans)//account nums match
                        ctMaster += ctTrans;
                    //don't read a trans record, wait for next master record
                    else if (ctMaster < ctTrans)
                        break;
                    //input appearing in the transaction file which doesn't have a corresponding account
                    else if (ctMaster > ctTrans) {
                        Console.WriteLine("Transaction with no corresponding account line "
                            + this.LineNum + " account number " + ctTrans.acctNum);
                    }

                    ReadTransFileRecord(ref ctTrans);
                }//end loop

                //write the new record
                writer.Write(ctMaster.acctNum);
                writer.Write(ctMaster.ctBal);
                writer.Write(ctMaster.name);

                ReadMasterFileRecord(ref ctMaster);
            }//end loop

            //could be mulitple unmatched transactions at the end of the list
            while (ctTrans != null) {
                Console.WriteLine("Transaction with no corresponding account line "
                    + this.LineNum + " account number " + ctTrans.acctNum);
                ReadTransFileRecord(ref ctTrans);
            }

            writer.Flush();
            writer.Close();
            Console.WriteLine("The master file has been updated... ");
        }
コード例 #5
0
        public override void ReadMasterFileRecord(ref MasterRecord ctMaster)
        {
            try {
                String line = masterRecords.ReadLine();
                String[] toks = line.Split(' ');

                int offset = toks[0].Length + toks[1].Length + 1;

                ctMaster.acctNum = Convert.ToInt32(toks[0]);
                ctMaster.ctBal = Convert.ToDecimal(toks[1]);
                ctMaster.name = line.Substring(offset, line.Length - offset);
            }
            catch (ArgumentException) {
                ctMaster = null;
            }
            catch(NullReferenceException){
                ctMaster = null;
            }
        }
コード例 #6
0
 //Reads one master file record from the old master file
 public abstract void ReadMasterFileRecord(ref MasterRecord ctMaster);
コード例 #7
0
 //Reads one master file record from the old master file
 public abstract void ReadMasterFileRecord(ref MasterRecord ctMaster);
コード例 #8
0
        public override void ReadMasterFileRecord(ref MasterRecord ctMaster)
        {
            try {
                ctMaster.acctNum = masterRecords.ReadInt32();
                ctMaster.ctBal = masterRecords.ReadDecimal();

                //apparently strings are prefixed with their length
                ctMaster.name = masterRecords.ReadString();

                this.LineNum++;
            }
            catch (ArgumentException) {
                ctMaster = null;
            }
            catch (NullReferenceException) {
                ctMaster = null;
            }
            catch (EndOfStreamException) {
                ctMaster = null;
            }
        }