public GraphDisplayWindow(PerformanceTable perfData) { InitializeComponent(); //links the x axis (month) to the transfers for that month ( y axis) ((LineSeries)Perf_Chart.Series[0]).ItemsSource = new KeyValuePair <string, int>[] { new KeyValuePair <string, int>("January", perfData.January.Value), new KeyValuePair <string, int>("February", perfData.February.Value), new KeyValuePair <string, int>("March", perfData.March.Value), new KeyValuePair <string, int>("April", perfData.April.Value), new KeyValuePair <string, int>("May", perfData.May.Value), new KeyValuePair <string, int>("June", perfData.June.Value), new KeyValuePair <string, int>("July", perfData.July.Value), new KeyValuePair <string, int>("August", perfData.August.Value), new KeyValuePair <string, int>("September", perfData.September.Value), new KeyValuePair <string, int>("October", perfData.October.Value), new KeyValuePair <string, int>("November", perfData.November.Value), new KeyValuePair <string, int>("December", perfData.December.Value), }; }
public void GeneratePerformanceLog(ForSaleTable ActItem) { var PerfQuery = from u in DataContextInv.PerformanceTables where u.ItemName == ActItem.ItemName select u; if (PerfQuery.Count() == 0) // then a perf record for the item doesnt exist { PerformanceTable PerformanceLog = new PerformanceTable(); PerformanceLog.ItemName = ActItem.ItemName; PerformanceLog.January = 0; PerformanceLog.February = 0; PerformanceLog.March = 0; PerformanceLog.April = 0; PerformanceLog.May = 0; PerformanceLog.June = 0; PerformanceLog.July = 0; PerformanceLog.August = 0; PerformanceLog.September = 0; PerformanceLog.October = 0; PerformanceLog.November = 0; PerformanceLog.December = 0; //returns the current month , e.g. January string currentMonth = DateTime.Now.ToString("MMMM"); Console.WriteLine("The quantity is " + ActItem.Quantity); if (currentMonth == "January") { PerformanceLog.January += ActItem.Quantity.Value; } if (currentMonth == "February") { PerformanceLog.February = ActItem.Quantity.Value; } if (currentMonth == "March") { PerformanceLog.March = ActItem.Quantity.Value; } if (currentMonth == "April") { PerformanceLog.April = ActItem.Quantity.Value; } if (currentMonth == "May") { PerformanceLog.May = ActItem.Quantity.Value; } if (currentMonth == "June") { PerformanceLog.June = ActItem.Quantity.Value; } if (currentMonth == "July ") { PerformanceLog.July = ActItem.Quantity.Value; } if (currentMonth == "August") { PerformanceLog.August = ActItem.Quantity.Value; } if (currentMonth == "September") { PerformanceLog.September = ActItem.Quantity.Value; } if (currentMonth == "October") { PerformanceLog.October = ActItem.Quantity.Value; } if (currentMonth == "November") { PerformanceLog.November = ActItem.Quantity.Value; } if (currentMonth == "December") { PerformanceLog.December = ActItem.Quantity.Value; } DataContextInv.PerformanceTables.InsertOnSubmit(PerformanceLog); DataContextInv.SubmitChanges(); } else { //get the actual record in the performance table var PerfData = DataContextInv.PerformanceTables.Single(x => x.ItemName == ActItem.ItemName); string currentMonth = DateTime.Now.ToString("MMMM"); if (currentMonth == "January") { //increment the value by the quantity of item PerfData.January += ActItem.Quantity.Value; } if (currentMonth == "February") { PerfData.February += ActItem.Quantity.Value; } if (currentMonth == "March") { PerfData.March += ActItem.Quantity.Value; } if (currentMonth == "April") { PerfData.April += ActItem.Quantity.Value; } if (currentMonth == "May") { PerfData.May += ActItem.Quantity.Value; } if (currentMonth == "June") { PerfData.June += ActItem.Quantity.Value; } if (currentMonth == "July ") { PerfData.July += ActItem.Quantity.Value; } if (currentMonth == "August") { PerfData.August += ActItem.Quantity.Value; } if (currentMonth == "September") { PerfData.September += ActItem.Quantity.Value; } if (currentMonth == "October") { PerfData.October += ActItem.Quantity.Value; } if (currentMonth == "November") { PerfData.November += ActItem.Quantity.Value; } if (currentMonth == "December") { PerfData.December += ActItem.Quantity.Value; } DataContextInv.SubmitChanges(); } }
public string GeneratePerformanceAnalysisText(PerformanceTable PerfData) { //create a an array where index 0 corresponds to january , 1 to February and so on int[] TransfersMonths = new int[12]; TransfersMonths[0] = PerfData.January.Value; TransfersMonths[1] = PerfData.February.Value; TransfersMonths[2] = PerfData.March.Value; TransfersMonths[3] = PerfData.April.Value; TransfersMonths[4] = PerfData.May.Value; TransfersMonths[5] = PerfData.June.Value; TransfersMonths[6] = PerfData.July.Value; TransfersMonths[7] = PerfData.August.Value; TransfersMonths[8] = PerfData.September.Value; TransfersMonths[9] = PerfData.October.Value; TransfersMonths[10] = PerfData.November.Value; TransfersMonths[11] = PerfData.December.Value; int lastHighestVal = 0; int lastHighestIndex = 0; int lastLowestVal = 0; int lastLowestIndex = 0; string worstMonth = ""; string bestMonth = ""; //iterate through the array for (int pos = 0; pos < TransfersMonths.Length; pos++) { //if its the first iteration then setup the variables if (pos == 0) { lastHighestIndex = pos; lastHighestVal = TransfersMonths[pos]; lastLowestIndex = pos; lastLowestVal = TransfersMonths[pos]; } //if the month being iterated through has had more transfers than last highest month else if (TransfersMonths[pos] > lastHighestVal) { //update the last highest values and index lastHighestVal = TransfersMonths[pos]; lastHighestIndex = pos; } //if the month being iterated through has had less transfers than last highest month else if (TransfersMonths[pos] < lastLowestVal) { //update the last lowest values and index lastLowestVal = TransfersMonths[pos]; lastLowestIndex = pos; } } if (lastHighestIndex == 0) { bestMonth = "January"; } if (lastHighestIndex == 1) { bestMonth = "February"; } if (lastHighestIndex == 2) { bestMonth = "March"; } if (lastHighestIndex == 3) { bestMonth = "April"; } if (lastHighestIndex == 4) { bestMonth = "May"; } if (lastHighestIndex == 5) { bestMonth = "June"; } if (lastHighestIndex == 6) { bestMonth = "July"; } if (lastHighestIndex == 7) { bestMonth = "August"; } if (lastHighestIndex == 8) { bestMonth = "September"; } if (lastHighestIndex == 9) { bestMonth = "October"; } if (lastHighestIndex == 10) { bestMonth = "November"; } if (lastHighestIndex == 11) { bestMonth = "December"; } if (lastLowestIndex == 0) { worstMonth = "January"; } if (lastLowestIndex == 1) { worstMonth = "February"; } if (lastLowestIndex == 2) { worstMonth = "March"; } if (lastLowestIndex == 3) { worstMonth = "April"; } if (lastLowestIndex == 4) { worstMonth = "May"; } if (lastLowestIndex == 5) { worstMonth = "June"; } if (lastLowestIndex == 6) { worstMonth = "July"; } if (lastLowestIndex == 7) { worstMonth = "August"; } if (lastLowestIndex == 8) { worstMonth = "September"; } if (lastLowestIndex == 9) { worstMonth = "October"; } if (lastLowestIndex == 10) { worstMonth = "November"; } if (lastLowestIndex == 11) { worstMonth = "December"; } return(PerfData.ItemName.Replace(" ", "") + " has shown to sell best in the month " + bestMonth + " and sells worst in the month " + worstMonth); }
partial void DeletePerformanceTable(PerformanceTable instance);
partial void UpdatePerformanceTable(PerformanceTable instance);
partial void InsertPerformanceTable(PerformanceTable instance);