예제 #1
0
		public void SetTransactions(db DBConnection, string commandValue)
		{
            DBConnection.ExecuteQuery(commandValue);
            
            while (DBConnection.QueryStep())
            {
                addedTrans = new Transaction();
                addedTrans.date = DBConnection.QueryReturnInt(0);
                addedTrans.type = DBConnection.QueryReturnInt(2);
                addedTrans.amount = DBConnection.QueryReturnFloat(3);
                addedTrans.verified = DBConnection.QueryReturnBool(4);
                addedTrans.description = DBConnection.QueryReturnString(1);
                //dbListNum = System.Convert.ToInt32(reader[5]);
                dbTransList.Add(DBConnection.QueryReturnInt(5),addedTrans);
                dbListNum++;
            }
		}
예제 #2
0
        void ReadInitFiles(int monthVal, bool onStart)
        {
           
            #region AccountTransactionDB
            //Get Account Transaction Info from database
            //SQLiteConnection connector = new SQLiteConnection(dbPath);
            //connector.Open();
            //SQLiteCommand mycommand = new SQLiteCommand(connector);

            string commandValue = "SELECT date,description,category,amount,cleared,id FROM Transactions WHERE Month=";
            commandValue += monthVal;
            
            DBConnection.ExecuteQuery(commandValue);
            
            while (DBConnection.QueryStep())
            {
                addedTrans = new Transaction();
                addedTrans.date = DBConnection.QueryReturnInt(0);
                addedTrans.type = DBConnection.QueryReturnInt(2);
                addedTrans.amount = DBConnection.QueryReturnFloat(3);
                addedTrans.verified = DBConnection.QueryReturnBool(4);
                addedTrans.description = DBConnection.QueryReturnString(1);
                //dbListNum = System.Convert.ToInt32(reader[5]);
                dbTransList.Add(DBConnection.QueryReturnInt(5),addedTrans);
                dbListNum++;
            }
            //reader.Close();
            if (dbListNum == 0)
            {
                numTransactions = 1;
            }
            else
            {
                numTransactions = dbListNum+1;
            }
            #endregion
            
            #region AmazonTransactionDB
            //Get Amazon Account Transaction Info from database
            commandValue = "";
            commandValue = "SELECT * FROM AmazonTransactions WHERE Month=";
            commandValue += monthVal;
            commandValue += " ORDER BY ID";

            AmazonTransaction amazonTrans;
            DBConnection.ExecuteQuery(commandValue);
            
            while (DBConnection.QueryStep())
            {
                amazonTrans = new AmazonTransaction();
                amazonTrans.type = DBConnection.QueryReturnInt(0);
                amazonTrans.description = DBConnection.QueryReturnString(1);
                amazonTrans.amount = DBConnection.QueryReturnFloat(2);
                amazonTransList.Add(DBConnection.QueryReturnInt(4),amazonTrans);
                amazonListNum++;
            }

            aMnumTransactions = amazonListNum+1;
            
            //Get the monthly start amount
            commandValue = "SELECT * FROM StartAmount WHERE Month=";
            commandValue += monthVal;
            commandValue += " AND TransactionType=0";

            DBConnection.ExecuteQuery(commandValue);
            
            while (DBConnection.QueryStep())
            {
                previousAmount = DBConnection.QueryReturnFloat(1);
            }
            previousTotalTextBox.Text = previousAmount.ToString("0.00");
            #endregion

            #region CarOil
            commandValue = "SELECT Mileage FROM CarOil WHERE Car='Alan'";
            
            
            try
            {
				DBConnection.ExecuteQuery(commandValue);

                while (DBConnection.QueryStep())
                {
                    alanCarOilText.Text = DBConnection.QueryReturnString(0);
                }
            }
            catch (System.Data.SQLite.SQLiteException)
            {
                Console.WriteLine("Table Not Found\n");
            }
            
            commandValue = "SELECT Mileage FROM CarOil WHERE Car='Katie'";
            
            try
            {
				DBConnection.ExecuteQuery(commandValue);

                while (DBConnection.QueryStep())
                {
                     katieCarOilText.Text =  DBConnection.QueryReturnString(0);               	
                }       
            }
            catch (System.Data.SQLite.SQLiteException)
            {
                Console.WriteLine("Table Not Found\n");
            }
            #endregion

        }
예제 #3
0
		void AddTransactionValues(bool firstEntry)
		{
            int dateVal = 0;
            float amountVal = 0.0f;
            string tempTransaction = transactionTextBox[numTransactions-1].Text;
            string tempBudgetText =  budgetCombo[numTransactions-1].Text;
            float tempVal = 0.0f;
            tempVal = System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
            //int selectedIndex = budgetCombo[numTransactions-1].SelectedIndex;
            dateVal = System.Convert.ToInt32(dateTextBox[numTransactions-1].Text);
            amountVal = System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
            if (dateVal != 0 && amountVal != 0.0 && tempTransaction != "")
            {
            	string command;
            	if (firstEntry)
            	{
                    command = DBConnection.BuildInsertQuery("First",
                                              dateTextBox[numTransactions-1].Text,
                                              tempTransaction,
                                              BudgetInfo.GetBudgetIndexString(budgetCombo[numTransactions-1].Text),
                                              amountTextBox[numTransactions-1].Text,
                                              System.Convert.ToInt32(clearedCB[numTransactions-1].Checked).ToString(),
                                              currentMonth.ToString());            	
            	}
            	else
            	{
                    command = DBConnection.BuildInsertQuery("Transactions",
                                              dateTextBox[numTransactions-1].Text,
                                              tempTransaction,
                                              BudgetInfo.GetBudgetIndexString(budgetCombo[numTransactions-1].Text),
                                              amountTextBox[numTransactions-1].Text,
                                              System.Convert.ToInt32(clearedCB[numTransactions-1].Checked).ToString(),
                                              currentMonth.ToString());
            	}
				DBConnection.DBUpdate(command);

                command = "SELECT last_insert_rowid()";
                int rowID = 0;
                rowID = System.Convert.ToInt32(DBConnection.ReturnTotals(command));

                //Add a new item to the Transaction List
                Transaction newTrans = new Transaction();
                newTrans.date = System.Convert.ToInt32(dateTextBox[numTransactions-1].Text);
                newTrans.type = BudgetInfo.GetBudgetIndex(budgetCombo[numTransactions-1].Text);
                newTrans.description = transactionTextBox[numTransactions-1].Text;
                newTrans.amount = System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
                newTrans.verified = clearedCB[numTransactions-1].Checked;
                dbTransList.Add(rowID, newTrans);
                //dbListNum++;

                //Then increment the transactions
                AddMainTransactions(numTransactions);
                numTransactions++;
                //Then reorder transactions by date
                ReorderTransactions();
            }
            else
            {
                if (dateVal == 0)
                {
                    MessageBox.Show("Date is not Valid:  Please Enter a Valid Date");
                }
                else if (amountVal == 0.0)
                {
                    MessageBox.Show("Amount is not Valid:  Please Enter a Valid Amount");                        
                }
                else
                {
                    MessageBox.Show("Description is not Valid:  Please Enter a Valid Description");                        
                }
            }
		}
예제 #4
0
        void amountBoxChanged(object sender, System.EventArgs e)
        {
            System.Windows.Forms.TextBox changedBox = new System.Windows.Forms.TextBox();

            changedBox = (System.Windows.Forms.TextBox)sender;
            int tempInt = System.Convert.ToInt32(changedBox.Tag);
            int keyListNum = System.Convert.ToInt32(listNumTextBox[tempInt].Text);
            
            Transaction newTrans = new Transaction();
            if (dbTransList.ContainsKey(keyListNum))
            {
                newTrans = dbTransList[keyListNum];
                
                if (newTrans.amount != System.Convert.ToSingle(changedBox.Text))
                {
            
                    dbTransList.Remove(keyListNum);
                    newTrans.date = System.Convert.ToInt32(dateTextBox[tempInt].Text);
                    newTrans.type = budgetCombo[tempInt].SelectedIndex;
                    newTrans.description = transactionTextBox[tempInt].Text;
                    newTrans.amount = System.Convert.ToSingle(amountTextBox[tempInt].Text);
                    newTrans.verified = clearedCB[tempInt].Checked;
                    dbTransList.Add(keyListNum,newTrans);  
                                
                    string command = "UPDATE Transactions SET Amount=";
                    command += amountTextBox[tempInt].Text;
                    command += " WHERE ID=";
                    command += keyListNum.ToString();
                    DBConnection.DBUpdate(command);
                    ReorderTransactions();
                }
            }
                
        }
예제 #5
0
        void ReorderTransactions()
        {
            int transCounter = 0;
            int dateCounter = 1;
            while (transCounter < numTransactions)
            {
                foreach (KeyValuePair<int,Transaction> pair in dbTransList)
                {
                    Transaction tempTransaction = new Transaction();
                    tempTransaction = (Transaction)pair.Value;
                    int tempDate = tempTransaction.date;
                    if (tempTransaction.date == dateCounter)
                    {
                        //float tempValue = previousInfo[i,0];
                        listNumTextBox[transCounter].Text = pair.Key.ToString();
                        listNumTextBox[transCounter].Tag = transCounter;
                        dateTextBox[transCounter].Text = tempTransaction.date.ToString();//previousInfo[i,0].ToString();
                        dateTextBox[transCounter].Tag = transCounter;
                        int tempValue = 0;
                        foreach (string value in budgetItemList)//int i = 0; i < BudgetInfo.numBudget; i++)
                        {
                        	if (BudgetInfo.budgetCategories[tempTransaction.type] == value)//budgetItem[i])
                        	{

                        		break;
                        	}
                        	tempValue++;
                        }
                        budgetCombo[transCounter].SelectedIndex = tempValue;//GetBudgetIndex(tempTransaction.type);//tempValue;//tempTransaction.type;//System.Convert.ToInt32(tempValue);
                        budgetCombo[transCounter].Tag = transCounter;
                        transactionTextBox[transCounter].Text = tempTransaction.description;//previousInfoText[i];
                        transactionTextBox[transCounter].Tag = transCounter;
                        amountTextBox[transCounter].Text = tempTransaction.amount.ToString("0.00");//previousInfo[i,2].ToString("0.00");
                        amountTextBox[transCounter].Tag = transCounter;
                        clearedCB[transCounter].Checked = tempTransaction.verified;//System.Convert.ToBoolean(previousInfo[i,3]);                        
                        clearedCB[transCounter].Tag = transCounter;
                        transCounter++;
                    }
                }
                dateCounter++;
                if (dateCounter > 40)
                {
                    transCounter = numTransactions+1;
                }
            }
            transCounter = 0;
            /*while (transCounter < aMnumTransactions-1)
            {
                foreach (KeyValuePair<int,AmazonTransaction> pair in amazonTransList)
                {
                    AmazonTransaction tempTransaction = new AmazonTransaction();
                    tempTransaction = (AmazonTransaction)pair.Value;
                    aMkeyListNumText[transCounter].Text = pair.Key.ToString();
                    aMkeyListNumText[transCounter].Tag = transCounter;
                    int tempValue = 0;
                    foreach (string value in budgetItemList)// (int i = 0; i < BudgetInfo.numBudget; i++)
                    {
                    	if (BudgetInfo.budgetCategories[tempTransaction.type] == value)//budgetItem[i])
                    	{
                    		//tempValue = i;
                    		//i = BudgetInfo.numBudget;
                    		break;
                    	}
                    	tempValue++;
                    }
                     aMbudgetCombo[transCounter].SelectedIndex = tempValue;//tempTransaction.type;//System.Convert.ToInt32(tempValue);
                    aMbudgetCombo[transCounter].Tag = transCounter;
                    aMtransactionTextBox[transCounter].Text = tempTransaction.description;//previousInfoText[i];
                    aMtransactionTextBox[transCounter].Tag = transCounter;
                    aMamountTextBox[transCounter].Text = tempTransaction.amount.ToString("0.00");//previousInfo[i,2].ToString("0.00");
                    aMamountTextBox[transCounter].Tag = transCounter;
                    transCounter++;
                }
            }*/
            //calculationTimer.Enabled = true;
        }
예제 #6
0
        void ReadInitFiles(int monthVal, bool onStart)
        {
           
            #region AccountTransactionDB
            //Get Account Transaction Info from database
            SQLiteConnection connector = new SQLiteConnection(dbPath);
            connector.Open();
            SQLiteCommand mycommand = new SQLiteCommand(connector);

            string commandValue = "SELECT * FROM Transactions WHERE Month=";
            commandValue += monthVal;
            
            mycommand.CommandText = commandValue;
            
            SQLiteDataReader reader = mycommand.ExecuteReader();
            while (reader.Read())
            {
                addedTrans = new Transaction();
                addedTrans.date = System.Convert.ToInt32(reader[0]);
                addedTrans.type = System.Convert.ToInt32(reader[2]);
                addedTrans.amount = System.Convert.ToSingle(reader[3]);
                addedTrans.verified = System.Convert.ToBoolean(reader[4]);
                addedTrans.description = reader[1].ToString();
                //dbListNum = System.Convert.ToInt32(reader[5]);
                dbTransList.Add(System.Convert.ToInt32(reader[6]),addedTrans);
                dbListNum++;
            }
            reader.Close();
            if (dbListNum == 0)
            {
                numTransactions = 1;
            }
            else
            {
                numTransactions = dbListNum+1;
            }
            #endregion
            
            #region AmazonTransactionDB
            //Get Amazon Account Transaction Info from database
            commandValue = "";
            commandValue = "SELECT * FROM AmazonTransactions WHERE Month=";
            commandValue += monthVal;

            mycommand.CommandText = commandValue;
            
            reader = mycommand.ExecuteReader();
            AmazonTransaction amazonTrans;
            while (reader.Read())
            {
                amazonTrans = new AmazonTransaction();
                amazonTrans.type = System.Convert.ToInt32(reader[0]);
                amazonTrans.description = reader[1].ToString();
                amazonTrans.amount = System.Convert.ToSingle(reader[2]);
                amazonTransList.Add(System.Convert.ToInt32(reader[4]),amazonTrans);
                amazonListNum++;
            }
            reader.Close();

            aMnumTransactions = amazonListNum+1;
            
            //Get the monthly start amount
            commandValue = "SELECT * FROM StartAmount WHERE Month=";
            commandValue += monthVal;
            commandValue += " AND TransactionType=0";
            
            mycommand.CommandText = commandValue;
            
            reader = mycommand.ExecuteReader();
            while (reader.Read())
            {
                previousAmount = System.Convert.ToSingle(reader[1]);
            }
            previousTotalTextBox.Text = previousAmount.ToString("0.00");
            reader.Close();
            #endregion

            //Only add the savings transactions on startup
            #region SavingsInformation
            if (onStart)
            {
                #region MainSavingsDB
                //Get the Start amount for the savings accounts from database
                //Get the monthly start amount
                int savingsIndexerValue = 0;
                for (int i = 0; i < 7; i++)
                {
                    savingsIndexerValue = i + 1;
                    commandValue = "SELECT * FROM StartAmount WHERE Month=0";
                    commandValue += " AND TransactionType=";
                    commandValue += savingsIndexerValue.ToString();
    
                    mycommand.CommandText = commandValue;
    
                    reader = mycommand.ExecuteReader();
                    while (reader.Read())
                    {
                        MainSavingsInfo[i].StartAmount = System.Convert.ToSingle(reader[1]);
                        SavingsStartBox[i].Text = MainSavingsInfo[i].StartAmount.ToString("0.00");
                    }
                    reader.Close();
                }
    
    
                for (int i = 0; i < 7; i++)
                {
                    commandValue = "SELECT * FROM SavingsTransactions WHERE Type=";
                    commandValue += i.ToString();
                    mycommand.CommandText = commandValue;
    
                    reader = mycommand.ExecuteReader();
                    float tempTotalAmount = MainSavingsInfo[i].StartAmount;
                    while (reader.Read())
                    {
                        int savingsType = i;// System.Convert.ToInt32(reader[1]);
                        float tempAmount = System.Convert.ToSingle(reader[0]);
                        tempTotalAmount += tempAmount;
                        MainSavingsInfo[savingsType].AmountValue[MainSavingsInfo[savingsType].Transactions] = tempAmount;
                        MainSavingsInfo[savingsType].TotalValue[MainSavingsInfo[savingsType].Transactions] = tempTotalAmount;
                        MainSavingsInfo[savingsType].CurrentTotalAmount = MainSavingsInfo[savingsType].TotalValue[MainSavingsInfo[savingsType].Transactions];
                        AddSavingsTransaction(savingsType,
                                              MainSavingsInfo[savingsType].AmountValue[MainSavingsInfo[savingsType].Transactions],
                                              MainSavingsInfo[savingsType].TotalValue[MainSavingsInfo[savingsType].Transactions]);
                        MainSavingsInfo[savingsType].Transactions++;
                    }
                    reader.Close();
                }
                #endregion
                
                #region INGSavingsDB
                //Get the Start amount for the savings accounts from database
                //Get the monthly start amount
                savingsIndexerValue = 0;
                for (int i = 0; i < 3; i++)
                {
                    savingsIndexerValue = i + 8;
                    commandValue = "SELECT * FROM StartAmount WHERE Month=0";
                    commandValue += " AND TransactionType=";
                    commandValue += savingsIndexerValue.ToString();
                    mycommand.CommandText = commandValue;
    
                    reader = mycommand.ExecuteReader();
                    while (reader.Read())
                    {
                        INGSavingsInfo[i].StartAmount = System.Convert.ToSingle(reader[1]);
                        INGSavingsStartBox[i].Text = INGSavingsInfo[i].StartAmount.ToString("0.00");
                    }
                    reader.Close();
                }
    
    
                for (int i = 0; i < 3; i++)
                {
                    savingsIndexerValue = i+7;
                    commandValue = "SELECT * FROM SavingsTransactions WHERE Type=";
                    commandValue += savingsIndexerValue.ToString();
                    mycommand.CommandText = commandValue;
    
                    reader = mycommand.ExecuteReader();
                    float tempTotalAmount = INGSavingsInfo[i].StartAmount;
                    while (reader.Read())
                    {
                        int savingsType = i;// System.Convert.ToInt32(reader[1]);
                        float tempAmount = System.Convert.ToSingle(reader[0]);
                        tempTotalAmount += tempAmount;
                        INGSavingsInfo[savingsType].AmountValue[INGSavingsInfo[savingsType].Transactions] = tempAmount;
                        INGSavingsInfo[savingsType].TotalValue[INGSavingsInfo[savingsType].Transactions] = tempTotalAmount;
                        INGSavingsInfo[savingsType].CurrentTotalAmount = INGSavingsInfo[savingsType].TotalValue[INGSavingsInfo[savingsType].Transactions];
                        AddINGSavingsTransaction(savingsType,
                                              INGSavingsInfo[savingsType].AmountValue[INGSavingsInfo[savingsType].Transactions],
                                              INGSavingsInfo[savingsType].TotalValue[INGSavingsInfo[savingsType].Transactions]);
                        INGSavingsInfo[savingsType].Transactions++;
                        //AddINGSavingsTransaction(savingsType,INGSavingsInfo[savingsType].AmountValue[INGSavingsInfo[savingsType].Transactions],INGSavingsInfo[savingsType].TotalValue[INGSavingsInfo[savingsType].Transactions]);
    
                    }
                    reader.Close();
                }  
                #endregion            
            }
            #endregion
            #region CarOil
            commandValue = "SELECT Mileage FROM CarOil WHERE Car='Alan'";
            
            mycommand.CommandText = commandValue;
            
            reader = mycommand.ExecuteReader();
            while (reader.Read())
            {
                alanCarOilText.Text = reader[0].ToString();
            }
            reader.Close();
            
            commandValue = "SELECT Mileage FROM CarOil WHERE Car='Katie'";
            
            mycommand.CommandText = commandValue;
            
            reader = mycommand.ExecuteReader();
            while (reader.Read())
            {
                katieCarOilText.Text = reader[0].ToString();
            }
            reader.Close();
            #endregion
            connector.Close();

        }
예제 #7
0
     // Handle the KeyDown event to determine the type of character entered into the control.
     #region AddTransactions
     private void addButtonClick(object sender, System.EventArgs e)
     {
         int dateVal = 0;
         float amountVal = 0.0f;
         try
         {
             string tempTransaction = transactionTextBox[numTransactions-1].Text;
             float tempVal = 0.0f;
             tempVal = System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
             int selectedIndex = budgetCombo[numTransactions-1].SelectedIndex;
             dateVal = System.Convert.ToInt32(dateTextBox[numTransactions-1].Text);
             amountVal = System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
             if (dateVal != 0 && amountVal != 0.0 && tempTransaction != "")
             {
                 SQLiteConnection connector = new SQLiteConnection(dbPath);
                 connector.Open();
                 SQLiteCommand mycommand = new SQLiteCommand(connector);
                 string command = "INSERT INTO Transactions (Date,Description,Category,Amount,Cleared,Month) VALUES (";
                 command += dateTextBox[numTransactions-1].Text + ",'";
                 if (tempTransaction.Contains("'"))
                 {
                     tempTransaction = tempTransaction.Replace("'","''");// = Replace(lsLastName, "'", "''");
                 }
                 command += tempTransaction + "',";
                 command += budgetCombo[numTransactions-1].SelectedIndex.ToString() + ",";
                 command += amountTextBox[numTransactions-1].Text + ",";
                 command += System.Convert.ToInt32(clearedCB[numTransactions-1].Checked).ToString() + ",";
                 command += currentMonth.ToString() + ");";
                 mycommand.CommandText = command;
                 mycommand.ExecuteScalar();
                 command = "SELECT last_insert_rowid()";
                 mycommand.CommandText = command;
                 SQLiteDataReader reader = mycommand.ExecuteReader();
                 int rowID = 0;
                 while (reader.Read())
                 {
                     rowID = System.Convert.ToInt32(reader[0]);
                 }
                 connector.Close();
 
                 #region SavingsAccountStuff              
                 if (tempVal > 0.0 && selectedIndex < monthlySavingsIndex &&
                     selectedIndex != mtSavingsIndex &&
                     selectedIndex != itSavingsIndex &&
                     String.Compare(budgetCombo[numTransactions-1].Text,"Deposit") != 0)
                 {
                     Deduction getDeductionLocation = new Deduction();
                     getDeductionLocation.ShowDialog();
                     selectedIndex = getDeductionLocation.selectedValue;
                     if (selectedIndex == 0)
                     {
                         selectedIndex = ingSavingsIndex;
                     }
                     else if (selectedIndex == 1)
                     {
                         selectedIndex = mtSavingsIndex;
                     }
                     else if (selectedIndex == 2)
                     {
                         selectedIndex = itSavingsIndex;
                     }
                     else
                     {
                         selectedIndex += deductionOffset;                        
                     }
                 }
                 //AddToLayout(numTransactions);
                 string savingsDBString = "";
                 if (selectedIndex == citizensSavingsIndex || 
                     selectedIndex == miscSavingsIndex)
                 {
                     int indexer = 0;
                     if (selectedIndex == citizensSavingsIndex)
                     {
                         indexer = 0;//selectedIndex - 29;
                     }
                     else
                     {
                         indexer = 1;//selectedIndex - 29;
                     }
                     int tempInt = MainSavingsInfo[indexer].Transactions;
                     float tempFloat = -1.0f * tempVal;//System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
                     
                     MainSavingsInfo[indexer].AmountValue[tempInt] = tempFloat;
                     savingsDBString = "INSERT INTO SavingsTransactions (Amount,Type) VALUES (";
                     savingsDBString += tempFloat.ToString() + "," + indexer.ToString() + ")";
                     ExecuteQuery(savingsDBString);
                     if (tempInt == 0)
                     {
                         MainSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + MainSavingsInfo[indexer].StartAmount;
                     }
                     else
                     {
                         MainSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + MainSavingsInfo[indexer].TotalValue[(tempInt - 1)];
                     }
                     AddSavingsTransaction(indexer, MainSavingsInfo[indexer].AmountValue[tempInt], MainSavingsInfo[indexer].TotalValue[tempInt]);
                     MainSavingsInfo[indexer].Transactions++;
                 }
                 else if (selectedIndex == monthlySavingsIndex)
                 {
                     float tempFloat = -1.0f * tempVal;//tempVal.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
                     float[] tempAmount = {55.0f,80.00f,17.0f,70.0f,0.0f};
                     tempFloat -= tempAmount[0];
                     tempFloat -= tempAmount[1];
                     tempFloat -= tempAmount[2];
                     tempFloat -= tempAmount[3];
                     tempAmount[4] = tempFloat;
                     
                     //Add to the Citizens Tax Column
                     for (int i = 2; i < 7;i++)
                     {
                         savingsDBString = "INSERT INTO SavingsTransactions (Amount,Type) VALUES (";
                         savingsDBString += tempAmount[i-2].ToString() + "," + i.ToString() + ")";
                         ExecuteQuery(savingsDBString);
                         int tempInt = MainSavingsInfo[i].Transactions;
                         MainSavingsInfo[i].AmountValue[tempInt] = tempAmount[i-2];
                         if (tempInt == 0)
                         {
                             MainSavingsInfo[i].TotalValue[tempInt] = tempAmount[i-2] + MainSavingsInfo[i].StartAmount;
                         }
                         else
                         {
                             MainSavingsInfo[i].TotalValue[tempInt] = tempAmount[i-2] + MainSavingsInfo[i].TotalValue[(tempInt - 1)];
                         }
                         AddSavingsTransaction(i, MainSavingsInfo[i].AmountValue[tempInt], MainSavingsInfo[i].TotalValue[tempInt]);
                         MainSavingsInfo[i].Transactions++;
                     }
                 }
                 else if (selectedIndex >= fromTaxesSavingsIndex && 
                          selectedIndex <= fromHealthSavingsIndex)
                 {
                     int indexer = selectedIndex - otherCitizensOffsetIndex;
                     int tempInt = MainSavingsInfo[indexer].Transactions;
                     float tempFloat = -1.0f * tempVal;//System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
                     
                     //int dbIndex = indexer;
                     savingsDBString = "INSERT INTO SavingsTransactions (Amount,Type) VALUES (";
                     savingsDBString += tempFloat.ToString() + "," + indexer.ToString() + ")";
                     ExecuteQuery(savingsDBString);
                     
                     MainSavingsInfo[indexer].AmountValue[tempInt] = tempFloat;
                     if (tempInt == 0)
                     {
                         MainSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + MainSavingsInfo[indexer].StartAmount;
                     }
                     else
                     {
                         MainSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + MainSavingsInfo[indexer].TotalValue[(tempInt - 1)];                    
                     }
                     AddSavingsTransaction(indexer, MainSavingsInfo[indexer].AmountValue[tempInt], MainSavingsInfo[indexer].TotalValue[tempInt]);
                     MainSavingsInfo[indexer].Transactions++;
                 }
                 else if (selectedIndex == ingSavingsIndex)
                 {
                     int indexer = 0;//selectedIndex - otherCitizensOffsetIndex;
                     int tempInt = INGSavingsInfo[indexer].Transactions;
                     float tempFloat = -1.0f * tempVal;//System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
                     
                     int dbIndexer = 7;
                     savingsDBString = "INSERT INTO SavingsTransactions (Amount,Type) VALUES (";
                     savingsDBString += tempFloat.ToString() + "," + dbIndexer.ToString() + ")";
                     ExecuteQuery(savingsDBString);
 
                     INGSavingsInfo[indexer].AmountValue[tempInt] = tempFloat;
                     if (tempInt == 0)
                     {
                         INGSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + INGSavingsInfo[indexer].StartAmount;
                     }
                     else
                     {
                         INGSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + INGSavingsInfo[indexer].TotalValue[(tempInt - 1)];
                     }
                     AddINGSavingsTransaction(indexer, INGSavingsInfo[indexer].AmountValue[tempInt], INGSavingsInfo[indexer].TotalValue[tempInt]);
                     INGSavingsInfo[indexer].Transactions++;
                 }                
                 else if (selectedIndex == mtSavingsIndex)
                 {
                     int indexer = 1;//selectedIndex - otherCitizensOffsetIndex;
                     int tempInt = INGSavingsInfo[indexer].Transactions;
                     float tempFloat = -1.0f * tempVal;//System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
                     
                     int dbIndexer = 8;
                     savingsDBString = "INSERT INTO SavingsTransactions (Amount,Type) VALUES (";
                     savingsDBString += tempFloat.ToString() + "," + dbIndexer.ToString() + ")";
                     ExecuteQuery(savingsDBString);
 
                     INGSavingsInfo[indexer].AmountValue[tempInt] = tempFloat;
                     if (tempInt == 0)
                     {
                         INGSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + INGSavingsInfo[indexer].StartAmount;
                     }
                     else
                     {
                         INGSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + INGSavingsInfo[indexer].TotalValue[(tempInt - 1)];
                     }
                     AddINGSavingsTransaction(indexer, INGSavingsInfo[indexer].AmountValue[tempInt], INGSavingsInfo[indexer].TotalValue[tempInt]);
                     INGSavingsInfo[indexer].Transactions++;
                 }
                 else if (selectedIndex == itSavingsIndex)
                 {
                     int indexer = 2;//selectedIndex - otherCitizensOffsetIndex;
                     int tempInt = INGSavingsInfo[indexer].Transactions;
                     float tempFloat = -1.0f * tempVal;//System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
                     
                     int dbIndexer = 9;
                     savingsDBString = "INSERT INTO SavingsTransactions (Amount,Type) VALUES (";
                     savingsDBString += tempFloat.ToString() + "," + dbIndexer.ToString() + ")";
                     ExecuteQuery(savingsDBString);
 
                     INGSavingsInfo[indexer].AmountValue[tempInt] = tempFloat;
                     if (tempInt == 0)
                     {
                         INGSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + INGSavingsInfo[indexer].StartAmount;
                     }
                     else
                     {
                         INGSavingsInfo[indexer].TotalValue[tempInt] = tempFloat + INGSavingsInfo[indexer].TotalValue[(tempInt - 1)];
                     }
                     AddINGSavingsTransaction(indexer, INGSavingsInfo[indexer].AmountValue[tempInt], INGSavingsInfo[indexer].TotalValue[tempInt]);
                     INGSavingsInfo[indexer].Transactions++;
                 }
                 #endregion
 
                 //Add a new item to the Dictionary
                 Transaction newTrans = new Transaction();
                 newTrans.date = System.Convert.ToInt32(dateTextBox[numTransactions-1].Text);
                 newTrans.type = budgetCombo[numTransactions-1].SelectedIndex;
                 newTrans.description = transactionTextBox[numTransactions-1].Text;
                 newTrans.amount = System.Convert.ToSingle(amountTextBox[numTransactions-1].Text);
                 newTrans.verified = clearedCB[numTransactions-1].Checked;
                 dbTransList.Add(rowID, newTrans);
                 //dbListNum++;
 
                 //Then increment the transactions
                 AddToLayout(numTransactions);
                 numTransactions++;
                 //Then reorder transactions by date
                 ReorderTransactions();
             }
             else
             {
                 if (dateVal == 0)
                 {
                     MessageBox.Show("Date is not Valid:  Please Enter a Valid Date");
                 }
                 else if (amountVal == 0.0)
                 {
                     MessageBox.Show("Amount is not Valid:  Please Enter a Valid Amount");                        
                 }
                 else
                 {
                     MessageBox.Show("Description is not Valid:  Please Enter a Valid Description");                        
                 }
             }
         }
         catch (FormatException)
         {
             MessageBox.Show("Please Enter a Number");
         }
     }
예제 #8
0
        private void descriptionBoxChanged(object sender, System.EventArgs e)
        {
            System.Windows.Forms.TextBox changedBox = new System.Windows.Forms.TextBox();

            changedBox = (System.Windows.Forms.TextBox)sender;
            int tempInt = System.Convert.ToInt32(changedBox.Tag);
            int keyListNum = System.Convert.ToInt32(listNumTextBox[tempInt].Text);
            
            Transaction newTrans = new Transaction();
            if (dbTransList.ContainsKey(keyListNum))
            {
                newTrans = dbTransList[keyListNum];
                
                if (String.Compare(newTrans.description,changedBox.Text) != 0)
                {
            
                    dbTransList.Remove(keyListNum);
                    newTrans.date = System.Convert.ToInt32(dateTextBox[tempInt].Text);
                    newTrans.type = budgetCombo[tempInt].SelectedIndex;
                    newTrans.description = transactionTextBox[tempInt].Text;
                    newTrans.amount = System.Convert.ToSingle(amountTextBox[tempInt].Text);
                    newTrans.verified = clearedCB[tempInt].Checked;
                    dbTransList.Add(keyListNum,newTrans);  
                                
                    string command = "UPDATE Transactions SET Description='";
                    string tempTransaction = transactionTextBox[tempInt].Text;
                    if (tempTransaction.Contains("'"))
                    {
                        tempTransaction = tempTransaction.Replace("'","''");
                    }
                    command += tempTransaction;
                    command += "' WHERE ID=";
                    command += keyListNum.ToString();
                    ExecuteQuery(command);
                    ReorderTransactions();
                }
            }
                
        }
예제 #9
0
        private void verifiedCBChanged(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            System.Windows.Forms.CheckBox sentBox = new System.Windows.Forms.CheckBox();

            sentBox = (System.Windows.Forms.CheckBox)sender;
            int tempInt = System.Convert.ToInt32(sentBox.Tag);
            int keyListNum = System.Convert.ToInt32(listNumTextBox[tempInt].Text);
            
            Transaction newTrans = new Transaction();
            if (dbTransList.ContainsKey(keyListNum))
            {
                dbTransList.Remove(keyListNum);
                newTrans.date = System.Convert.ToInt32(dateTextBox[tempInt].Text);
                newTrans.type = budgetCombo[tempInt].SelectedIndex;
                newTrans.description = transactionTextBox[tempInt].Text;
                newTrans.amount = System.Convert.ToSingle(amountTextBox[tempInt].Text);
                newTrans.verified = clearedCB[tempInt].Checked;
                dbTransList.Add(keyListNum,newTrans);  
                            
                string command = "UPDATE Transactions SET Cleared=";
                command += System.Convert.ToInt32(clearedCB[tempInt].Checked).ToString();
                command += " WHERE ID=";
                command += keyListNum.ToString();
                ExecuteQuery(command);
            }
        }
예제 #10
0
		void ReorderTransactions()
		{
            calculationTimer.Enabled = false;

            int transCounter = 0;
            int dateCounter = 1;
            while (transCounter < numTransactions)
            {
                foreach (KeyValuePair<int,Transaction> pair in dbTransList)
                {
                    Transaction tempTransaction = new Transaction();
                    tempTransaction = (Transaction)pair.Value;
                    int tempDate = tempTransaction.date;
                    if (tempTransaction.date == dateCounter)
                    {
                        //float tempValue = previousInfo[i,0];
                        listNumTextBox[transCounter].Text = pair.Key.ToString();
                        listNumTextBox[transCounter].Tag = transCounter;
                        dateTextBox[transCounter].Text = tempTransaction.date.ToString();//previousInfo[i,0].ToString();
                        dateTextBox[transCounter].Tag = transCounter;
                        //tempValue = previousInfo[i,1];
                        budgetCombo[transCounter].SelectedIndex = tempTransaction.type;//System.Convert.ToInt32(tempValue);
                        budgetCombo[transCounter].Tag = transCounter;
                        transactionTextBox[transCounter].Text = tempTransaction.description;//previousInfoText[i];
                        transactionTextBox[transCounter].Tag = transCounter;
                        //tempValue = previousInfo[i,2];
                        amountTextBox[transCounter].Text = tempTransaction.amount.ToString("0.00");//previousInfo[i,2].ToString("0.00");
                        amountTextBox[transCounter].Tag = transCounter;
                        clearedCB[transCounter].Checked = tempTransaction.verified;//System.Convert.ToBoolean(previousInfo[i,3]);                        
                        clearedCB[transCounter].Tag = transCounter;
                        transCounter++;
                    }
                }
                dateCounter++;
                if (dateCounter > 40)
                {
                    transCounter = numTransactions+1;
                }
            }
            transCounter = 0;
            while (transCounter < aMnumTransactions-1)
            {
                foreach (KeyValuePair<int,AmazonTransaction> pair in amazonTransList)
                {
                    AmazonTransaction tempTransaction = new AmazonTransaction();
                    tempTransaction = (AmazonTransaction)pair.Value;
                    aMkeyListNumText[transCounter].Text = pair.Key.ToString();
                    aMkeyListNumText[transCounter].Tag = transCounter;
                    aMbudgetCombo[transCounter].SelectedIndex = tempTransaction.type;//System.Convert.ToInt32(tempValue);
                    aMbudgetCombo[transCounter].Tag = transCounter;
                    aMtransactionTextBox[transCounter].Text = tempTransaction.description;//previousInfoText[i];
                    aMtransactionTextBox[transCounter].Tag = transCounter;
                    aMamountTextBox[transCounter].Text = tempTransaction.amount.ToString("0.00");//previousInfo[i,2].ToString("0.00");
                    aMamountTextBox[transCounter].Tag = transCounter;
                    transCounter++;
                }
            }
            calculationTimer.Enabled = true;
		}