Esempio n. 1
0
        static public void DeleteMonthBudget(MonthBudget monthBudget)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionStr))
                {
                    conn.Open();
                    if (conn.State == System.Data.ConnectionState.Open)
                    {
                        using (SqlCommand command = conn.CreateCommand())
                        {
                            command.CommandType = System.Data.CommandType.StoredProcedure;
                            command.CommandText = "stpDeleteMonthBudget";

                            //add parameters
                            command.Parameters.Add(new SqlParameter("@Date", monthBudget.Date));
                            command.Parameters.Add(new SqlParameter("@User", Username));

                            command.ExecuteNonQuery();
                        }
                    }
                }
            }
            catch
            {
            }
        }
Esempio n. 2
0
        static public void UpdateMonthBudget(MonthBudget monthBudget)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionStr))
                {
                    conn.Open();
                    if (conn.State == System.Data.ConnectionState.Open)
                    {
                        using (SqlCommand command = conn.CreateCommand())
                        {
                            command.CommandType = System.Data.CommandType.StoredProcedure;
                            command.CommandText = "stpUpdateMonthlyBudget";

                            //add parameters
                            command.Parameters.Add(new SqlParameter("@BudgetValue", monthBudget.BudgetVal));
                            command.Parameters.Add(new SqlParameter("@RemainingBudget", monthBudget.Value));
                            command.Parameters.Add(new SqlParameter("@IncomeAmount", monthBudget.IncAmount));
                            command.Parameters.Add(new SqlParameter("@ExpenseAmount", monthBudget.ExpAmount));
                            command.Parameters.Add(new SqlParameter("@Date", monthBudget.Date));
                            command.Parameters.Add(new SqlParameter("@User", Username));

                            command.ExecuteNonQuery();
                        }
                    }
                }
            }
            catch
            {
            }
        }
Esempio n. 3
0
        public void CreateMonthlyBudget(int month, int year)
        {
            MonthBudget monthBudget = new MonthBudget(DefaultMonthlyBudget, month, year);

            MonthlyBudgets.Add(monthBudget);
            Account.InsertMonthlyBudget(monthBudget);
            monthBudget.Setup = false;
            CalcMonthBudget();
            OrganizeMonthBudgetsByDate();
            return;
        }
Esempio n. 4
0
        static public MonthBudget SelectMonthBudget(DateTime date)
        {
            string getMonthBudgetQuery = "SELECT * FROM [MonthlyBudgets] WHERE [User] = '" + Username + "' AND MONTH([Date]) = " + date.Month
                                         + " AND YEAR([Date]) = " + date.Year;
            MonthBudget monthBudget = new MonthBudget();

            try
            {
                using (SqlConnection conn = new SqlConnection(ConnectionStr))
                {
                    conn.Open();
                    if (conn.State == System.Data.ConnectionState.Open)
                    {
                        using (SqlCommand command = conn.CreateCommand())
                        {
                            command.CommandText = getMonthBudgetQuery;

                            using (SqlDataReader reader = command.ExecuteReader())
                            {
                                while (reader.Read())
                                {
                                    monthBudget.BudgetVal = reader.GetDecimal(0);
                                    monthBudget.Value     = reader.GetDecimal(1);
                                    monthBudget.IncAmount = reader.GetDecimal(2);
                                    monthBudget.ExpAmount = reader.GetDecimal(3);
                                    monthBudget.Date      = reader.GetDateTime(4);
                                    monthBudget.Setup     = false;
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }

            return(monthBudget);
        }