Exemple #1
0
        public List <MonthlyRevenue> AllMonthlyRevenues()
        {
            List <MonthlyRevenue> list = new List <MonthlyRevenue>();
            MyConnection          currentConnection = new MyConnection();
            SqlConnection         connection        = currentConnection.CurrentConnection;
            SqlCommand            command;
            SqlDataReader         reader;
            string query = "SELECT * FROM MonthlyRevenue ORDER BY Year, Month";

            command = new SqlCommand(query, connection);

            connection.Open();

            reader = command.ExecuteReader();
            while (reader.Read())
            {
                MonthlyRevenue item = new MonthlyRevenue();
                item.BankDeposits     = Convert.ToDecimal(reader["BankDeposits"]);
                item.Consignments     = Convert.ToDecimal(reader["Consignmet"]);
                item.Month            = Convert.ToInt16(reader["Month"]);
                item.MonthlyRevenueID = reader["MonthlyRevenueID"].ToString();
                item.Motorized        = Convert.ToDecimal(reader["Motorized"]);
                item.Notes            = reader["Notes"].ToString();
                item.OutOfState       = Convert.ToDecimal(reader["OutOfState"]);
                item.Use       = Convert.ToDecimal(reader["StoreUse"]);
                item.Wholesale = Convert.ToDecimal(reader["Wholesale"]);
                item.Year      = Convert.ToInt16(reader["Year"]);

                list.Add(item);
            }
            reader.Close();
            connection.Close();
            return(list);
        }
Exemple #2
0
        public void SetMonthlyRevenue()
        {
            MonthlyRevenue monthlyRevenue    = new MonthlyRevenue();
            MyConnection   currentConnection = new MyConnection();
            SqlConnection  connection        = currentConnection.CurrentConnection;
            SqlCommand     command;
            SqlDataReader  reader;
            string         query = "SELECT TOP 1 * FROM MonthlyRevenue WHERE Year = @Year AND Month = @Month";

            command = new SqlCommand(query, connection);
            command.Parameters.AddWithValue("@Month", Month);
            command.Parameters.AddWithValue("@Year", Year);

            connection.Open();
            reader = command.ExecuteReader();

            while (reader.Read())
            {
                MonthlyRevenueID = reader["MonthlyRevenueID"].ToString();
                Month            = Convert.ToInt16(reader["Month"]);
                Year             = Convert.ToInt16(reader["Year"]);
                BankDeposits     = Convert.ToDecimal(reader["BankDeposits"]);
                OutOfState       = Convert.ToDecimal(reader["OutOfState"]);
                Wholesale        = Convert.ToDecimal(reader["Wholesale"]);
                Consignments     = Convert.ToDecimal(reader["Consignment"]);
                Motorized        = Convert.ToDecimal(reader["Motorized"]);
                Use   = Convert.ToDecimal(reader["StoreUse"]);
                Notes = reader["Notes"].ToString();
            }
            reader.Close();
            connection.Close();
        }