Exemplo n.º 1
0
        private void LoadGroupsJoin(TourStatisticBinding tourStatisticBinding)
        {
            //Back to main thread update UI
            if (InvokeRequired)
            {
                BeginInvoke(new Action(() =>
                {
                    dgvStatisticGroupDetail.ShowLoading(true);
                }));
            }

            //Fill DataTable
            var           groups = _tourWithGroups.FirstOrDefault(t => t.Tour.Id == tourStatisticBinding.TourId).Groups;
            List <object> data   = new List <object>();

            foreach (var group in groups)
            {
                data.Add(new
                {
                    group.Id,
                    group.Name,
                    Tour = group.Tour.Name,
                    group.StartDate,
                    group.EndDate,
                    PriceTour = GroupBLL.GetPriceTourOfGroup(group),
                    Revenue   = GroupBLL.GetRevenueOfGroup(group),
                    Cost      = GroupBLL.GetTotalCostOfGroup(group),
                });
            }

            //Back to main thread update UI
            if (InvokeRequired)
            {
                BeginInvoke(new Action(() =>
                {
                    //Clear loading column
                    dgvStatisticGroupDetail.Columns.Clear();

                    dgvStatisticGroupDetail.Columns.Add("Id", "Mã");
                    dgvStatisticGroupDetail.Columns.Add("Name", "Tên đoàn");
                    dgvStatisticGroupDetail.Columns.Add("Tour", "Tour");
                    dgvStatisticGroupDetail.Columns.Add("StartDate", "Ngày đi");
                    dgvStatisticGroupDetail.Columns.Add("EndDate", "Ngày về");
                    dgvStatisticGroupDetail.Columns.Add("PriceTour", "Giá vé");
                    dgvStatisticGroupDetail.Columns.Add("Revenue", "Doanh Thu");
                    dgvStatisticGroupDetail.Columns.Add("Cost", "Chi phí");

                    dgvStatisticGroupDetail.Columns["StartDate"].DefaultCellStyle.Format = "dd/MM/yyyy";
                    dgvStatisticGroupDetail.Columns["EndDate"].DefaultCellStyle.Format   = "dd/MM/yyyy";

                    foreach (DataGridViewColumn column in dgvStatisticGroupDetail.Columns)
                    {
                        column.DataPropertyName = column.Name;
                    }

                    dgvStatisticGroupDetail.DataSource = data;
                }));
            }
        }
Exemplo n.º 2
0
        private void LoadGroups(string type = null, string value = null)
        {
            //Back to main thread update UI
            if (InvokeRequired)
            {
                BeginInvoke(new Action(() =>
                {
                    dgvGroupList.ShowLoading(true);
                }));
            }

            //Fill DataTable
            var           groups = GroupBLL.ListGroups(type, value);
            List <object> data   = new List <object>();

            foreach (var group in groups)
            {
                data.Add(new
                {
                    group.Id,
                    group.Name,
                    Tour = group.Tour.Name,
                    group.StartDate,
                    group.EndDate,
                    PriceTour = GroupBLL.GetPriceTourOfGroup(group),
                    Revenue   = GroupBLL.GetRevenueOfGroup(group),
                    Cost      = GroupBLL.GetTotalCostOfGroup(group),
                });
            }

            //Back to main thread update UI
            if (InvokeRequired)
            {
                BeginInvoke(new Action(() =>
                {
                    //Clear loading column
                    dgvGroupList.Columns.Clear();

                    dgvGroupList.Columns.Add("Id", "Mã");
                    dgvGroupList.Columns.Add("Name", "Tên đoàn");
                    dgvGroupList.Columns.Add("Tour", "Tour");
                    dgvGroupList.Columns.Add("StartDate", "Ngày đi");
                    dgvGroupList.Columns.Add("EndDate", "Ngày về");
                    dgvGroupList.Columns.Add("PriceTour", "Giá vé");
                    dgvGroupList.Columns.Add("Revenue", "Doanh Thu");
                    dgvGroupList.Columns.Add("Cost", "Chi phí");

                    dgvGroupList.Columns["StartDate"].DefaultCellStyle.Format = "dd/MM/yyyy";
                    dgvGroupList.Columns["EndDate"].DefaultCellStyle.Format   = "dd/MM/yyyy";

                    dgvGroupList.Columns["PriceTour"].DefaultCellStyle.Format = "N0";
                    dgvGroupList.Columns["Revenue"].DefaultCellStyle.Format   = "N0";
                    dgvGroupList.Columns["Cost"].DefaultCellStyle.Format      = "N0";

                    foreach (DataGridViewColumn column in dgvGroupList.Columns)
                    {
                        column.DataPropertyName = column.Name;
                    }

                    dgvGroupList.DataSource = data;
                }));
            }
        }