private void cmdNext_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            Printer lPrinter     = null;
            bool    lPrinterName = false;

            ADODB.Recordset rs = default(ADODB.Recordset);
            short           x  = 0;

            //    On Local Error Resume Next
            if (gID)
            {
                modRecordSet.cnnDB.Execute("UPDATE PrintLocation SET PrintLocation.PrintLocation_Name = '" + Strings.Replace(txtName.Text, "'", "''") + "' WHERE (((PrintLocation.PrintLocationID)=" + gID + "));");
            }
            else
            {
                modRecordSet.cnnDB.Execute("INSERT INTO PrintLocation ( PrintLocation_Name, PrintLocation_Disabled ) SELECT '" + Strings.Replace(txtName.Text, "'", "''") + "', False");
                rs  = modRecordSet.getRS(ref "SELECT Max(PrintLocation.PrintLocationID) AS MaxOfPrintLocationID FROM PrintLocation;");
                gID = rs.Fields(0).Value;
            }
            modRecordSet.cnnDB.Execute("DELETE PrintLocationPrinterLnk.* From PrintLocationPrinterLnk WHERE (((PrintLocationPrinterLnk.PrintLocationPrinterLnk_PrintLocationID)=" + gID + "));");
            for (x = 0; x <= this.lstPrinter.Items.Count - 1; x++)
            {
                if (lstPrinter.GetItemChecked(x))
                {
                    modRecordSet.cnnDB.Execute("INSERT INTO PrintLocationPrinterLnk ( PrintLocationPrinterLnk_PrintLocationID, PrintLocationPrinterLnk_PrinterName ) SELECT " + gID + ", '" + Strings.Replace(GID.GetItemString(ref lstPrinter, ref x), "'", "''") + "';");
                }
            }



            this.Close();
        }
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs            = default(ADODB.Recordset);
            ADODB.Recordset rsMajor       = default(ADODB.Recordset);
            ADODB.Recordset rsMinor       = default(ADODB.Recordset);
            string          majorSQL      = null;
            string          majorSQLgroup = null;
            string          minorSQL      = null;
            string          minorSQLgroup = null;

            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            string sql = null;

            if (Strings.LCase(Convert.ToString(cmbMajor.SelectedIndex)) == Strings.LCase(Convert.ToString(cmbMinor.SelectedIndex)))
            {
                cmbMinor.SelectedIndex = 0;
                System.Windows.Forms.Application.DoEvents();
            }
            switch (Strings.LCase(Convert.ToString(cmbMajor.SelectedIndex)))
            {
            case "supplier":
                majorSQL      = "SELECT Supplier.SupplierID AS sectionAkey, Supplier.Supplier_Name AS sectionAname FROM Supplier ORDER BY Supplier.Supplier_Name;";
                majorSQLgroup = "aStockItem.StockItem_SupplierID";
                break;

            case "pricing group":
                majorSQL      = "SELECT aPricingGroup.PricingGroupID AS sectionAkey, aPricingGroup.PricingGroup_Name AS sectionAname FROM aPricingGroup;";
                majorSQLgroup = "aStockItem.StockItem_PricingGroupID";
                break;

            case "stock group":
                majorSQL      = "SELECT aStockGroup.StockGroupID AS sectionAkey, aStockGroup.StockGroup_Name AS sectionAname FROM aStockGroup;";
                majorSQLgroup = "aStockItem.StockItem_StockGroupID";
                break;

            case "deposit type":
                majorSQL      = "SELECT aDeposit.DepositID AS sectionAkey, aDeposit.Deposit_Name AS sectionAname FROM aDeposit;";
                majorSQLgroup = "aStockItem.StockItem_DepositID";
                break;

            case "shrink type":
                majorSQL      = "SELECT aShrink.ShrinkID AS sectionAkey, aShrink.Shrink_Name AS sectionAname FROM aShrink;";
                majorSQLgroup = "aStockItem.StockItem_ShrinkID";
                break;
            }
            switch (Strings.LCase(Convert.ToString(cmbMinor.SelectedIndex)))
            {
            case "supplier":
                minorSQL      = "SELECT Supplier.SupplierID AS sectionAkey, Supplier.Supplier_Name AS sectionAname FROM Supplier;";
                minorSQLgroup = "aStockItem.StockItem_SupplierID";
                break;

            case "pricing group":
                minorSQL      = "SELECT aPricingGroup.PricingGroupID AS sectionAkey, aPricingGroup.PricingGroup_Name AS sectionAname FROM aPricingGroup;";
                minorSQLgroup = "aStockItem.StockItem_PricingGroupID";
                break;

            case "stock group":
                minorSQL      = "SELECT aStockGroup.StockGroupID AS sectionAkey, aStockGroup.StockGroup_Name AS sectionAname FROM aStockGroup;";
                minorSQLgroup = "aStockItem.StockItem_StockGroupID";
                break;

            case "deposit type":
                minorSQL      = "SELECT aDeposit.DepositID AS sectionAkey, aDeposit.Deposit_Name AS sectionAname FROM aDeposit;";
                minorSQLgroup = "aStockItem.StockItem_DepositID";
                break;

            case "shrink type":
                minorSQL      = "SELECT aShrink.ShrinkID AS sectionAkey, aShrink.Shrink_Name AS sectionAname FROM aShrink;";
                minorSQLgroup = "aStockItem.StockItem_ShrinkID";
                break;
            }
            if (string.IsNullOrEmpty(minorSQL))
            {
                Report.Load("cryGroupSalesMajor.rpt");
                sql = "SELECT " + majorSQLgroup + " AS sectionB, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([exclusiveSum]-[depositSum]) AS price, Sum([exclusiveSum]-[depositSum]) AS content, Sum([exclusiveSum]-[depositSum]-[listCostSum]) AS listProfit, Sum([exclusiveSum]-[depositSum]-[actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost FROM StockList INNER JOIN ";
                sql = sql + "aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY " + majorSQLgroup + ";";
            }
            else
            {
                Report.Load("cryGroupSalesMinor.rpt");
                sql = "SELECT " + majorSQLgroup + " AS sectionA, " + minorSQLgroup + " AS sectionB, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([exclusiveSum]-[depositSum]) AS price, Sum([exclusiveSum]-[depositSum]) AS content, Sum([exclusiveSum]-[depositSum]-[listCostSum]) AS listProfit, Sum([exclusiveSum]-[depositSum]-[actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost FROM StockList INNER JOIN ";
                sql = sql + "aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY " + majorSQLgroup + ", " + minorSQLgroup + ";";
            }
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modReport.getRSreport(ref "SELECT Report.Report_Heading, aCompany.Company_Name FROM aCompany, Report;");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            Report.SetParameterValue("txtDayEnd", rs.Fields("Report_Heading"));
            rs.Close();
            rs = modReport.getRSreport(ref sql);
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            if (rs.BOF | rs.EOF)
            {
                ReportNone.SetParameterValue("txtCompanyName", Report.ParameterFields("txtCompanyName").ToString);
                ReportNone.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString);
                My.MyProject.Forms.frmReportShow.Text = ReportNone.ParameterFields("txtTitle").ToString;
                My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = ReportNone;
                My.MyProject.Forms.frmReportShow.mReport = ReportNone;
                My.MyProject.Forms.frmReportShow.sMode   = "0";
                My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }
            if (string.IsNullOrEmpty(minorSQL))
            {
                rsMajor = modReport.getRSreport(ref majorSQL);
                Report.Database.Tables(1).SetDataSource(rs);
                Report.Database.Tables(2).SetDataSource(rsMajor);
                Report.SetParameterValue("txtTitle", "Group Sales Profit Summary by " + Convert.ToString(cmbMajor.SelectedIndex));
            }
            else
            {
                rsMajor = modReport.getRSreport(ref majorSQL);
                Report.Database.Tables(1).SetDataSource(rsMajor);
                Report.Database.Tables(2).SetDataSource(rs);

                rsMinor = modReport.getRSreport(ref minorSQL);
                Report.Database.Tables(3).SetDataSource(rsMinor);
                Report.SetParameterValue("txtTitle", "Group Sales Profit Summary by " + Convert.ToString(cmbMajor.SelectedIndex) + " by " + GID.GetItemString(ref cmbMinor, ref cmbMinor.SelectedIndex));
            }

            //Report.VerifyOnEveryPrint = True
            My.MyProject.Forms.frmReportShow.Text = Report.ParameterFields("txtTitle").ToString;
            My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report;
            My.MyProject.Forms.frmReportShow.mReport = Report;
            My.MyProject.Forms.frmReportShow.sMode   = "0";
            My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }