Exemplo n.º 1
0
 public void AddtoChart(MyChartSeries t)
 {
     _Chart.Add(t);
 }
Exemplo n.º 2
0
 public Chart(MyChartSeries t)
 {
     _Chart.Add(t);
 }
Exemplo n.º 3
0
        private void btnOk_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (cbbChoice.Text)
                {
                    case "Revenue/Day":
                        {
                            csMyStackChartSeries.SeriesTitle = "Revenue of " + dpDate.Text;
                            DateTime date = (DateTime)dpDate.SelectedDate;
                            DataTable dt = InvoiceBLL.GetInvoiceByDay(date);
                            Chart c = new Chart();
                            foreach (DataRow dr in dt.Rows)
                            {
                                MyChartSeries mcs = new MyChartSeries();
                                mcs.Name = "Schedule " + dr["InvoiceID"].ToString();
                                mcs.Count = float.Parse(dr["Total"].ToString());
                                c.AddtoChart(mcs);
                            }
                            DataContext = c;
                            break;
                        }
                    default:
                        {
                            int month = int.Parse(cbbMonth.Text);
                            int year = int.Parse(cbbYear.Text); 
                            csMyChartSeries.SeriesTitle = "Number of schedule in " +
                                CultureInfo.CurrentCulture.DateTimeFormat.MonthNames.GetValue(month - 1).ToString();

                            Chart c = new Chart();
                            if (cbbChoice.Text == "Schedule/Month")
                            {
                                DataTable dt = InvoiceBLL.GetScheduleByMonth(month, year);
                                foreach (DataRow dr in dt.Rows)
                                {
                                    MyChartSeries mcs = new MyChartSeries();
                                    mcs.Name = dr["CustomerID"].ToString();
                                    mcs.Count = int.Parse(dr["NumberOfSchedule"].ToString());
                                    c.AddtoChart(mcs);
                                }
                            }
                            else if (cbbChoice.Text == "Shipper/Month")
                            {
                                DataTable dt = InvoiceBLL.GetShipperByMonth(month, year);
                                List<Shipper> shippers = new List<Shipper>();
                                shippers = ShipperBLL.GetAllShipper();
                                foreach (DataRow dr in dt.Rows)
                                {
                                    MyChartSeries mcs = new MyChartSeries();
                                    int ShipperID = int.Parse(dr["ShipperID"].ToString());
                                    string SName = ((Shipper)shippers.Where(q => q.ShipperID == ShipperID).FirstOrDefault()).Name;
                                    mcs.Name = SName;
                                    mcs.Count = int.Parse(dr["NumberOfSchedule"].ToString());
                                    c.AddtoChart(mcs);
                                }
                            }
                            DataContext = c;
                            break;
                        }
                }
            }
            catch (Exception g)
            {
                System.Windows.Forms.MessageBox.Show(g.Message);
            }
        }