예제 #1
0
        private void GetYear()
        {
            try
            {
                this.Dispatcher.Invoke((Action)(() => { this.stpYearRevenueProfittMonth.Children.Clear(); }));
                list_ec_tb_year.Clear();
                tb_year.Clear();
                total_year = -1;
                uid_img    = -1;

                tb_year = bus_tb_order.GetYearFromOrder("", StaticClass.GeneralClass.flag_database_type_general);

                foreach (DataRow datarow in tb_year.Rows)
                {
                    EC_tb_Charting ec_tb_charting = new EC_tb_Charting();
                    ec_tb_charting.Year = datarow["Year"].ToString();
                    list_ec_tb_year.Add(ec_tb_charting);

                    //create new image year
                    total_year++;
                    uid_img++;

                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        Image img = new Image()
                        {
                            Width = 40,
                            Height = 40,
                            VerticalAlignment = VerticalAlignment.Center,
                            HorizontalAlignment = HorizontalAlignment.Center,
                            Margin = new Thickness(5, 0, 0, 5),
                            Name = "img" + ec_tb_charting.Year,
                            Uid = "uid" + uid_img.ToString()
                        };

                        if (total_year == 0)
                        {
                            img.Source = bitmapimage_circle_focus_year;
                            GetDataFollowYear(ec_tb_charting.Year, "");
                        }
                        else
                        {
                            img.Source = bitmapimage_circle_year;
                        }

                        Grid grd = new Grid();
                        grd.MouseDown += new MouseButtonEventHandler(grd_MouseDown);
                        TextBlock tbl = new TextBlock()
                        {
                            Text = ec_tb_charting.Year,
                            Foreground = System.Windows.Media.Brushes.White,
                            FontWeight = FontWeights.Medium,
                            Margin = new Thickness(5, 0, 0, 5),
                            VerticalAlignment = System.Windows.VerticalAlignment.Center,
                            HorizontalAlignment = System.Windows.HorizontalAlignment.Center,
                        };
                        grd.Children.Add(img);
                        grd.Children.Add(tbl);
                        stpYearRevenueProfittMonth.Children.Add(grd);
                    }));
                }

                if (total_year == -1)
                {
                    list_ec_tb_revenue_profit_month.Clear();
                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        ctcRevenueMonth.ItemsSource = null;
                        ctlProfitMonth.ItemsSource = null;
                    }));
                }
            }
            catch (Exception ex)
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    ModernDialog md = new ModernDialog();
                    md.Title = FindResource("notification").ToString();
                    md.Content = ex.Message;
                    md.ShowDialog();
                }));
            }
        }
예제 #2
0
        private void GetDataFollowYear(string _str_year, string condition)
        {
            try
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    this.ctRevenueProfitMonth.Title = FindResource("revenue_and_profit_in").ToString() + " " + _str_year + " (" + FindResource("unit").ToString() + ": " + StaticClass.GeneralClass.currency_setting_general + ")";

                    //using for revenue year
                    this.ctcRevenueMonth.ItemsSource = null;
                    this.ctlProfitMonth.ItemsSource = null;
                }));

                tb_revenue_year.Clear();
                list_ec_tb_revenue_profit_month.Clear();
                tb_revenue_year = bus_tb_orderdetail.GetTotalRevenueYear(_str_year, condition, StaticClass.GeneralClass.flag_database_type_general);

                for (int m = 1; m <= 12; m++)
                {
                    EC_tb_Charting ec_tb_charting = new EC_tb_Charting();
                    if (m >= 10)
                    {
                        ec_tb_charting.Month = m.ToString();
                    }
                    else
                    {
                        if (StaticClass.GeneralClass.flag_database_type_general == false)
                        {
                            ec_tb_charting.Month = "0" + m.ToString();
                        }
                        else
                        {
                            ec_tb_charting.Month = m.ToString();
                        }
                    }

                    list_ec_tb_revenue_profit_month.Add(ec_tb_charting);
                }

                foreach (DataRow dr in tb_revenue_year.Rows)
                {
                    for (int i = 0; i < list_ec_tb_revenue_profit_month.Count; i++)
                    {
                        if (list_ec_tb_revenue_profit_month[i].Month == dr["RevenueMonth"].ToString())
                        {
                            list_ec_tb_revenue_profit_month[i].Revenue = Convert.ToDouble(dr["TotalRevenueMonth"].ToString());
                            break;
                        }
                    }
                }

                //using for profit year
                tb_capital_year.Clear();
                tb_capital_year = bus_tb_orderdetail.GetTotalCapitalYear(_str_year, condition, StaticClass.GeneralClass.flag_database_type_general);

                foreach (DataRow dr in tb_capital_year.Rows)
                {
                    for (int i = 0; i < list_ec_tb_revenue_profit_month.Count; i++)
                    {
                        if (list_ec_tb_revenue_profit_month[i].Month == dr["CapitalMonth"].ToString())
                        {
                            double profit = list_ec_tb_revenue_profit_month[i].Revenue - Convert.ToDouble(dr["TotalCapitalMoth"].ToString());
                            list_ec_tb_revenue_profit_month[i].Profit = profit;
                            break;
                        }
                    }
                }

                this.Dispatcher.Invoke((Action)(() =>
                {
                    this.ctcRevenueMonth.ItemsSource = list_ec_tb_revenue_profit_month;
                    this.ctlProfitMonth.ItemsSource = list_ec_tb_revenue_profit_month;
                }));

                //add data to the table of revenue and profit in month
                this.Dispatcher.Invoke((Action)(() =>
                {
                    tblRevenueMonth.Text = FindResource("revenue").ToString() + "(" + StaticClass.GeneralClass.currency_setting_general.Trim() + ")";
                    tblProfitMonth.Text = FindResource("profit").ToString() + "(" + StaticClass.GeneralClass.currency_setting_general.Trim() + ")";
                    grdTableRevenueProfitMonth.ColumnDefinitions.Clear();
                    grdTableRevenueProfitMonth.Children.Clear();
                }));

                for (int i = 0; i < 12; i++)
                {
                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        ColumnDefinition cd = new ColumnDefinition()
                        {
                            Width = new GridLength(1, GridUnitType.Star)
                        };
                        grdTableRevenueProfitMonth.ColumnDefinitions.Add(cd);
                        Border bd = new Border()
                        {
                            BorderBrush = new BrushConverter().ConvertFromString("#FF212121") as Brush, BorderThickness = new Thickness(1, 0, 0, 0)
                        }; Grid.SetRowSpan(bd, 3); Grid.SetColumn(bd, i);
                        grdTableRevenueProfitMonth.Children.Add(bd);

                        TextBlock tblMonth = new TextBlock()
                        {
                            Text = list_ec_tb_revenue_profit_month[i].Month, Style = FindResource("textBlockValue") as Style, HorizontalAlignment = HorizontalAlignment.Center,
                        };
                        Grid.SetColumn(tblMonth, i);
                        grdTableRevenueProfitMonth.Children.Add(tblMonth);

                        TextBlock tblRevenue = new TextBlock()
                        {
                            Text = list_ec_tb_revenue_profit_month[i].Revenue == 0 ? FindResource("null").ToString() : GeneralClass.GetNumFormatDisplay((decimal)list_ec_tb_revenue_profit_month[i].Revenue), Style = FindResource("textBlockValue") as Style
                        };
                        if (list_ec_tb_revenue_profit_month[i].Revenue == 0)
                        {
                            tblRevenue.Foreground = new BrushConverter().ConvertFromString("#FF212121") as Brush;
                        }
                        Grid.SetColumn(tblRevenue, i); Grid.SetRow(tblRevenue, 1);
                        grdTableRevenueProfitMonth.Children.Add(tblRevenue);

                        TextBlock tblProfit = new TextBlock()
                        {
                            Text = list_ec_tb_revenue_profit_month[i].Profit == 0 ? FindResource("null").ToString() : GeneralClass.GetNumFormatDisplay((decimal)list_ec_tb_revenue_profit_month[i].Profit), Style = FindResource("textBlockValue") as Style
                        };
                        if (list_ec_tb_revenue_profit_month[i].Profit == 0)
                        {
                            tblProfit.Foreground = new BrushConverter().ConvertFromString("#FF212121") as Brush;
                        }
                        Grid.SetColumn(tblProfit, i); Grid.SetRow(tblProfit, 2);
                        grdTableRevenueProfitMonth.Children.Add(tblProfit);
                    }));
                }
                this.Dispatcher.Invoke((Action)(() =>
                {
                    Separator sp1 = new Separator()
                    {
                        VerticalAlignment = VerticalAlignment.Bottom, Background = new BrushConverter().ConvertFromString("#FF616161") as Brush,
                    }; Grid.SetColumnSpan(sp1, list_ec_tb_revenue_profit_month.Count);
                    grdTableRevenueProfitMonth.Children.Add(sp1);

                    Separator sp2 = new Separator()
                    {
                        VerticalAlignment = VerticalAlignment.Bottom, Background = new BrushConverter().ConvertFromString("#FF616161") as Brush,
                    }; Grid.SetColumnSpan(sp2, list_ec_tb_revenue_profit_month.Count); Grid.SetRow(sp2, 1);
                    grdTableRevenueProfitMonth.Children.Add(sp2);
                }));
            }
            catch (Exception ex)
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    ModernDialog md = new ModernDialog();
                    md.MaxWidth = 9999;
                    md.Title = FindResource("notification").ToString();
                    md.Content = ex.Message;
                    md.ShowDialog();
                }));
            }
        }
예제 #3
0
        private void GetRevenueProfitAll()
        {
            //using for revenue
            this.Dispatcher.Invoke((Action)(() =>
            {
                this.ctcRevenueYear.ItemsSource = null;
                this.ctlProfitYear.ItemsSource = null;
            }));

            tb_revenue_all.Clear();
            list_ec_tb_revenue_profit_year.Clear();
            tb_revenue_all = bus_tb_orderdetail.GetTotalRevenueAll("", StaticClass.GeneralClass.flag_database_type_general);
            foreach (DataRow dr in tb_revenue_all.Rows)
            {
                EC_tb_Charting ec_tb_charting = new EC_tb_Charting();
                ec_tb_charting.Year    = dr["RevenueAll"].ToString();
                ec_tb_charting.Revenue = Convert.ToDouble(dr["TotalRevenueAll"].ToString());
                list_ec_tb_revenue_profit_year.Add(ec_tb_charting);
            }

            //using for profit
            tb_capital_all.Clear();
            tb_capital_all = bus_tb_orderdetail.GetTotalCapitalAll("", StaticClass.GeneralClass.flag_database_type_general);

            foreach (DataRow dr in tb_capital_all.Rows)
            {
                for (int i = 0; i < list_ec_tb_revenue_profit_year.Count; i++)
                {
                    if (list_ec_tb_revenue_profit_year[i].Year == dr["CapitalAll"].ToString())
                    {
                        double profit = list_ec_tb_revenue_profit_year[i].Revenue - Convert.ToDouble(dr["TotalCapitalAll"].ToString());
                        list_ec_tb_revenue_profit_year[i].Profit = profit;
                        break;
                    }
                }
            }

            this.Dispatcher.Invoke((Action)(() =>
            {
                this.ctcRevenueYear.ItemsSource = list_ec_tb_revenue_profit_year;
                this.ctlProfitYear.ItemsSource = list_ec_tb_revenue_profit_year;
            }));

            //add data to the table of revenue and profit in years
            this.Dispatcher.Invoke((Action)(() =>
            {
                tblRevenueYear.Text = FindResource("revenue").ToString() + "(" + StaticClass.GeneralClass.currency_setting_general.Trim() + ")";
                tblProfitYear.Text = FindResource("profit").ToString() + "(" + StaticClass.GeneralClass.currency_setting_general.Trim() + ")";
                grdTableRevenueProfitYear.ColumnDefinitions.Clear();
                grdTableRevenueProfitYear.Children.Clear();
            }));

            for (int i = 0; i < list_ec_tb_revenue_profit_year.Count; i++)
            {
                this.Dispatcher.Invoke((Action)(() =>
                {
                    ColumnDefinition cd = new ColumnDefinition()
                    {
                        Width = new GridLength(1, GridUnitType.Star)
                    };
                    grdTableRevenueProfitYear.ColumnDefinitions.Add(cd);
                    Border bd = new Border()
                    {
                        BorderBrush = new BrushConverter().ConvertFromString("#FF212121") as Brush, BorderThickness = new Thickness(1, 0, 0, 0)
                    }; Grid.SetRowSpan(bd, 3); Grid.SetColumn(bd, i);
                    grdTableRevenueProfitYear.Children.Add(bd);
                    TextBlock tblYear = new TextBlock()
                    {
                        Text = list_ec_tb_revenue_profit_year[i].Year, Style = FindResource("textBlockValue") as Style, HorizontalAlignment = HorizontalAlignment.Center
                    };
                    Grid.SetColumn(tblYear, i);
                    grdTableRevenueProfitYear.Children.Add(tblYear);

                    TextBlock tblRevenue = new TextBlock()
                    {
                        Text = GeneralClass.GetNumFormatDisplay((decimal)list_ec_tb_revenue_profit_year[i].Revenue), Style = FindResource("textBlockValue") as Style
                    };
                    Grid.SetColumn(tblRevenue, i); Grid.SetRow(tblRevenue, 1);
                    grdTableRevenueProfitYear.Children.Add(tblRevenue);

                    TextBlock tblProfit = new TextBlock()
                    {
                        Text = GeneralClass.GetNumFormatDisplay((decimal)list_ec_tb_revenue_profit_year[i].Profit), Style = FindResource("textBlockValue") as Style
                    };
                    Grid.SetColumn(tblProfit, i); Grid.SetRow(tblProfit, 2);
                    grdTableRevenueProfitYear.Children.Add(tblProfit);
                }));
            }

            //fixed
            this.Dispatcher.Invoke((Action)(() =>
            {
                Separator sp1 = new Separator()
                {
                    VerticalAlignment = VerticalAlignment.Bottom, Background = new BrushConverter().ConvertFromString("#FF616161") as Brush,
                }; Grid.SetColumnSpan(sp1, list_ec_tb_revenue_profit_year.Count > 0 ? list_ec_tb_revenue_profit_year.Count : 1);
                grdTableRevenueProfitYear.Children.Add(sp1);

                Separator sp2 = new Separator()
                {
                    VerticalAlignment = VerticalAlignment.Bottom, Background = new BrushConverter().ConvertFromString("#FF616161") as Brush,
                }; Grid.SetRow(sp2, 1); Grid.SetColumnSpan(sp2, list_ec_tb_revenue_profit_year.Count > 0 ? list_ec_tb_revenue_profit_year.Count : 1);
                grdTableRevenueProfitYear.Children.Add(sp2);
            }));
        }