private List <spMonthlyActivity_Result> GetReleaseData() { using (var context = new WMS5Entities()) { var day = new DateTime(DateTime.Today.Year, 1, 1); return(context.spMonthlyActivity(day, "RELEASE").ToList()); } }
private float GetOldReleaseData(List <spMonthlyActivity_Result> releaseData) { using (var context = new WMS5Entities()){ var day = new DateTime(DateTime.Today.Year, 1, 1); var beginDate = day.AddYears(-1); var endDate = beginDate.AddDays(DateTime.Today.DayOfYear); var oldReleases = (float)context.spTransSummary("RELEASE", beginDate, endDate).First().Quantity; return((float)(releaseData.Sum(o => o.Pallets) - oldReleases) / (oldReleases == 0 ? 1 : oldReleases)); } }
private void DisplayToday() { using (var context = new WMS5Entities()) { var receiptData = context.spHourlyActivity(DateTime.Today.AddHours(6), "RECEIPT").ToList(); var releaseData = context.spHourlyActivity(DateTime.Today.AddHours(6), "RELEASE").ToList(); var max = ((int)(Math.Ceiling((double)receiptData.Max(o => o.Pallets) / 10))) * 10; var interval = max / 5; ChartSeries series = new ChartSeries("Receipts", ChartSeriesType.Column); series.SortPoints = false; chartReceipts.PrimaryYAxis.Range = new MinMaxInfo(0, max, interval); chartReleases.PrimaryYAxis.Range = new MinMaxInfo(0, max, interval); foreach (var data in receiptData) { series.Points.Add(DateTime.Today.Add((TimeSpan)data.BeginTime).ToString("h tt"), (double)data.Pallets); //+ "-" + DateTime.Today.Add((TimeSpan)data.EndTime).ToString("hh tt"), (double)data.Pallets); } chartReceipts.Series.Add(series); gaugeReceipts.Value = (float)receiptData.Sum(o => o.Pallets); ChartSeries s2 = new ChartSeries("Releases", ChartSeriesType.Column); s2.SortPoints = false; foreach (var data in releaseData) { s2.Points.Add(DateTime.Today.Add((TimeSpan)data.BeginTime).ToString("h tt"), (double)data.Pallets);// + "-" + DateTime.Today.Add((TimeSpan)data.EndTime).ToString("hh"), (double)data.Pallets); } chartReleases.Series.Add(s2); gaugeReleases.Value = (float)releaseData.Sum(o => o.Pallets); var beginDate = DateTime.Today.AddDays(-1); var endDate = DateTime.Now.AddDays(-1); var oldReceipts = (float)context.spTransSummary("RECEIPT", beginDate, endDate).First().Quantity; float value = ((float)(receiptData.Sum(o => o.Pallets) - oldReceipts) / oldReceipts); lblReceipts.Text = value.ToString("p1"); if (value < 0) { lblReceipts.ImageIndex = 0; lblReceiptChange.Text = "Receiving is DOWN"; } else { lblReceipts.ImageIndex = 1; lblReceiptChange.Text = "Receiving is UP"; } var oldReleases = (float)context.spTransSummary("RELEASE", beginDate, endDate).First().Quantity; value = ((float)(releaseData.Sum(o => o.Pallets) - oldReleases) / (oldReleases == 0 ? 1 : oldReleases)); lblReleases.Text = value.ToString("p1"); if (value < 0) { lblReleases.ImageIndex = 0; lblReleaseChange.Text = "Shipping is DOWN"; } else { lblReleases.ImageIndex = 1; lblReleaseChange.Text = "Shipping is UP"; } lblReceiptPeriod.Text = "Yesterday"; lblReleasePeriod.Text = "Yesterday"; gaugeReceipts.MaximumValue = 600; gaugeReceipts.MajorDifference = 60; gaugeReceipts.MinorDifference = 30; gaugeReceipts.Ranges.Clear(); gaugeReceipts.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Red, 0, 180, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReceipts.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Yellow, 180, 420, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReceipts.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Lime, 420, 600, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReceipts.GaugeLabel = "Received Today"; gaugeReceipts.Value = (float)receiptData.Sum(o => o.Pallets); gaugeReleases.MaximumValue = 600; gaugeReleases.MajorDifference = 60; gaugeReleases.MinorDifference = 30; gaugeReleases.Ranges.Clear(); gaugeReleases.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Red, 0, 180, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReleases.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Yellow, 180, 420, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReleases.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Lime, 420, 600, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReleases.GaugeLabel = "Released Today"; gaugeReleases.Value = (float)releaseData.Sum(o => o.Pallets); chartReceipts.Series[0].Style.DisplayText = true; chartReceipts.Series[0].Style.TextOrientation = ChartTextOrientation.Up; chartReleases.Series[0].Style.DisplayText = true; chartReleases.Series[0].Style.TextOrientation = ChartTextOrientation.Up; } }
private void DisplayThisWeek() { chartReceipts.PrimaryYAxis.Range = new MinMaxInfo(0, 600, 100); chartReceipts.PrimaryXAxis.LabelAlignment = StringAlignment.Center; chartReleases.PrimaryYAxis.Range = new MinMaxInfo(0, 600, 100); chartReleases.PrimaryXAxis.LabelAlignment = StringAlignment.Center; using (var context = new WMS5Entities()) { var monday = DateTime.Today.AddDays(-(int)DateTime.Today.DayOfWeek + (int)DayOfWeek.Monday); var receiptData = context.spDailyActivity(monday, "RECEIPT").ToList(); var releaseData = context.spDailyActivity(monday, "RELEASE").ToList(); ChartSeries series = new ChartSeries("Receipts", ChartSeriesType.Column); series.SortPoints = false; foreach (var data in receiptData) { series.Points.Add(((DateTime)data.BeginDate).ToString("ddd"), (double)data.Pallets); } ChartSeries s2 = new ChartSeries("Releases", ChartSeriesType.Column); s2.SortPoints = false; foreach (var data in releaseData) { s2.Points.Add(((DateTime)data.BeginDate).ToString("ddd"), (double)data.Pallets); } chartReceipts.Series.Add(series); chartReleases.Series.Add(s2); chartReceipts.Series[0].Style.Callout.DisplayTextAndFormat = "{2}"; chartReceipts.PrimaryXAxis.LabelRotate = false; var beginDate = monday.AddDays(-7); var endDate = beginDate.AddDays((int)DateTime.Today.DayOfWeek - (int)DayOfWeek.Monday); endDate = endDate.Add(DateTime.Now.TimeOfDay); var oldReceipts = (float)context.spTransSummary("RECEIPT", beginDate, endDate).First().Quantity; float value = ((float)(receiptData.Sum(o => o.Pallets) - oldReceipts) / oldReceipts); lblReceipts.Text = value.ToString("p1"); if (value < 0) { lblReceipts.ImageIndex = 0; lblReceiptChange.Text = "Receiving is DOWN"; } else { lblReceipts.ImageIndex = 1; lblReceiptChange.Text = "Receiving is UP"; } var oldReleases = (float)context.spTransSummary("RELEASE", beginDate, endDate).First().Quantity; value = ((float)(releaseData.Sum(o => o.Pallets) - oldReleases) / (oldReleases == 0 ? 1 : oldReleases)); lblReleases.Text = value.ToString("p1"); if (value < 0) { lblReleases.ImageIndex = 0; lblReleaseChange.Text = "Shipping is DOWN"; } else { lblReleases.ImageIndex = 1; lblReleaseChange.Text = "Shipping is UP"; } lblReceiptPeriod.Text = "Last Week"; lblReleasePeriod.Text = "Last Week"; gaugeReceipts.MaximumValue = 2500; gaugeReceipts.MajorDifference = 500; gaugeReceipts.MinorDifference = 250; gaugeReceipts.Ranges.Clear(); gaugeReceipts.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Red, 0, 750, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReceipts.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Yellow, 750, 1750, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReceipts.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Lime, 1750, 2500, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReceipts.GaugeLabel = "Received This Week"; gaugeReceipts.Value = (float)receiptData.Sum(o => o.Pallets); gaugeReleases.MaximumValue = 2500; gaugeReleases.MajorDifference = 500; gaugeReleases.MinorDifference = 250; gaugeReleases.Ranges.Clear(); gaugeReleases.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Red, 0, 750, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReleases.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Yellow, 750, 1750, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReleases.Ranges.Add(new Syncfusion.Windows.Forms.Gauge.Range(Color.Lime, 1750, 2500, 5, Syncfusion.Windows.Forms.Gauge.TickPlacement.Inside)); gaugeReleases.GaugeLabel = "Released This Week"; gaugeReleases.Value = (float)releaseData.Sum(o => o.Pallets); chartReceipts.Series[0].Style.DisplayText = true; chartReceipts.Series[0].Style.TextOrientation = ChartTextOrientation.Up; chartReleases.Series[0].Style.DisplayText = true; chartReleases.Series[0].Style.TextOrientation = ChartTextOrientation.Up; } }