private void buttonGenerateReport_Click(object sender, EventArgs e)
        {
            var window = new CreateReportForm {
                Owner = this
            };

            DialogResult result = window.ShowDialog();

            if (result != DialogResult.OK || window.SelectedReportType == null)
            {
                return;
            }
            var dataTable = SqlHelpers.GetDataTable(CBuilder.QueryTransformer.ResultAST.GetSQL(SqlGenerationOptions), SqlQuery);

            switch (window.SelectedReportType)
            {
            case ReportType.ActiveReports14:
                CreateActiveReport(dataTable);
                break;

            case ReportType.Stimulsoft:
                CreateStimulsoftReport(dataTable);
                break;

            case ReportType.FastReport:
                CreateFastReport(dataTable);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Ejemplo n.º 2
0
        private void createNewTab(eTabType type)
        {
            switch (type)
            {
            case eTabType.MAIN_TAB:
                break;

            case eTabType.CUSTOMER_TAB:
            {
                //Hieu
                //Edit
                var newTab = isExitTabPage("Danh sách khách hàng");
                if (newTab == null)
                {
                    newTab = new TabPage("Danh sách khách hàng");
                    var customerList = new CustomerList();
                    customerList.Dock = DockStyle.Fill;
                    newTab.Controls.Add(customerList);

                    tabControl.TabPages.Add(newTab);
                }

                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.VENDOR_TAB:
            {
                var newTab = isExitTabPage("Danh sách nhà cung cấp");
                if (newTab == null)
                {
                    newTab = new TabPage("Danh sách nhà cung cấp");
                    var vendorList = new VendorList();
                    vendorList.Dock = DockStyle.Fill;
                    newTab.Controls.Add(vendorList);

                    tabControl.TabPages.Add(newTab);
                }

                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.ORDER_TAB:
            {
                var customerOrder = new CreateCustomerOrderForm();
                var result        = customerOrder.ShowDialog();
                if (result == DialogResult.OK)
                {
                    var newTab = isExitTabPage("Giao dịch");
                    if (newTab == null)
                    {
                        newTab            = new TabPage("Giao dịch");
                        newTab.AutoScroll = true;
                        var order = new OrderDetailForm(customerOrder.OrderId);
                        order.Dock = DockStyle.Top;
                        newTab.Controls.Add(order);

                        tabControl.TabPages.Add(newTab);
                    }

                    tabControl.SelectedTab = newTab;
                }
                else if (result == DialogResult.Retry)
                {
                    createNewTab(eTabType.CUSTOMER_TAB);
                }

                break;
            }

            case eTabType.CUSTOMER_ORDER_LIST_TAB:
            {
                var selectForm = new SelectOrderForm();
                var result     = selectForm.ShowDialog();

                if (result == DialogResult.OK)
                {
                    var text   = "Đơn hàng " + selectForm.OrderKey;
                    var newTab = isExitTabPage(text);

                    if (newTab == null)
                    {
                        newTab            = new TabPage(text);
                        newTab.AutoScroll = true;
                        var order = new CustomerOrderDetail(selectForm.OrderId);
                        order.Dock = DockStyle.Fill;
                        newTab.Controls.Add(order);

                        tabControl.TabPages.Add(newTab);
                    }

                    tabControl.SelectedTab = newTab;
                }

                break;
            }

            case eTabType.STORE_TAB:
            {
                var text   = "Danh sách kho hàng";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var store = new InventoryList();
                    store.Dock = DockStyle.Fill;
                    newTab.Controls.Add(store);

                    tabControl.TabPages.Add(newTab);
                }
                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.PRODUCT_TAB:
            {
                var text   = "Danh sách mặt hàng";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var product = new ProductList();
                    product.Dock = DockStyle.Fill;
                    newTab.Controls.Add(product);
                    this.newProductMenuItem.Click += product.showDialogAddProduct;         //7ung
                    tabControl.TabPages.Add(newTab);
                }

                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.STAFF_TAB:
            {
                var text   = "Danh sách nhân viên";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var staff = new StaffList();
                    staff.Dock = DockStyle.Fill;
                    newTab.Controls.Add(staff);

                    tabControl.TabPages.Add(newTab);
                }
                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.INOUT_INVENTORY:
            {
                var text   = "Quản lý đơn hàng nhập xuất kho";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var store = new InOutInventoryList();
                    store.Dock = DockStyle.Fill;
                    newTab.Controls.Add(store);

                    tabControl.TabPages.Add(newTab);
                }
                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.INVENTORY_LIST:
            {
                var text   = "Quản lý kho hàng";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var store = new InventoryList();
                    store.Dock = DockStyle.Fill;
                    newTab.Controls.Add(store);

                    tabControl.TabPages.Add(newTab);
                }
                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.VENDOR_ORDER_TAB:
            {
                var vendorOrder = new CreateVendorOrderForm();
                var result      = vendorOrder.ShowDialog();
                if (result == DialogResult.OK)
                {
                    var text   = "Giao dịch đơn hàng " + vendorOrder.DocumentKey;
                    var newTab = isExitTabPage(text);

                    if (newTab == null)
                    {
                        newTab            = new TabPage(text);
                        newTab.AutoScroll = true;
                        var order = new VendorOrderDetailForm(vendorOrder.OrderId);
                        order.Dock = DockStyle.Top;
                        newTab.Controls.Add(order);

                        tabControl.TabPages.Add(newTab);
                    }
                    tabControl.SelectedTab = newTab;
                }
                else if (result == DialogResult.Retry)
                {
                    createNewTab(eTabType.VENDOR_TAB);
                }
                break;
            }

            case eTabType.VENDOR_ORDER_LIST_TAB:
            {
                var selectForm = new SelectVendorOrderForm();
                var result     = selectForm.ShowDialog();

                if (result == DialogResult.OK)
                {
                    var text   = "Đơn hàng " + selectForm.DocumentKey;
                    var newTab = isExitTabPage(text);

                    if (newTab == null)
                    {
                        newTab            = new TabPage(text);
                        newTab.AutoScroll = true;
                        var order = new VendorOrderDetail(selectForm.OrderId);
                        order.DocumentKey = selectForm.DocumentKey;
                        order.Dock        = DockStyle.Fill;
                        newTab.Controls.Add(order);

                        tabControl.TabPages.Add(newTab);
                    }
                    tabControl.SelectedTab = newTab;
                }
                break;
            }

            case eTabType.REVENUE_REPORT_TAB:
            {
                var text   = "Báo cáo doanh thu";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var report = new RevenueReport();
                    report.Dock = DockStyle.Fill;
                    newTab.Controls.Add(report);

                    tabControl.TabPages.Add(newTab);
                }
                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.CUSTOMER_REPORT_TAB:
            {
                var text   = "Báo cáo tình hình khách hàng";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var report = new CustomerReport();
                    report.Dock = DockStyle.Top;
                    newTab.Controls.Add(report);

                    tabControl.TabPages.Add(newTab);
                }
                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.CREATE_BUSINESS_REPORT_TAB:
            {
                var dialogCreate = new CreateReportForm();
                var r            = dialogCreate.ShowDialog();

                if (r == DialogResult.OK)
                {
                    var text   = "Báo cáo chi phí bán hàng";
                    var newTab = isExitTabPage(text);

                    if (newTab == null)
                    {
                        newTab            = new TabPage(text);
                        newTab.AutoScroll = true;
                        var report = new CreateBusinessFee(dialogCreate.DocumentId, true);
                        report.Dock = DockStyle.Top;
                        newTab.Controls.Add(report);

                        tabControl.TabPages.Add(newTab);
                    }
                    tabControl.SelectedTab = newTab;
                }
                break;
            }

            case eTabType.VIEW_BUSINESS_REPORT_TAB:
            {
                var text   = "Xem cáo chi phí bán hàng";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var report = new ViewBusinessFee();
                    report.Dock = DockStyle.Top;
                    newTab.Controls.Add(report);

                    tabControl.TabPages.Add(newTab);
                }
                tabControl.SelectedTab = newTab;
                break;
            }

            case eTabType.INVENTORY_REPORT_TAB:
            {
                var text   = "Báo cáo tồn kho";
                var newTab = isExitTabPage(text);

                if (newTab == null)
                {
                    newTab            = new TabPage(text);
                    newTab.AutoScroll = true;
                    var report = new InventoryReport();
                    report.Dock = DockStyle.Fill;
                    newTab.Controls.Add(report);

                    tabControl.TabPages.Add(newTab);
                }
                tabControl.SelectedTab = newTab;
                break;
            }

            default:
                break;
            }
        }