private static void AddDefaultExpenseTypes(int userID)
 {
     if (DBMethods.GetAccountType(userID) == "Corporate")
     {
         DBMethods.AddExpenseTypetoCategory("User1", userID, "Salaries");
         DBMethods.AddExpenseTypetoCategory("User2", userID, "Salaries");
         DBMethods.AddExpenseTypetoCategory("Flour", userID, "Raw Materials");
         DBMethods.AddExpenseTypetoCategory("Sugar", userID, "Raw Materials");
         DBMethods.AddExpenseTypetoCategory("Cacao", userID, "Raw Materials");
         DBMethods.AddExpenseTypetoCategory("Flour", userID, "Raw Materials");
         DBMethods.AddExpenseTypetoCategory("KDV", userID, "Taxes");
         DBMethods.AddExpenseTypetoCategory("OTV", userID, "Taxes");
         DBMethods.AddExpenseTypetoCategory("TV Ads", userID, "Marketing");
         DBMethods.AddExpenseTypetoCategory("Internet Ads", userID, "Marketing");
         DBMethods.AddExpenseTypetoCategory("Street Posters", userID, "Marketing");
     }
     else
     {
         DBMethods.AddExpenseType("Shopping", userID);
         DBMethods.AddExpenseType("Food", userID);
         DBMethods.AddExpenseType("Transport", userID);
         DBMethods.AddExpenseType("Electric", userID);
         DBMethods.AddExpenseType("Gas", userID);
         DBMethods.AddExpenseType("Home", userID);
         DBMethods.AddExpenseType("Entertainment", userID);
         DBMethods.AddExpenseType("Water", userID);
         DBMethods.AddExpenseType("Health", userID);
         DBMethods.AddExpenseType("Beauty", userID);
         DBMethods.AddExpenseType("Gift", userID);
     }
 }
Esempio n. 2
0
        private void TryLogin()
        {
            int login  = DBMethods.TryLogin(txtUser.Text, txtPass.Text);
            int userID = DBMethods.GetUserID(txtUser.Text);

            if (login == 0) //login failed
            {
                MessageBox.Show("Wrong username or password");
            }
            else //login successful
            {
                this.Hide();
                if (login == 3) //corporate
                {
                    FormMainCorporate f = new FormMainCorporate(userID, _DomainController);
                    f.Show();
                }
                else //not corporate
                {
                    FormMain formMain = new FormMain(userID, _DomainController);
                    formMain.Show();
                    if (login == 1) //admin
                    {
                        FormAdmin formAdmin = new FormAdmin(_DomainController, formMain);
                        formAdmin.Show();
                    }
                }
            }
        }
Esempio n. 3
0
 public FormMain(int userID, DomainController domainController)
 {
     this._DomainController = domainController;
     this.UserID            = userID;
     InitializeComponent();
     InitializeUI();
     lblUsername.Text = DBMethods.GetUser(userID).UserName;
 }
 public FormMainCorporate(int userID, DomainController domainController)
 {
     this._DomainController = domainController;
     this.UserID            = userID;
     InitializeComponent();
     InitializeUI();
     lblUsername.Text = DBMethods.GetUser(userID).UserName;
     listBoxEmployees.SelectedIndex = -1;
 }
        /// <summary>
        /// Add expense types radio buttons of given category
        /// </summary>
        /// <param name="eCat"></param>
        public void AddExpenseTypeControls(string eCat)
        {
            List <string> ExpenseTypes = DBMethods.GetExpenseTypesOfCat(eCat, UserID);

            foreach (string e in ExpenseTypes)
            {
                AddExpenseTypeRadiotoUI(e);
            }
        }
        /// <summary>
        /// Adds Income Radio Buttons to UI
        /// </summary>
        public void AddIncomeControls()
        {
            List <string> Cats = DBMethods.GetIncomeCats(UserID);

            foreach (string c in Cats)
            {
                AddIncomeCatRadiotoUI(c);
            }
        }
        /// <summary>
        /// Add income types radio buttons of given category
        /// </summary>
        /// <param name="iCat"></param>
        public void AddIncomeTypeControls(string iCat)
        {
            List <string> IncomeTypes = DBMethods.GetIncomeTypesOfCat(iCat, UserID);

            foreach (string i in IncomeTypes)
            {
                AddIncomeTypeRadiotoUI(i);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Adds Expense Radio Buttons to UI
        /// </summary>
        public void AddExpenseControls()
        {
            List <string> ExpenseTypes = DBMethods.GetExpenseTypeNames(UserID);

            foreach (string e in ExpenseTypes)
            {
                AddExpenseTypeRadiotoUI(e);
            }
        }
Esempio n. 9
0
        /// <summary>
        /// Adds Income Radio Buttons to UI
        /// </summary>
        public void AddIncomeControls()
        {
            List <string> IncomeTypes = DBMethods.GetIncomeTypeNames(UserID);

            foreach (string i in IncomeTypes)
            {
                AddIncomeTypeRadiotoUI(i);
            }
        }
Esempio n. 10
0
        private void BtnDeleteIncome_Click(object sender, EventArgs e)
        {
            int id = (int)dataGridIncomes.SelectedRows[0].Cells["IncomeID"].Value;

            DBMethods.DeleteIncome(id);
            UpdateDataGrids();
            _MainUI.UpdateBalance();
            _MainUI.UpdateCharts();
        }
        public void UpdateCharts()
        {
            Dictionary <String, decimal> ExpenseDict = DBMethods.GetExpenseData(UserID);

            chartExpenses.Series["ExpenseData"].Points.DataBindXY(ExpenseDict.Keys, ExpenseDict.Values);

            Dictionary <String, decimal> CategoryDict = DBMethods.GetCategoryExpenseDictionary(UserID);

            chartCategoryExpenses.Series["ExpenseData"].Points.DataBindXY(CategoryDict.Keys, CategoryDict.Values);
        }
Esempio n. 12
0
        /// <summary>
        /// Method to use for clicking enter or add button
        /// </summary>
        private void AddIncomeOrExpense()
        {
            RadioButton selectedExp = flowLayoutExpenses.Controls.OfType <RadioButton>()
                                      .FirstOrDefault(r => r.Checked);

            RadioButton selectedInc = flowLayoutIncomes.Controls.OfType <RadioButton>()
                                      .FirstOrDefault(r => r.Checked);

            if (selectedExp == null && selectedInc == null)
            {
                MessageBox.Show("Please select a type");
                return;
            }

            int recur = (int)numRecur.Value;

            if (recur > 1 && comboBoxRecur.Text == "")
            {
                MessageBox.Show("Please select recurring interval");
                return;
            }


            if (selectedExp != null)
            {
                string eType = selectedExp.Text;

                DBMethods.AddExpense(numAmount.Value, eType, UserID, dateTimeExpInc.Value);

                if (recur > 1)
                {
                    DBMethods.AddRecurringExpense(recur, comboBoxRecur.Text, numAmount.Value, eType, UserID, dateTimeExpInc.Value);
                }

                MessageBox.Show("Expense added!");
            }
            else if (selectedInc != null)
            {
                string iType = selectedInc.Text;

                DBMethods.AddIncome(numAmount.Value, iType, UserID, dateTimeExpInc.Value);

                if (recur > 1)
                {
                    DBMethods.AddRecurringIncome(recur, comboBoxRecur.Text, numAmount.Value, iType, UserID, dateTimeExpInc.Value);
                }

                MessageBox.Show("Income added!");
            }

            UpdateFormHistory();
            UpdateBalance();
            UpdateCharts();
        }
Esempio n. 13
0
        private void PopulateListBoxs()
        {
            foreach (string e in DBMethods.GetExpenseTypeNames(UserID))
            {
                listExpenseTypes.Items.Add(e);
            }

            foreach (string i in DBMethods.GetIncomeTypeNames(UserID))
            {
                listIncomeTypes.Items.Add(i);
            }
        }
Esempio n. 14
0
        private void UpdateCategoryListBoxs()
        {
            List <String> inc1 = DBMethods.GetIncomeCats(UserID);
            List <String> exp1 = DBMethods.GetExpenseCats(UserID);
            List <String> inc2 = DBMethods.GetIncomeCats(UserID);
            List <String> exp2 = DBMethods.GetExpenseCats(UserID);

            listIncomeCategories.DataSource   = inc1;
            listIncomeCategories2.DataSource  = inc2;
            listExpenseCategories.DataSource  = exp1;
            listExpenseCategories2.DataSource = exp2;
        }
        internal static int CreateAccount(string username, string password, string userType)
        {
            int userID = DBMethods.AddUser(username, password, userType);

            if (userID > 0) //User Added
            {
                AddDefaultCategories(userID);
                AddDefaultExpenseTypes(userID);
                AddDefaultIncomeTypes(userID);
            }

            return(userID);
        }
Esempio n. 16
0
 internal static void AddCategory(string name, string incexp, int userID)
 {
     if (incexp == "Expense")
     {
         DBMethods.AddExpenseCategory(name, userID);
     }
     else if (incexp == "Income")
     {
         DBMethods.AddIncomeCategory(name, userID);
     }
     else
     {
         throw new ArgumentException("Invalid Type");
     }
 }
Esempio n. 17
0
 public static void AddTypetoCategory(string name, string incexp, string cat, int userID)
 {
     if (incexp == "Expense")
     {
         DBMethods.AddExpenseTypetoCategory(name, userID, cat);
     }
     else if (incexp == "Income")
     {
         DBMethods.AddIncomeTypetoCategory(name, userID, cat);
     }
     else
     {
         throw new ArgumentException("Invalid Type");
     }
 }
Esempio n. 18
0
 public static void AddType(string name, string type, int userID)
 {
     if (type == "Expense")
     {
         DBMethods.AddExpenseType(name, userID);
     }
     else if (type == "Income")
     {
         DBMethods.AddIncomeType(name, userID);
     }
     else
     {
         throw new ArgumentException("Invalid Type");
     }
 }
 public void UpdateBalance()
 {
     if (radioTotal.Checked)
     {
         decimal balance = DBMethods.CalculateBalance(UserID);
         lblBalance.Text = balance.ToString();
     }
     else if (radioToDate.Checked)
     {
         decimal balance = DBMethods.CalculateBalanceToDate(UserID);
         lblBalance.Text = balance.ToString();
     }
     else
     {
         lblBalance.Text = "How?";
     }
 }
        private static void AddDefaultCategories(int userID)
        {
            if (DBMethods.GetAccountType(userID) == "Corporate")
            {
                DBMethods.AddExpenseCategory("Salaries", userID);
                DBMethods.AddExpenseCategory("Raw Materials", userID);
                DBMethods.AddExpenseCategory("Taxes", userID);
                DBMethods.AddExpenseCategory("Marketing", userID);

                DBMethods.AddIncomeCategory("Domestic Sales", userID);
                DBMethods.AddIncomeCategory("International Sales", userID);
            }
            else
            {
                DBMethods.AddExpenseCategory("General Expense", userID);
                DBMethods.AddIncomeCategory("General Income", userID);
            }
        }
Esempio n. 21
0
 private void BtnDeleteExpenseCategory_Click(object sender, EventArgs e)
 {
     if (DBMethods.TypeOfExpenseCategoryExists(listExpenseCategories.Text, UserID))
     {
         DialogResult result = MessageBox.Show("This action will also delete types and expenses of the selected category. Do you wish to continue?",
                                               "Confirm Delete", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             DBMethods.DeleteTypesAndExpensesofExpenseCategory(listExpenseCategories.Text, UserID);
         }
         else if (result == DialogResult.No)
         {
             return;
         }
     }
     DBMethods.DeleteExpenseCategory(listExpenseCategories.Text, UserID);
     UpdateCategoryListBoxs();
     fm.UpdateUI();
 }
        private static void AddDefaultIncomeTypes(int userID)
        {
            if (DBMethods.GetAccountType(userID) == "Corporate")
            {
                DBMethods.AddIncomeTypetoCategory("İstanbul", userID, "Domestic Sales");
                DBMethods.AddIncomeTypetoCategory("İzmir", userID, "Domestic Sales");
                DBMethods.AddIncomeTypetoCategory("Ankara", userID, "Domestic Sales");

                DBMethods.AddIncomeTypetoCategory("New York", userID, "International Sales");
                DBMethods.AddIncomeTypetoCategory("Paris", userID, "International Sales");
                DBMethods.AddIncomeTypetoCategory("London", userID, "International Sales");
            }
            else
            {
                DBMethods.AddIncomeType("Salary", userID);
                DBMethods.AddIncomeType("Rent", userID);
                DBMethods.AddIncomeType("Dividents", userID);
            }
        }
Esempio n. 23
0
        private void BtnShow_Click(object sender, EventArgs e)
        {
            _MainUI.Close();

            int userID = DBMethods.GetUserID(listUsers.Text);

            if (DBMethods.GetAccountType(userID) == "Corporate")
            {
                FormMainCorporate f = new FormMainCorporate(userID, _DomainController);
                f.Show();
                _MainUI = f;
            }
            else
            {
                FormMain f = new FormMain(userID, _DomainController);
                f.Show();
                _MainUI = f;
            }
        }
Esempio n. 24
0
 private void BtnDeleteIncomeType_Click(object sender, EventArgs e)
 {
     if (DBMethods.IncomeOfTypeExists(listExpenseTypes.Text, UserID))
     {
         DialogResult result = MessageBox.Show("This action will also delete recorded incomes of the selected type. Do you wish to continue?",
                                               "Confirm Delete", MessageBoxButtons.YesNo);
         if (result == DialogResult.Yes)
         {
             DBMethods.DeleteIncomesOfType(listExpenseTypes.Text, UserID);
         }
         else if (result == DialogResult.No)
         {
             return;
         }
     }
     dc.DeleteIncomeType(listIncomeTypes.Text, UserID);
     UpdateListBoxs();
     formMain.UpdateUI();
 }
 /// <summary>
 /// Add recurring Income
 /// </summary>
 /// <param name="recur"></param>
 /// <param name="interval"></param>
 /// <param name="amount"></param>
 /// <param name="iType"></param>
 /// <param name="userID"></param>
 /// <param name="dt"></param>
 internal static void AddRecurringIncome(int recur, string interval, decimal amount, string iType, int userID, DateTime dt)
 {
     if (interval == "Months")
     {
         int toAdd = 1;
         for (int r = recur; r > 1; r--)
         {
             DBMethods.AddIncome(amount, iType, userID, dt.AddMonths(toAdd));
             toAdd++;
         }
     }
     else if (interval == "Weeks")
     {
         int toAdd = 1;
         for (int r = recur; r > 1; r--)
         {
             DBMethods.AddIncome(amount, iType, userID, dt.AddDays(toAdd * 7));
             toAdd++;
         }
     }
 }
Esempio n. 26
0
 public void UpdateDataGrids()
 {
     dataGridExpenses.DataSource = DBMethods.GetExpenseHistory(UserID);
     dataGridIncomes.DataSource  = DBMethods.GetIncomeHistory(UserID);
 }
Esempio n. 27
0
 private void UpdateListIncomeTypes()
 {
     listIncomeTypes.DataSource = DBMethods.GetIncomeTypesOfCat(listIncomeCategories2.Text, UserID);
 }
 internal void InitializeUserTypes()
 {
     DBMethods.AddUserType("Admin");
     DBMethods.AddUserType("User");
     DBMethods.AddUserType("Corporate");
 }
Esempio n. 29
0
 internal static void DeleteIncomeType(string itName, int userID)
 {
     DBMethods.DeleteIncomeType(itName, userID);
 }
Esempio n. 30
0
 internal static void DeleteExpenseType(string etName, int userID)
 {
     DBMethods.DeleteExpenseType(etName, userID);
 }