Пример #1
0
        /// <summary>
        /// Commits the changes in the given row to the database.
        /// </summary>
        /// <param name="ofxRow">Any tables row.</param>
        public void saveRow(DataRow row)
        {
            if (row.Table == this.Account)
            {
                accountTA.Update(row);
            }

            else if (row.Table == this.AccountType)
            {
                accountTypeTA.Update(row);
            }

            else if (row.Table == this.Bank)
            {
                bankTA.Update(row);
            }

            else if (row.Table == this.BankInfo)
            {
                bankInfoTA.Update(row);
            }

            else if (row.Table == this.Bills)
            {
                billsTA.Update(row);
            }

            else if (row.Table == this.Envelope)
            {
                envelopeTA.Update(row);
            }

            else if (row.Table == this.EnvelopeGroup)
            {
                envelopeGroupTA.Update(row);
            }

            else if (row.Table == this.EnvelopeLine)
            {
                envelopeLineTA.Update(row);
            }

            else if (row.Table == this.FitLine)
            {
                fitLineTA.Update(row);
            }

            else if (row.Table == this.LineItem)
            {
                lineItemTA.Update(row);
            }

            else if (row.Table == this.LineType)
            {
                lineTypeTA.Update(row);
            }

            else if (row.Table == this.OFXFiles)
            {
                ofxFilesTA.Update(row);
            }

            else if (row.Table == this.Settings)
            {
                settingsTA.Update(row);
            }

            else if (row.Table == this.Transaction)
            {
                transactionTA.Update(row);
            }

            else
            {
                throw new Exception("Unknown Table");
            }
        }
Пример #2
0
        public void stressFillDataBase()
        {
            stressDS = new StressDataSet();
            rnd      = new Random();

            accountTypeTA = new AccountTypeTableAdapter();
            lineTypeTA    = new LineTypeTableAdapter();
            envGroupTA    = new EnvelopeGroupTableAdapter();
            accountTA     = new AccountTableAdapter();
            envelopeTA    = new EnvelopeTableAdapter();
            lineTA        = new LineItemTableAdapter();
            envLineTA     = new EnvelopeLineTableAdapter();

            // Reset the database
            DBquery.dropTables();
            DBquery.buildTables();

            // Fill the data tables
            accountTypeTA.Fill(stressDS.AccountType);
            lineTypeTA.Fill(stressDS.LineType);
            envGroupTA.Fill(stressDS.EnvelopeGroup);
            accountTA.Fill(stressDS.Account);
            envelopeTA.Fill(stressDS.Envelope);
            lineTA.Fill(stressDS.LineItem);
            envLineTA.Fill(stressDS.EnvelopeLine);

            accountID  = DBquery.getNewID("id", "Account");
            aTypeID    = DBquery.getNewID("id", "AccountType");
            envelopeID = DBquery.getNewID("id", "Envelope");
            eGroupID   = DBquery.getNewID("id", "EnvelopeGroup");
            eLineID    = DBquery.getNewID("id", "EnvelopeLine");
            lTypeID    = DBquery.getNewID("id", "LineType");

            lineID  = DBquery.getNewID("id", "LineItem");
            transID = DBquery.getNewID("transactionID", "LineItem");
            date    = DateTime.Now.AddMonths(-12 * 100).Date;

            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();
            addAccount();

            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();
            addEnvelope();

            int num;

            // Make alot of entries
            while (date < DateTime.Now.AddMonths(3).Date)
            {
                num = rnd.Next(0, 10000);

                if (num == 0)
                {
                    addAccountType();
                }
                else if (num == 1)
                {
                    addLineType();
                }
                else if (num == 2)
                {
                    addEnvelopeGroup();
                }

                if (10 < num && num < 15)
                {
                    addAccount();
                }

                if (30 < num && num < 34)
                {
                    addEnvelope();
                }


                if (100 < num && num < 200)
                {
                    complexTrans();
                }
                else
                {
                    simpleTrans();
                }
            }

            // Save the data
            accountTypeTA.Update(stressDS.AccountType);
            lineTypeTA.Update(stressDS.LineType);
            envGroupTA.Update(stressDS.EnvelopeGroup);
            accountTA.Update(stressDS.Account);
            envelopeTA.Update(stressDS.Envelope);
            lineTA.Update(stressDS.LineItem);
            envLineTA.Update(stressDS.EnvelopeLine);
        }