예제 #1
0
        public void GetPlayerReports(Player player, LoadSeason season)
        {
            try
            {
                mydb.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine("Openning Getting Reports" + e);
                Console.ReadLine();
            }
            try
            {
                string        query    = $"SELECT DayNumber, Net, Gross, Temprature, Weather_Condition, Price_Per_Cup, Pitchers_Sold, Cost_Of_Pitcher, Cups_Sold, Pitchers_Available, Quality_Of_Supply FROM dbo.Report WHERE Player_Id = {player.PlayerId} ORDER BY DayNumber";
                SqlCommand    myCmd    = new SqlCommand(query, mydb);
                SqlDataReader myReader = myCmd.ExecuteReader();
                while (myReader.Read())
                {
                    DailyReport report = new DailyReport();
                    report.DayNumber         = myReader.GetInt32(0);
                    report.Net               = double.Parse(myReader.GetSqlMoney(1).ToString());
                    report.Gross             = double.Parse(myReader.GetSqlMoney(2).ToString());
                    report.WTemp             = myReader.GetInt32(3);
                    report.WCondition        = myReader.GetString(4);
                    report.PricePerCup       = double.Parse(myReader.GetSqlMoney(5).ToString());
                    report.PitchersSold      = myReader.GetInt32(6);
                    report.CostOfPitcher     = double.Parse(myReader.GetSqlMoney(7).ToString());
                    report.CupsSold          = myReader.GetInt32(8);
                    report.PitchersAvailable = myReader.GetInt32(9);
                    report.QualityOfSupply   = myReader.GetString(10);
                    season.MyReports.Add(report);
                    loadGameDay = report.DayNumber;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Finding reports" + e);
                Console.ReadLine();
            }

            try
            {
                mydb.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Closing reports" + e);
                Console.ReadLine();
            }
        }
예제 #2
0
        private void SaveDay(Player player1, DailyReport aReport)
        {
            SaveGame mySave = new SaveGame();
            DateTime myGame = DateTime.Now;

            if (dayCount == 1)
            {
                mySave.InsertIntoPlayer(player1, myGame, seasonLength);
                player1.PlayerId = mySave.GetPlayerId(player1, myGame);
            }
            mySave.InsertIntoReport(aReport, player1.PlayerId);
            if (player1.MySupplies.MyLemons.Count > 0)
            {
                mySave.InsertIntoLemons(player1.MySupplies.MyLemons, player1.PlayerId, dayCount);
            }
            if (player1.MySupplies.MySugar.Count > 0)
            {
                mySave.InsertIntoSugar(player1.MySupplies.MySugar, player1.PlayerId, dayCount);
            }
        }
예제 #3
0
        public void InsertIntoReport(DailyReport aReport, int playerId)
        {
            try
            {
                mydb.Open();
            }
            catch (Exception e)
            {
                Console.WriteLine("Openning Inser to Reports" + e);
                Console.ReadLine();
            }

            string addQuery = $"INSERT INTO dbo.Report (DayNumber, Net, Gross, Temprature, Weather_Condition, Price_Per_Cup, Pitchers_Sold, Cost_Of_Pitcher, Cups_Sold, Pitchers_Available, Quality_Of_Supply, Player_Id) VALUES ({aReport.DayNumber}, {aReport.Net}, {aReport.Gross}, {aReport.WTemp}, '{aReport.WCondition}', {aReport.PricePerCup}, {aReport.PitchersSold}, {aReport.CostOfPitcher}, {aReport.CupsSold}, {aReport.PitchersAvailable}, '{aReport.QualityOfSupply}', {playerId})";

            try
            {
                SqlCommand myAdd = new SqlCommand(addQuery, mydb);
                myAdd.ExecuteNonQuery();
            }
            catch (Exception e)
            {
                Console.WriteLine("Inserting to Reports " + e);
                Console.ReadLine();
            }


            try
            {
                mydb.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Closing Report Insert" + e);
                Console.ReadLine();
            }
        }
예제 #4
0
 public static void EndOfDayReport(DailyReport report, string message)
 {
     Console.Clear();
     Console.WriteLine($"╔═══════════════════════════════════════════╗");
     Console.WriteLine("║ Day {0,-2} SALES       {1,3}\u00B0 - {2,-13}    ║", report.DayNumber, report.WTemp, report.WCondition);
     Console.WriteLine("║                                            ║");
     Console.WriteLine("║  Manager: {0,-12}                     ║", report.SellerName);
     Console.WriteLine("║    Bottom Line─────────────────────────────╢");
     Console.WriteLine("║     Total Sales               : ${0,-7}   ║", report.Gross.ToString("0.00"));
     Console.WriteLine("║     Net   Sales               : ${0,-7}   ║", report.Net.ToString("0.00"));
     Console.WriteLine("║                                            ║");
     Console.WriteLine("║    Relevant Stats──────────────────────────╢");
     Console.WriteLine("║     Total Pitchers Available   : {0,-2}        ║", report.PitchersAvailable);
     Console.WriteLine("║     Total Pitchers Sold        : {0,-2}        ║", report.PitchersSold);
     Console.WriteLine("║     Total Cups Sold            : {0,-2}        ║", report.CupsSold);
     Console.WriteLine("║     Price of Cup               : ${0,-6}   ║", report.PricePerCup.ToString("0.00"));
     Console.WriteLine("║     Quality of Pitcher         : {0,-6}    ║", report.QualityOfSupply);
     Console.WriteLine("║     Cost    of Pitcher         : ${0,-6}   ║", report.CostOfPitcher.ToString("0.00"));
     Console.WriteLine("║     Total People Outside       : {0,-2}        ║", report.CrowdCount);
     Console.WriteLine("║                                            ║");
     Console.WriteLine($"╠═══════════════════════════════════════════╝");
     Console.WriteLine($"║   {message}                                ");
     Console.WriteLine($"╚═══════════════════════════════════════════");
 }