Beispiel #1
0
        private void loadStockSales()
        {
            ADODB.Recordset rs      = default(ADODB.Recordset);
            ADODB.Recordset rsStock = default(ADODB.Recordset);
            ADODB.Recordset rsGroup = default(ADODB.Recordset);
            string          sql     = null;

            ADODB.Recordset rsData = default(ADODB.Recordset);
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report     = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            Report.Load("crySalesByShrink.rpt");
            ReportNone.Load("cryNoRecords.rpt");

            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 "SELECT * FROM Link Where LinkID=2 AND Link_SectionID=1");
            if (string.IsNullOrEmpty(rs.Fields("Link_Name").Value))
            {
                Report.ReportDefinition.Sections("Section2").SectionFormat.EnableSuppress = true;
            }
            else
            {
                Report.SetParameterValue("txtFilter", Strings.Replace(rs.Fields("Link_Name").Value, "''", "'"));
            }

            sql = "SELECT aStockItem.StockItemID, aStockItem.StockItem_Name, thejoin.shrink, thejoin.quantity, thejoin.price, thejoin.list, thejoin.actual FROM aStockItem INNER JOIN (SELECT SaleItem.SaleItem_StockItemID AS StockItem, SaleItem.SaleItem_ShrinkQuantity AS shrink, Sum(IIf([SaleItem_Reversal],0-[SaleItem_Quantity],[SaleItem_Quantity])) AS quantity, Sum(([SaleItem_Price]*[SaleItem_Quantity])) AS price, Sum((([SaleItem_ListCost]+[SaleItem_DepositCost])*IIf([SaleItem_Reversal],0-[SaleItem_Quantity],[SaleItem_Quantity]))*(1+[SaleItem_Vat]/100)) AS list, Sum((([SaleItem_ActualCost]+[SaleItem_DepositCost])*IIf([SaleItem_Reversal],0-[SaleItem_Quantity],[SaleItem_Quantity]))*(1+[SaleItem_Vat]/100)) AS actual From SaleItem Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Revoke) = 0)) GROUP BY SaleItem.SaleItem_StockItemID, SaleItem.SaleItem_ShrinkQuantity ) AS thejoin ON aStockItem.StockItemID = thejoin.StockItem ";
            sql = sql + rs.Fields("Link_SQL").Value + " ORDER BY aStockItem.StockItem_Name, thejoin.shrink;";


            rs = modReport.getRSreport(ref sql);

            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;
            }



            Report.Database.Tables(1).SetDataSource(rs);
            //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();
        }
Beispiel #2
0
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As New cryItemGroupCompare
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryItemGroupCompare.rpt");
            ReportNone.Load("cryNoRecords");
            modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=1 AND Link_SectionID=1");
            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT 1, DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID WHERE " + rs.Fields("Link_SQL").Value + ";");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=2 AND Link_SectionID=1");
            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT 2, DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID " + rs.Fields("Link_SQL").Value + " GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;");

            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 "SELECT Link.* From Link Where (((Link.Link_SectionID) = 1)) ORDER BY Link.Link_SectionID;");
            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;
            }
            rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'ddd dd mmm\", \"yyyy') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID;");
            if (rsData.BOF | rsData.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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            //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();
        }
Beispiel #3
0
        private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs  = default(ADODB.Recordset);
            string          sql = null;

            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            Report.Load("cryStockItemPrice.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();
            Report.SetParameterValue("txtFilter", lblHeading.Text);
            Report.SetParameterValue("txtTitle1", "Where Sales Channel = " + cmbChannel.CtlText);

            //Report.Database.SetDataSource(adoPrimaryRS, 3)
            Report.Database.Tables(1).SetDataSource(adoPrimaryRS);
            //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();
        }
        private void report_WHTransfer()
        {
            ADODB.Recordset rs  = default(ADODB.Recordset);
            string          sql = null;

            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            Report.Load("cryWHTransfer.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT Company.Company_Name FROM Company;");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();

            Report.SetParameterValue("txtFrom", lblWHA.Text);
            Report.SetParameterValue("txtTo", lblWHB.Text);
            Report.SetParameterValue("txtPerson", My.MyProject.Forms.frmMenu.lblUser);

            sql = "SELECT HandheldWHTransfer.HandHeldID, StockItem.StockItem_Name, HandheldWHTransfer.Quantity";
            sql = sql + " FROM HandheldWHTransfer INNER JOIN StockItem ON HandheldWHTransfer.HandHeldID = StockItem.StockItemID WHERE (((HandheldWHTransfer.WHouseID)=" + lWHB + "));";
            Debug.Print(sql);
            rs = modRecordSet.getRS(ref sql);

            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = default(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;
            }
            Report.Database.Tables(1).SetDataSource(rs);

            //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();
        }
        private void stockitemGroup()
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            ADODB.Recordset rs  = default(ADODB.Recordset);
            string          sql = null;

            Report.Load("cryStockItemGrouping.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            Report.SetParameterValue("txtTitle", this.Text);
            Report.SetParameterValue("txtFilter", this.lblHeading.Text);
            rs.Close();
            sql = "SELECT StockItem.StockItemID, StockItem.StockItem_Name, StockItem.StockItem_ReceiptName, StockItem.StockItem_Quantity, StockItem.StockItem_ListCost , Deposit.Deposit_Name, StockGroup.StockGroup_Name, Shrink.Shrink_Name, Supplier.Supplier_Name, PricingGroup.PricingGroup_Name FROM (((Deposit INNER JOIN (StockItem INNER JOIN Supplier ON StockItem.StockItem_SupplierID = Supplier.SupplierID) ON Deposit.DepositID = StockItem.StockItem_DepositID) INNER JOIN PricingGroup ON StockItem.StockItem_PricingGroupID = PricingGroup.PricingGroupID) INNER JOIN StockGroup ON StockItem.StockItem_StockGroupID = StockGroup.StockGroupID) INNER JOIN Shrink ON StockItem.StockItem_ShrinkID = Shrink.ShrinkID ";
            sql = sql + gFilterSQL + " ORDER BY StockItem.StockItem_Name;";
            rs  = modRecordSet.getRS(ref sql);
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = default(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;
            }
            //Report.Database.SetDataSource(rs, 3)
            Report.Database.Tables(1).SetDataSource(rs);
            //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();
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
Beispiel #6
0
        private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs  = default(ADODB.Recordset);
            string          sql = null;

            //Dim Report As New cryKeyboardName
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryKeyboardName.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT KeyboardLayout.KeyboardLayout_Name, keyboard.keyboard_Name, KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_Description, keyboard.keyboard_Order, keyboard.keyboard_Show FROM (KeyboardKeyboardLayoutLnk INNER JOIN keyboard ON KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_KeyboardID = keyboard.KeyboardID) INNER JOIN KeyboardLayout ON KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_KeyboardLayoutID = KeyboardLayout.KeyboardLayoutID Where (((KeyboardLayout.KeyboardLayoutID) = " + gParentID + ")) ORDER BY keyboard.keyboard_Order, keyboard.keyboard_Name;");

            //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;
            }
            Report.Database.Tables(0).SetDataSource(rs);
            Report.Database.Tables(1).SetDataSource(rs);
            //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();
        }
        private void stockitemOrderLevels()
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            ADODB.Recordset rs  = default(ADODB.Recordset);
            string          sql = null;

            Report.Load("cryStockItemORderLevels.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            Report.SetParameterValue("txtTitle", this.Text);
            Report.SetParameterValue("txtFilter", this.lblHeading.Text);
            rs.Close();
            sql = "SELECT StockItem.StockItemID, StockItem.StockItem_Name, StockItem.StockItem_Quantity, StockItem.StockItem_MinimumStock, [StockItem_MinimumStock]/[StockItem_Quantity] AS minimumCase, StockItem.StockItem_OrderQuantity, StockItem.StockItem_OrderRounding, StockItem.StockItem_OrderDynamic, [StockItem_Quantity]=[StockItem_OrderQuantity] AS brokenPack FROM StockItem ";
            sql = sql + gFilterSQL + " ORDER BY StockItem.StockItem_Name;";
            rs  = modRecordSet.getRS(ref sql);
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = default(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.CRViewer1.Refresh();
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }
            //Report.Database.SetDataSource(rs, 3)
            Report.Database.Tables(1).SetDataSource(rs);
            //Report.VerifyOnEveryPrint = True
            My.MyProject.Forms.frmReportShow.Text = Report.ParameterFields("txtTitle").ToString;
            My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report;
            My.MyProject.Forms.frmReportShow.CRViewer1.Refresh();
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
Beispiel #8
0
        private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs  = default(ADODB.Recordset);
            string          sql = null;

            ADODB.Recordset rsData = default(ADODB.Recordset);
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report  = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report1 = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            Report.Load("cryNegativeProfit.rpt");
            Report1.Load("crysqZero.rpt");
            string lOrder = null;
            string lWhere = null;

            if (gRS.RecordCount)
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                rs = modRecordSet.getRS(ref "SELECT * FROM Company");
                Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
                rs.Close();

                //Report.VerifyOnEveryPrint = True
                Report.Database.Tables(1).SetDataSource(gRS);
                //Report.Database.SetDataSource(gRS, 3)
                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();
            }
            if (gRSsq.RecordCount)
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
                rs = modRecordSet.getRS(ref "SELECT * FROM Company");
                Report1.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
                rs.Close();

                //Report1.VerifyOnEveryPrint = True
                Report1.Database.Tables(1).SetDataSource(gRSsq);
                //Report1.Database.SetDataSource(gRSsq, 3)
                My.MyProject.Forms.frmReportShow.Text = Report1.ParameterFields("txtTitle").ToString;
                My.MyProject.Forms.frmReportShow.CRViewer1.ReportSource = Report1;
                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();
            }
        }
        private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs     = default(ADODB.Recordset);
            ADODB.Recordset rsQty  = default(ADODB.Recordset);
            ADODB.Recordset RSitem = default(ADODB.Recordset);
            bool            ltype  = false;

            //Dim Report As New cryCashTransaction
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryCashTransaction.rpt");
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            //UPGRADE_WARNING: Couldn't resolve default property of object Report.txtCompanyName. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT * FROM Channel ORDER BY ChannelID");
            while (!(rs.EOF))
            {
                switch (rs.Fields("ChannelID").Value)
                {
                case 1:
                    Report.SetParameterValue("txtCS1", rs.Fields("Channel_Code"));
                    break;

                case 2:
                    Report.SetParameterValue("txtCS2", rs.Fields("Channel_Code"));
                    break;

                case 3:
                    Report.SetParameterValue("txtCS3", rs.Fields("Channel_Code"));
                    break;

                case 4:
                    Report.SetParameterValue("txtCS4", rs.Fields("Channel_Code"));
                    break;

                case 5:
                    Report.SetParameterValue("txtCS5", rs.Fields("Channel_Code"));
                    break;

                case 6:
                    Report.SetParameterValue("txtCS6", rs.Fields("Channel_Code"));
                    break;

                case 7:
                    Report.SetParameterValue("txtCS7", rs.Fields("Channel_Code"));
                    break;

                case 8:
                    Report.SetParameterValue("txtCS8", rs.Fields("Channel_Code"));
                    break;
                }
                rs.moveNext();
            }
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT CashTransaction.*, StockItem.StockItem_Name FROM StockItem INNER JOIN CashTransaction ON StockItem.StockItemID = CashTransaction.CashTransaction_StockItemID;");
            //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();
                //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            //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();
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
Beispiel #10
0
        private static void report_PayoutReason()
        {
            ADODB.Recordset rsDayEnd = default(ADODB.Recordset);
            string lPGID = null;
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryPayout
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryPayout.rpt");
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            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();
            if (Interaction.MsgBox("Do you wish to see All Payouts?", MsgBoxStyle.Question + MsgBoxStyle.YesNo) == MsgBoxResult.Yes) {
                sql = "SELECT Payout.* From Payout ORDER BY Payout.PayoutID;";
            } else {
                lPGID = My.MyProject.Forms.frmPayoutGroupList.getItem();
                sql = "SELECT Payout.* From aPayoutGroup1, Payout WHERE (((aPayoutGroup1.PayoutGroup_Name)=(Left([Payout].[Payout_Narrative],Len([aPayoutGroup1].[PayoutGroup_Name])))) AND ((aPayoutGroup1.PayoutGroupID)=" + lPGID + "));";
            }
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modReport.getRSreport(ref sql);
            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;
            }
            rsDayEnd = modReport.getRSreport(ref "SELECT * FROM DayEnd");
            Report.Database.Tables(1).SetDataSource(rsDayEnd);

            Report.Database.Tables(2).SetDataSource(rs);

            //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();
        }
Beispiel #11
0
        private void loadQTY()
        {
            ADODB.Recordset rs     = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As New cryItemItemCompareQty
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report     = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryItemItemCompareQty.rpt");
            ReportNone.Load("cryNoRecords.rpt");
            modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where Link_SectionID=3");
            while (!(rs.EOF))
            {
                if (!string.IsNullOrEmpty(rs.Fields("Link_SQL").Value))
                {
                    modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT " + rs.Fields("LinkID").Value + ", DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID WHERE " + rs.Fields("Link_SQL").Value + ";");
                }
                rs.moveNext();
            }

            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT theJoin.LinkID, theJoin.DayEndID, 0 FROM LinkItem RIGHT JOIN [SELECT Link.LinkID, DayEnd.DayEndID From Link, DayEnd WHERE (((Link.Link_SQL)<>'') AND ((Link.Link_SectionID)=3))]. AS theJoin ON (LinkItem.LinkItem_DayEndID = theJoin.DayEndID) AND (LinkItem.LinkItem_LinkID = theJoin.LinkID) WHERE (((LinkItem.LinkItem_LinkID) Is Null));");
            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 "SELECT [Link].[LinkID], [Link].[Link_Name], Sum([LinkItem].[LinkItem_Value]) AS SumOfLinkItem_Value FROM Link INNER JOIN LinkItem ON [Link].[LinkID]=[LinkItem].[LinkItem_LinkID] WHERE ((([Link].[Link_SQL])<>'') And (([Link].[Link_SectionID])=3)) GROUP BY [Link].[LinkID], [Link].[Link_Name] ORDER BY [Link].[LinkID];");

            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;
            }
            rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'yyyy mm dd ddd') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID ORDER BY DayEnd.DayEnd_Date;");
            if (rsData.BOF | rsData.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();
                //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            System.Windows.Forms.Application.DoEvents();
            //Report.VerifyOnEveryPrint = True
            System.Windows.Forms.Application.DoEvents();
            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();
        }
Beispiel #12
0
        public void mnuDashboard_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            //Dim Report As New cryMenuSalesCube
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("c:\\4posserver\\Reports\\cryMenuSalesCube.rpt");
            ADODB.Recordset rs = default(ADODB.Recordset);
            decimal lTotal = default(decimal);

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            //money
            rs = modRecordSet.getRS(ref "SELECT Sum(Sale.Sale_Total) AS amount FROM Company INNER JOIN (Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN Sale ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID) ON Company.Company_DayEndID = Sale.Sale_DayEndID WHERE (((Sale.Sale_PaymentType)<>5) AND ((Consignment.ConsignmentID) Is Null) AND ((Consignment_1.ConsignmentID) Is Null));");
            if (Information.IsDBNull(rs.Fields("amount").Value)) {
                Report.SetParameterValue("txtCubeMoney.", "0.00");
            } else {
                Report.SetParameterValue("txtCubeMoney", Strings.FormatNumber(rs.Fields("amount").Value, 2));
            }
            rs.Close();

            //Stock
            rs = modRecordSet.getRS(ref "SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS amount FROM Company INNER JOIN (Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID) ON Company.Company_DayEndID = Sale.Sale_DayEndID WHERE (((SaleItem.SaleItem_Revoke)=False) AND ((Consignment.ConsignmentID) Is Null) AND ((Consignment_1.ConsignmentID) Is Null));");
            if (Information.IsDBNull(rs.Fields("amount").Value)) {
                Report.SetParameterValue("txtCubeStock", "0.00");
            } else {
                Report.SetParameterValue("txtCubeStock", Strings.FormatNumber(rs.Fields("amount").Value, 2));
            }
            rs.Close();

            //Account sales
            rs = modRecordSet.getRS(ref "SELECT Sum(Sale.Sale_Total) AS amount, Sale.Sale_PaymentType FROM Company INNER JOIN (Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN (CustomerTransaction INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID) ON Company.Company_DayEndID = Sale.Sale_DayEndID Where (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 2 Or (CustomerTransaction.CustomerTransaction_TransactionTypeID) = 3) And ((Consignment.ConsignmentID) Is Null) And ((Consignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_PaymentType HAVING (((Sale.Sale_PaymentType)=5));");
            if (Information.IsDBNull(rs.Fields("amount").Value)) {
                Report.SetParameterValue("txtCubeAccountSales", "0.00");
            } else {
                if (rs.RecordCount) {
                    Report.SetParameterValue("txtCubeAccountSales", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                } else {
                    Report.SetParameterValue("txtCubeAccountSales", "0.00");
                }
            }
            rs.Close();

            //Account payments
            rs = modRecordSet.getRS(ref "SELECT Sum(Sale.Sale_Total) AS amount, Sale.Sale_PaymentType FROM Company INNER JOIN (Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN (CustomerTransaction INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID) ON Company.Company_DayEndID = Sale.Sale_DayEndID Where (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 2 Or (CustomerTransaction.CustomerTransaction_TransactionTypeID) = 3) And ((Consignment.ConsignmentID) Is Null) And ((Consignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_PaymentType HAVING (((Sale.Sale_PaymentType)<>5));");
            if (Information.IsDBNull(rs.Fields("amount").Value)) {
                Report.SetParameterValue("txtCubeAccountPayment", "0.00");
            } else {
                if (rs.RecordCount) {
                    Report.SetParameterValue("txtCubeAccountPayment", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                } else {
                    Report.SetParameterValue("txtCubeAccountPayment", "0.00");
                }
            }
            rs.Close();

            //Direct Sales
            rs = modRecordSet.getRS(ref "SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS amount FROM Company INNER JOIN (Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID) ON Company.Company_DayEndID = Sale.Sale_DayEndID WHERE (((SaleItem.SaleItem_Revoke)=False) AND ((Consignment.ConsignmentID) Is Null) AND ((Consignment_1.ConsignmentID) Is Null) AND ((Sale.Sale_PaymentType)<>5));");
            if (Information.IsDBNull(rs.Fields("amount").Value)) {
                Report.SetParameterValue("txtCubeDirect", "0.00");
            } else {
                Report.SetParameterValue("txtCubeDirect", Strings.FormatNumber(rs.Fields("amount").Value, 2));
            }
            rs.Close();

            //Open Tables
            ADODB.Connection cn = new ADODB.Connection();
            cn = modRecordSet.openConnectionInstance(ref "waitron.mdb");
            if (cn == null) {
                Report.SetParameterValue("txtCubeOpenTbl", "Not Found!");
            } else {
                rs = modRecordSet.getRSwaitron(ref "SELECT Sum([TableTranactionItem_price]*[TableTranactionItem_quantity]) AS Amount FROM OpenTable INNER JOIN TableTranactionItem ON (OpenTable.OpenTable_TableID = TableTranactionItem.TableTranactionItem_TableID) AND (OpenTable.OpenTable_WaitronID = TableTranactionItem.TableTranactionItem_WaitronID);", ref cn);
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtCubeOpenTbl", "0.00");
                } else {
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtCubeOpenTbl", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                    } else {
                        Report.SetParameterValue("txtCubeOpenTbl", "0.00");
                    }
                }
                rs.Close();
            }

            Report.SetParameterValue("txtCubeAccount", Strings.FormatNumber(Report.ParameterFields("txtCubeAccountSales").ToString - Report.ParameterFields("txtCubeAccountPayment").ToString, 2));
            //    Report.txtCubeDirect.SetText FormatNumber(Report.txtCubeMoney.Text - Report.txtCubeAccountPayment.Text, 2)

            //Profit Summary

            rs = modRecordSet.getRS(ref "SELECT Sum(([SaleItem_ActualCost]*[SaleItem_Quantity])) AS actualExcl, Sum(([SaleItem_ActualCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS actualIncl, Sum(([SaleItem_ListCost]*[SaleItem_Quantity])) AS listExcl, Sum(([SaleItem_ListCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS listIncl, Sum([SaleItem_Price]*[SaleItem_Quantity]/(1+[SaleItem_Vat]/100)) AS priceExcl, Sum([SaleItem_Price]*[SaleItem_Quantity]) AS priceIncl, Sum(([SaleItem_DepositCost]*[SaleItem_Quantity])) AS depositExcl, Sum(([SaleItem_DepositCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS depositIncl FROM (Sale INNER JOIN Company ON Sale.Sale_DayEndID = Company.Company_DayEndID) INNER JOIN (SaleItem LEFT JOIN Consignment ON SaleItem.SaleItem_SaleID = Consignment.Consignment_SaleID) ON Sale.SaleID = SaleItem.SaleItem_SaleID WHERE (((SaleItem.SaleItem_Reversal)=False) AND ((SaleItem.SaleItem_DepositType)=0) AND ((SaleItem.SaleItem_Revoke)=False) AND ((Consignment.ConsignmentID) Is Null));");
            Report.SetParameterValue("txtLEcost", Strings.FormatNumber(rs.Fields("listExcl").Value, 0));
            Report.SetParameterValue("txtAEcost", Strings.FormatNumber(rs.Fields("actualExcl").Value, 0));
            Report.SetParameterValue("txtLIcost", Strings.FormatNumber(rs.Fields("listIncl").Value, 0));
            Report.SetParameterValue("txtAIcost", Strings.FormatNumber(rs.Fields("actualIncl").Value, 0));
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLEcost").ToString))
                Report.SetParameterValue("txtLEcost", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLIcost").ToString))
                Report.SetParameterValue("txtLIcost", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAEcost").ToString))
                Report.SetParameterValue("txtAEcost", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAIcost").ToString))
                Report.SetParameterValue("txtAIcost", "0");

            Report.SetParameterValue("txtLEdeposit", Strings.FormatNumber(rs.Fields("depositExcl").Value, 0));
            Report.SetParameterValue("txtLIdeposit", Strings.FormatNumber(rs.Fields("depositIncl").Value, 0));
            Report.SetParameterValue("txtAEdeposit", Strings.FormatNumber(rs.Fields("depositExcl").Value, 0));
            Report.SetParameterValue("txtAIdeposit", Strings.FormatNumber(rs.Fields("depositIncl").Value, 0));
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLEdeposit").ToString))
                Report.SetParameterValue("txtLEdeposit", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLIdeposit").ToString))
                Report.SetParameterValue("txtLIdeposit", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAEdeposit").ToString))
                Report.SetParameterValue("txtAEdeposit", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAIdeposit").ToString))
                Report.SetParameterValue("txtAIdeposit", "0");

            Report.SetParameterValue("txtLEcontent", Strings.FormatNumber(rs.Fields("priceExcl").Value - rs.Fields("depositExcl").Value, 0));
            Report.SetParameterValue("txtLIcontent", Strings.FormatNumber(rs.Fields("priceIncl").Value - rs.Fields("depositIncl").Value, 0));
            Report.SetParameterValue("txtAEcontent", Strings.FormatNumber(rs.Fields("priceExcl").Value - rs.Fields("depositExcl").Value, 0));
            Report.SetParameterValue("txtAIcontent", Strings.FormatNumber(rs.Fields("priceIncl").Value - rs.Fields("depositIncl").Value, 0));
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLEcontent").ToString))
                Report.SetParameterValue("txtLEcontent", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLIcontent").ToString))
                Report.SetParameterValue("txtLIcontent", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAEcontent").ToString))
                Report.SetParameterValue("txtAEcontent", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAIcontent").ToString))
                Report.SetParameterValue("txtAIcontent", "0");

            Report.SetParameterValue("txtLEProfit", Strings.FormatNumber((rs.Fields("priceExcl").Value - rs.Fields("depositExcl").Value) - (rs.Fields("listExcl")).Value, 0));
            Report.SetParameterValue("txtLIProfit", Strings.FormatNumber((rs.Fields("priceIncl").Value - rs.Fields("depositIncl").Value) - (rs.Fields("listIncl")).Value, 0));
            Report.SetParameterValue("txtAEProfit", Strings.FormatNumber((rs.Fields("priceExcl").Value - rs.Fields("depositExcl").Value) - (rs.Fields("actualExcl")).Value, 0));
            Report.SetParameterValue("txtAIProfit", Strings.FormatNumber((rs.Fields("priceIncl").Value - rs.Fields("depositIncl").Value) - (rs.Fields("actualIncl")).Value, 0));
            if (Convert.ToDecimal(Report.ParameterFields("txtLEcost").ToString) == 0) {
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLEProfit").ToString))
                    Report.SetParameterValue("txtLEProfit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLIProfit").ToString))
                    Report.SetParameterValue("txtLIProfit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAEProfit").ToString))
                    Report.SetParameterValue("txtAEProfit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAIProfit").ToString))
                    Report.SetParameterValue("txtAIProfit", "0");
            } else {
                Report.SetParameterValue("txtLEPerc", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtLEProfit").ToString) / Convert.ToDecimal(Report.ParameterFields("txtLEcost").ToString) * 100, 2) + "%");
                Report.SetParameterValue("txtLIPerc", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtLIProfit").ToString) / Convert.ToDecimal(Report.ParameterFields("txtLIcost").ToString) * 100, 2) + "%");
                Report.SetParameterValue("txtAEPerc", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtAEProfit").ToString) / Convert.ToDecimal(Report.ParameterFields("txtAEcost").ToString) * 100, 2) + "%");
                Report.SetParameterValue("txtAIPerc", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtAIProfit").ToString) / Convert.ToDecimal(Report.ParameterFields("txtAIcost").ToString) * 100, 2) + "%");
            }
            Report.SetParameterValue("txtLEtotalProfit", Strings.FormatNumber(rs.Fields("priceExcl").Value - rs.Fields("listExcl").Value - rs.Fields("depositExcl").Value, 0));
            Report.SetParameterValue("txtLItotalProfit", Strings.FormatNumber(rs.Fields("priceIncl").Value - rs.Fields("listIncl").Value - rs.Fields("depositIncl").Value, 0));
            Report.SetParameterValue("txtAEtotalProfit", Strings.FormatNumber(rs.Fields("priceExcl").Value - rs.Fields("actualExcl").Value - rs.Fields("depositExcl").Value, 0));
            Report.SetParameterValue("txtAItotalProfit", Strings.FormatNumber(rs.Fields("priceIncl").Value - rs.Fields("actualIncl").Value - rs.Fields("depositIncl").Value, 0));
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLEtotalProfit").ToString))
                Report.SetParameterValue("txtLEtotalProfit", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLItotalProfit").ToString))
                Report.SetParameterValue("txtLItotalProfit", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAEtotalProfit").ToString))
                Report.SetParameterValue("txtAEtotalProfit", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAItotalProfit").ToString))
                Report.SetParameterValue("txtAItotalProfit", "0");

            Report.SetParameterValue("txtLEtotal", Strings.FormatNumber(rs.Fields("priceExcl").Value, 0));
            Report.SetParameterValue("txtLItotal", Strings.FormatNumber(rs.Fields("priceIncl").Value, 0));
            Report.SetParameterValue("txtAEtotal", Strings.FormatNumber(rs.Fields("priceExcl").Value, 0));
            Report.SetParameterValue("txtAItotal", Strings.FormatNumber(rs.Fields("priceIncl").Value, 0));
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLEtotal").ToString))
                Report.SetParameterValue("txtLEtotal", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtLItotal").ToString))
                Report.SetParameterValue("txtLItotal", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAEtotal").ToString))
                Report.SetParameterValue("txtAEtotal", "0");
            if (string.IsNullOrEmpty(Report.ParameterFields("txtAItotal").ToString))
                Report.SetParameterValue("txtAItotal", "0");

            if (Convert.ToDecimal(Report.ParameterFields("txtLEcost").ToString) == 0) {
            } else {
                Report.SetParameterValue("txtLEtotalPerc", Strings.FormatNumber((1 - (rs.Fields("listExcl").Value + rs.Fields("depositExcl").Value) / rs.Fields("priceExcl").Value) * 100, 2) + "%");
                Report.SetParameterValue("txtLItotalPerc", Strings.FormatNumber((1 - (rs.Fields("listIncl").Value + rs.Fields("depositIncl").Value) / rs.Fields("priceIncl").Value) * 100, 2) + "%");
                Report.SetParameterValue("txtAEtotalPerc", Strings.FormatNumber((1 - (rs.Fields("actualExcl").Value + rs.Fields("depositExcl").Value) / rs.Fields("priceExcl").Value) * 100, 2) + "%");
                Report.SetParameterValue("txtAItotalPerc", Strings.FormatNumber((1 - (rs.Fields("actualIncl").Value + rs.Fields("depositIncl").Value) / rs.Fields("priceIncl").Value) * 100, 2) + "%");
            }

            CrystalReportViewer1.ReportSource = Report;
            CrystalReportViewer1.Show();
            CrystalReportViewer1.Refresh();
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;

            tmrReportCancel.Enabled = true;

            System.Windows.Forms.Application.DoEvents();
            gIndex = -1;
            Text1.Focus();
            tmrMenuShow_Tick(tmrMenuShow, new System.EventArgs());
        }
Beispiel #13
0
        private static void report_GRVDetails()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsGRVItem = default(ADODB.Recordset);
            ADODB.Recordset rsGRVItemReturn = default(ADODB.Recordset);
            ADODB.Recordset rsGRVDeposit = default(ADODB.Recordset);
            ADODB.Recordset rsGRVDepositReturn = default(ADODB.Recordset);
            ADODB.Recordset rsGRVMain = default(ADODB.Recordset);
            ADODB.Recordset rsGRVPricing = default(ADODB.Recordset);

            string sql = null;
            //Dim Report As New cryGRVDetails
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryGRVDetails.rpt");
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            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();

            //New sql
            //Set rsGRVItem = getRSreport("SELECT aGRV.GRVID,Sum(IIf([GRVItem_Return],0,[GRVItem_DepositCost]*[GRVItem_Quantity])) AS depositExcl, Sum(IIf([GRVItem_Return],0,((((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100))))) AS inclusive,Sum(IIf([GRVItem_Return],0,(((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])))) AS exclusive, Sum(IIf([GRVItem_Return],0,([GRVItem_DepositCost]*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100))) AS depositIncl FROM (aGRV INNER JOIN DayEnd ON aGRV.GRV_DayEndID = DayEnd.DayEndID) INNER JOIN aGRVItem ON aGRV.GRVID = aGRVItem.GRVItem_GRVID Where (((aGRV.GRV_GRVStatusID) = 3)) AND (GRVItem_StockItemQuantity<>0) GROUP BY aGRV.GRVID;")
            //Old

            // not showing Returned VAT   Set rsGRVItem = getRSreport("SELECT aGRV.GRVID, Sum(IIf([GRVItem_Return],0,(((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])))) AS exclusive, Sum(IIf([GRVItem_Return],0,((((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100))))) AS inclusive, Sum(IIf([GRVItem_Return],0,[GRVItem_DepositCost]*[GRVItem_Quantity])) AS depositExcl, Sum(IIf([GRVItem_Return],0,([GRVItem_DepositCost]*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100))) AS depositIncl FROM (aGRV INNER JOIN DayEnd ON aGRV.GRV_DayEndID = DayEnd.DayEndID) LEFT JOIN aGRVItem ON aGRV.GRVID = aGRVItem.GRVItem_GRVID Where (((aGRV.GRV_GRVStatusID) = 3) AND (GRVItem_StockItemQuantity <> 0)) GROUP BY aGRV.GRVID;")
            sql = "SELECT aGRV.GRVID, Sum(IIf([GRVItem_Return],0-(((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])),(((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])))) AS exclusive, Sum(IIf([GRVItem_Return],0-((((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100))),((((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100))))) AS inclusive, Sum(IIf([GRVItem_Return],0-([GRVItem_DepositCost]*[GRVItem_Quantity]),[GRVItem_DepositCost]*[GRVItem_Quantity])) AS depositExcl, ";
            sql = sql + "Sum(IIf([GRVItem_Return],0-(([GRVItem_DepositCost]*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100)),([GRVItem_DepositCost]*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100))) AS depositIncl FROM (aGRV INNER JOIN DayEnd ON aGRV.GRV_DayEndID = DayEnd.DayEndID) ";
            sql = sql + "LEFT JOIN aGRVItem ON aGRV.GRVID = aGRVItem.GRVItem_GRVID Where (((aGRV.GRV_GRVStatusID) = 3) AND (GRVItem_StockItemQuantity <> 0)) GROUP BY aGRV.GRVID;";
            rsGRVItem = modReport.getRSreport(ref sql);
            if (rsGRVItem.BOF | rsGRVItem.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;
            }

            rsGRVItemReturn = modReport.getRSreport(ref "SELECT aGRV.GRVID, Sum(IIf([GRVItem_Return],(((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])),0)) AS exclusive, Sum(IIf([GRVItem_Return],((((([GRVItem_PackSize]/[GRVItem_StockItemQuantity]*[GRVItem_ContentCost])-[GRVItem_DiscountAmount])*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100))),0)) AS inclusive, Sum(IIf([GRVItem_Return],[GRVItem_DepositCost]*[GRVItem_Quantity],0)) AS depositExcl, Sum(IIf([GRVItem_Return],([GRVItem_DepositCost]*[GRVItem_Quantity])*(1+[GRVItem_VatRate]/100),0)) AS depositIncl FROM (aGRV INNER JOIN DayEnd ON aGRV.GRV_DayEndID = DayEnd.DayEndID) LEFT JOIN aGRVItem ON aGRV.GRVID = aGRVItem.GRVItem_GRVID Where (((aGRV.GRV_GRVStatusID) = 3)) GROUP BY aGRV.GRVID;");
            if (rsGRVItemReturn.BOF | rsGRVItemReturn.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;
            }

            rsGRVDeposit = modReport.getRSreport(ref "SELECT aGRV.GRVID, Sum(IIf([GRVDeposit_Return],0,(IIf([GRVDeposit_Type]=1 Or [GRVDeposit_Type]=3,[GRVDeposit_Quantity]*([GRVDeposit_CaseQuantity]*[GRVDeposit_UnitCost]*(1+[GRVDeposit_VatRate]/100)),0))+(IIf([GRVDeposit_Type]=2 Or [GRVDeposit_Type]=3,[GRVDeposit_quantity]*([GRVDeposit_CaseCost]*(1+[GRVDeposit_VatRate]/100)),0)))) AS inclusiveDepositReturn, Sum(IIf([GRVDeposit_Return],0,(IIf([GRVDeposit_Type]=1 Or [GRVDeposit_Type]=3,[GRVDeposit_Quantity]*([GRVDeposit_CaseQuantity]*[GRVDeposit_UnitCost]),0))+(IIf([GRVDeposit_Type]=2 Or [GRVDeposit_Type]=3,[GRVDeposit_quantity]*([GRVDeposit_CaseCost]),0)))) AS exclusiveDepositReturn FROM (aGRV LEFT JOIN aGRVDeposit ON aGRV.GRVID = aGRVDeposit.GRVDeposit_GRVID) INNER JOIN DayEnd ON aGRV.GRV_DayEndID = DayEnd.DayEndID Where (((aGRV.GRV_GRVStatusID) = 3)) GROUP BY aGRV.GRVID;");
            if (rsGRVDeposit.BOF | rsGRVDeposit.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;
            }

            rsGRVDepositReturn = modReport.getRSreport(ref "SELECT aGRV.GRVID, Sum(IIf([GRVDeposit_Return],(IIf([GRVDeposit_Type]=1 Or [GRVDeposit_Type]=3,[GRVDeposit_Quantity]*([GRVDeposit_CaseQuantity]*[GRVDeposit_UnitCost]*(1+[GRVDeposit_VatRate]/100)),0))+(IIf([GRVDeposit_Type]=2 Or [GRVDeposit_Type]=3,[GRVDeposit_quantity]*([GRVDeposit_CaseCost]*(1+[GRVDeposit_VatRate]/100)),0)),0)) AS inclusiveDepositReturn, Sum(IIf([GRVDeposit_Return],(IIf([GRVDeposit_Type]=1 Or [GRVDeposit_Type]=3,[GRVDeposit_Quantity]*([GRVDeposit_CaseQuantity]*[GRVDeposit_UnitCost]),0))+(IIf([GRVDeposit_Type]=2 Or [GRVDeposit_Type]=3,[GRVDeposit_quantity]*([GRVDeposit_CaseCost]),0)),0)) AS exclusiveDepositReturn FROM (aGRV LEFT JOIN aGRVDeposit ON aGRV.GRVID = aGRVDeposit.GRVDeposit_GRVID) INNER JOIN DayEnd ON aGRV.GRV_DayEndID = DayEnd.DayEndID Where (((aGRV.GRV_GRVStatusID) = 3)) GROUP BY aGRV.GRVID;");
            if (rsGRVDepositReturn.BOF | rsGRVDepositReturn.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;
            }

            rsGRVMain = modReport.getRSreport(ref "SELECT aGRV.GRVID, aGRV.GRV_InvoiceInclusive, aGRV.GRV_InvoiceVat, aGRV.GRV_InvoiceDiscount, aGRV.GRV_SundriesPlus, aGRV.GRV_SundriesMinus, aGRV.GRV_ContentExclusive, ([GRV_ContentExclusive]*(1+[GRV_Ullage]/100)-[GRV_ContentExclusive]) AS Ullage, (1+[GRV_InvoiceVat]/([GRV_InvoiceInclusive]-[GRV_InvoiceVat])) AS vat, Supplier.SupplierID, Supplier.Supplier_Name, aPurchaseOrder.PurchaseOrder_Reference, aGRV.GRV_InvoiceNumber, aGRV.GRV_InvoiceDate FROM ((aGRV INNER JOIN DayEnd ON aGRV.GRV_DayEndID = DayEnd.DayEndID) INNER JOIN aPurchaseOrder ON aGRV.GRV_PurchaseOrderID = aPurchaseOrder.PurchaseOrderID) INNER JOIN Supplier ON aPurchaseOrder.PurchaseOrder_SupplierID = Supplier.SupplierID WHERE (((aGRV.GRV_GRVStatusID)=3) AND ((aGRV.GRV_InvoiceInclusive)<>0));");
            if (rsGRVMain.BOF | rsGRVMain.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;
            }

            sql = "SELECT aGRV.GRVID, Sum((([GRVItem_PackSize]/[GRVItem_StockItemQuantity])*[GRVItem_ContentCost]-[GRVItem_DiscountAmount])*[GRVItem_Quantity]*(IIf([GRVItem_Return],-1,1))) AS exclusive, Sum((([GRVItem_PackSize]/[GRVItem_StockItemQuantity])*[GRVItem_ContentCost]-[GRVItem_DiscountAmount])*[GRVItem_Quantity]*(IIf([GRVItem_Return],-1,1))*(1+[GRVItem_VatRate]/100)) AS inclusive, Sum((([GRVItem_PackSize]/[GRVItem_StockItemQuantity])*[GRVItem_ContentCost])*[GRVItem_Quantity]*(IIf([GRVItem_Return],-1,1))) AS PriceExcl, Sum((([GRVItem_PackSize]/[GRVItem_StockItemQuantity])*[GRVItem_ContentCost])*[GRVItem_Quantity]*(IIf([GRVItem_Return],-1,1))*(1+[GRVItem_VatRate]/100)) AS PriceIncl, Sum([DayEndStockItemLnk_ListCost]*[GRVItem_PackSize]*[GRVItem_Quantity]*(IIf([GRVItem_Return],-1,1))) AS listExcl, Sum([DayEndStockItemLnk_ListCost]*[GRVItem_PackSize]*[GRVItem_Quantity]*(IIf([GRVItem_Return],-1,1))*(1+[GRVItem_VatRate]/100)) AS listIncl, ";
            sql = sql + "Sum([DayEndStockItemLnk_ActualCost]*[GRVItem_PackSize]*[GRVItem_Quantity]*(IIf([GRVItem_Return],-1,1))*(1+[GRVItem_VatRate]/100)) AS actualIncl, Sum([DayEndStockItemLnk_ActualCost]*[GRVItem_PackSize]*[GRVItem_Quantity]*(IIf([GRVItem_Return],-1,1))) AS actualExcl FROM DayEndStockItemLnk INNER JOIN ((aGRV INNER JOIN DayEnd ON aGRV.GRV_DayEndID = DayEnd.DayEndID) INNER JOIN aGRVItem ON aGRV.GRVID = aGRVItem.GRVItem_GRVID) ON (DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aGRVItem.GRVItem_StockItemID) AND (DayEndStockItemLnk.DayEndStockItemLnk_DayEndID = aGRV.GRV_DayEndID) Where (((aGRV.GRV_GRVStatusID) = 3) AND (GRVItem_StockItemQuantity <> 0)) GROUP BY aGRV.GRVID;";
            rsGRVPricing = modReport.getRSreport(ref sql);
            if (rsGRVPricing.BOF | rsGRVPricing.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;
            }

            Report.Database.Tables(1).SetDataSource(rsGRVItem);
            Report.Database.Tables(2).SetDataSource(rsGRVItemReturn);
            Report.Database.Tables(3).SetDataSource(rsGRVDeposit);
            Report.Database.Tables(4).SetDataSource(rsGRVDepositReturn);
            Report.Database.Tables(5).SetDataSource(rsGRVMain);
            Report.Database.Tables(6).SetDataSource(rsGRVPricing);

            //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();
        }
Beispiel #14
0
        private static void report_CustomerMovementCD()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryCustomerMovementCD
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryCustomerMovementCD.rpt");
            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();
            //Set rs = getRSreport("SELECT aCustomer.Customer_InvoiceName, CustomerTransaction.CustomerTransaction_PersonName, DayEnd.DayEnd_Date, Sale.Sale_DatePOS, CustomerTransaction.CustomerTransaction_TransactionTypeID, Sale.Sale_Total, IIf([CustomerTransaction_TransactionTypeID]=2,[Sale_Total],Null) AS purchase, IIf([CustomerTransaction_TransactionTypeID]<>2,0-[Sale_Total],Null) AS payment, IIf([CustomerTransaction_TransactionTypeID]=2,[Sale_Total],0-[Sale_Total]) AS total FROM ((aCustomer INNER JOIN CustomerTransaction ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) INNER JOIN DayEnd ON CustomerTransaction.CustomerTransaction_DayEndID = DayEnd.DayEndID ORDER BY aCustomer.Customer_InvoiceName, CustomerTransaction.CustomerTransactionID;")
            //changed to aCustomer1 from aCustomer cuz it was not loading all the data of customers   Set rs = getRSreport("SELECT aCustomer.Customer_InvoiceName, CustomerTransaction.CustomerTransaction_PersonName, DayEnd.DayEnd_Date, Sale.Sale_DatePOS, CustomerTransaction.CustomerTransaction_TransactionTypeID, IIf([CustomerTransaction_TransactionTypeID]=8,[CustomerTransaction_Amount],IIf([CustomerTransaction_TransactionTypeID]<>2,0-[Sale_Total],Null)) AS payment, IIf([CustomerTransaction_TransactionTypeID]=2,[Sale_Total],Null) AS purchase, IIf([CustomerTransaction_TransactionTypeID]=2,[Sale_Total],0-[Sale_Total]) AS total FROM ((aCustomer INNER JOIN CustomerTransaction ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) INNER JOIN DayEnd ON CustomerTransaction.CustomerTransaction_DayEndID = DayEnd.DayEndID ORDER BY aCustomer.Customer_InvoiceName, CustomerTransaction.CustomerTransactionID;")
            sql = "SELECT aCustomer1.Customer_InvoiceName, CustomerTransaction.CustomerTransaction_PersonName, DayEnd.DayEnd_Date, CustomerTransaction.CustomerTransaction_Date, CustomerTransaction.CustomerTransaction_TransactionTypeID, IIf([CustomerTransaction_TransactionTypeID]=3,[CustomerTransaction_Amount],0) AS ePay, IIf([CustomerTransaction_TransactionTypeID]=4,[CustomerTransaction_Amount],0) AS Debit, IIf([CustomerTransaction_TransactionTypeID]=5,[CustomerTransaction_Amount],0) AS Credit, (ePay+Debit+Credit) AS total";
            sql = sql + " FROM (aCustomer1 INNER JOIN CustomerTransaction ON aCustomer1.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) INNER JOIN DayEnd ON CustomerTransaction.CustomerTransaction_DayEndID = DayEnd.DayEndID Where (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 3)) Or (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 4)) Or (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 5)) ORDER BY aCustomer1.Customer_InvoiceName, CustomerTransaction.CustomerTransactionID;";
            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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            //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();
        }
Beispiel #15
0
        private void mnuMoney_Click()
        {
            tmrReportCancel.Enabled = false;
            //Dim Report As New cryMenuMoney
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryMenuMoney.rpt");
            ADODB.Recordset rs = default(ADODB.Recordset);
            decimal lTotal = default(decimal);

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            //get payoutTotal
            rs = modRecordSet.getRS(ref "SELECT Sum(Payout.Payout_Amount) AS amount FROM Company INNER JOIN Payout ON Company.Company_DayEndID = Payout.Payout_DayEndID;");
            if (Information.IsDBNull(rs.Fields("amount").Value)) {
                Report.SetParameterValue("txtPayout", "0.00");
            } else {
                Report.SetParameterValue("txtPayout", Strings.FormatNumber(rs.Fields("amount").Value, 2));
            }
            rs.Close();

            //get outages
            rs = modRecordSet.getRS(ref "SELECT Sum((([Declaration_Cash]+[Declaration_Cheque]+[Declaration_Card]-[Declaration_Payout])-([Declaration_CashServer]+[Declaration_ChequeServer]+[Declaration_CardServer]-[Declaration_PayoutServer]))) AS amount FROM Company INNER JOIN Declaration ON Company.Company_DayEndID = Declaration.Declaration_DayEndID;");
            if (Information.IsDBNull(rs.Fields("amount").Value)) {
                Report.SetParameterValue("txtOutage", "0.00");
            } else {
                Report.SetParameterValue("txtOutage", Strings.FormatNumber(rs.Fields("amount").Value, 2));
            }
            rs.Close();

            //do money movement
            lTotal = 0;
            rs = modRecordSet.getRS(ref "SELECT Sale.Sale_PaymentType, Sum(Sale.Sale_Total) AS amount FROM Company INNER JOIN (Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN Sale ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID) ON Company.Company_DayEndID = Sale.Sale_DayEndID  Where (((Consignment.ConsignmentID) Is Null) And ((Consignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_PaymentType;");
            while (!(rs.EOF)) {
                switch (rs.Fields("Sale_PaymentType").Value) {
                    case 1:
                        Report.SetParameterValue("txtMoneyCash", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                        lTotal = lTotal + rs.Fields("amount").Value;
                        break;
                    case 2:
                        Report.SetParameterValue("txtMoneyCRcard", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                        lTotal = lTotal + rs.Fields("amount").Value;
                        break;
                    case 3:
                        Report.SetParameterValue("txtMoneyDRcard", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                        lTotal = lTotal + rs.Fields("amount").Value;
                        break;
                    case 4:
                        Report.SetParameterValue("txtMoneyCheque", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                        lTotal = lTotal + rs.Fields("amount").Value;
                        break;
                }
                rs.MoveNext();
            }
            rs.Close();
            Report.SetParameterValue("txtMoneyTotal", Strings.FormatNumber(lTotal, 2));
            Report.SetParameterValue("txtMoneyTill", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtMoneyTotal").ToString) + Convert.ToDecimal(Report.ParameterFields("txtOutage").ToString) - Convert.ToDecimal(Report.ParameterFields("txtPayout").ToString)), 2);

            CrystalReportViewer1.ReportSource = Report;
            CrystalReportViewer1.Refresh();
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            tmrReportCancel.Enabled = true;
        }
Beispiel #16
0
        private static void report_Salespastel()
        {
            int intF = 0;
            CrystalDecisions.CrystalReports.Engine.Groups rDisplay_F = default(CrystalDecisions.CrystalReports.Engine.Groups);
            decimal vVatSales = default(decimal);
            string sql2 = null;
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            bool lMode = false;
            decimal lPasteCurr = default(decimal);
            decimal vInSales = default(decimal);
            decimal vExSales = default(decimal);
            decimal lTotal = default(decimal);
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsSale = default(ADODB.Recordset);
            ADODB.Recordset rsPTotals = default(ADODB.Recordset);
            Report.Load("cryPastelCube.rpt");

            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount=0,HomeAmount=0,PastelDate=#" + Convert.ToDateTime(DateAndTime.Today) + "#, Reference = '4POS'");

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            ADODB.Recordset rsPTotalss = default(ADODB.Recordset);
            if (modReport.openConnectionReport()) {
                rs = modReport.getRSreport(ref "SELECT aCompany.Company_Name, Report.Report_Heading FROM aCompany, Report;");
                Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
                Report.SetParameterValue("txtFilter", rs.Fields("Report_Heading"));

                //get payoutTotal
                rs = modReport.getRSreport(ref "SELECT Sum(Payout.Payout_Amount) AS [amount] FROM Payout;");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtPayout", "0.00");
                    Report.SetParameterValue("txtPayout1", "0.00");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + ",HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 18");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + ",HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 19");

                } else {
                    Report.SetParameterValue("txtPayout", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                    Report.SetParameterValue("txtPayout1", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 18");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 19");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 18");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 19");
                }
                rs.Close();
                //get outages
                rs = modReport.getRSreport(ref "SELECT Sum(([Declaration_Cash]+[Declaration_Cheque]+[Declaration_Card]-[Declaration_Payout])-([Declaration_CashServer]+[Declaration_ChequeServer]+[Declaration_CardServer]-[Declaration_PayoutServer])) AS amount FROM Declaration;");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtOutage", "0.00");
                    Report.SetParameterValue("txtOutage1", "0.00");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 5");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 6");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 5");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 6");
                } else {
                    if (rs.Fields("amount").Value < 0) {
                        Report.SetParameterValue("txtOutage", Strings.FormatNumber(-1 * rs.Fields("amount").Value, 2));
                        Report.SetParameterValue("txtOutage1", Strings.FormatNumber(-1 * rs.Fields("amount").Value, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 5");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 6");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 5");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 6");
                    } else {
                        Report.SetParameterValue("txtOutage", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                        Report.SetParameterValue("txtOutage1", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 5");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 6");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 5");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 6");
                    }
                }
                rs.Close();
                //get account movement
                lTotal = 0;
                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Total) AS amount, Sale.Sale_PaymentType, Sum([Sale_Total]-[Sale_Discount]) AS Subtotal, Sum(Sale.Sale_Discount) AS discount FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (CustomerTransaction INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 2 Or (CustomerTransaction.CustomerTransaction_TransactionTypeID) = 3) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_PaymentType;");
                while (!(rs.EOF)) {
                    switch (rs.Fields("Sale_PaymentType").Value) {
                        case 5:
                            //Report.txtCubeAccountSales.SetText FormatNumber(rs("subtotal"), 2)
                            Report.SetParameterValue("txtAccountSales", Strings.FormatNumber(rs.Fields("subtotal").Value, 2));
                            Report.SetParameterValue("txtAccountSales1", Strings.FormatNumber(rs.Fields("subtotal").Value, 2));
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("subtotal").Value, 2)) + " WHERE IDDescription = 7");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("subtotal").Value, 2)) + " WHERE IDDescription = 8");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("subtotal").Value, 2)) + " WHERE IDDescription = 7");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("subtotal").Value, 2)) + " WHERE IDDescription");
                            break;
                        case 1:
                            //Report.txtAccountCash.SetText FormatNumber(0 - rs("amount"), 2)
                            lTotal = lTotal - rs.Fields("amount").Value;
                            break;
                        case 2:
                            //Report.txtAccountCRcard.SetText FormatNumber(0 - rs("amount"), 2)
                            lTotal = lTotal - rs.Fields("amount").Value;
                            break;
                        case 3:
                            //Report.txtAccountDRcard.SetText FormatNumber(0 - rs("amount"), 2)
                            lTotal = lTotal - rs.Fields("amount").Value;
                            break;
                        case 4:
                            //Report.txtAccountCheque.SetText FormatNumber(0 - rs("amount"), 2)
                            lTotal = lTotal - rs.Fields("amount").Value;
                            break;
                    }
                    rs.moveNext();
                }

                lTotal = lTotal + Convert.ToDecimal(Report.ParameterFields("txtAccountSales").ToString);

                //Get Output Vat
                sql2 = "SELECT SaleItem.SaleItem_StockItemID, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ActualCost]*[SaleItem_Quantity],[SaleItem_ActualCost]*[SaleItem_Quantity])) AS actualCostSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ListCost]*[SaleItem_Quantity],[SaleItem_ListCost]*[SaleItem_Quantity])) AS listCostSum, Sum(([SaleItem_Price]*[SaleItem_Quantity]/(1+[SaleItem_Vat]/100))) AS exclusiveSum, Sum(([SaleItem_Price]*[SaleItem_Quantity])) AS inclusiveSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_DepositCost]*[SaleItem_Quantity],[SaleItem_DepositCost]*[SaleItem_Quantity])) AS depositSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ShrinkQuantity]*[SaleItem_Quantity],[SaleItem_ShrinkQuantity]*[SaleItem_Quantity])) AS quantitySum FROM Sale INNER JOIN (aConsignment AS aConsignment_1 RIGHT JOIN (SaleItem LEFT JOIN aConsignment ON SaleItem.SaleItem_SaleID=aConsignment.Consignment_SaleID) ON aConsignment_1.Consignment_ReversalSaleID=SaleItem.SaleItem_SaleID) ON Sale.SaleID=SaleItem.SaleItem_SaleID" + " Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null))" + " GROUP BY SaleItem.SaleItem_StockItemID;";
                rsSale = modReport.getRSreport(ref sql2);
                vInSales = 0;

                if (rsSale.EOF | rsSale.BOF) {
                    Report.SetParameterValue("txtOutputVat", Strings.FormatNumber(vInSales, 2));
                    Report.SetParameterValue("txtOutputVat1", Strings.FormatNumber(vInSales, 2));
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(vInSales, 2)) + " WHERE IDDescription = 26");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vInSales, 2)) + " WHERE IDDescription = 27");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(vInSales, 2)) + " WHERE IDDescription = 26");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vInSales, 2)) + " WHERE IDDescription = 27");
                } else {
                    while (rsSale.EOF == false) {
                        vInSales = vInSales + rsSale.Fields("inclusiveSum").Value;
                        vExSales = vExSales + rsSale.Fields("exclusiveSum").Value;
                        rsSale.moveNext();
                    }
                    vVatSales = vInSales - vExSales;
                    Report.SetParameterValue("txtOutputVat", Strings.FormatNumber(vVatSales, 2));
                    Report.SetParameterValue("txtOutputVat1", Strings.FormatNumber(vVatSales, 2));
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(vVatSales, 2)) + " WHERE IDDescription = 26");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vVatSales, 2)) + " WHERE IDDescription = 27");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(vVatSales, 2)) + " WHERE IDDescription = 26");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vVatSales, 2)) + " WHERE IDDescription = 27");
                }
                rsSale.Close();
                //get Settlement movement
                vInSales = 0;
                rsSale = modReport.getRSreport(ref "SELECT Sum([CustomerTransaction_Amount]) AS SttTotal From CustomerTransaction WHERE CustomerTransaction_TransactionTypeID=8;");
                if (Information.IsDBNull(rsSale.Fields("SttTotal").Value)) {
                    Report.SetParameterValue("txtSettlement", Strings.FormatNumber(vInSales, 0));
                    Report.SetParameterValue("txtSettlement1", Strings.FormatNumber(vInSales, 0));
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(vInSales, 0)) + " WHERE IDDescription = 11");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vInSales, 0)) + " WHERE IDDescription = 12");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(vInSales, 0)) + " WHERE IDDescription = 11");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vInSales, 0)) + " WHERE IDDescription = 12");
                } else {
                    if (rsSale.Fields("SttTotal").Value < 0) {
                        Report.SetParameterValue("txtSettlement", Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 0));
                        Report.SetParameterValue("txtSettlement1", Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 0));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 0)) + " WHERE IDDescription = 11");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 0)) + " WHERE IDDescription = 12");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 0)) + " WHERE IDDescription = 11");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 0)) + " WHERE IDDescription = 12");
                    } else {
                        Report.SetParameterValue("txtSettlement", Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 0));
                        Report.SetParameterValue("txtSettlement1", Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 0));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 0)) + " WHERE IDDescription = 11");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 0)) + " WHERE IDDescription = 12");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 0)) + " WHERE IDDescription = 11");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 0)) + " WHERE IDDescription = 12");
                    }
                }

                rsSale.Close();

                rsSale = modReport.getRSreport(ref "SELECT Sum(SupplierTransaction.SupplierTransaction_Amount) AS SttTotal FROM SupplierTransaction WHERE (((SupplierTransaction.SupplierTransaction_TransactionTypeID)=8));");
                vInSales = 0;
                if (Information.IsDBNull(rsSale.Fields("SttTotal").Value)) {
                    Report.SetParameterValue("txtSettlementD", Strings.FormatNumber(vInSales, 2));
                    Report.SetParameterValue("txtSettlementD1", Strings.FormatNumber(vInSales, 2));
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(vInSales, 2)) + " WHERE IDDescription = 24");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vInSales, 2)) + " WHERE IDDescription = 25");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(vInSales, 2)) + " WHERE IDDescription = 24");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vInSales, 2)) + " WHERE IDDescription = 25");
                } else {
                    if (rsSale.Fields("SttTotal").Value < 0) {
                        Report.SetParameterValue("txtSettlementD", Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2));
                        Report.SetParameterValue("txtSettlementD1", Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 24");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 25");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 24");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 25");
                    } else {
                        Report.SetParameterValue("txtSettlementD", Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2));
                        Report.SetParameterValue("txtSettlementD1", Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 24");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 25");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 24");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 25");
                    }
                }

                rsSale.Close();
                rsSale = modReport.getRSreport(ref "SELECT Sum(SupplierTransaction.SupplierTransaction_Amount) AS SttTotal FROM SupplierTransaction WHERE (((SupplierTransaction.SupplierTransaction_TransactionTypeID)=3));");
                vInSales = 0;
                if (Information.IsDBNull(rsSale.Fields("SttTotal").Value)) {
                    Report.SetParameterValue("txtCreditorPay", Strings.FormatNumber(vInSales, 2));
                    Report.SetParameterValue("txtCreditorPay1", Strings.FormatNumber(vInSales, 2));
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(vInSales, 2)) + " WHERE IDDescription = 22");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vInSales, 2)) + " WHERE IDDescription = 23");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(vInSales, 2)) + " WHERE IDDescription = 22");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * vInSales, 2)) + " WHERE IDDescription = 23");
                } else {
                    if (rsSale.Fields("SttTotal").Value < 0) {
                        Report.SetParameterValue("txtCreditorPay", Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2));
                        Report.SetParameterValue("txtCreditorPay1", Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 22");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 23");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 22");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 23");
                    } else {
                        Report.SetParameterValue("txtCreditorPay", Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2));
                        Report.SetParameterValue("txtCreditorPay1", Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 22");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 23");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 22");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rsSale.Fields("SttTotal").Value, 2)) + " WHERE IDDescription = 23");
                    }
                }

                //do money movement
                lTotal = 0;
                rs = modReport.getRSreport(ref "SELECT Sale.Sale_PaymentType, Sum(Sale.Sale_Total) AS amount FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_PaymentType;");
                while (!(rs.EOF)) {
                    switch (rs.Fields("Sale_PaymentType").Value) {
                        case 1:
                            Report.SetParameterValue("txtMoneyCash", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                            lTotal = lTotal + rs.Fields("amount").Value;
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 1");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 1");
                            break;
                        case 2:
                            Report.SetParameterValue("txtMoneyCRcard", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                            lTotal = lTotal + rs.Fields("amount").Value;
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 3");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 3");
                            break;
                        case 3:
                            Report.SetParameterValue("txtMoneyDRcard", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                            lTotal = lTotal + rs.Fields("amount").Value;
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 4");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 4");
                            break;
                        case 4:
                            Report.SetParameterValue("txtMoneyCheque", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                            lTotal = lTotal + rs.Fields("amount").Value;
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 2");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("amount").Value, 2)) + " WHERE IDDescription = 2");
                            break;
                    }
                    rs.moveNext();
                }
                rs.Close();

                Report.SetParameterValue("txtMoneyTotal", Strings.FormatNumber(lTotal, 2));
                modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * lTotal, 2)) + " WHERE IDDescription = 13");
                modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * lTotal, 2)) + " WHERE IDDescription = 13");

                //do invoice discount
                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Discount) AS amount FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null));");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtStockDiscount", "0.00");
                } else {
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtStockDiscount", Strings.FormatNumber(0 - rs("amount").Value, 2));
                        Report.SetParameterValue("txtSCmDiscount", Strings.FormatNumber(0 - rs("amount").Value, 2));
                    } else {
                        Report.SetParameterValue("txtStockDiscount", "0.00");
                    }
                }
                rs.Close();

                rs = modReport.getRSreport(ref "SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS content, CBool([SaleItem_DepositType]) AS depositType, SaleItem.SaleItem_Reversal, Sum(([SaleItem_DepositCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS deposit FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY CBool([SaleItem_DepositType]), SaleItem.SaleItem_Reversal;");
                while (!(rs.EOF)) {
                    if (rs.Fields("depositType").Value) {
                        if (rs.Fields("SaleItem_Reversal").Value) {
                            Report.SetParameterValue("txtStockDepositSold", Strings.FormatNumber(rs("content"), 2));
                        } else {
                            Report.SetParameterValue("txtStockDepositReturn", Strings.FormatNumber(rs("content"), 2));
                        }
                    } else {
                        if (rs.Fields("SaleItem_Reversal").Value) {
                            Report.SetParameterValue("txtStockCreditContent", Strings.FormatNumber(rs("content"), 2));
                            Report.SetParameterValue("txtStockCreditDeposit", Strings.FormatNumber(0 - rs("deposit").Value, 2));
                        } else {
                            Report.SetParameterValue("txtStockSoldContent", Strings.FormatNumber(rs("content"), 2));
                            Report.SetParameterValue("txtStockSoldDeposit", Strings.FormatNumber(rs("deposit"), 2));
                        }
                    }
                    rs.moveNext();
                }
                rs.Close();
                 // ERROR: Not supported in C#: OnErrorStatement

                rs = modReport.getRSreport(ref "SELECT Sum(aCustomerTransaction.CustomerTransaction_Amount) AS SumOfCustomerTransaction_Amount FROM aCustomerTransaction INNER JOIN DayEnd ON aCustomerTransaction.CustomerTransaction_DayEndID = DayEnd.DayEndID WHERE (((aCustomerTransaction.CustomerTransaction_TransactionTypeID)=3 Or (aCustomerTransaction.CustomerTransaction_TransactionTypeID)=4 Or (aCustomerTransaction.CustomerTransaction_TransactionTypeID)=5) AND ((aCustomerTransaction.CustomerTransaction_ReferenceID)=0));");
                if (rs.RecordCount) {
                    if (rs.Fields("SumOfCustomerTransaction_Amount").Value < 0) {
                        Report.SetParameterValue("txtAccountEFT", Strings.FormatNumber(0, 2));
                        Report.SetParameterValue("txtAccountEFT1", Strings.FormatNumber(0, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("SumOfCustomerTransaction_Amount").Value, 2)) + " WHERE IDDescription = 9");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("SumOfCustomerTransaction_Amount").Value, 2)) + " WHERE IDDescription = 10");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("SumOfCustomerTransaction_Amount").Value, 2)) + " WHERE IDDescription = 9");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("SumOfCustomerTransaction_Amount").Value, 2)) + " WHERE IDDescription = 10");
                    } else {
                        if (Information.IsDBNull(rs.Fields("SumOfCustomerTransaction_Amount").Value)) {
                            Report.SetParameterValue("txtAccountEFT", "0.00");
                            Report.SetParameterValue("txtAccountEFT1", "0.00");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(0) + " WHERE IDDescription = 9");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(0) + " WHERE IDDescription = 10");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(0) + " WHERE IDDescription = 9");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(0) + " WHERE IDDescription = 10");
                        } else {
                            Report.SetParameterValue("txtAccountEFT", Strings.FormatNumber(rs.Fields("SumOfCustomerTransaction_Amount").Value, 2));
                            Report.SetParameterValue("txtAccountEFT1", Strings.FormatNumber(rs.Fields("SumOfCustomerTransaction_Amount").Value, 2));
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("SumOfCustomerTransaction_Amount").Value, 2)) + " WHERE IDDescription = 9");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("SumOfCustomerTransaction_Amount").Value, 2)) + " WHERE IDDescription = 10");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("SumOfCustomerTransaction_Amount").Value, 2)) + " WHERE IDDescription = 9");
                            modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("SumOfCustomerTransaction_Amount").Value, 2)) + " WHERE IDDescription = 10");
                        }
                    }
                } else {
                    Report.SetParameterValue("txtAccountEFT", Strings.FormatNumber(0, 2));
                    Report.SetParameterValue("txtAccountEFT1", Strings.FormatNumber(0, 2));
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 9");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 10");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 9");
                    modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 10");
                }
                //Set rs = getRSreport(sql)
                rDisplay_F = modRecordSet.getRS(ref "SELECT * FROM PastelDescription Order By IDDescription ASC");
                for (intF = 1; intF <= 29; intF++) {
                    Report.SetParameterValue("txtDes1", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar1", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc1", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes2", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar2", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc2", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes3", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar3", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc3", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes4", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar4", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc4", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes5", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar5", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc5", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes6", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar6", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc6", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes7", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar7", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc7", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes8", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar8", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc8", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes9", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar9", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc9", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes10", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar10", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc10", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes11", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar11", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc11", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes12", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar12", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc12", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes13", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar13", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc13", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes14", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar14", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc14", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes15", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar15", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc15", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes16", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar16", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc16", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes17", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar17", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc17", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes18", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar18", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc18", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes19", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar19", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc19", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes20", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar20", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc20", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes21", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar21", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc21", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes22", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar22", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc22", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes23", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar23", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc23", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes24", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar24", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc24", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes25", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar25", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc25", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes26", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar26", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc26", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes27", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar27", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc27", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes28", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar28", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc28", rDisplay_F("AccountNumber"));
                    rDisplay_F.moveNext();
                    Report.SetParameterValue("txtDes29", rDisplay_F("Description"));
                    Report.SetParameterValue("txtNar29", rDisplay_F("Decription1"));
                    Report.SetParameterValue("txtAcc29", rDisplay_F("AccountNumber"));
                    break; // TODO: might not be correct. Was : Exit For
                }

                if (lMode) {
                } else {
                    rs = modReport.getRSreport(ref "SELECT Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]) AS listSales, Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ActualCost]) AS actualSales, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]) AS listShrink, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ActualCost]) AS actualShrink, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS listGRV, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ActualCost]) AS actualGRV FROM DayEndStockItemLnk;");

                    if (Information.IsDBNull(rs.Fields("listShrink").Value)) {
                        Report.SetParameterValue("txtSHRL", Strings.FormatNumber(0, 2));
                        Report.SetParameterValue("txtSHRL1", Strings.FormatNumber(0, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 14");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 15");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 14");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 15");
                    } else {
                        if (rs.Fields("listShrink").Value < 0) {
                            Report.SetParameterValue("txtSHRL", Strings.FormatNumber(-1 * rs.Fields("listShrink").Value, 2));
                            Report.SetParameterValue("txtSHRL1", Strings.FormatNumber(-1 * rs.Fields("listShrink").Value, 2));
                        } else {
                            Report.SetParameterValue("txtSHRL", Strings.FormatNumber(rs.Fields("listShrink").Value, 2));
                            Report.SetParameterValue("txtSHRL1", Strings.FormatNumber(rs.Fields("listShrink").Value, 2));
                        }

                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("listShrink").Value, 2)) + " WHERE IDDescription = 14");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("listShrink").Value, 2)) + " WHERE IDDescription = 15");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("listShrink").Value, 2)) + " WHERE IDDescription = 14");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("listShrink").Value, 2)) + " WHERE IDDescription = 15");
                    }

                    if (Information.IsDBNull(rs.Fields("listGRV").Value)) {
                        Report.SetParameterValue("txtGRVL1", Strings.FormatNumber(0, 2));
                        Report.SetParameterValue("txtGRVL", Strings.FormatNumber(0, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 20");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 21");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 20");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 21");
                    } else {
                        Report.SetParameterValue("txtGRVL1", Strings.FormatNumber(rs.Fields("listGRV").Value, 2));
                        Report.SetParameterValue("txtGRVL", Strings.FormatNumber(rs.Fields("listGRV").Value, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("listGRV").Value, 2)) + " WHERE IDDescription = 20");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("listGRV").Value, 2)) + " WHERE IDDescription = 21");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("listGRV").Value, 2)) + " WHERE IDDescription = 20");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("listGRV").Value, 2)) + " WHERE IDDescription = 21");
                    }

                    if (Information.IsDBNull(rs.Fields("listSales").Value)) {
                        Report.SetParameterValue("txtSaleL", Strings.FormatNumber(0, 2));
                        Report.SetParameterValue("txtSaleL1", Strings.FormatNumber(0, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 16");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 17");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 16");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(0, 2)) + " WHERE IDDescription = 17");
                    } else {
                        Report.SetParameterValue("txtSaleL", Strings.FormatNumber(rs.Fields("listSales").Value, 2));
                        Report.SetParameterValue("txtSaleL1", Strings.FormatNumber(rs.Fields("listSales").Value, 2));
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("listSales").Value, 2)) + " WHERE IDDescription = 16");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET Amount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("listSales").Value, 2)) + " WHERE IDDescription = 17");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(rs.Fields("listSales").Value, 2)) + " WHERE IDDescription = 16");
                        modRecordSet.cnnDB.Execute("UPDATE PastelDescription SET HomeAmount = " + Convert.ToDecimal(Strings.FormatNumber(-1 * rs.Fields("listSales").Value, 2)) + " WHERE IDDescription = 17");
                    }
                }
                rs = modReport.getRSreport(ref "SELECT Sum([SaleItem_ListCost]*[SaleItem_Quantity]) AS list, Sum([SaleItem_ActualCost]*[SaleItem_Quantity]) AS actual FROM aConsignment INNER JOIN SaleItem ON aConsignment.Consignment_SaleID = SaleItem.SaleItem_SaleID;");
                if (Information.IsDBNull(rs.Fields("list").Value)) {
                    Report.SetParameterValue("txtConsLsales", Strings.FormatNumber("0", 2));
                    Report.SetParameterValue("txtConsAsales", Strings.FormatNumber("0", 2));
                } else {
                    Report.SetParameterValue("txtConsLsales", Strings.FormatNumber(rs("list"), 2));
                    Report.SetParameterValue("txtConsAsales", Strings.FormatNumber(rs("actual"), 2));
                }
                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Total) AS [amount] FROM aConsignment INNER JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID;");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtConsPsales", Strings.FormatNumber("0", 2));
                } else {
                    Report.SetParameterValue("txtConsPsales", Strings.FormatNumber(rs("amount"), 2));
                }

                rs = modReport.getRSreport(ref "SELECT Sum([SaleItem_ListCost]*[SaleItem_Quantity]) AS list, Sum([SaleItem_ActualCost]*[SaleItem_Quantity]) AS actual FROM aConsignment INNER JOIN SaleItem ON aConsignment.Consignment_CompleteSaleID = SaleItem.SaleItem_SaleID;");
                if (Information.IsDBNull(rs.Fields("list").Value)) {
                    Report.SetParameterValue("txtConsLPurchase", Strings.FormatNumber("0", 2));
                    Report.SetParameterValue("txtConsAPurchase", Strings.FormatNumber("0", 2));
                } else {
                    Report.SetParameterValue("txtConsLPurchase", Strings.FormatNumber(rs("list"), 2));
                    Report.SetParameterValue("txtConsAPurchase", Strings.FormatNumber(rs("actual"), 2));
                }

                rs = modReport.getRSreport(ref "SELECT Sum(theJoin.list) AS list, Sum(theJoin.actual) AS actual FROM (SELECT  1 AS sale, Sum([SaleItem_Quantity]*[SaleItem_ListCost]) AS list, Sum([SaleItem_Quantity]*[SaleItem_actualCost]) AS actual FROM SaleItem INNER JOIN aConsignment ON SaleItem.SaleItem_SaleID = aConsignment.Consignment_CompleteSaleID Union SELECT 0 AS sale, Sum(0-[SaleItem_Quantity]*[SaleItem_ListCost]) AS list, Sum(0-[SaleItem_Quantity]*[SaleItem_actualCost]) AS actual FROM aConsignment INNER JOIN SaleItem ON aConsignment.Consignment_SaleID = SaleItem.SaleItem_SaleID WHERE (((aConsignment.Consignment_CompleteSaleID) Is Not Null))) AS theJoin;");
                if (Information.IsDBNull(rs.Fields("list").Value)) {
                    Report.SetParameterValue("txtConsLreturn", Strings.FormatNumber("0", 2));
                    Report.SetParameterValue("txtConsAreturn", Strings.FormatNumber("0", 2));
                } else {
                    Report.SetParameterValue("txtConsLreturn", Strings.FormatNumber(rs("list"), 2));
                    Report.SetParameterValue("txtConsAreturn", Strings.FormatNumber(rs("actual"), 2));
                }

                rs = modReport.getRSreport(ref "SELECT Sum([Sale]![Sale_Total]+[Sale_1]![Sale_Total]) AS priceReturn, Sale.Sale_Total FROM Sale INNER JOIN (Sale AS Sale_1 INNER JOIN aConsignment ON Sale_1.SaleID = aConsignment.Consignment_ReversalSaleID) ON Sale.SaleID = aConsignment.Consignment_CompleteSaleID GROUP BY Sale.Sale_Total;");
                if (rs.BOF | rs.EOF) {
                    Report.SetParameterValue("txtConsPPurchase", Strings.FormatNumber("0", 2));
                    Report.SetParameterValue("txtConsPreturn", Strings.FormatNumber("0", 2));
                } else {
                    if (Information.IsDBNull(rs.Fields("Sale_Total").Value)) {
                        Report.SetParameterValue("txtConsPPurchase", Strings.FormatNumber("0", 2));
                        Report.SetParameterValue("txtConsPreturn", Strings.FormatNumber("0", 2));
                    } else {
                        Report.SetParameterValue("txtConsPPurchase", Strings.FormatNumber(rs("Sale_Total"), 2));
                        Report.SetParameterValue("txtConsPreturn", Strings.FormatNumber(rs("priceReturn"), 2));
                    }
                }

                rs = modReport.getRSreport(ref "SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS SCTotal, Sale.Sale_ChannelID FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_ChannelID;");
                //lTotal = CCur(Report.txtSCmDiscount.Text)
                while (!(rs.EOF)) {
                    switch (rs.Fields("Sale_ChannelID").Value) {
                    }
                    lTotal = lTotal + rs.Fields("SCTotal").Value;
                    rs.moveNext();
                }
                rsPTotals = modRecordSet.getRS(ref "SELECT SUM(Amount) As totDebit FROM PastelDescription WHERE Amount > 0");
                rsPTotalss = modRecordSet.getRS(ref "SELECT SUM(Amount) as totCredit FROM PastelDescription WHERE Amount < 0");

                if (Information.IsDBNull(rsPTotals.Fields("totDebit").Value)) {
                    Report.SetParameterValue("txtDebit", Strings.FormatNumber(0, 2));
                } else {
                    Report.SetParameterValue("txtDebit", Strings.FormatNumber(rsPTotals.Fields("totDebit").Value));
                }
                if (Information.IsDBNull(rsPTotalss.Fields("totCredit").Value)) {
                    Report.SetParameterValue("txtCredit", Strings.FormatNumber(0, 2));
                } else {
                    Report.SetParameterValue("txtCredit", Strings.FormatNumber(rsPTotalss.Fields("totCredit").Value));
                }

                //Pastel export file
                if (modBResolutions.blpastel == true) {
                    System.Windows.Forms.Cursor.Current = Cursors.Default;
                    return;
                }
                My.MyProject.Forms.frmReportShow.Text = "Pastel Report";
                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();

            }
        }
Beispiel #17
0
        private static void report_SalesVat()
        {
            ADODB.Recordset rsDep = default(ADODB.Recordset);
            int txtStockDepositReturn = 0;
            int txtStockDepositSold = 0;
            string sql2 = null;
            ADODB.Recordset rs = default(ADODB.Recordset);
            decimal vInSales = default(decimal);
            decimal vExSales = default(decimal);
            decimal vTaxSales = default(decimal);
            decimal vVatSales = default(decimal);
            decimal vNonTaxSales = default(decimal);
            ADODB.Recordset rsSales = default(ADODB.Recordset);
            ADODB.Recordset rsSalesTotal = default(ADODB.Recordset);
            ADODB.Recordset rsDiscount = default(ADODB.Recordset);

            string sql = null;
            //Dim Report As New CryVreporting
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("CryVreporting.rpt");
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            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();

            sql2 = "SELECT SaleItem.SaleItem_StockItemID, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ActualCost]*[SaleItem_Quantity],[SaleItem_ActualCost]*[SaleItem_Quantity])) AS actualCostSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ListCost]*[SaleItem_Quantity],[SaleItem_ListCost]*[SaleItem_Quantity])) AS listCostSum, Sum(([SaleItem_Price]*[SaleItem_Quantity]/(1+[SaleItem_Vat]/100))) AS exclusiveSum, Sum(([SaleItem_Price]*[SaleItem_Quantity])) AS inclusiveSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_DepositCost]*[SaleItem_Quantity],[SaleItem_DepositCost]*[SaleItem_Quantity])) AS depositSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ShrinkQuantity]*[SaleItem_Quantity],[SaleItem_ShrinkQuantity]*[SaleItem_Quantity])) AS quantitySum FROM Sale INNER JOIN (aConsignment AS aConsignment_1 RIGHT JOIN (SaleItem LEFT JOIN aConsignment ON SaleItem.SaleItem_SaleID=aConsignment.Consignment_SaleID) ON aConsignment_1.Consignment_ReversalSaleID=SaleItem.SaleItem_SaleID) ON Sale.SaleID=SaleItem.SaleItem_SaleID" + " Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null))" + " GROUP BY SaleItem.SaleItem_StockItemID;";

            rsSales = modReport.getRSreport(ref sql2);

            if (rsSales.BOF | rsSales.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;
            }

            sql2 = "SELECT SaleItem.SaleItem_StockItemID, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ActualCost]*[SaleItem_Quantity],[SaleItem_ActualCost]*[SaleItem_Quantity])) AS actualCostSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ListCost]*[SaleItem_Quantity],[SaleItem_ListCost]*[SaleItem_Quantity])) AS listCostSum, Sum(([SaleItem_Price]*[SaleItem_Quantity]/(1+[SaleItem_Vat]/100))) AS exclusiveSum, Sum(([SaleItem_Price]*[SaleItem_Quantity])) AS inclusiveSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_DepositCost]*[SaleItem_Quantity],[SaleItem_DepositCost]*[SaleItem_Quantity])) AS depositSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ShrinkQuantity]*[SaleItem_Quantity],[SaleItem_ShrinkQuantity]*[SaleItem_Quantity])) AS quantitySum FROM Sale INNER JOIN (aConsignment AS aConsignment_1 RIGHT JOIN (SaleItem LEFT JOIN aConsignment ON SaleItem.SaleItem_SaleID=aConsignment.Consignment_SaleID) ON aConsignment_1.Consignment_ReversalSaleID=SaleItem.SaleItem_SaleID) ON Sale.SaleID=SaleItem.SaleItem_SaleID" + " Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null))" + " GROUP BY SaleItem.SaleItem_StockItemID;";

            rsSalesTotal = modReport.getRSreport(ref sql2);

            while (rsSalesTotal.EOF == false) {
                vInSales = vInSales + rsSalesTotal.Fields("inclusiveSum").Value;

                vExSales = vExSales + rsSalesTotal.Fields("exclusiveSum").Value;

                if (rsSalesTotal.Fields("inclusiveSum").Value == rsSalesTotal.Fields("exclusiveSum").Value) {
                    vNonTaxSales = vNonTaxSales + rsSalesTotal.Fields("inclusiveSum").Value;
                } else {
                    vTaxSales = vTaxSales + rsSalesTotal.Fields("exclusiveSum").Value;
                }
                rsSalesTotal.moveNext();
            }

            txtStockDepositSold = 0;
            //UPGRADE_WARNING: Couldn't resolve default property of object txtStockDepositReturn. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            txtStockDepositReturn = 0;
            rsDep = modReport.getRSreport(ref "SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS content, CBool([SaleItem_DepositType]) AS depositType, SaleItem.SaleItem_Reversal, Sum(([SaleItem_DepositCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS deposit FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY CBool([SaleItem_DepositType]), SaleItem.SaleItem_Reversal;");
            while (!(rsDep.EOF)) {
                if (rsDep("depositType").Value) {
                    if (rsDep("SaleItem_Reversal").Value) {
                        txtStockDepositSold = rsDep("content").Value;
                    } else {
                        txtStockDepositReturn = rsDep("content").Value;
                    }
                } else {
                    //            If rsDep("SaleItem_Reversal") Then
                    //                Report.txtStockCreditContent.SetText FormatNumber(rsDep("content"), 2)
                    //                Report.txtStockCreditDeposit.SetText FormatNumber(0 - rsDep("deposit"), 2)
                    //
                    //            Else
                    //                Report.txtStockSoldContent.SetText FormatNumber(rsDep("content"), 2)
                    //                Report.txtStockSoldDeposit.SetText FormatNumber(rsDep("deposit"), 2)
                    //            End If
                }
                rsDep.moveNext();
            }
            rsDep.Close();
            vInSales = vInSales + (txtStockDepositSold + txtStockDepositReturn);
            vExSales = vExSales + (txtStockDepositSold + txtStockDepositReturn);
            vVatSales = vInSales - vExSales;

            //do invoice discount
            rsDiscount = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Discount) AS amount FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null));");
            if (Information.IsDBNull(rsDiscount.Fields("amount").Value)) {
                Report.SetParameterValue("txtDiscountsGiven", "0.00");
            } else {
                if (rsDiscount.RecordCount) {
                    Report.SetParameterValue("txtDiscountsGiven", Strings.FormatNumber(0 - rsDiscount.Fields("amount").Value, 2));
                } else {
                    Report.SetParameterValue("txtDiscountsGiven", "0.00");
                }
            }

            Report.Database.Tables(1).SetDataSource(rsSales);
            Report.SetParameterValue("txtInSales", Strings.FormatNumber(vInSales, 2));
            Report.SetParameterValue("txtExSales", Strings.FormatNumber(vExSales, 2));
            Report.SetParameterValue("txtTaxSales", Strings.FormatNumber(vTaxSales, 2));
            Report.SetParameterValue("txtVatSales", Strings.FormatNumber(vVatSales, 2));
            Report.SetParameterValue("txtNonTaxSales", Strings.FormatNumber(vNonTaxSales, 2));

            //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();
        }
Beispiel #18
0
        private static void report_RevokeTransactionlist()
        {
            string sql = null;
            decimal SumSales = default(decimal);
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");

            // to get getSQL
            bool gl = false;
            string lWhere = null;
            short x = 0;
            string lString = null;
            string getSQL = null;

            lWhere = lWhere + " AND (SaleItem_Revoke=True)";
            //If chkReversal.value Then lWhere = lWhere & " AND (SaleItem_Reversal=True)"
            //If chkFC.value Then lWhere = lWhere & " AND (Sale_PaymentType=8)"

            //lString = ""
            //For x = 0 To Me.lstChannel.ListCount - 1
            //    If Me.lstChannel.Selected(x) Then
            //        lString = lString & " OR Sale_ChannelID=" & lstChannel.ItemData(x)
            //    End If
            //Next x
            //If lString <> "" Then
            //    lString = " AND (" & Mid(lString, 4) & ")"
            //    lWhere = lWhere & lString
            //End If

            //lString = ""
            //For x = 0 To Me.lstPerson.ListCount - 1
            //    If Me.lstPerson.Selected(x) Then
            //        lString = lString & " OR Sale_PersonID=" & lstPerson.ItemData(x)
            //    End If
            //Next x
            //If lString <> "" Then
            //    lString = " AND (" & Mid(lString, 4) & ")"
            //    lWhere = lWhere & lString
            //End If

            //lString = ""
            //For x = 0 To Me.lstPOS.ListCount - 1
            //    If Me.lstPOS.Selected(x) Then
            //        lString = lString & " OR Sale_POSID=" & lstPOS.ItemData(x)
            //    End If
            //Next x
            //If lString <> "" Then
            //    lString = " AND (" & Mid(lString, 4) & ")"
            //    lWhere = lWhere & lString
            //End If

            //lString = ""
            //gl = False
            //For x = 0 To Me.lstSaleref.ListCount - 1
            //    If Me.lstSaleref.Selected(x) Then
            //        If x = 0 Then
            //          lString = lString & " Sale_CardRef <>''"
            //          gl = True
            //        ElseIf x = 1 Then
            //          If gl = True Then
            //             lString = lString & " OR Sale_OrderRef <>''"
            //          Else
            //             lString = lString & " Sale_OrderRef <>''"
            //             gl = True
            //          End If
            //        ElseIf x = 2 Then
            //           If gl = True Then
            //            lString = lString & " OR Sale_SerialRef <>''"
            //           Else
            //            lString = lString & " Sale_SerialRef <>''"
            //           End If
            //        End If
            //    End If
            //Next x
            //If lString <> "" Then
            //    lString = " AND (" & Mid(lString, 2) & ")"
            //    lWhere = lWhere & lString
            //End If

            if (!string.IsNullOrEmpty(lWhere))
                lWhere = " WHERE " + Strings.Mid(lWhere, 6);

            sql = "SELECT DISTINCT Sale.*, aConsignment.*, aCustomer.Customer_InvoiceName, aChannel.Channel_Name, aPerson.Person_FirstName & ' ' & aPerson.Person_LastName AS PersonName, aPerson.Person_Comm, aPerson1.Person_FirstName & ' ' & aPerson1.Person_LastName AS MgrName FROM (SaleItem INNER JOIN ((aChannel INNER JOIN (aCustomer RIGHT JOIN (CustomerTransaction RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID) ON aChannel.ChannelID = Sale.Sale_ChannelID) INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) ON SaleItem.SaleItem_SaleID = Sale.SaleID) LEFT JOIN aPerson1 ON Sale.Sale_ManagerID = aPerson1.PersonID ";
            sql = sql + lWhere;

            getSQL = sql;
            // to get getSQL

            //Report = New cryPOSreportRevoke
            Report.Load("cryPOSreportRevoke.rpt");

            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 getSQL);

            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;
            }

            sql = "SELECT SaleItem.*, IIf([SaleItem_DepositType]=1,[Deposit_Name]+'-bottle',IIf([SaleItem_DepositType]=2,[Deposit_Name]+'-Crate',[Deposit_Name]+'-Case')) AS StockItem_Name FROM SaleItem INNER JOIN aDeposit ON SaleItem.SaleItem_StockItemID = aDeposit.DepositID Where (((SaleItem.SaleItem_DepositType) <> 0)) Union ";
            sql = sql + "SELECT SaleItem.*, aStockItem.StockItem_Name FROM SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Recipe) = 0)) Union ";
            sql = sql + "SELECT SaleItem.*, aRecipe.Recipe_Name AS StockItem_Name FROM SaleItem INNER JOIN aRecipe ON SaleItem.SaleItem_StockItemID = aRecipe.RecipeID WHERE (((SaleItem.SaleItem_DepositType)=0) AND ((SaleItem.SaleItem_Recipe)<>0));";

            sql = "SELECT SaleItem.*, IIf([SaleItem_DepositType]=1,[Deposit_Name]+'-bottle',IIf([SaleItem_DepositType]=2,[Deposit_Name]+'-Crate',[Deposit_Name]+'-Case')) AS StockItem_Name FROM SaleItem INNER JOIN aDeposit ON SaleItem.SaleItem_StockItemID = aDeposit.DepositID Where (((SaleItem.SaleItem_DepositType) <> 0) AND ((SaleItem.SaleItem_Revoke) <> 0)) Union SELECT SaleItem.*, aStockItem.StockItem_Name FROM SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID Where (((SaleItem.SaleItem_DepositType) = 0) AND ((SaleItem.SaleItem_Revoke) <> 0))";
            rsData = modReport.getRSreport(ref sql);

            if (rsData.BOF | rsData.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 emp_Clicked = True Then
            //   SumSales = 0
            //   Do While rs.EOF = False
            //      SumSales = SumSales + rs("Sale_Total")
            //      rs.moveNext
            //   Loop
            //      'Resise to excluding vat
            //      SumSales = SumSales - (SumSales * 0.14)
            //      rs.MoveFirst
            //      Report.txtComm.SetText rs("Person_Comm")
            //      Report.txtTotalCommision.SetText FormatNumber((SumSales * rs("Person_Comm")) / 100, 2)
            //End If

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            //Report.VerifyOnEveryPrint = True
            My.MyProject.Forms.frmReportShow.Text = Report.ParameterFields("txtComm").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();
        }
Beispiel #19
0
        private static void report_SalesCube()
        {
            string sql = null;
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            bool lMode = false;
            ADODB.Recordset rs = default(ADODB.Recordset);
            decimal lTotal = default(decimal);
            decimal lSettDiscount = default(decimal);
            decimal OnlyAcclSettDiscount = default(decimal);

            decimal newDis = default(decimal);
            decimal oldDis = default(decimal);

            //For Split tender
            decimal lCash = default(decimal);
            decimal lDebit = default(decimal);
            decimal lCheque = default(decimal);
            decimal lCredit = default(decimal);

            if (My.MyProject.Forms.frmMenu.gSuper == true) {
                Report.Load("crySalesCubeSuper.rpt");
            } else {
                //Set Report = New crySalesCube
                Report.Load("crySalesCubeTouch.rpt");
            }

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            if (modReport.openConnectionReport()) {
                rs = modReport.getRSreport(ref "SELECT aCompany.Company_Name, Report.Report_Heading FROM aCompany, Report;");
                Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
                Report.SetParameterValue("txtFilter", rs.Fields("Report_Heading"));

                //change translation for report
                //
                modRecordSet.rsLang.filter = "LanguageLayoutLnk_LanguageID=" + 1974;
                if (modRecordSet.rsLang.RecordCount)
                    Report.SetParameterValue("Text41", Strings.Replace(modRecordSet.rsLang.Fields("LanguageLayoutLnk_Description").Value, Constants.vbCrLf, " "));
                //
                modRecordSet.rsLang.filter = "LanguageLayoutLnk_LanguageID=" + 1975;
                if (modRecordSet.rsLang.RecordCount)
                    Report.SetParameterValue("Text42", Strings.Replace(modRecordSet.rsLang.Fields("LanguageLayoutLnk_Description").Value, Constants.vbCrLf, " "));
                //
                modRecordSet.rsLang.filter = "LanguageLayoutLnk_LanguageID=" + 1976;
                if (modRecordSet.rsLang.RecordCount)
                    Report.SetParameterValue("Text43", Strings.Replace(modRecordSet.rsLang.Fields("LanguageLayoutLnk_Description").Value, Constants.vbCrLf, " "));
                //
                modRecordSet.rsLang.filter = "LanguageLayoutLnk_LanguageID=" + 1977;
                if (modRecordSet.rsLang.RecordCount)
                    Report.SetParameterValue("Text44", Strings.Replace(modRecordSet.rsLang.Fields("LanguageLayoutLnk_Description").Value, Constants.vbCrLf, " "));

                //
                modRecordSet.rsLang.filter = "LanguageLayoutLnk_LanguageID=" + 1974;
                if (modRecordSet.rsLang.RecordCount)
                    Report.SetParameterValue("Text57", Strings.Replace(modRecordSet.rsLang.Fields("LanguageLayoutLnk_Description").Value, Constants.vbCrLf, " "));
                //
                modRecordSet.rsLang.filter = "LanguageLayoutLnk_LanguageID=" + 1975;
                if (modRecordSet.rsLang.RecordCount)
                    Report.SetParameterValue("Text58", Strings.Replace(modRecordSet.rsLang.Fields("LanguageLayoutLnk_Description").Value, Constants.vbCrLf, " "));
                //
                modRecordSet.rsLang.filter = "LanguageLayoutLnk_LanguageID=" + 1976;
                if (modRecordSet.rsLang.RecordCount)
                    Report.SetParameterValue("Text59", Strings.Replace(modRecordSet.rsLang.Fields("LanguageLayoutLnk_Description").Value, Constants.vbCrLf, " "));
                //
                modRecordSet.rsLang.filter = "LanguageLayoutLnk_LanguageID=" + 1977;
                if (modRecordSet.rsLang.RecordCount)
                    Report.SetParameterValue("Text60", Strings.Replace(modRecordSet.rsLang.Fields("LanguageLayoutLnk_Description").Value, Constants.vbCrLf, " "));
                //change translation for report

                //get payoutTotal
                rs = modReport.getRSreport(ref "SELECT Sum(Payout.Payout_Amount) AS [amount] FROM Payout;");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtPayout", "0.00");

                } else {
                    Report.SetParameterValue("txtPayout", Strings.FormatNumber(rs.Fields("amount").Value, 2));

                }
                rs.Close();

                //get outages.............................

                rs = modReport.getRSreport(ref "SELECT Sum(([Declaration_Cash]+[Declaration_Cheque]+[Declaration_Card]-[Declaration_Payout])-([Declaration_CashServer]+[Declaration_ChequeServer]+[Declaration_CardServer]-[Declaration_PayoutServer])) AS amount FROM Declaration;");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtOutage", "0.00");
                } else {
                    Report.SetParameterValue("txtOutage", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                }
                rs.Close();

                //get account movement.....................
                lCash = 0;
                lDebit = 0;
                lCheque = 0;
                lCredit = 0;

                lTotal = 0;
                lSettDiscount = 0;
                OnlyAcclSettDiscount = 0;

                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Total) AS amount, Sale.Sale_PaymentType, Sum([Sale_Total]-[Sale_Discount]) AS Subtotal, Sum(Sale.Sale_Discount) AS discount, Sum(Sale.Sale_Cash) AS amountCash,Sum(Sale.Sale_Card) AS amountCard,Sum(Sale.Sale_CDebit) AS amountCredit,Sum(Sale.Sale_Cheque) AS amountCheque FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (CustomerTransaction INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 2 Or (CustomerTransaction.CustomerTransaction_TransactionTypeID) = 3) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null) And ((Sale.Sale_SaleChk)=False)) GROUP BY Sale.Sale_PaymentType;");
                //Set rs = getRSreport("SELECT Sum(Sale.Sale_Total) AS amount, Sale.Sale_PaymentType, Sum([Sale_Total]-[Sale_Discount]) AS Subtotal, Sum(Sale.Sale_Discount) AS discount, Sum(Sale.Sale_Cash) AS amountCash,Sum(Sale.Sale_Card) AS amountCard,Sum(Sale.Sale_CDebit) AS amountCredit,Sum(Sale.Sale_Cheque) AS amountCheque FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (CustomerTransaction INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 2 Or (CustomerTransaction.CustomerTransaction_TransactionTypeID) = 3) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_PaymentType;")
                while (!(rs.EOF)) {
                    switch (rs.Fields("Sale_PaymentType").Value) {
                        case 5:
                            //Revise
                            Report.SetParameterValue("txtAccountSales", Strings.FormatNumber(rs.Fields("subtotal").Value, 2));
                            Report.SetParameterValue("txtCubeAccountSales", Strings.FormatNumber(rs.Fields("subtotal").Value, 2));
                            //05 March 2009 Fixed
                            //changed above both line cuz was showing wrong figures on discounts on Universal paints
                            Report.SetParameterValue("txtAccountSales", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                            Report.SetParameterValue("txtCubeAccountSales", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                            OnlyAcclSettDiscount = OnlyAcclSettDiscount + rs.Fields("discount").Value;
                            break;
                        case 1:
                            lTotal = lTotal - rs.Fields("amount").Value;
                            lCash = lCash + rs.Fields("amountCash").Value;

                            break;
                        case 2:
                            lTotal = lTotal - rs.Fields("amount").Value;
                            lCredit = lCredit + rs.Fields("amountCredit").Value;

                            break;
                        case 3:
                            lTotal = lTotal - rs.Fields("amount").Value;
                            lDebit = lDebit + rs.Fields("amountCard").Value;

                            break;
                        case 4:
                            lTotal = lTotal - rs.Fields("amount").Value;
                            lCheque = lCheque + rs.Fields("amountCheque").Value;
                            break;
                        case 7:
                            lTotal = lTotal - rs.Fields("amount").Value;
                            lCash = lCash + rs.Fields("amountCash").Value;
                            lDebit = lDebit + rs.Fields("amountCard").Value;
                            lCredit = lCredit + rs.Fields("amountCredit").Value;
                            lCheque = lCheque + rs.Fields("amountCheque").Value;
                            break;
                    }

                    lSettDiscount = lSettDiscount + rs.Fields("discount").Value;
                    rs.moveNext();
                }

                //Assign account payment......
                Report.SetParameterValue("txtAccountCash", Strings.FormatNumber(0 - lCash, 2));
                Report.SetParameterValue("txtAccountCRcard", Strings.FormatNumber(0 - lCredit, 2));
                Report.SetParameterValue("txtAccountDRcard", Strings.FormatNumber(0 - lDebit, 2));
                Report.SetParameterValue("txtAccountCheque", Strings.FormatNumber(0 - lCheque, 2));

                Report.SetParameterValue("txtAccountPayment", Strings.FormatNumber(lTotal, 2));
                Report.SetParameterValue("txtCubeAccountPayment", Strings.FormatNumber(lTotal, 2));

                //05 March 2009 Fixed
                //changed cuz was showing wrong figures on discounts
                //lTotal = lTotal + CCur(Report.txtAccountSales.Text) '
                lTotal = lTotal + Convert.ToDecimal(Report.ParameterFields("txtCubeAccountSales").ToString);

                Report.SetParameterValue("txtCubeAccount", Strings.FormatNumber(lTotal, 2));
                Report.SetParameterValue("txtAccountTotal", Strings.FormatNumber(lTotal, 2));

                //Settlement Discount........

                rs = modReport.getRSreport(ref "SELECT Sum(CustomerTransaction_Amount) AS lSettDiscount FROM CustomerTransaction WHERE CustomerTransaction_TransactionTypeID = 8;");
                // AND CustomerTransaction_ReferenceID <> 0;")
                if (Information.IsDBNull(rs.Fields("lSettDiscount").Value)) {
                    Report.SetParameterValue("txtSettlementDiscount", "0.00");
                } else {
                    Report.SetParameterValue("txtSettlementDiscount", Strings.FormatNumber(rs.Fields("lSettDiscount").Value, 2));
                }
                rs.Close();

                //---------------------------
                //Do money movement...
                lCash = 0;
                lDebit = 0;
                lCheque = 0;
                lCredit = 0;

                lTotal = 0;
                //Set rs = getRSreport("SELECT Sale.Sale_PaymentType,Sum(Sale.Sale_Total) as AmountTotal, Sum(Sale.Sale_Cash) AS amountCash,Sum(Sale.Sale_Card) AS amountCard,Sum(Sale.Sale_Cheque) AS amountCheque,Sum(Sale.Sale_CDebit) AS amountCredit FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null) And ((Sale.Sale_SaleChk)=False)) GROUP BY Sale.Sale_PaymentType;")
                rs = modReport.getRSreport(ref "SELECT Sale.Sale_PaymentType,Sum(Sale.Sale_Total) as AmountTotal, Sum(Sale.Sale_Cash) AS amountCash,Sum(Sale.Sale_Card) AS amountCard,Sum(Sale.Sale_Cheque) AS amountCheque,Sum(Sale.Sale_CDebit) AS amountCredit FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_PaymentType;");
                while (!(rs.EOF)) {
                    switch (rs.Fields("Sale_PaymentType").Value) {
                        case 1:
                            lCash = lCash + rs.Fields("amountCash").Value;
                            lTotal = lTotal + rs.Fields("AmountTotal").Value;
                            break;
                        case 2:
                            lCredit = lCredit + rs.Fields("amountCredit").Value;
                            lTotal = lTotal + rs.Fields("AmountTotal").Value;
                            break;
                        case 3:
                            lDebit = lDebit + rs.Fields("amountCard").Value;
                            lTotal = lTotal + rs.Fields("AmountTotal").Value;
                            break;
                        case 4:
                            lTotal = lTotal + rs.Fields("AmountTotal").Value;
                            lCheque = lCheque + rs.Fields("amountCheque").Value;
                            break;
                        case 7:
                            lTotal = lTotal + rs.Fields("AmountTotal").Value;
                            lCash = lCash + rs.Fields("amountCash").Value;
                            lDebit = lDebit + rs.Fields("amountCard").Value;
                            lCredit = lCredit + rs.Fields("amountCredit").Value;
                            lCheque = lCheque + rs.Fields("amountCheque").Value;
                            break;
                    }
                    rs.moveNext();
                }

                //Assign values....
                Report.SetParameterValue("txtMoneyCash", Strings.FormatNumber(lCash, 2));
                Report.SetParameterValue("txtMoneyCRcard", Strings.FormatNumber(lCredit, 2));
                Report.SetParameterValue("txtMoneyDRcard", Strings.FormatNumber(lDebit, 2));
                Report.SetParameterValue("txtMoneyCheque", Strings.FormatNumber(lCheque, 2));
                rs.Close();
                Report.SetParameterValue("txtCubeMoney", Strings.FormatNumber(lTotal, 2));
                Report.SetParameterValue("txtMoneyTotal", Strings.FormatNumber(lTotal, 2));
                //Report.txtMoneyTotal.SetText FormatNumber(lTotal - (CCur(Report.txtStockDiscount.Text) + newDis + CCur(Abs(IIf(Report.txtStockGratuity.Text = " ", "0", Report.txtStockGratuity.Text)))), 2)
                //-------------

                //------------- Discounts
                //Set rs = getRSreport("SELECT Sum(Sale.Sale_Discount) AS amount FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null) And ((Sale.Sale_SaleChk)=False));")
                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Discount) AS amount FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null));");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtStockDiscount", "0.00");
                    oldDis = 0;
                } else {
                    if (rs.RecordCount) {
                        //Report.txtStockDiscount.SetText FormatNumber(0 - rs("amount"), 2)
                        Report.SetParameterValue("txtSCmDiscount", Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                        oldDis = Convert.ToDecimal(Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                    } else {
                        Report.SetParameterValue("txtStockDiscount", "0.00");
                        oldDis = 0;
                    }
                }
                rs.Close();

                //Set rs = getRSreport("SELECT Sum(Sale.Sale_Discount) AS amount FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null) AND ((Sale.Sale_DisChk) = False) And ((Sale.Sale_SaleChk)=False));")
                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Discount) AS amount FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null) AND ((Sale.Sale_DisChk) = False));");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtStockDiscount", "0.00");
                    oldDis = 0;
                } else {
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtStockDiscount", Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                        //Report.txtSCmDiscount.SetText FormatNumber(0 - rs("amount"), 2)
                        oldDis = Convert.ToDecimal(Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                    } else {
                        Report.SetParameterValue("txtStockDiscount", "0.00");
                        oldDis = 0;
                    }
                }
                rs.Close();
                //------------- Discounts with New Chk

                //Set rs = getRSreport("SELECT Sum(Sale.Sale_Discount) AS amount FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null) AND ((Sale.Sale_DisChk) = True) And ((Sale.Sale_SaleChk)=False));")
                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Discount) AS amount FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null) AND ((Sale.Sale_DisChk) = True));");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtStockDiscount", "0.00");
                } else {
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtStockDiscount", Strings.FormatNumber(0 - rs("amount").Value, 2));
                        newDis = Convert.ToDecimal(Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                        Report.SetParameterValue("txtSCmDiscount", Strings.FormatNumber(0 - rs("amount").Value, 2));
                    } else {
                        Report.SetParameterValue("txtStockDiscount", "0.00");
                    }
                }
                rs.Close();

                //-------------Grutity
                //Set rs = getRSreport("SELECT Sum(Sale.Sale_Gratuity) AS amountGr FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null) And ((Sale.Sale_SaleChk)=False));")
                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Gratuity) AS amountGr FROM aConsignment RIGHT JOIN (aConsignment AS aConsignment_1 RIGHT JOIN Sale ON aConsignment_1.Consignment_SaleID = Sale.SaleID) ON aConsignment.Consignment_ReversalSaleID = Sale.SaleID WHERE (((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null));");
                if (Information.IsDBNull(rs.Fields("amountGr").Value)) {
                    Report.SetParameterValue("txtStockGratuity", "0.00");
                    Report.SetParameterValue("txtStockGratuity", " ");
                    Report.SetParameterValue("Text94", " ");
                } else {
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtStockGratuity", Strings.FormatNumber(0 - rs.Fields("amountGr").Value, 2));
                        //Report.txtSCmDiscount.SetText FormatNumber(0 - rs("amount"), 2)
                    } else {
                        Report.SetParameterValue("txtStockGratuity", "0.00");
                        Report.SetParameterValue("txtStockGratuity", " ");
                        Report.SetParameterValue("Text94", " ");
                    }
                }
                rs.Close();
                rs = modReport.getRSreport(ref "SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS content, CBool([SaleItem_DepositType]) AS depositType, SaleItem.SaleItem_Reversal, Sum(([SaleItem_DepositCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS deposit FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY CBool([SaleItem_DepositType]), SaleItem.SaleItem_Reversal;");
                while (!(rs.EOF)) {
                    if (rs.Fields("depositType").Value) {
                        if (rs.Fields("SaleItem_Reversal").Value) {
                            Report.SetParameterValue("txtStockDepositSold", Strings.FormatNumber(rs.Fields("content").Value, 2));
                        } else {
                            Report.SetParameterValue("txtStockDepositReturn", Strings.FormatNumber(rs.Fields("content").Value, 2));
                        }
                    } else {
                        if (rs.Fields("SaleItem_Reversal").Value) {
                            Report.SetParameterValue("txtStockCreditContent", Strings.FormatNumber(rs.Fields("content").Value, 2));
                            Report.SetParameterValue("txtStockCreditDeposit", Strings.FormatNumber(0 - rs.Fields("deposit").Value, 2));
                        } else {
                            Report.SetParameterValue("txtStockSoldContent", Strings.FormatNumber(rs.Fields("content").Value, 2));
                            Report.SetParameterValue("txtStockSoldDeposit", Strings.FormatNumber(rs.Fields("deposit").Value, 2));
                        }
                    }
                    rs.moveNext();
                }
                rs.Close();

                Report.SetParameterValue("txtStockDepositReturn1", Report.ParameterFields("txtStockDepositReturn").ToString);
                Report.SetParameterValue("txtStockDepositSold1", Report.ParameterFields("txtStockDepositSold").ToString);
                Report.SetParameterValue("txtTotalDepositMove", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockDepositReturn1").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockDepositSold1").ToString), 2));

                 // ERROR: Not supported in C#: OnErrorStatement

                Report.SetParameterValue("txtStockSoldContent", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockSoldContent").ToString) - Convert.ToDecimal(Report.ParameterFields("txtStockSoldDeposit").ToString), 2));
                Report.SetParameterValue("txtStockCreditContent", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockCreditContent").ToString) - Convert.ToDecimal(Report.ParameterFields("txtStockCreditDeposit").ToString), 2));
                Report.SetParameterValue("txtStockSold", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockSoldContent").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockSoldDeposit").ToString), 2));
                Report.SetParameterValue("txtStockCreditTotal", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockCreditContent").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockCreditDeposit").ToString), 2));
                Report.SetParameterValue("txtStockSold1", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockSold").ToString) + (oldDis), 2));
                Report.SetParameterValue("txtStockCreditTotal1", Report.ParameterFields("txtStockCreditTotal").ToString);
                Report.SetParameterValue("txtTotalStockMove", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockSold1").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockCreditTotal1").ToString), 2));
                Report.SetParameterValue("txtMoneyTill", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtMoneyTotal").ToString) + Convert.ToDecimal(Report.ParameterFields("txtOutage").ToString) - Convert.ToDecimal(Report.ParameterFields("txtPayout").ToString), 2));
                Report.SetParameterValue("txtCubeDirect", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtCubeMoney").ToString) + Convert.ToDecimal(Report.ParameterFields("txtCubeAccountPayment").ToString), 2));
                Report.SetParameterValue("txtCubeStock", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtCubeDirect").ToString) + Convert.ToDecimal(Report.ParameterFields("txtCubeAccountSales").ToString), 2));
                lTotal = Convert.ToDecimal(Report.ParameterFields("txtStockCreditTotal").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockDepositReturn").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockDepositSold").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockSold").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockDiscount").ToString) + Convert.ToDecimal(System.Math.Abs((Report.ParameterFields("txtStockGratuity").ToString == " " ? "0" : Report.ParameterFields("txtStockGratuity").ToString)));
                //lTotal = CCur(Report.txtStockCreditTotal.Text) + CCur(Report.txtStockDepositReturn.Text) + CCur(Report.txtStockDepositSold.Text) + CCur(Report.txtStockSold.Text) + CCur(Report.txtStockDiscount.Text) + newDis '+ CCur(Abs(IIf(Report.txtStockGratuity.Text = " ", "0", Report.txtStockGratuity.Text)))
                Report.SetParameterValue("txtStockTotal", Strings.FormatNumber(lTotal, 2));
                //------------- Discounts with New Chk
                Report.SetParameterValue("txtStockDiscount", Strings.FormatNumber(newDis + Convert.ToDecimal(Report.ParameterFields("txtStockDiscount").ToString), 2));

                // to change StockTotal, MoneyTotal, CubeStock, CubeMoney, CubeDirect
                Report.SetParameterValue("txtStockTotal", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockTotal").ToString) - (Convert.ToDecimal(System.Math.Abs((Report.ParameterFields("txtStockGratuity").ToString == " " ? "0" : Report.ParameterFields("txtStockGratuity").ToString)))), 2));
                Report.SetParameterValue("txtMoneyTotal", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtMoneyTotal").ToString) - (Convert.ToDecimal(System.Math.Abs((Report.ParameterFields("txtStockGratuity").ToString == " " ? "0" : Report.ParameterFields("txtStockGratuity").ToString)))), 2));
                Report.SetParameterValue("txtCubeStock", Strings.FormatNumber((Convert.ToDecimal(Report.ParameterFields("txtCubeStock").ToString)) - (Convert.ToDecimal(System.Math.Abs((Report.ParameterFields("txtStockGratuity").ToString == " " ? "0" : Report.ParameterFields("txtStockGratuity").ToString)))), 2));
                //+ OnlyAcclSettDiscount
                Report.SetParameterValue("txtCubeMoney", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtCubeMoney").ToString) - (Convert.ToDecimal(System.Math.Abs((Report.ParameterFields("txtStockGratuity").ToString == " " ? "0" : Report.ParameterFields("txtStockGratuity").ToString)))), 2));
                Report.SetParameterValue("txtCubeDirect", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtCubeDirect").ToString) - (Convert.ToDecimal(System.Math.Abs((Report.ParameterFields("txtStockGratuity").ToString == " " ? "0" : Report.ParameterFields("txtStockGratuity").ToString)))), 2));

                //Old Account Journal Movement
                rs = modReport.getRSreport(ref "SELECT Sum(aCustomerTransaction.CustomerTransaction_Amount) AS SumOfCustomerTransaction_Amount FROM aCustomerTransaction INNER JOIN DayEnd ON aCustomerTransaction.CustomerTransaction_DayEndID = DayEnd.DayEndID WHERE (((aCustomerTransaction.CustomerTransaction_TransactionTypeID)=3 Or (aCustomerTransaction.CustomerTransaction_TransactionTypeID)=4 Or (aCustomerTransaction.CustomerTransaction_TransactionTypeID)=5) AND ((aCustomerTransaction.CustomerTransaction_ReferenceID)=0));");
                //Set rs = getRSreport("SELECT Sum(aCustomerTransaction.CustomerTransaction_Amount) AS SumOfCustomerTransaction_Amount FROM aCustomerTransaction INNER JOIN DayEnd ON aCustomerTransaction.CustomerTransaction_DayEndID = DayEnd.DayEndID WHERE (((aCustomerTransaction.CustomerTransaction_TransactionTypeID)=3 Or (aCustomerTransaction.CustomerTransaction_TransactionTypeID)=4 Or (aCustomerTransaction.CustomerTransaction_TransactionTypeID)=5 Or (aCustomerTransaction.CustomerTransaction_TransactionTypeID)=8) AND ((aCustomerTransaction.CustomerTransaction_ReferenceID)=0));")
                if (rs.RecordCount) {
                    Report.SetParameterValue("txtAccountEFT", Strings.FormatNumber(rs.Fields("SumOfCustomerTransaction_Amount").Value, 2));
                } else {
                    Report.SetParameterValue("txtAccountEFT", Strings.FormatNumber(0, 2));
                }

                //**************************
                //*** Profit Summary ***
                //**************************
                //        Set rs = getRSreport("SELECT Sum(([SaleItem_ActualCost]*[SaleItem_Quantity])) AS actualExcl, Sum(([SaleItem_ActualCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS actualIncl, Sum(([SaleItem_ListCost]*[SaleItem_Quantity])) AS listExcl, Sum(([SaleItem_ListCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS listIncl, Sum([SaleItem_Price]*[SaleItem_Quantity]/(1+[SaleItem_Vat]/100)) AS priceExcl, Sum([SaleItem_Price]*[SaleItem_Quantity]) AS priceIncl, Sum(([SaleItem_DepositCost]*[SaleItem_Quantity])) AS depositExcl, Sum(([SaleItem_DepositCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS depositIncl FROM aConsignment AS aConsignment_1 RIGHT JOIN (SaleItem LEFT JOIN aConsignment ON SaleItem.SaleItem_SaleID = aConsignment.Consignment_SaleID) ON aConsignment_1.Consignment_ReversalSaleID = SaleItem.SaleItem_SaleID WHERE (((SaleItem.SaleItem_DepositType)=0) AND ((SaleItem.SaleItem_Revoke)=False) AND ((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null));")

                sql = "SELECT Sum(IIf([SaleItem_Reversal],0-[SaleItem_ActualCost]*[SaleItem_Quantity],[SaleItem_ActualCost]*[SaleItem_Quantity])) AS actualExcl, Sum(((IIf([SaleItem_Reversal],0-[SaleItem_ActualCost]*[SaleItem_Quantity],[SaleItem_ActualCost]*[SaleItem_Quantity]))*(1+[SaleItem_Vat]/100))) AS actualIncl, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ListCost]*[SaleItem_Quantity],[SaleItem_ListCost]*[SaleItem_Quantity])) AS listExcl, Sum(((IIf([SaleItem_Reversal],0-[SaleItem_ListCost]*[SaleItem_Quantity],[SaleItem_ListCost]*[SaleItem_Quantity]))*(1+[SaleItem_Vat]/100))) AS listIncl, Sum(([SaleItem_Price]*[SaleItem_Quantity]/(1+[SaleItem_Vat]/100))) AS priceExcl, Sum(([SaleItem_Price]*[SaleItem_Quantity])) AS priceIncl, Sum(IIf([SaleItem_Reversal],0-[SaleItem_DepositCost]*[SaleItem_Quantity],[SaleItem_DepositCost]*[SaleItem_Quantity])) AS depositExcl, Sum((IIf([SaleItem_Reversal],0-[SaleItem_DepositCost]*[SaleItem_Quantity],[SaleItem_DepositCost]*[SaleItem_Quantity]))*(1+[SaleItem_Vat]/100)) AS depositIncl ";
                sql = sql + "FROM aConsignment AS aConsignment_1 RIGHT JOIN (SaleItem LEFT JOIN aConsignment ON SaleItem.SaleItem_SaleID = aConsignment.Consignment_SaleID) ON aConsignment_1.Consignment_ReversalSaleID = SaleItem.SaleItem_SaleID ";
                sql = sql + "WHERE (((SaleItem.SaleItem_DepositType)=0) AND ((SaleItem.SaleItem_Revoke)=False) AND ((aConsignment.ConsignmentID) Is Null) AND ((aConsignment_1.ConsignmentID) Is Null));";

                rs = modReport.getRSreport(ref sql);
                Report.SetParameterValue("txtLEcost", Strings.FormatNumber(rs.Fields("listExcl").Value, 0));
                Report.SetParameterValue("txtAEcost", Strings.FormatNumber(rs.Fields("actualExcl").Value, 0));
                Report.SetParameterValue("txtLIcost", Strings.FormatNumber(rs.Fields("listIncl").Value, 0));
                Report.SetParameterValue("txtAIcost", Strings.FormatNumber(rs.Fields("actualIncl").Value, 0));
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLEcost").ToString))
                    Report.SetParameterValue("txtLEcost", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLIcost").ToString))
                    Report.SetParameterValue("txtLIcost", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAEcost").ToString))
                    Report.SetParameterValue("txtAEcost", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAIcost").ToString))
                    Report.SetParameterValue("txtAIcost", "0");

                Report.SetParameterValue("txtLEdeposit", Strings.FormatNumber(rs.Fields("depositExcl").Value, 0));
                Report.SetParameterValue("txtLIdeposit", Strings.FormatNumber(rs.Fields("depositIncl").Value, 0));
                Report.SetParameterValue("txtAEdeposit", Strings.FormatNumber(rs.Fields("depositExcl").Value, 0));
                Report.SetParameterValue("txtAIdeposit", Strings.FormatNumber(rs.Fields("depositIncl").Value, 0));
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLEdeposit").ToString))
                    Report.SetParameterValue("txtLEdeposit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLIdeposit").ToString))
                    Report.SetParameterValue("txtLIdeposit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAEdeposit").ToString))
                    Report.SetParameterValue("txtAEdeposit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAIdeposit").ToString))
                    Report.SetParameterValue("txtAIdeposit", "0");

                Report.SetParameterValue("txtLEcontent", Strings.FormatNumber(rs.Fields("priceExcl").Value - rs.Fields("depositExcl").Value + (oldDis), 0));
                Report.SetParameterValue("txtLIcontent", Strings.FormatNumber(rs.Fields("priceIncl").Value - rs.Fields("depositIncl").Value + (oldDis), 0));
                Report.SetParameterValue("txtAEcontent", Strings.FormatNumber(rs.Fields("priceExcl").Value - rs.Fields("depositExcl").Value + (oldDis), 0));
                Report.SetParameterValue("txtAIcontent", Strings.FormatNumber(rs.Fields("priceIncl").Value - rs.Fields("depositIncl").Value + (oldDis), 0));
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLEcontent").ToString))
                    Report.SetParameterValue("txtLEcontent", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLIcontent").ToString))
                    Report.SetParameterValue("txtLIcontent", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAEcontent").ToString))
                    Report.SetParameterValue("txtAEcontent", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAIcontent").ToString))
                    Report.SetParameterValue("txtAIcontent", "0");

                Report.SetParameterValue("txtLEProfit", Strings.FormatNumber((rs.Fields("priceExcl").Value - rs.Fields("depositExcl").Value) - (rs.Fields("listExcl")).Value, 0));
                Report.SetParameterValue("txtLIProfit", Strings.FormatNumber((rs.Fields("priceIncl").Value - rs.Fields("depositIncl").Value) - (rs.Fields("listIncl")).Value, 0));
                Report.SetParameterValue("txtAEProfit", Strings.FormatNumber((rs.Fields("priceExcl").Value - rs.Fields("depositExcl").Value) - (rs.Fields("actualExcl")).Value, 0));
                Report.SetParameterValue("txtAIProfit", Strings.FormatNumber((rs.Fields("priceIncl").Value - rs.Fields("depositIncl").Value) - (rs.Fields("actualIncl")).Value, 0));
                if (Convert.ToDecimal(Report.ParameterFields("txtLEcost").ToString) == 0) {
                    if (string.IsNullOrEmpty(Report.ParameterFields("txtLEProfit").ToString))
                        Report.SetParameterValue("txtLEProfit", "0");
                    if (string.IsNullOrEmpty(Report.ParameterFields("txtLIProfit").ToString))
                        Report.SetParameterValue("txtLIProfit", "0");
                    if (string.IsNullOrEmpty(Report.ParameterFields("txtAEProfit").ToString))
                        Report.SetParameterValue("txtAEProfit", "0");
                    if (string.IsNullOrEmpty(Report.ParameterFields("txtAIProfit").ToString))
                        Report.SetParameterValue("txtAIProfit", "0");
                } else {
                    Report.SetParameterValue("txtLEPerc", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtLEProfit").ToString) / Convert.ToDecimal(Report.ParameterFields("txtLEcost").ToString) * 100, 2) + "%");
                    Report.SetParameterValue("txtLIPerc", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtLIProfit").ToString) / Convert.ToDecimal(Report.ParameterFields("txtLIcost").ToString) * 100, 2) + "%");
                    Report.SetParameterValue("txtAEPerc", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtAEProfit").ToString) / Convert.ToDecimal(Report.ParameterFields("txtAEcost").ToString) * 100, 2) + "%");
                    Report.SetParameterValue("txtAIPerc", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtAIProfit").ToString) / Convert.ToDecimal(Report.ParameterFields("txtAIcost").ToString) * 100, 2) + "%");
                }
                Report.SetParameterValue("txtLEtotalProfit", Strings.FormatNumber(rs.Fields("priceExcl").Value - rs.Fields("listExcl").Value - rs.Fields("depositExcl").Value + (oldDis), 0));
                Report.SetParameterValue("txtLItotalProfit", Strings.FormatNumber(rs.Fields("priceIncl").Value - rs.Fields("listIncl").Value - rs.Fields("depositIncl").Value + (oldDis), 0));

                Report.SetParameterValue("txtAEtotalProfit", Strings.FormatNumber(rs.Fields("priceExcl").Value - rs.Fields("actualExcl").Value - rs.Fields("depositExcl").Value + (oldDis), 0));
                Report.SetParameterValue("txtAItotalProfit", Strings.FormatNumber(rs.Fields("priceIncl").Value - rs.Fields("actualIncl").Value - rs.Fields("depositIncl").Value + (oldDis), 0));
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLEtotalProfit").ToString))
                    Report.SetParameterValue("txtLEtotalProfit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLItotalProfit").ToString))
                    Report.SetParameterValue("txtLItotalProfit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAEtotalProfit").ToString))
                    Report.SetParameterValue("txtAEtotalProfit", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAItotalProfit").ToString))
                    Report.SetParameterValue("txtAItotalProfit", "0");

                Report.SetParameterValue("txtLEtotal", Strings.FormatNumber(rs.Fields("priceExcl").Value + (oldDis), 0));
                Report.SetParameterValue("txtLItotal", Strings.FormatNumber(rs.Fields("priceIncl").Value + (oldDis), 0));
                Report.SetParameterValue("txtAEtotal", Strings.FormatNumber(rs.Fields("priceExcl").Value + (oldDis), 0));
                Report.SetParameterValue("txtAItotal", Strings.FormatNumber(rs.Fields("priceIncl").Value + (oldDis), 0));
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLEtotal").ToString))
                    Report.SetParameterValue("txtLEtotal", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtLItotal").ToString))
                    Report.SetParameterValue("txtLItotal", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAEtotal").ToString))
                    Report.SetParameterValue("txtAEtotal", "0");
                if (string.IsNullOrEmpty(Report.ParameterFields("txtAItotal").ToString))
                    Report.SetParameterValue("txtAItotal", "0");

                if (Convert.ToDecimal(Report.ParameterFields("txtLEcost").ToString) == 0) {
                } else {
                    Report.SetParameterValue("txtLEtotalPerc", Strings.FormatNumber((1 - ((rs.Fields("listExcl").Value + oldDis) + rs.Fields("depositExcl").Value) / rs.Fields("priceExcl").Value) * 100, 2) + "%");
                    Report.SetParameterValue("txtLItotalPerc", Strings.FormatNumber((1 - ((rs.Fields("listIncl").Value + oldDis) + rs.Fields("depositIncl").Value) / rs.Fields("priceIncl").Value) * 100, 2) + "%");
                    Report.SetParameterValue("txtAEtotalPerc", Strings.FormatNumber((1 - ((rs.Fields("actualExcl").Value + oldDis) + rs.Fields("depositExcl").Value) / rs.Fields("priceExcl").Value) * 100, 2) + "%");
                    Report.SetParameterValue("txtAItotalPerc", Strings.FormatNumber((1 - ((rs.Fields("actualIncl").Value + oldDis) + rs.Fields("depositIncl").Value) / rs.Fields("priceIncl").Value) * 100, 2) + "%");
                }

                //***Stock Holding
                if (lMode) {
                } else {
                    rs = modReport.getRSreport(ref "SELECT Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]) AS listSales, Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ActualCost]) AS actualSales, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]) AS listShrink, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ActualCost]) AS actualShrink, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS listGRV, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ActualCost]) AS actualGRV FROM DayEndStockItemLnk;");
                    if (Information.IsDBNull(rs.Fields("listShrink").Value)) {
                        Report.SetParameterValue("txtSHRL", Strings.FormatNumber(0, 2));
                    } else {
                        Report.SetParameterValue("txtSHRL", Strings.FormatNumber(rs.Fields("listShrink").Value, 2));
                    }
                    if (Information.IsDBNull(rs.Fields("listGRV").Value)) {
                        Report.SetParameterValue("txtGRVL", Strings.FormatNumber(0, 2));
                    } else {
                        Report.SetParameterValue("txtGRVL", Strings.FormatNumber(rs.Fields("listGRV").Value, 2));
                    }
                    if (Information.IsDBNull(rs.Fields("listSales").Value)) {
                        Report.SetParameterValue("txtSaleL", Strings.FormatNumber(0, 2));
                    } else {
                        Report.SetParameterValue("txtSaleL", Strings.FormatNumber(rs.Fields("listSales").Value, 2));
                    }

                    //Report.txtSHRA.SetText FormatNumber(rs("actualShrink"), 2)
                    //Report.txtGRVA.SetText FormatNumber(rs("actualGRV"), 2)
                    //Report.txtSaleA.SetText FormatNumber(rs("actualSales"), 2)

                    rs = modReport.getRSreport(ref "SELECT Sum(([DayEndStockItemLnk]![DayEndStockItemLnk_ListCost]-[DayEndStockItemLnkfrom]![DayEndStockItemLnk_ListCost])*[DayEndStockItemLnk]![DayEndStockItemLnk_Quantity]) AS totalProfitList, Sum(([DayEndStockItemLnk]![DayEndStockItemLnk_ActualCost]-[DayEndStockItemLnkfrom]![DayEndStockItemLnk_ActualCost])*[DayEndStockItemLnk]![DayEndStockItemLnk_Quantity]) AS totalProfitActual FROM [SELECT DayEndStockItemLnkFirst.* From DayEndStockItemLnkFirst Union SELECT DayEndStockItemLnk.* From DayEndStockItemLnk ]. AS dayendStockItemLnkFrom INNER JOIN DayEndStockItemLnk ON dayendStockItemLnkFrom.DayEndStockItemLnk_StockItemID = DayEndStockItemLnk.DayEndStockItemLnk_StockItemID WHERE (((DayEndStockItemLnk.DayEndStockItemLnk_DayEndID)=[DayEndStockItemLnkfrom]![DayEndStockItemLnk_DayEndID]+1));");
                    if (Information.IsDBNull(rs.Fields("totalProfitList").Value)) {
                        Report.SetParameterValue("TxtSVarianceL", Strings.FormatNumber(0, 2));
                    } else {
                        Report.SetParameterValue("txtSVarianceL", Strings.FormatNumber(rs.Fields("totalProfitList").Value, 2));
                    }
                    Report.SetParameterValue("txtSVarianceA", Strings.FormatNumber(0, 2));

                    rs = modReport.getRSreport(ref "SELECT Sum(([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ListCost]) AS list, Sum(([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_actualCost]) AS actual FROM Report INNER JOIN DayEndStockItemLnk ON Report.Report_DayEndEndID = DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;");
                    Report.SetParameterValue("txtSHLclose", Strings.FormatNumber(rs.Fields("list").Value, 2));
                    //        Report.txtSHAclose.SetText FormatNumber(rs("actual"), 2)

                    rs = modReport.getRSreport(ref "SELECT Sum(IIf([DayEndDeposittemLnk_DepositType]=0,[DayEndDepositItemLnk_UnitCost]*([DayEndDepositItemLnk_Quantity]-DayEndDepositItemLnk_QuantitySales-DayEndDepositItemLnk_QuantityShrink+DayEndDepositItemLnk_QuantityGRV),[DayEndDepositItemLnk_CaseCost]*([DayEndDepositItemLnk_Quantity]-DayEndDepositItemLnk_QuantitySales-DayEndDepositItemLnk_QuantityShrink+DayEndDepositItemLnk_QuantityGRV))) AS actual FROM Report INNER JOIN DayEndDepositItemLnk ON Report.Report_DayEndEndID = DayEndDepositItemLnk.DayEndDepositItemLnk_DayEndID;");
                    Report.SetParameterValue("txtSHAclose", Strings.FormatNumber(rs.Fields("actual").Value, 2));

                    rs = modReport.getRSreport(ref "SELECT Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]) AS list, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_actualCost]) AS actual FROM Report INNER JOIN DayEndStockItemLnk ON Report.Report_DayEndStartID = DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;");
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtSHLopen", Strings.FormatNumber(rs.Fields("list").Value, 2));
                        Report.SetParameterValue("txtSHAopen", Strings.FormatNumber(rs.Fields("actual").Value, 2));
                    } else {
                        Report.SetParameterValue("txtSHLopen", Strings.FormatNumber(0, 2));
                        Report.SetParameterValue("txtSHAopen", Strings.FormatNumber(0, 2));
                    }

                    rs = modReport.getRSreport(ref "SELECT Sum((IIf([DayEndDeposittemLnk_DepositType]=0,[DayEndDepositItemLnk_UnitCost],[DayEndDepositItemLnk_CaseCost])*([DayEndDepositItemLnk_Quantity]))) AS Quantity FROM Report INNER JOIN DayEndDepositItemLnk ON Report.Report_DayEndStartID = DayEndDepositItemLnk.DayEndDepositItemLnk_DayEndID;");
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtSHAopen", Strings.FormatNumber(rs.Fields("quantity").Value, 2));
                    } else {
                        Report.SetParameterValue("txtSHAopen", Strings.FormatNumber(0, 2));
                    }

                    //Set rs = getRSreport("SELECT Sum(IIf([DayEndDeposittemLnk_DepositType]=0,[DayEndDepositItemLnk_UnitCost],[DayEndDepositItemLnk_CaseCost])*[DayEndDepositItemLnk_QuantitySales]) AS Sales, Sum(IIf([DayEndDeposittemLnk_DepositType]=0,[DayEndDepositItemLnk_UnitCost],[DayEndDepositItemLnk_CaseCost])*[DayEndDepositItemLnk_QuantityShrink]) AS Shrink, Sum(IIf([DayEndDeposittemLnk_DepositType]=0,[DayEndDepositItemLnk_UnitCost],[DayEndDepositItemLnk_CaseCost])*[DayEndDepositItemLnk_QuantityGRV]) AS GRV From Report, DayEndDepositItemLnk")
                    rs = modReport.getRSreport(ref "SELECT Sum(IIf([DayEndDeposittemLnk_DepositType]=0,[DayEndDepositItemLnk_UnitCost],[DayEndDepositItemLnk_CaseCost])*[DayEndDepositItemLnk_QuantitySales]) AS Sales, Sum(IIf([DayEndDeposittemLnk_DepositType]=0,[DayEndDepositItemLnk_UnitCost],[DayEndDepositItemLnk_CaseCost])*[DayEndDepositItemLnk_QuantityShrink]) AS Shrink, Sum(IIf([DayEndDeposittemLnk_DepositType]=0,[DayEndDepositItemLnk_UnitCost],[DayEndDepositItemLnk_CaseCost])*[DayEndDepositItemLnk_QuantityGRV]) AS GRV From DayEndDepositItemLnk");
                    Report.SetParameterValue("txtSHRA", Strings.FormatNumber(0 - rs.Fields("Shrink").Value, 2));
                    Report.SetParameterValue("txtGRVA", Strings.FormatNumber(rs.Fields("GRV").Value, 2));
                    Report.SetParameterValue("txtSaleA", Strings.FormatNumber(0 - rs.Fields("Sales").Value, 2));
                    Report.SetParameterValue("txtSVarianceA", Strings.FormatNumber(0, 2));
                    Report.SetParameterValue("txtSVarianceT", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtSVarianceA").ToString) + Convert.ToDecimal(Report.ParameterFields("txtSVarianceA").ToString), 2));
                    Report.SetParameterValue("txtSaleT", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtSaleA").ToString) + Convert.ToDecimal(Report.ParameterFields("txtSaleL").ToString), 2));
                    Report.SetParameterValue("txtGRVT", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtGRVA").ToString) + Convert.ToDecimal(Report.ParameterFields("txtGRVL").ToString), 2));
                    Report.SetParameterValue("txtSHRT", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtSHRA").ToString) + Convert.ToDecimal(Report.ParameterFields("txtSHRL").ToString), 2));
                    Report.SetParameterValue("txtSHTopen", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtSHAopen").ToString) + Convert.ToDecimal(Report.ParameterFields("txtSHLopen").ToString), 2));
                    Report.SetParameterValue("txtSHTclose", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtSHAclose").ToString) + Convert.ToDecimal(Report.ParameterFields("txtSHLclose").ToString), 2));
                }
                rs = modReport.getRSreport(ref "SELECT Sum([SaleItem_ListCost]*[SaleItem_Quantity]) AS list, Sum([SaleItem_ActualCost]*[SaleItem_Quantity]) AS actual FROM aConsignment INNER JOIN SaleItem ON aConsignment.Consignment_SaleID = SaleItem.SaleItem_SaleID;");
                if (Information.IsDBNull(rs.Fields("list").Value)) {
                    Report.SetParameterValue("txtConsLsales", Strings.FormatNumber("0", 2));
                    Report.SetParameterValue("txtConsAsales", Strings.FormatNumber("0", 2));
                } else {
                    Report.SetParameterValue("txtConsLsales", Strings.FormatNumber(rs.Fields("list").Value, 2));
                    Report.SetParameterValue("txtConsAsales", Strings.FormatNumber(rs.Fields("actual").Value, 2));
                }
                rs = modReport.getRSreport(ref "SELECT Sum(Sale.Sale_Total) AS [amount] FROM aConsignment INNER JOIN Sale ON aConsignment.Consignment_SaleID = Sale.SaleID;");
                if (Information.IsDBNull(rs.Fields("amount").Value)) {
                    Report.SetParameterValue("txtConsPsales", Strings.FormatNumber("0", 2));
                } else {
                    Report.SetParameterValue("txtConsPsales", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                }

                rs = modReport.getRSreport(ref "SELECT Sum([SaleItem_ListCost]*[SaleItem_Quantity]) AS list, Sum([SaleItem_ActualCost]*[SaleItem_Quantity]) AS actual FROM aConsignment INNER JOIN SaleItem ON aConsignment.Consignment_CompleteSaleID = SaleItem.SaleItem_SaleID;");
                if (Information.IsDBNull(rs.Fields("list").Value)) {
                    Report.SetParameterValue("txtConsLPurchase", Strings.FormatNumber("0", 2));
                    Report.SetParameterValue("txtConsAPurchase", Strings.FormatNumber("0", 2));
                } else {
                    Report.SetParameterValue("txtConsLPurchase", Strings.FormatNumber(rs.Fields("list").Value, 2));
                    Report.SetParameterValue("txtConsAPurchase", Strings.FormatNumber(rs.Fields("actual").Value, 2));
                }

                rs = modReport.getRSreport(ref "SELECT Sum(theJoin.list) AS list, Sum(theJoin.actual) AS actual FROM (SELECT  1 AS sale, Sum([SaleItem_Quantity]*[SaleItem_ListCost]) AS list, Sum([SaleItem_Quantity]*[SaleItem_actualCost]) AS actual FROM SaleItem INNER JOIN aConsignment ON SaleItem.SaleItem_SaleID = aConsignment.Consignment_CompleteSaleID Union SELECT 0 AS sale, Sum(0-[SaleItem_Quantity]*[SaleItem_ListCost]) AS list, Sum(0-[SaleItem_Quantity]*[SaleItem_actualCost]) AS actual FROM aConsignment INNER JOIN SaleItem ON aConsignment.Consignment_SaleID = SaleItem.SaleItem_SaleID WHERE (((aConsignment.Consignment_CompleteSaleID) Is Not Null))) AS theJoin;");
                if (Information.IsDBNull(rs.Fields("list").Value)) {
                    Report.SetParameterValue("txtConsLreturn", Strings.FormatNumber("0", 2));
                    Report.SetParameterValue("txtConsAreturn", Strings.FormatNumber("0", 2));
                } else {
                    Report.SetParameterValue("txtConsLreturn", Strings.FormatNumber(rs.Fields("list").Value, 2));
                    Report.SetParameterValue("txtConsAreturn", Strings.FormatNumber(rs.Fields("actual").Value, 2));
                }

                rs = modReport.getRSreport(ref "SELECT Sum([Sale]![Sale_Total]+[Sale_1]![Sale_Total]) AS priceReturn, Sale.Sale_Total FROM Sale INNER JOIN (Sale AS Sale_1 INNER JOIN aConsignment ON Sale_1.SaleID = aConsignment.Consignment_ReversalSaleID) ON Sale.SaleID = aConsignment.Consignment_CompleteSaleID GROUP BY Sale.Sale_Total;");
                if (rs.BOF | rs.EOF) {
                    Report.SetParameterValue("txtConsPPurchase", Strings.FormatNumber("0", 2));
                    Report.SetParameterValue("txtConsPreturn", Strings.FormatNumber("0", 2));
                } else {
                    if (Information.IsDBNull(rs.Fields("Sale_Total").Value)) {
                        Report.SetParameterValue("txtConsPPurchase", Strings.FormatNumber("0", 2));
                        Report.SetParameterValue("txtConsPreturn", Strings.FormatNumber("0", 2));
                    } else {
                        Report.SetParameterValue("txtConsPPurchase", Strings.FormatNumber(rs.Fields("Sale_Total").Value, 2));
                        Report.SetParameterValue("txtConsPreturn", Strings.FormatNumber(rs.Fields("priceReturn").Value, 2));
                    }
                }
                rs = modReport.getRSreport(ref "SELECT * FROM aChannel");

                while (!(rs.EOF)) {
                    switch (rs.Fields("ChannelID").Value) {
                        case 1:
                            Report.SetParameterValue("txtSC1", rs.Fields("Channel_Code"));
                            break;
                        case 2:
                            Report.SetParameterValue("txtSC2", rs.Fields("Channel_Code"));
                            break;
                        case 3:
                            Report.SetParameterValue("txtSC3", rs.Fields("Channel_Code"));
                            break;
                        case 4:
                            Report.SetParameterValue("txtSC4", rs.Fields("Channel_Code"));
                            break;
                        case 5:
                            Report.SetParameterValue("txtSC5", rs.Fields("Channel_Code"));
                            break;
                        case 6:
                            Report.SetParameterValue("txtSC6", rs.Fields("Channel_Code"));
                            break;
                        case 7:
                            Report.SetParameterValue("txtSC7", rs.Fields("Channel_Code"));
                            break;
                        case 8:
                            Report.SetParameterValue("txtSC8", rs.Fields("Channel_Code"));
                            break;
                        case 9:
                            Report.SetParameterValue("txtSC9", rs.Fields("Channel_Code"));
                            break;
                    }
                    rs.moveNext();
                }

                //Set rs = getRSreport("SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS SCTotal, Sale.Sale_ChannelID FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null) And ((Sale.Sale_SaleChk)=False)) GROUP BY Sale.Sale_ChannelID;")
                rs = modReport.getRSreport(ref "SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS SCTotal, Sale.Sale_ChannelID FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_ChannelID;");
                //lTotal = CCur(Report.txtSCmDiscount.Text)
                lTotal = oldDis;
                while (!(rs.EOF)) {
                    switch (rs.Fields("Sale_ChannelID").Value) {
                        case 1:
                            Report.SetParameterValue("txtSCm1", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                        case 2:
                            Report.SetParameterValue("txtSCm2", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                        case 3:
                            Report.SetParameterValue("txtSCm3", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                        case 4:
                            Report.SetParameterValue("txtSCm4", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                        case 5:
                            Report.SetParameterValue("txtSCm5", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                        case 6:
                            Report.SetParameterValue("txtSCm6", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                        case 7:
                            Report.SetParameterValue("txtSCm7", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                        case 8:
                            Report.SetParameterValue("txtSCm8", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                        case 9:
                            Report.SetParameterValue("txtSCm9", Strings.FormatNumber(rs.Fields("SCTotal").Value, 2));
                            break;
                    }
                    lTotal = lTotal + rs.Fields("SCTotal").Value;
                    rs.moveNext();
                }
                Report.SetParameterValue("txtSCmTotal", Strings.FormatNumber(lTotal, 2));

                rs = modReport.getRSreport(ref "SELECT Sum(aCustomer.Customer_Current) AS SumOfCustomer_Current, Sum(aCustomer.Customer_30Days) AS SumOfCustomer_30Days, Sum(aCustomer.Customer_60Days) AS SumOfCustomer_60Days, Sum(aCustomer.Customer_90Days) AS SumOfCustomer_90Days, Sum(aCustomer.Customer_120Days) AS SumOfCustomer_120Days, Sum(aCustomer.Customer_150Days) AS SumOfCustomer_150Days FROM aCustomer;");
                lTotal = 0;
                if (rs.RecordCount) {
                    Report.SetParameterValue("txtCA1", Strings.FormatNumber(rs.Fields("SumOfCustomer_Current").Value, 0));
                    Report.SetParameterValue("txtCA2", Strings.FormatNumber(rs.Fields("SumOfCustomer_30Days").Value, 0));
                    Report.SetParameterValue("txtCA3", Strings.FormatNumber(rs.Fields("SumOfCustomer_60Days").Value, 0));
                    Report.SetParameterValue("txtCA4", Strings.FormatNumber(rs.Fields("SumOfCustomer_90Days").Value, 0));
                    Report.SetParameterValue("txtCA5", Strings.FormatNumber(rs.Fields("SumOfCustomer_120Days").Value, 0));
                    Report.SetParameterValue("txtCA6", Strings.FormatNumber(rs.Fields("SumOfCustomer_150Days").Value, 0));
                    Report.SetParameterValue("txtCAtotal", Strings.FormatNumber(rs.Fields("SumOfCustomer_Current").Value + rs.Fields("SumOfCustomer_30Days").Value + rs.Fields("SumOfCustomer_60Days").Value + rs.Fields("SumOfCustomer_90Days").Value + rs.Fields("SumOfCustomer_120Days").Value + rs.Fields("SumOfCustomer_150Days").Value, 0));
                }

                My.MyProject.Forms.frmReportShow.Text = "Sale Dashboard";
                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();
            }
        }
Beispiel #20
0
        private static void report_ProfitByDayEnd()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryProfitByDayEnd
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryProfitByDayEnd.rpt");
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            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();
            sql = "SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ActualCost]*[SaleItem_Quantity],[SaleItem_ActualCost]*[SaleItem_Quantity])) AS actualExcl, Sum(((IIf([SaleItem_Reversal],0-[SaleItem_ActualCost]*[SaleItem_Quantity],[SaleItem_ActualCost]*[SaleItem_Quantity]))*(1+[SaleItem_Vat]/100))) AS actualIncl, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ListCost]*[SaleItem_Quantity],[SaleItem_ListCost]*[SaleItem_Quantity])) AS listExcl, Sum(((IIf([SaleItem_Reversal],0-[SaleItem_ListCost]*[SaleItem_Quantity],[SaleItem_ListCost]*[SaleItem_Quantity]))*(1+[SaleItem_Vat]/100))) AS listIncl, Sum(([SaleItem_Price]*[SaleItem_Quantity]/(1+[SaleItem_Vat]/100))) AS priceExcl, Sum(([SaleItem_Price]*[SaleItem_Quantity])) AS priceIncl, Sum(IIf([SaleItem_Reversal],0-[SaleItem_DepositCost]*[SaleItem_Quantity],[SaleItem_DepositCost]*[SaleItem_Quantity])) AS depositExcl, ";
            sql = sql + "Sum((IIf([SaleItem_Reversal],0-[SaleItem_DepositCost]*[SaleItem_Quantity],[SaleItem_DepositCost]*[SaleItem_Quantity]))*(1+[SaleItem_Vat]/100)) AS depositIncl FROM (Sale INNER JOIN (aConsignment AS aConsignment_1 RIGHT JOIN (SaleItem LEFT JOIN aConsignment ON SaleItem.SaleItem_SaleID = aConsignment.Consignment_SaleID) ON aConsignment_1.Consignment_ReversalSaleID = SaleItem.SaleItem_SaleID) ON Sale.SaleID = SaleItem.SaleItem_SaleID) INNER JOIN DayEnd ON Sale.Sale_DayEndID = DayEnd.DayEndID Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY DayEnd.DayEndID, DayEnd.DayEnd_Date ORDER BY DayEnd.DayEndID;";
            rs = modReport.getRSreport(ref sql);

            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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            //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();
        }
Beispiel #21
0
        private static void report_ProductPerformanceGRVDeals()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            string lOrder = null;
            //Dim CRXDatabaseField As CrystalDecisions.CrystalReports.Engine.DatabaseFieldDefinition
            CrystalDecisions.CrystalReports.Engine.FieldDefinition CRXDatabaseField = default(CrystalDecisions.CrystalReports.Engine.FieldDefinition);

            //    Dim lEmpID As Long
            //
            //    lEmpID = 0
            //    If MsgBox("Do you wish to see report for all Customers?", vbInformation + vbYesNo) = vbYes Then
            //    Else
            //        lEmpID = frmCustomerList.getItem(8)
            //        If lEmpID = 0 Then Exit Sub
            //    End If

            lOrder = "StockItem_Name";
            lOrder = " ORDER BY " + lOrder;

            Report = null;
            Report.Load("cryStockitemTopGroupGRVDeal");
            //Report = New cryStockitemTopGroupGRVDeal

            while (Report.DataDefinition.SortFields.Count) {
                //'Report.RecordSortFields.delete(1)
            }

            //Screen.MousePointer = vbHourglass
            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();

            //    sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, Sum(StockListCustomer.inclusiveSum) AS inclusive, Sum(StockListCustomer.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(StockListCustomer.quantitySum) AS quantity, Sum(StockListCustomer.listCostSum) AS listCost, Sum(StockListCustomer.actualCostSum) AS actualCost, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department, StockListCustomer.CustomerTransaction_CustomerID "
            //    sql = sql & "FROM StockListCustomer INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockListCustomer.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, StockListCustomer.CustomerTransaction_CustomerID HAVING (((StockListCustomer.CustomerTransaction_CustomerID)=" & lEmpID & ")) "
            //
            //    sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, StockListCustomerByGroup.inclusiveSum AS inclusive, StockListCustomerByGroup.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockListCustomerByGroup.quantitySum AS quantity, StockListCustomerByGroup.listCostSum AS listCost, StockListCustomerByGroup.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aStockGroup.StockGroup_Name AS department, StockListCustomerByGroup.CustomerTransaction_CustomerID, StockListCustomerByGroup.Customer_InvoiceName, StockListCustomerByGroup.DayEndID, StockListCustomerByGroup.DayEnd_Date " ', StockListCustomerByGroup.CustomerTransactionID "
            //    sql = sql & "FROM StockListCustomerByGroup INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockListCustomerByGroup.SaleItem_StockItemID = aStockItem1.StockItemID "
            //    sql = sql & "WHERE (((StockListCustomerByGroup.quantitySum)<>" & 0 & ")) "
            //    If lEmpID > 0 Then sql = sql & "AND (((StockListCustomerByGroup.CustomerTransaction_CustomerID)=" & lEmpID & ")) "
            //
            //    sql = Replace(sql, "StockGroup", "PricingGroup")
            //    Report.txtTitle.SetText "Product Performance - by Pricing Group"
            //    sql = sql & lOrder

            int lStkID = 0;

            lStkID = 0;
            if (Interaction.MsgBox("Do you wish to see report for all Stock Items?", MsgBoxStyle.Information + MsgBoxStyle.YesNo) == MsgBoxResult.Yes) {
            } else {
                lStkID = My.MyProject.Forms.frmStockList.getItem();
                if (lStkID == 0)
                    return;
            }

            sql = "SELECT aGRVItem.GRVItem_GRVID, aGRVItem.GRVItem_StockItemID, aGRVItem.GRVItem_Name, aGRVItem.GRVItem_QuantityOrder, aGRVItem.GRVItem_Quantity, aGRVItem.GRVItem_ContentCost, aGRV.GRV_InvoiceDate, Supplier.Supplier_Name, aGRVItem.GRVItem_ContentCost*aGRVItem.GRVItem_Quantity AS Expr1,";
            sql = sql + " (SELECT aGRVPromotionItem1.PromotionItem_Price FROM aGRVPromotion1 INNER JOIN aGRVPromotionItem1 ON aGRVPromotion1.PromotionID = aGRVPromotionItem1.PromotionItem_PromotionID WHERE (((aGRVPromotionItem1.PromotionItem_StockItemID)=aGRVItem.GRVItem_StockItemID) AND ((aGRVPromotion1.Promotion_StartDate)<=aGRV.GRV_InvoiceDate) AND ((aGRVPromotion1.Promotion_EndDate)>=aGRV.GRV_InvoiceDate))) AS DealPrice,";
            sql = sql + " (SELECT aGRVPromotion1.Promotion_Name FROM aGRVPromotion1 INNER JOIN aGRVPromotionItem1 ON aGRVPromotion1.PromotionID = aGRVPromotionItem1.PromotionItem_PromotionID WHERE (((aGRVPromotionItem1.PromotionItem_StockItemID)=aGRVItem.GRVItem_StockItemID) AND ((aGRVPromotion1.Promotion_StartDate)<=aGRV.GRV_InvoiceDate) AND ((aGRVPromotion1.Promotion_EndDate)>=aGRV.GRV_InvoiceDate))) AS DealName,";
            sql = sql + " aPurchaseOrder.PurchaseOrder_DateCreated, aGRV.GRV_Date FROM Report, (aGRVItem INNER JOIN aGRV ON aGRVItem.GRVItem_GRVID = aGRV.GRVID) INNER JOIN (aPurchaseOrder INNER JOIN Supplier ON aPurchaseOrder.PurchaseOrder_SupplierID = Supplier.SupplierID) ON aGRV.GRV_PurchaseOrderID = aPurchaseOrder.PurchaseOrderID";
            //    sql = sql & " Where (((aGRVItem.GRVItem_StockItemID) = 698))"
            if (lStkID == 0) {
                sql = sql + " WHERE (((aGRV.GRV_DayEndID)>=[Report]![Report_DayEndStartID] And (aGRV.GRV_DayEndID)<=[Report]![Report_DayEndEndID]))";
            } else {
                sql = sql + " WHERE (((aGRVItem.GRVItem_StockItemID) = " + lStkID + ") AND ((aGRV.GRV_DayEndID)>=[Report]![Report_DayEndStartID] And (aGRV.GRV_DayEndID)<=[Report]![Report_DayEndEndID]))";
            }
            sql = sql + " ORDER BY aGRVItem.GRVItem_ContentCost;";

            Debug.Print(sql);
            rs = modReport.getRSreport(ref sql);
            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;
            }

            //Report.VerifyOnEveryPrint = True
            Report.Database.Tables(1).SetDataSource(rs);
            Report.SetDataSource(rs);
            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();
        }
Beispiel #22
0
        private static void report_ProductPerformanceEmployee()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As CrystalDecisions.CrystalReports.Engine.ReportDocument
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            string lOrder = null;
            //Dim CRXDatabaseField As CrystalDecisions.CrystalReports.Engine.DatabaseFieldDefinition

            int lEmpID = 0;

            lEmpID = My.MyProject.Forms.frmPersonList.getItem();
            if (lEmpID == 0)
                return;

            //Select Case Me.cmbSortField.ListIndex
            //        Case 0
            lOrder = "StockItem_Name";
            //        Case 1
            //            lOrder = "[exclusiveSum]-[depositSum]-[listCostSum]"
            //        Case 2
            //            lOrder = "[exclusiveSum]-[depositSum]"
            //        Case 3
            //            lOrder = "[exclusiveSum]-[depositSum]-[listCostSum]"
            //        Case 4
            //            lOrder = "IIf([exclusiveSum]=0,0,([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum])"
            //        Case 5
            //            lOrder = "StockList.quantitySum"
            //End Select

            //If Me.cmbSort.ListIndex Then lOrder = lOrder & " DESC"
            lOrder = " ORDER BY " + lOrder;

            //UPGRADE_NOTE: Object Report may not be destroyed until it is garbage collected. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6E35BFF6-CD74-4B09-9689-3E1A43DF8969"'
            Report = null;

            //If Me.optType(0).value Then
            Report.Load("cryStockitemTopEmployee.rpt");
            //ElseIf Me.optType(1).value Then
            //    Set Report = New cryStockitemTopByGroup
            //Else
            //    Set Report = New cryStockitemTopGroup
            //End If
            //Do While Report.DataDefinition.SortFields.Count
            //'Report.RecordSortFields.delete(1)
            //Loop

            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();

            if (lEmpID > 0) {
                rs = modRecordSet.getRS(ref "SELECT Person.Person_FirstName & ' ' & Person.Person_LastName AS MgrName From Person WHERE (((Person.PersonID)=" + lEmpID + "));");
                Report.SetParameterValue("txtFilter", rs.Fields("MgrName"));
            }
            //Set rs = getRSreport("SELECT * FROM Link Where LinkID=2 AND Link_SectionID=1")
            //Report.txtFilter.SetText Replace(rs("Link_Name"), "''", "'")

            //If Me.optType(0).value Then
            //    If rs("Link_SQL") <> "" Then
            //        sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity, StockList.listCostSum AS listCost, StockList.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aStockGroup.StockGroup_Name AS department FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID "
            //    Else
            //        Select Case Me.cmbSortField.ListIndex
            //            Case 0
            //sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name "
            sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, Sum(StockListEmployee.inclusiveSum) AS inclusive, Sum(StockListEmployee.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(StockListEmployee.quantitySum) AS quantity, Sum(StockListEmployee.listCostSum) AS listCost, Sum(StockListEmployee.actualCostSum) AS actualCost, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department, StockListEmployee.Sale_PersonID ";
            sql = sql + "FROM StockListEmployee INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockListEmployee.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, StockListEmployee.Sale_PersonID Having (((StockListEmployee.Sale_PersonID) = " + lEmpID + ")) ";

            //            Case 1
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, ([exclusiveSum]-[depositSum]-[listCostSum]) "
            //                'lOrder = "[exclusiveSum]-[depositSum]-[listCostSum]"
            //            Case 2
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, ([exclusiveSum]-[depositSum]) "
            //                'lOrder = "[exclusiveSum]-[depositSum]"
            //            Case 3
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, ([exclusiveSum]-[depositSum]-[listCostSum]) "
            //                'lOrder = "[exclusiveSum]-[depositSum]-[listCostSum]"
            //            Case 4
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, IIf([exclusiveSum]=0,0,([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]) "
            //                'lOrder = "IIf([exclusiveSum]=0,0,([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum])"
            //            Case 5
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, StockList.quantitySum "
            //                'lOrder = "StockList.quantitySum"
            //        End Select
            //    End If
            //
            //ElseIf Me.optType(1).value Then
            //    If rs("Link_SQL") <> "" Then
            //        sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity, StockList.listCostSum AS listCost, StockList.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aStockGroup.StockGroup_Name AS department FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID "
            //    Else
            //        Select Case Me.cmbSortField.ListIndex
            //            Case 0
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name "
            //            Case 1
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, ([exclusiveSum]-[depositSum]-[listCostSum]) "
            //                'lOrder = "[exclusiveSum]-[depositSum]-[listCostSum]"
            //            Case 2
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, ([exclusiveSum]-[depositSum]) "
            //                'lOrder = "[exclusiveSum]-[depositSum]"
            //            Case 3
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, ([exclusiveSum]-[depositSum]-[listCostSum]) "
            //                'lOrder = "[exclusiveSum]-[depositSum]-[listCostSum]"
            //            Case 4
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, IIf([exclusiveSum]=0,0,([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]) "
            //                'lOrder = "IIf([exclusiveSum]=0,0,([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum])"
            //            Case 5
            //                sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //                sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name, StockList.quantitySum "
            //                'lOrder = "StockList.quantitySum"
            //        End Select
            //        'sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //        'sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name "
            //    End If
            //    Select Case Me.cmbGroup.ListIndex
            //        Case 0
            //            sql = Replace(sql, "StockGroup", "PricingGroup")
            //            Report.txtTitle.SetText "Product Performance - by Pricing Group"
            //        Case 1
            //            Report.txtTitle.SetText "Product Performance - by Stock Group"
            //        Case 2
            //            sql = Replace(sql, "StockGroup", "Supplier")
            //            sql = Replace(sql, "aSupplier", "Supplier")
            //            Report.txtTitle.SetText "Product Performance - by Supplier"
            //        Case 3
            //            sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity, StockList.listCostSum AS listCost, StockList.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aReportGroup1.ReportGroup_Name AS department FROM StockList INNER JOIN (aStockItem1 INNER JOIN aReportGroup1 ON aStockItem1.StockItem_ReportID = aReportGroup1.ReportID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID "
            //            Report.txtTitle.SetText "Product Performance - by Report Group"
            //    End Select
            //
            //    If Me.chkPageBreak.value Then
            //        Report.ReportDefinition.Sections(5).SectionFormat.EnableNewPageAfter = True
            //    Else
            //        Report.ReportDefinition.Sections(5).SectionFormat.EnableNewPageAfter = False
            //    End If
            //
            //Else
            //    'If rs("Link_SQL") <> "" Then
            //        sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity, StockList.listCostSum AS listCost, StockList.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aStockGroup.StockGroup_Name AS department FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID "
            //    'Else
            //    '    sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, 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, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0)) AS gpActual, Sum(IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0)) AS gpList, aStockGroup.StockGroup_Name AS department "
            //    '    sql = sql & "FROM StockList INNER JOIN (aStockItem1 INNER JOIN aStockGroup ON aStockItem1.StockItem_StockGroupID = aStockGroup.StockGroupID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID GROUP BY  aStockItem1.StockItemID, aStockItem1.StockItem_Name, aStockGroup.StockGroup_Name "
            //    'End If
            //    Select Case Me.cmbGroup.ListIndex
            //        Case 0
            //            sql = Replace(sql, "StockGroup", "PricingGroup")
            //            Report.txtTitle.SetText "Product Performance - by Pricing Group"
            //        Case 1
            //            Report.txtTitle.SetText "Product Performance - by Stock Group"
            //        Case 2
            //            sql = Replace(sql, "StockGroup", "Supplier")
            //            sql = Replace(sql, "aSupplier", "Supplier")
            //            Report.txtTitle.SetText "Product Performance - by Supplier"
            //        Case 3
            //            sql = "SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity, StockList.listCostSum AS listCost, StockList.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aReportGroup1.ReportGroup_Name AS department FROM StockList INNER JOIN (aStockItem1 INNER JOIN aReportGroup1 ON aStockItem1.StockItem_ReportID = aReportGroup1.ReportID) ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID "
            //            Report.txtTitle.SetText "Product Performance - by Report Group"
            //    End Select

            //    If Me.chkPageBreak.value Then
            //        Report.ReportDefinition.Sections(5).SectionFormat.EnableNewPageAfter = True
            //    Else
            //        Report.ReportDefinition.Sections(5).SectionFormat.EnableNewPageAfter = False
            //    End If
            //End If

            //for customer
            //SELECT aStockItem1.StockItemID, aStockItem1.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity, StockList.listCostSum AS listCost, StockList.actualCostSum AS actualCost, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[actualCostSum])/[exclusiveSum]*100,0) AS gpActual, IIf([exclusiveSum],([exclusiveSum]-[depositSum]-[listCostSum])/[exclusiveSum]*100,0) AS gpList, aCustomer.Customer_InvoiceName AS department
            //FROM aCustomer INNER JOIN (CustomerTransaction INNER JOIN (Sale INNER JOIN (SaleItem INNER JOIN (StockList INNER JOIN aStockItem1 ON StockList.SaleItem_StockItemID = aStockItem1.StockItemID) ON SaleItem.SaleItem_StockItemID = StockList.SaleItem_StockItemID) ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON aCustomer.CustomerID = CustomerTransaction.CustomerTransaction_CustomerID
            //WHERE (((aCustomer.CustomerID)=2) AND ((CustomerTransaction.CustomerTransaction_TransactionTypeID)=2)) OR (((CustomerTransaction.CustomerTransaction_TransactionTypeID)=3));

            //If rs("Link_SQL") = "" Then
            //Else
            //    sql = sql & rs("Link_SQL")
            //End If

            sql = sql + lOrder;
            Debug.Print(sql);
            rs = modReport.getRSreport(ref sql);

            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;
            }

            //Report.VerifyOnEveryPrint = True
            Report.Database.Tables(1).SetDataSource(rs);
            Report.SetDataSource(rs);
            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();
        }
Beispiel #23
0
        private void loadQTY()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As New cryItemItemCompareQty
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryItemItemCompareQty.rpt");
            ReportNone.Load("cryNoRecords.rpt");
            modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where Link_SectionID=3");
            while (!(rs.EOF)) {
                if (!string.IsNullOrEmpty(rs.Fields("Link_SQL").Value)) {
                    modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT " + rs.Fields("LinkID").Value + ", DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID WHERE " + rs.Fields("Link_SQL").Value + ";");
                }
                rs.moveNext();
            }

            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT theJoin.LinkID, theJoin.DayEndID, 0 FROM LinkItem RIGHT JOIN [SELECT Link.LinkID, DayEnd.DayEndID From Link, DayEnd WHERE (((Link.Link_SQL)<>'') AND ((Link.Link_SectionID)=3))]. AS theJoin ON (LinkItem.LinkItem_DayEndID = theJoin.DayEndID) AND (LinkItem.LinkItem_LinkID = theJoin.LinkID) WHERE (((LinkItem.LinkItem_LinkID) Is Null));");
            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 "SELECT [Link].[LinkID], [Link].[Link_Name], Sum([LinkItem].[LinkItem_Value]) AS SumOfLinkItem_Value FROM Link INNER JOIN LinkItem ON [Link].[LinkID]=[LinkItem].[LinkItem_LinkID] WHERE ((([Link].[Link_SQL])<>'') And (([Link].[Link_SectionID])=3)) GROUP BY [Link].[LinkID], [Link].[Link_Name] ORDER BY [Link].[LinkID];");

            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;
            }
            rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'yyyy mm dd ddd') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID ORDER BY DayEnd.DayEnd_Date;");
            if (rsData.BOF | rsData.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();
                //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            System.Windows.Forms.Application.DoEvents();
            //Report.VerifyOnEveryPrint = True
            System.Windows.Forms.Application.DoEvents();
            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();
        }
        private void InformationReport(ref bool ltype)
        {
            string sql = null;

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

            ADODB.Recordset RSitem = default(ADODB.Recordset);
            //Dim Report As New crySupplierOrderInformation
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("crySupplierOrderInformation.rpt");
            if (string.IsNullOrEmpty(this.DataList1.BoundText))
            {
                return;
            }
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            lDays = 10;
            modRecordSet.cnnDB.Execute("UPDATE StockitemHistory SET StockitemHistory.StockitemHistory_Value = 0;");
            modRecordSet.cnnDB.Execute("UPDATE StockitemHistory SET StockitemHistory.StockitemHistory_Value = [StockitemHistory]![StockitemHistory_Day11]+[StockitemHistory]![StockitemHistory_Day2]+[StockitemHistory]![StockitemHistory_Day3]+[StockitemHistory]![StockitemHistory_Day4]+[StockitemHistory]![StockitemHistory_Day5]+[StockitemHistory]![StockitemHistory_Day6]+[StockitemHistory]![StockitemHistory_Day7]+[StockitemHistory]![StockitemHistory_Day8]+[StockitemHistory]![StockitemHistory_Day9]+[StockitemHistory]![StockitemHistory_Day10];");

            modRecordSet.cnnDB.Execute("UPDATE Company, StockBreakTransaction INNER JOIN StockitemHistory ON StockBreakTransaction.StockBreakTransaction_ParentID = StockitemHistory.StockitemHistory_StockItemID SET StockitemHistory.StockitemHistory_Value = [StockitemHistory_Value]+[StockBreakTransaction_MoveQuantity] WHERE ((([Company_DayEndID]-[StockBreakTransaction_DayEndID]+1)<=" + lDays + "));");
            modRecordSet.cnnDB.Execute("UPDATE Company, StockBreakTransaction INNER JOIN StockitemHistory ON StockBreakTransaction.StockBreakTransaction_ChildID = StockitemHistory.StockitemHistory_StockItemID SET StockitemHistory.StockitemHistory_Value = [StockitemHistory_Value]-([StockBreakTransaction_MoveQuantity]*[StockBreakTransaction_Quantity]) WHERE ((([Company_DayEndID]-[StockBreakTransaction_DayEndID]+1)<=" + lDays + "));");
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();
            if (ltype)
            {
                sql = "SELECT WarehouseStockItemLnk.WarehouseStockItemLnk_StockItemID, WarehouseStockItemLnk.WarehouseStockItemLnk_WarehouseID, StockItem.StockItem_SupplierID, StockitemHistory.StockitemHistory_Value, StockItem.StockItem_Name, StockItem.StockItem_ListCost, StockItem.StockItem_Quantity, StockItem.StockItem_OrderQuantity, StockItem.StockItem_OrderRounding, WarehouseStockItemLnk.WarehouseStockItemLnk_Quantity FROM WarehouseStockItemLnk INNER JOIN (StockitemHistory INNER JOIN StockItem ON StockitemHistory.StockitemHistory_StockItemID = StockItem.StockItemID) ON WarehouseStockItemLnk.WarehouseStockItemLnk_StockItemID = StockItem.StockItemID Where WarehouseStockItemLnk.WarehouseStockItemLnk_WarehouseID = 2 And StockItem.StockItem_SupplierID = " + this.DataList1.BoundText + " AND StockItem.StockItem_Discontinued=0  And (WarehouseStockItemLnk.WarehouseStockItemLnk_Quantity <= [StockitemHistory]![StockitemHistory_Value]) ORDER BY StockItem.StockItem_Name;";
            }
            else
            {
                sql = "SELECT WarehouseStockItemLnk.WarehouseStockItemLnk_StockItemID, WarehouseStockItemLnk.WarehouseStockItemLnk_WarehouseID, StockItem.StockItem_SupplierID, StockitemHistory.StockitemHistory_Value, StockItem.StockItem_Name, StockItem.StockItem_ListCost, StockItem.StockItem_Quantity, StockItem.StockItem_OrderQuantity, StockItem.StockItem_OrderRounding, WarehouseStockItemLnk.WarehouseStockItemLnk_Quantity FROM WarehouseStockItemLnk INNER JOIN (StockitemHistory INNER JOIN StockItem ON StockitemHistory.StockitemHistory_StockItemID = StockItem.StockItemID) ON WarehouseStockItemLnk.WarehouseStockItemLnk_StockItemID = StockItem.StockItemID Where WarehouseStockItemLnk.WarehouseStockItemLnk_WarehouseID = 2 And StockItem.StockItem_SupplierID = " + this.DataList1.BoundText + " AND StockItem.StockItem_Discontinued=0 ORDER BY StockItem.StockItem_Name;";
            }
            RSitem = modRecordSet.getRS(ref sql);
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            if (RSitem.BOF | RSitem.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;
            }
            rs = modRecordSet.getRS(ref "SELECT * From Supplier WHERE SupplierID=" + this.DataList1.BoundText);
            Report.Database.Tables(1).SetDataSource(RSitem);
            Report.Database.Tables(2).SetDataSource(rs);
            //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();
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
Beispiel #25
0
        private static void report_Gratuity()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryGratuity
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryGratuity.rpt");
            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 "SELECT [Person_FirstName]+' '+[Person_LastName] AS person_Name, aPOS.POS_Name, Sale.* FROM (Sale INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) INNER JOIN aPOS ON Sale.Sale_PosID = aPOS.POSID Where (((Sale.Sale_Gratuity) <> 0)) ORDER BY Sale.Sale_Gratuity DESC;");
            //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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            //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();
        }
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs  = default(ADODB.Recordset);
            string          sql = null;

            ADODB.Recordset rsData = default(ADODB.Recordset);

            //Dim Report As New cryPricelistRealNoGroup 'cryPricelistReal
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            switch (this.cmbGroup.SelectedIndex)
            {
            case 0:
                Report.Load("cryPricelistReal.rpt");
                chkPageBreak.Enabled = true;
                break;

            case 1:
                Report.Load("cryPricelistReal.rpt");
                chkPageBreak.Enabled = true;
                break;

            case 2:
                Report.Load("cryPricelistReal.rpt");
                chkPageBreak.Enabled = true;
                break;

            case 3:
                Report.Load("cryPricelistRealNoGroup.rpt");
                chkPageBreak.Enabled = false;
                break;
            }

            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            ReportNone.Load("cryNoRecords.rpt");
            string lOrder = null;
            string lWhere = null;

            switch (this.cmbSortField.SelectedIndex)
            {
            case 0:
                lOrder = "StockItem.StockItem_Name";
                break;

            case 1:
                lOrder = "[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100)";
                break;

            case 2:
                lOrder = "POSCatalogueChannelLnk.POSCatalogueChannelLnk_Price";
                break;

            case 3:
                lOrder = "([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100))";
                break;

            case 4:
                lOrder = "IIf([POSCatalogueChannelLnk_Price],([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100))/[POSCatalogueChannelLnk_Price]*100)";
                break;
            }
            if (this.cmbSort.SelectedIndex)
            {
                lOrder = lOrder + " DESC";
            }
            lOrder = " ORDER BY " + lOrder + ", StockItem.StockItem_Name, Catalogue.Catalogue_Quantity";

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=2 AND Link_SectionID=1");
            Report.SetParameterValue("txtFilter", Strings.Replace(rs.Fields("Link_Name").Value, "''", "'"));

            //sql = "SELECT PricingGroup.PricingGroup_Name AS Department, StockItem.StockItem_Name, Catalogue.Catalogue_Barcode, Catalogue.Catalogue_Quantity, StockItem.StockItem_ListCost, Vat.Vat_Amount, POSCatalogueChannelLnk.POSCatalogueChannelLnk_Price, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS cost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS exclusiveCost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100) AS inclusiveCost, IIf([POSCatalogueChannelLnk_Price],([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100))/[POSCatalogueChannelLnk_Price]*100) AS gpPercentage, ([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100)) AS profit "
            //sql = sql & "FROM Vat INNER JOIN (POSCatalogueChannelLnk INNER JOIN ((StockItem INNER JOIN PricingGroup ON StockItem.StockItem_PricingGroupID = PricingGroup.PricingGroupID) INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) ON (POSCatalogueChannelLnk.POSCatalogueChannelLnk_Quantity = Catalogue.Catalogue_Quantity) AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID)) ON Vat.VatID = StockItem.StockItem_VatID "

            //with w/h =2 qty
            //sql = "SELECT PricingGroup.PricingGroup_Name AS Department, StockItem.StockItem_Name, Catalogue.Catalogue_Barcode, Catalogue.Catalogue_Quantity, StockItem.StockItem_ListCost, Vat.Vat_Amount, POSCatalogueChannelLnk.POSCatalogueChannelLnk_Price, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS cost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS exclusiveCost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100) AS inclusiveCost, IIf([POSCatalogueChannelLnk_Price],([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100))/[POSCatalogueChannelLnk_Price]*100) AS gpPercentage, ([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100)) AS profit, WarehouseStockItemLnk.WarehouseStockItemLnk_Quantity "
            //sql = sql & "FROM (Vat INNER JOIN (POSCatalogueChannelLnk INNER JOIN ((StockItem INNER JOIN PricingGroup ON StockItem.StockItem_PricingGroupID = PricingGroup.PricingGroupID) INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) ON (POSCatalogueChannelLnk.POSCatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID) AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_Quantity = Catalogue.Catalogue_Quantity)) ON Vat.VatID = StockItem.StockItem_VatID) INNER JOIN WarehouseStockItemLnk ON StockItem.StockItemID = WarehouseStockItemLnk.WarehouseStockItemLnk_StockItemID "

            //with all W/H qty
            if (chkQty.Enabled == false)
            {
                sql = "SELECT PricingGroup.PricingGroup_Name AS Department, StockItem.StockItem_Name, Catalogue.Catalogue_Barcode, Catalogue.Catalogue_Quantity, StockItem.StockItem_ListCost, Vat.Vat_Amount, POSCatalogueChannelLnk.POSCatalogueChannelLnk_Price, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS cost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS exclusiveCost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100) AS inclusiveCost, IIf([POSCatalogueChannelLnk_Price],([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100))/[POSCatalogueChannelLnk_Price]*100) AS gpPercentage, ([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100)) AS profit, 0 AS SumOfWarehouseStockItemLnk_Quantity ";
                sql = sql + "FROM (Vat INNER JOIN (POSCatalogueChannelLnk INNER JOIN ((StockItem INNER JOIN PricingGroup ON StockItem.StockItem_PricingGroupID = PricingGroup.PricingGroupID) INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) ON (POSCatalogueChannelLnk.POSCatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID) AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_Quantity = Catalogue.Catalogue_Quantity)) ON Vat.VatID = StockItem.StockItem_VatID) INNER JOIN WarehouseStockItemLnk ON StockItem.StockItemID = WarehouseStockItemLnk.WarehouseStockItemLnk_StockItemID ";
            }
            else
            {
                if (chkQty.CheckState)
                {
                    sql = "SELECT PricingGroup.PricingGroup_Name AS Department, StockItem.StockItem_Name, Catalogue.Catalogue_Barcode, Catalogue.Catalogue_Quantity, StockItem.StockItem_ListCost, Vat.Vat_Amount, POSCatalogueChannelLnk.POSCatalogueChannelLnk_Price, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS cost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS exclusiveCost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100) AS inclusiveCost, IIf([POSCatalogueChannelLnk_Price],([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100))/[POSCatalogueChannelLnk_Price]*100) AS gpPercentage, ([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100)) AS profit, Sum(WarehouseStockItemLnk.WarehouseStockItemLnk_Quantity) AS SumOfWarehouseStockItemLnk_Quantity ";
                    sql = sql + "FROM (Vat INNER JOIN (POSCatalogueChannelLnk INNER JOIN ((StockItem INNER JOIN PricingGroup ON StockItem.StockItem_PricingGroupID = PricingGroup.PricingGroupID) INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) ON (POSCatalogueChannelLnk.POSCatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID) AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_Quantity = Catalogue.Catalogue_Quantity)) ON Vat.VatID = StockItem.StockItem_VatID) INNER JOIN WarehouseStockItemLnk ON StockItem.StockItemID = WarehouseStockItemLnk.WarehouseStockItemLnk_StockItemID ";
                }
                else
                {
                    sql = "SELECT PricingGroup.PricingGroup_Name AS Department, StockItem.StockItem_Name, Catalogue.Catalogue_Barcode, Catalogue.Catalogue_Quantity, StockItem.StockItem_ListCost, Vat.Vat_Amount, POSCatalogueChannelLnk.POSCatalogueChannelLnk_Price, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS cost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost] AS exclusiveCost, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100) AS inclusiveCost, IIf([POSCatalogueChannelLnk_Price],([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100))/[POSCatalogueChannelLnk_Price]*100) AS gpPercentage, ([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100)) AS profit, 0 AS SumOfWarehouseStockItemLnk_Quantity ";
                    sql = sql + "FROM (Vat INNER JOIN (POSCatalogueChannelLnk INNER JOIN ((StockItem INNER JOIN PricingGroup ON StockItem.StockItem_PricingGroupID = PricingGroup.PricingGroupID) INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) ON (POSCatalogueChannelLnk.POSCatalogueChannelLnk_StockItemID = Catalogue.Catalogue_StockItemID) AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_Quantity = Catalogue.Catalogue_Quantity)) ON Vat.VatID = StockItem.StockItem_VatID) INNER JOIN WarehouseStockItemLnk ON StockItem.StockItemID = WarehouseStockItemLnk.WarehouseStockItemLnk_StockItemID ";
                }
            }

            switch (this.cmbGroup.SelectedIndex)
            {
            case 0:
                Report.SetParameterValue("txtTitle", "Price List - by Pricing Group");
                break;

            case 1:
                sql = Strings.Replace(sql, "PricingGroup", "StockGroup");
                Report.SetParameterValue("txtTitle", "Price List - by Stock Group");
                break;

            case 2:
                sql = Strings.Replace(sql, "PricingGroup", "Supplier");
                Report.SetParameterValue("txtTitle", "Price List - by Supplier");
                break;

            case 3:
                Report.SetParameterValue("txtTitle", "Price List - by Stock Name");
                break;
            }

            if (chkPageBreak.Enabled == true)
            {
                if (this.chkPageBreak.CheckState)
                {
                    Report.ReportDefinition.Sections(5).SectionFormat.EnableNewPageAfter = true;
                }
                else
                {
                    Report.ReportDefinition.Sections(5).SectionFormat.EnableNewPageAfter = false;
                }
            }
            else
            {
                Report.ReportDefinition.Sections(5).SectionFormat.EnableNewPageAfter = false;
            }

            //new code
            Report.SetParameterValue("txtChannel", "For " + cmbChannel.CtlText);

            if (string.IsNullOrEmpty(rs.Fields("Link_SQL").Value))
            {
                //sql = sql & "Where (POSCatalogueChannelLnk.POSCatalogueChannelLnk_ChannelID = 1) And (StockItem.StockItem_Disabled = 0) And ((StockItem.StockItem_Discontinued = 0) OR (Catalogue.Catalogue_Disabled = 0)) "
                sql = sql + "Where (POSCatalogueChannelLnk.POSCatalogueChannelLnk_ChannelID = " + this.cmbChannel.BoundText + " ) And (StockItem.StockItem_Disabled = 0) And ((StockItem.StockItem_Discontinued = 0) OR (Catalogue.Catalogue_Disabled = 0)) ";
                //chnaged for QTY 29 June 2010   sql = sql & "Where (WarehouseStockItemLnk.WarehouseStockItemLnk_WarehouseID = 2) AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_ChannelID = " & Me.cmbChannel.BoundText & " ) And (StockItem.StockItem_Disabled = 0) And ((StockItem.StockItem_Discontinued = 0) OR (Catalogue.Catalogue_Disabled = 0)) "
            }
            else
            {
                //sql = sql & rs("Link_SQL") & " AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_ChannelID = 1) And ((StockItem.StockItem_Disabled = 0) OR (StockItem.StockItem_Discontinued = 0)) And (Catalogue.Catalogue_Disabled = 0) "
                sql = sql + rs.Fields("Link_SQL").Value + " AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_ChannelID = " + this.cmbChannel.BoundText + " ) And ((StockItem.StockItem_Disabled = 0) OR (StockItem.StockItem_Discontinued = 0)) And (Catalogue.Catalogue_Disabled = 0) ";
                //chnaged for QTY 29 June 2010   sql = sql & rs("Link_SQL") & " AND (WarehouseStockItemLnk.WarehouseStockItemLnk_WarehouseID = 2) AND (POSCatalogueChannelLnk.POSCatalogueChannelLnk_ChannelID = " & Me.cmbChannel.BoundText & " ) And ((StockItem.StockItem_Disabled = 0) OR (StockItem.StockItem_Discontinued = 0)) And (Catalogue.Catalogue_Disabled = 0) "
            }


            sql = sql + "GROUP BY PricingGroup.PricingGroup_Name, StockItem.StockItem_Name, Catalogue.Catalogue_Barcode, Catalogue.Catalogue_Quantity, StockItem.StockItem_ListCost, Vat.Vat_Amount, POSCatalogueChannelLnk.POSCatalogueChannelLnk_Price, [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost], [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost], [Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100), IIf([POSCatalogueChannelLnk_Price],([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100))/[POSCatalogueChannelLnk_Price]*100), ([POSCatalogueChannelLnk_Price]-[Catalogue_Quantity]/[StockItem_Quantity]*[StockItem_ListCost]*(1+[Vat_Amount]/100)) ";
            switch (this.cmbGroup.SelectedIndex)
            {
            case 0:
                Report.SetParameterValue("txtTitle", "Price List - by Pricing Group");
                break;

            case 1:
                sql = Strings.Replace(sql, "PricingGroup", "StockGroup");
                Report.SetParameterValue("txtTitle", "Price List - by Stock Group");
                break;

            case 2:
                sql = Strings.Replace(sql, "PricingGroup", "Supplier");
                Report.SetParameterValue("txtTitle", "Price List - by Supplier");
                break;

            case 3:
                Report.SetParameterValue("txtTitle", "Price List - by Stock Name");
                break;
            }

            sql = sql + lOrder;
            Debug.Print(sql);
            rs = modRecordSet.getRS(ref sql);

            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;
            }

            //Report.VerifyOnEveryPrint = True
            Report.Database.Tables(1).SetDataSource(rs);
            //Report.Database.SetDataSource(rs, 3)
            //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";
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
Beispiel #27
0
        private void mnuAccount_Click()
        {
            tmrReportCancel.Enabled = false;
            //Dim Report As New cryMenuAccount
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryMenuAccount.rpt");
            ADODB.Recordset rs = default(ADODB.Recordset);
            decimal lTotal = default(decimal);

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            lTotal = 0;
            rs = modRecordSet.getRS(ref "SELECT Sum(Sale.Sale_Total) AS amount, Sale.Sale_PaymentType FROM Company INNER JOIN (Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN (CustomerTransaction INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID) ON Company.Company_DayEndID = Sale.Sale_DayEndID Where (((CustomerTransaction.CustomerTransaction_TransactionTypeID) = 2 Or (CustomerTransaction.CustomerTransaction_TransactionTypeID) = 3) And ((Consignment.ConsignmentID) Is Null) And ((Consignment_1.ConsignmentID) Is Null)) GROUP BY Sale.Sale_PaymentType;");
            while (!(rs.EOF)) {
                switch (rs.Fields("Sale_PaymentType").Value) {
                    case 5:
                        Report.SetParameterValue("txtAccountSales", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                        break;
                    case 1:
                        Report.SetParameterValue("txtAccountCash", Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                        lTotal = lTotal - rs.Fields("amount").Value;
                        break;
                    case 2:
                        Report.SetParameterValue("txtAccountCRcard", Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                        lTotal = lTotal - rs.Fields("amount").Value;
                        break;
                    case 3:
                        Report.SetParameterValue("txtAccountDRcard", Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                        lTotal = lTotal - rs.Fields("amount").Value;
                        break;
                    case 4:
                        Report.SetParameterValue("txtAccountCheque", Strings.FormatNumber(0 - rs.Fields("amount").Value, 2));
                        lTotal = lTotal - rs.Fields("amount").Value;
                        break;
                }
                rs.MoveNext();
            }
            Report.SetParameterValue("txtAccountPayment", Strings.FormatNumber(lTotal, 2));
            lTotal = lTotal + Convert.ToDecimal(Report.ParameterFields("txtAccountSales").ToString);
            Report.SetParameterValue("txtAccountTotal", Strings.FormatNumber(lTotal, 2));

            CrystalReportViewer1.ReportSource = Report;
            CrystalReportViewer1.Refresh();
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            tmrReportCancel.Enabled = true;
        }
Beispiel #28
0
        private static void report_Outage()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsDayEnd = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryOutage
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("crtOutage.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            Report.SetParameterValue("txtDayend", rs.Fields("Report_Heading"));
            rs.Close();

            sql = "SELECT Declaration.Declaration_DayEndID, aPOS.POSID, aPOS.POS_Name, Sum(Declaration.Declaration_Cash) AS SumOfDeclaration_Cash, Sum(Declaration.Declaration_CashServer) AS SumOfDeclaration_CashServer, Sum(Declaration.Declaration_CashCount) AS SumOfDeclaration_CashCount, Sum(Declaration.Declaration_Cheque) AS SumOfDeclaration_Cheque, Sum(Declaration.Declaration_ChequeServer) AS SumOfDeclaration_ChequeServer, Sum(Declaration.Declaration_ChequeCount) AS SumOfDeclaration_ChequeCount, Sum(Declaration.Declaration_Card) AS SumOfDeclaration_Card, Sum(Declaration.Declaration_CardServer) AS SumOfDeclaration_CardServer, Sum(Declaration.Declaration_CardCount) AS SumOfDeclaration_CardCount, Sum(Declaration.Declaration_Payout) AS SumOfDeclaration_Payout, Sum(Declaration.Declaration_PayoutServer) AS SumOfDeclaration_PayoutServer, Sum(Declaration.Declaration_PayoutCount) AS SumOfDeclaration_PayoutCount ";
            sql = sql + "FROM Declaration INNER JOIN aPOS ON Declaration.Declaration_POSID = aPOS.POSID GROUP BY Declaration.Declaration_DayEndID, aPOS.POSID, aPOS.POS_Name;";

            rs = modReport.getRSreport(ref sql);
            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;
            }
            rsDayEnd = modReport.getRSreport(ref "SELECT * FROM DayEnd");
            Report.Database.Tables(1).SetDataSource(rsDayEnd);

            Report.Database.Tables(2).SetDataSource(rs);

            //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();
        }
Beispiel #29
0
        private void mnuStock_Click()
        {
            tmrReportCancel.Enabled = false;
            //Dim Report As New cryMenuStock
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryMenuStock.rpt");
            ADODB.Recordset rs = default(ADODB.Recordset);
            decimal lTotal = default(decimal);

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            //do invoice discount
            rs = modRecordSet.getRS(ref "SELECT Sum(Sale.Sale_Discount) AS amount FROM (Consignment RIGHT JOIN (Consignment AS Consignment_1 RIGHT JOIN Sale ON Consignment_1.Consignment_SaleID = Sale.SaleID) ON Consignment.Consignment_ReversalSaleID = Sale.SaleID) INNER JOIN Company ON Sale.Sale_DayEndID = Company.Company_DayEndID WHERE (((Consignment.ConsignmentID) Is Null) AND ((Consignment_1.ConsignmentID) Is Null) AND ((Sale.Sale_PaymentType)<>5));");
            if (Information.IsDBNull(rs.Fields("amount").Value)) {
                Report.SetParameterValue("txtStockDiscount", "0.00");
            } else {
                if (rs.RecordCount) {
                    Report.SetParameterValue("txtStockDiscount", Strings.FormatNumber(rs.Fields("amount").Value, 2));
                } else {
                    Report.SetParameterValue("txtStockDiscount", "0.00");
                }
            }
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT Sum([SaleItem_Price]*[SaleItem_Quantity]) AS content, CBool([SaleItem_DepositType]) AS depositType, SaleItem.SaleItem_Reversal, Sum(([SaleItem_DepositCost]*[SaleItem_Quantity])*(1+[SaleItem_Vat]/100)) AS deposit FROM Company INNER JOIN (Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID) ON Company.Company_DayEndID = Sale.Sale_DayEndID Where (((SaleItem.SaleItem_Revoke) = False) And ((Consignment.ConsignmentID) Is Null) And ((Consignment_1.ConsignmentID) Is Null)) GROUP BY CBool([SaleItem_DepositType]), SaleItem.SaleItem_Reversal;");
            while (!(rs.EOF)) {
                if (rs.Fields("depositType").Value) {
                    if (rs.Fields("SaleItem_Reversal").Value) {
                        Report.SetParameterValue("txtStockDepositSold", Strings.FormatNumber(rs.Fields("content").Value, 2));
                    } else {
                        Report.SetParameterValue("txtStockDepositReturn", Strings.FormatNumber(rs.Fields("content").Value, 2));
                    }
                } else {
                    if (rs.Fields("SaleItem_Reversal").Value) {
                        Report.SetParameterValue("txtStockCreditContent", Strings.FormatNumber(rs.Fields("content").Value, 2));
                        Report.SetParameterValue("txtStockCreditDeposit", Strings.FormatNumber(0 - rs.Fields("deposit").Value, 2));
                    } else {
                        Report.SetParameterValue("txtStockSoldContent", Strings.FormatNumber(rs.Fields("content").Value, 2));
                        Report.SetParameterValue("txtStockSoldDeposit", Strings.FormatNumber(rs.Fields("deposit").Value, 2));
                    }
                }
                rs.MoveNext();
            }
            rs.Close();
            Report.SetParameterValue("txtStockSoldContent", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockSoldContent").ToString) - Convert.ToDecimal(Report.ParameterFields("txtStockSoldDeposit").ToString), 2));
            Report.SetParameterValue("txtStockCreditContent", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockCreditContent").ToString) - Convert.ToDecimal(Report.ParameterFields("txtStockCreditDeposit").ToString), 2));
            Report.SetParameterValue("txtStockSold", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockSoldContent").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockSoldDeposit").ToString), 2));
            Report.SetParameterValue("txtStockCreditTotal", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockCreditContent").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockCreditDeposit").ToString), 2));
            Report.SetParameterValue("txtStockTotal", Strings.FormatNumber(Convert.ToDecimal(Report.ParameterFields("txtStockSold").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockCreditTotal").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockDepositSold").ToString) + Convert.ToDecimal(Report.ParameterFields("txtStockDepositReturn").ToString), 2));
            // + CCur(Report.txtStockDiscount.Text),2)
            //    Report.txtStockTotal.SetText Report.txtStockDepositReturn.Text
            CrystalReportViewer1.ReportSource = Report;
            CrystalReportViewer1.Refresh();
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            tmrReportCancel.Enabled = true;
        }
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs     = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As New cryItemGroupCompare
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report     = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryItemGroupCompare.rpt");
            ReportNone.Load("cryNoRecords");
            modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=1 AND Link_SectionID=1");
            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT 1, DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID WHERE " + rs.Fields("Link_SQL").Value + ";");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=2 AND Link_SectionID=1");
            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT 2, DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID " + rs.Fields("Link_SQL").Value + " GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;");

            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 "SELECT Link.* From Link Where (((Link.Link_SectionID) = 1)) ORDER BY Link.Link_SectionID;");
            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;
            }
            rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'ddd dd mmm\", \"yyyy') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID;");
            if (rsData.BOF | rsData.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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            //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();
        }
Beispiel #31
0
        private static void report_HourlyReport()
        {
            ADODB.Recordset rsSale = default(ADODB.Recordset);
            decimal SumSales = default(decimal);
            string sql2 = null;
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryHourlyReport
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryHourlyReport.rpt");

            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();
            sql = "SELECT * FROM Sale";
            rs = modReport.getRSreport(ref sql);
            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;
            }

            sql2 = "SELECT SaleItem.SaleItem_StockItemID, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ActualCost]*[SaleItem_Quantity],[SaleItem_ActualCost]*[SaleItem_Quantity])) AS actualCostSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ListCost]*[SaleItem_Quantity],[SaleItem_ListCost]*[SaleItem_Quantity])) AS listCostSum, Sum(([SaleItem_Price]*[SaleItem_Quantity]/(1+[SaleItem_Vat]/100))) AS exclusiveSum, Sum(([SaleItem_Price]*[SaleItem_Quantity])) AS inclusiveSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_DepositCost]*[SaleItem_Quantity],[SaleItem_DepositCost]*[SaleItem_Quantity])) AS depositSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_ShrinkQuantity]*[SaleItem_Quantity],[SaleItem_ShrinkQuantity]*[SaleItem_Quantity])) AS quantitySum FROM Sale INNER JOIN (aConsignment AS aConsignment_1 RIGHT JOIN (SaleItem LEFT JOIN aConsignment ON SaleItem.SaleItem_SaleID=aConsignment.Consignment_SaleID) ON aConsignment_1.Consignment_ReversalSaleID=SaleItem.SaleItem_SaleID) ON Sale.SaleID=SaleItem.SaleItem_SaleID" + " Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null))" + " GROUP BY SaleItem.SaleItem_StockItemID;";

            rsSale = modReport.getRSreport(ref sql2);
            while (rsSale.EOF == false) {
                SumSales = SumSales + rsSale.Fields("inclusiveSum").Value;

                rsSale.moveNext();
            }

            Report.Database.Tables(1).SetDataSource(rs);

            Report.SetParameterValue("txtSum", Strings.FormatNumber(SumSales, 2));

            //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();
        }
Beispiel #32
0
        private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryKeyboardName
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryKeyboardName.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT KeyboardLayout.KeyboardLayout_Name, keyboard.keyboard_Name, KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_Description, keyboard.keyboard_Order, keyboard.keyboard_Show FROM (KeyboardKeyboardLayoutLnk INNER JOIN keyboard ON KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_KeyboardID = keyboard.KeyboardID) INNER JOIN KeyboardLayout ON KeyboardKeyboardLayoutLnk.KeyboardKeyboardLayoutLnk_KeyboardLayoutID = KeyboardLayout.KeyboardLayoutID Where (((KeyboardLayout.KeyboardLayoutID) = " + gParentID + ")) ORDER BY keyboard.keyboard_Order, keyboard.keyboard_Name;");

            //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;
            }
            Report.Database.Tables(0).SetDataSource(rs);
            Report.Database.Tables(1).SetDataSource(rs);
            //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();
        }
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            string  sql      = null;
            decimal SumSales = default(decimal);

            ADODB.Recordset rs     = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report     = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            //As New cryPOSreport
            ReportNone.Load("cryNoRecords.rpt");
            Report.Load("cryPOSreport.rpt");
            // ERROR: Not supported in C#: OnErrorStatement


            if (chkSum.CheckState)
            {
                Report.Load("cryPOSreportSum.rpt");
            }
            else
            {
                Report.Load("cryPOSreport.rpt");
                //Set Report = New cryPOSreportRevoke
            }

            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 getSQL());

            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;
            }

            sql = "SELECT SaleItem.*, IIf([SaleItem_DepositType]=1,[Deposit_Name]+'-bottle',IIf([SaleItem_DepositType]=2,[Deposit_Name]+'-Crate',[Deposit_Name]+'-Case')) AS StockItem_Name FROM SaleItem INNER JOIN aDeposit ON SaleItem.SaleItem_StockItemID = aDeposit.DepositID Where (((SaleItem.SaleItem_DepositType) <> 0)) Union ";
            sql = sql + "SELECT SaleItem.*, aStockItem.StockItem_Name FROM SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Recipe) = 0)) Union ";
            sql = sql + "SELECT SaleItem.*, aRecipe.Recipe_Name AS StockItem_Name FROM SaleItem INNER JOIN aRecipe ON SaleItem.SaleItem_StockItemID = aRecipe.RecipeID WHERE (((SaleItem.SaleItem_DepositType)=0) AND ((SaleItem.SaleItem_Recipe)<>0));";

            //sql = "SELECT SaleItem.*, IIf([SaleItem_DepositType]=1,[Deposit_Name]+'-bottle',IIf([SaleItem_DepositType]=2,[Deposit_Name]+'-Crate',[Deposit_Name]+'-Case')) AS StockItem_Name FROM SaleItem INNER JOIN aDeposit ON SaleItem.SaleItem_StockItemID = aDeposit.DepositID Where (((SaleItem.SaleItem_DepositType) <> 0) AND ((SaleItem.SaleItem_Revoke) <> 0)) Union SELECT SaleItem.*, aStockItem.StockItem_Name FROM SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID Where (((SaleItem.SaleItem_DepositType) = 0) AND ((SaleItem.SaleItem_Revoke) <> 0))"
            sql    = "SELECT SaleItem.*, IIf([SaleItem_DepositType]=1,[Deposit_Name]+'-bottle',IIf([SaleItem_DepositType]=2,[Deposit_Name]+'-Crate',[Deposit_Name]+'-Case')) AS StockItem_Name FROM SaleItem INNER JOIN aDeposit ON SaleItem.SaleItem_StockItemID = aDeposit.DepositID Where (((SaleItem.SaleItem_DepositType) <> 0)) Union SELECT SaleItem.*, aStockItem.StockItem_Name FROM SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID Where (((SaleItem.SaleItem_DepositType) = 0))";
            rsData = modReport.getRSreport(ref sql);

            if (rsData.BOF | rsData.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 (emp_Clicked() == true)
            {
                SumSales = 0;
                while (rs.EOF == false)
                {
                    SumSales = SumSales + rs.Fields("Sale_Total").Value;
                    rs.moveNext();
                }
                //Resise to excluding vat
                SumSales = SumSales - (SumSales * 0.14);
                rs.MoveFirst();
                Report.SetParameterValue("txtComm", (Information.IsDBNull(rs.Fields("Person_Comm").Value) ? 0 : rs.Fields("Person_Comm").Value));
                Report.SetParameterValue("txtTotalCommision", Strings.FormatNumber((SumSales * rs.Fields("Person_Comm").Value) / 100, 2));
            }

            if (chkOutCon.CheckState)
            {
                Report.SetParameterValue("txtTitle", "Point Of Sale Outstanding Consignments for Device");
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            //Report.VerifyOnEveryPrint = True
            My.MyProject.Forms.frmReportShow.Text = Report.ParameterFields("txtComm").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();
        }
Beispiel #34
0
        private static void report_Payout()
        {
            ADODB.Recordset rsDayEnd = default(ADODB.Recordset);
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryPayout
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryPayout.rpt");
            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();
            sql = "SELECT * FROM Payout";
            rs = modReport.getRSreport(ref sql);
            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;
            }
            rsDayEnd = modReport.getRSreport(ref "SELECT * FROM DayEnd");
            Report.Database.Tables(1).SetDataSource(rsDayEnd);

            Report.Database.Tables(2).SetDataSource(rs);

            //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();
        }
        private void cmdInv_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            int personID = 0;
            int posID = 0;
            string[] lArray = null;
            string lAddress = null;

            //On Error Resume Next
            ADODB.Connection cn = default(ADODB.Connection);
            short x = 0;
            string databaseName = null;
            int lID = 0;
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsItems = default(ADODB.Recordset);
            string sql = null;
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            if (lvTransaction.FocusedItem == null)
                return;
            //lID = Mid(Split(Me.lvTransaction.SelectedItem.Key, "_")(0), 2)
            if (Convert.ToDouble(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[2]) == 0) {
                Interaction.MsgBox("There is no Sale document attached!", MsgBoxStyle.Information);
                System.Windows.Forms.Cursor.Current = Cursors.Default;
                return;
            }
            lID = Convert.ToInt32(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[2]);
            //If openConnection() Then
            //    frmMain.lblPath.Caption = serverPath
            //    closeConnection
            //End If
            //Set cn = openConnectionInstance()
            //lMonth = cmbMonth.ItemData(cmbMonth.ListIndex)
            //Dim lLineitem As lineitem
            //If lMonth = gMonthEnd Then
            //    databaseName = ""
            //Else
            //    databaseName = "Month" & lMonth & ".mdb"
            //End If
            databaseName = Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[1];

            cn = modRecordSet.openConnectionInstance(ref databaseName);
            if (cn == null) {
                return;
            }

            transaction lTransaction = new transaction();
            lineItem lLineitem = null;
            customer lCustomer = new customer();
            transactionSpecial lSpecial = new transactionSpecial();
            if (Convert.ToDouble(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[3]) == 2) {
                //sale
                //Dim Report As New cryReceipt
                //Set Report = New cryReceipt

                rs = new ADODB.Recordset();
                sql = "SELECT Sale.* From Sale WHERE (((SaleID)=" + lID + "));";
                rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);

                if (rs.RecordCount) {
                    lTransaction.cashierID = rs.Fields("Sale_PersonID").Value;
                    lTransaction.channelID = rs.Fields("Sale_ChannelID").Value;
                    lTransaction.managerID = rs.Fields("Sale_ManagerID").Value;
                    lTransaction.paymentDiscount = rs.Fields("Sale_Discount").Value;
                    lTransaction.paymentSlip = rs.Fields("Sale_Slip").Value;
                    lTransaction.paymentSubTotal = rs.Fields("Sale_SubTotal").Value;
                    lTransaction.paymentTender = rs.Fields("Sale_Tender").Value;
                    lTransaction.paymentTotal = rs.Fields("Sale_Total").Value;
                    lTransaction.paymentType = rs.Fields("Sale_PaymentType").Value;
                    lTransaction.posID = rs.Fields("Sale_POSID").Value;
                    lTransaction.transactionDate = rs.Fields("Sale_DatePOS").Value;
                    lTransaction.transactionID = rs.Fields("Sale_Reference").Value + "";
                    lTransaction.transactionType = "Sale";
                    //If prPrevSerial_p = True Then strSerial = rs("Sale_Serialref")
                    rs.Close();

                    rs = modRecordSet.getRS(ref "SELECT * FROM Company");
                    lTransaction.companyName = rs.Fields("Company_Name").Value;
                    //gParameters.companyName
                    lTransaction.footer = " ";
                    //gParameters.footer & ""
                    lTransaction.heading1 = rs.Fields("Company_PhysicalAddress").Value;
                    //gParameters.heading1 & ""
                    lTransaction.heading2 = " ";
                    //gParameters.heading2 & ""
                    lTransaction.heading3 = " ";
                    //gParameters.heading3 & ""
                    lTransaction.taxNumber = rs.Fields("Company_TaxNumber").Value;
                    //gParameters.taxNumber & ""
                    rs.Close();

                    sql = "SELECT [Person_FirstName] & ' ' & [Person_LastName] AS personName From Person WHERE (((PersonID)=" + lTransaction.cashierID + "));";
                    rs = modRecordSet.getRS(ref sql);
                    //rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText
                    if (rs.RecordCount) {
                        lTransaction.cashierName = rs.Fields("personName").Value + "";
                    }
                    rs.Close();

                    sql = "SELECT [Person_FirstName] & ' ' & [Person_LastName] AS personName From Person WHERE (((PersonID)=" + lTransaction.managerID + "));";
                    rs = modRecordSet.getRS(ref sql);
                    //rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText
                    if (rs.RecordCount) {
                        lTransaction.managerName = rs.Fields("personName").Value + "";
                    }
                    rs.Close();

                    sql = "SELECT POS_Name From POS WHERE (((POS.POSID)=" + lTransaction.posID + "));";
                    rs = modRecordSet.getRS(ref sql);
                    //rs.Open sql, cn, adOpenStatic, adLockReadOnly, adCmdText
                    if (rs.RecordCount) {
                        lTransaction.posName = rs.Fields("POS_Name").Value + "";
                    }
                    rs.Close();

                    //sql = "SELECT SaleItem.*, StockItem.StockItem_Name AS longName, StockItem.StockItem_ReceiptName AS receiptName, Catalogue.Catalogue_Barcode AS code,'Sale' as saleType FROM (StockItem INNER JOIN SaleItem ON StockItem.StockItemID = SaleItem.SaleItem_StockItemID) INNER JOIN Catalogue ON (Catalogue.Catalogue_Quantity = SaleItem.SaleItem_ShrinkQuantity) AND (SaleItem.SaleItem_StockItemID = Catalogue.Catalogue_StockItemID) WHERE (((SaleItem.SaleItem_DepositType)=0) AND ((SaleItem.SaleItem_SaleID)=" & lID & "))"
                    //sql = sql & " UNION "
                    //sql = sql & "SELECT SaleItem.*, Deposit.Deposit_Name AS longName, Deposit.Deposit_ReceiptName AS receiptName, Deposit.Deposit_Key AS code,'Deposit' as saleType FROM Deposit INNER JOIN SaleItem ON Deposit.DepositID = SaleItem.SaleItem_StockItemID WHERE (((SaleItem.SaleItem_DepositType)<>0) AND ((SaleItem.SaleItem_SaleID)=" & lID & "));"
                    sql = "SELECT SaleItem.*, 'Sale' AS saleType From SaleItem Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_SaleID) = " + lID + "))";
                    sql = sql + " UNION ";
                    sql = sql + "SELECT SaleItem.*, 'Deposit' AS saleType From SaleItem WHERE (((SaleItem.SaleItem_DepositType)<>0) AND ((SaleItem.SaleItem_SaleID)=" + lID + "));";
                    rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
                    while (!(rs.EOF)) {
                        lLineitem = new lineItem();
                        lLineitem.build = 0;
                        lLineitem.depositType = rs.Fields("SaleItem_DepositType").Value;
                        lLineitem.id = rs.Fields("SaleItem_StockItemID").Value;
                        lLineitem.lineNo = rs.Fields("SaleItem_LineNo").Value;
                        lLineitem.originalPrice = rs.Fields("SaleItem_PriceOriginal").Value;
                        lLineitem.price = rs.Fields("SaleItem_Price").Value;
                        lLineitem.quantity = rs.Fields("SaleItem_Quantity").Value;
                        lLineitem.reversal = rs.Fields("SaleItem_Reversal").Value;
                        lLineitem.revoke = rs.Fields("SaleItem_Revoke").Value;
                        lLineitem.setBuild = rs.Fields("SaleItem_SetID").Value;
                        lLineitem.shrink = rs.Fields("SaleItem_ShrinkQuantity").Value;
                        lLineitem.vat = rs.Fields("SaleItem_Vat").Value;
                        lLineitem.transactionType = rs.Fields("SaleType").Value + "";
                        //lLineitem.code = rs("Code") & ""
                        switch (lLineitem.depositType) {
                            case 0:
                                sql = "SELECT StockItem.StockItem_Name AS longName, StockItem.StockItem_ReceiptName AS receiptName From StockItem WHERE (((StockItemID)=" + rs.Fields("SaleItem_StockItemID").Value + "));";
                                rsItems = modRecordSet.getRS(ref sql);
                                if (rsItems.RecordCount) {
                                    lLineitem.name = rs.Fields("SaleItem_ShrinkQuantity").Value + " x " + rsItems.Fields("longName").Value;
                                    lLineitem.receiptName = rs.Fields("SaleItem_ShrinkQuantity").Value + "x" + rsItems.Fields("receiptName").Value;
                                }
                                rsItems.Close();
                                sql = "SELECT Catalogue.Catalogue_Barcode AS code FROM Catalogue WHERE (Catalogue.Catalogue_Quantity = " + rs.Fields("SaleItem_ShrinkQuantity").Value + ") AND (Catalogue.Catalogue_StockItemID = " + rs.Fields("SaleItem_StockItemID").Value + ");";
                                rsItems = modRecordSet.getRS(ref sql);
                                if (rsItems.RecordCount) {
                                    lLineitem.code = rsItems.Fields("Code").Value + "";
                                }
                                rsItems.Close();
                                break;
                            case 1:
                                sql = "SELECT Deposit.Deposit_Name AS longName, Deposit.Deposit_ReceiptName AS receiptName, Deposit.Deposit_Key AS code From Deposit WHERE (((DepositID)=" + rs.Fields("SaleItem_StockItemID").Value + "));";
                                rsItems = modRecordSet.getRS(ref sql);
                                if (rsItems.RecordCount) {
                                    lLineitem.name = rs.Fields("longName").Value + "-Unit";
                                    lLineitem.receiptName = rs.Fields("receiptName").Value + "(U)";
                                    lLineitem.code = rsItems.Fields("Code").Value + "";
                                }
                                rsItems.Close();
                                break;
                            case 2:
                                sql = "SELECT Deposit.Deposit_Name AS longName, Deposit.Deposit_ReceiptName AS receiptName, Deposit.Deposit_Key AS code From Deposit WHERE (((DepositID)=" + rs.Fields("SaleItem_StockItemID").Value + "));";
                                rsItems = modRecordSet.getRS(ref sql);
                                if (rsItems.RecordCount) {
                                    lLineitem.name = rs.Fields("longName").Value + "-Empty Crate";
                                    lLineitem.receiptName = rs.Fields("receiptName").Value + "(E)";
                                    lLineitem.code = rsItems.Fields("Code").Value + "";
                                }
                                rsItems.Close();
                                break;
                            case 3:
                                sql = "SELECT Deposit.Deposit_Name AS longName, Deposit.Deposit_ReceiptName AS receiptName, Deposit.Deposit_Key AS code From Deposit WHERE (((DepositID)=" + rs.Fields("SaleItem_StockItemID").Value + "));";
                                rsItems = modRecordSet.getRS(ref sql);
                                if (rsItems.RecordCount) {
                                    lLineitem.name = rs.Fields("longName").Value + "-Full Case";
                                    lLineitem.receiptName = rs.Fields("receiptName").Value + "(F)";
                                    lLineitem.code = rsItems.Fields("Code").Value + "";
                                }
                                rsItems.Close();
                                break;
                        }
                        lTransaction.lineItems.Add(ref lLineitem);
                        rs.MoveNext();
                    }
                    rs.Close();

                    sql = "SELECT Customer.*, CustomerTransaction.* FROM (CustomerTransaction INNER JOIN Sale ON CustomerTransaction.CustomerTransaction_ReferenceID = Sale.SaleID) INNER JOIN Customer ON CustomerTransaction.CustomerTransaction_CustomerID = Customer.CustomerID WHERE (((Sale.SaleID)=" + lID + "));";
                    rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
                    if (rs.RecordCount) {
                        lCustomer.channelID = lTransaction.channelID;
                        lCustomer.creditLimit = rs.Fields("Customer_ChannelID").Value;
                        lCustomer.department = rs.Fields("Customer_DepartmentName").Value + "";
                        lCustomer.fax = rs.Fields("Customer_Fax").Value + "";
                        lCustomer.Key = rs.Fields("CustomerID").Value;
                        lCustomer.name = rs.Fields("Customer_InvoiceName").Value + "";
                        lCustomer.outstanding = 0;
                        lCustomer.person = rs.Fields("Customer_FirstName").Value + " " + rs.Fields("Customer_Surname").Value;
                        lCustomer.physical = rs.Fields("Customer_PhysicalAddress").Value + "";
                        lCustomer.postal = rs.Fields("Customer_PostalAddress").Value + "";
                        lCustomer.signed_Renamed = rs.Fields("CustomerTransaction_PersonName").Value;
                        lCustomer.telephone = rs.Fields("Customer_Telephone").Value + "";
                        lCustomer.terms = Convert.ToInt16(rs.Fields("Customer_Terms").Value + "");
                        lCustomer.tax = rs.Fields("Customer_VatNumber").Value + "";
                        if (rs.Fields("CustomerTransaction_TransactionTypeID").Value == 3) {
                            lTransaction.transactionType = "Payment";
                            lTransaction.paymentDiscount = 0;
                        }
                        lTransaction.customer_Renamed = lCustomer;
                    }
                    rs.Close();
                    sql = "SELECT Consignment.* FROM Consignment INNER JOIN Sale ON Consignment.Consignment_SaleID = Sale.SaleID WHERE (((Sale.SaleID)=" + lID + "));";
                    rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
                    if (rs.BOF & rs.EOF) {
                    } else {
                        lSpecial.address = rs.Fields("Consignment_Address").Value;
                        lSpecial.mobile = rs.Fields("Consignment_Mobile").Value;
                        lSpecial.name = rs.Fields("Consignment_Name").Value;
                        lSpecial.quote = 0;
                        lSpecial.saleID = lID;
                        lSpecial.telephone = rs.Fields("Consignment_Number").Value;
                        lSpecial.transactionType = "Consignment";
                        lTransaction.transactionSpecial_Renamed = lSpecial;
                    }
                    rs.Close();

                    sql = "SELECT Consignment.* FROM Consignment INNER JOIN Sale ON Consignment.Consignment_CompleteSaleID = Sale.SaleID WHERE (((Sale.SaleID)=" + lID + "));";
                    rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
                    if (rs.BOF & rs.EOF) {
                    } else {
                        lSpecial.address = rs.Fields("Consignment_Address").Value;
                        lSpecial.mobile = rs.Fields("Consignment_Mobile").Value;
                        lSpecial.name = rs.Fields("Consignment_Name").Value;
                        lSpecial.quote = 0;
                        lSpecial.saleID = lID;
                        lSpecial.telephone = rs.Fields("Consignment_Number").Value;
                        lSpecial.transactionType = "Consignment Complete";
                        lTransaction.transactionSpecial_Renamed = lSpecial;
                    }

                    printTransactionA4(ref lTransaction);
                }

            } else if (Convert.ToDouble(Strings.Split(this.lvTransaction.FocusedItem.Name, "_")[3]) == 3) {
                //payment
                //Dim Report As New cryPayment
                Report.Load("cryPayment.rpt");
                rs = modRecordSet.getRS(ref "SELECT * FROM Company");
                Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
                if (Information.IsDBNull(rs.Fields("Company_PhysicalAddress").Value)) {
                } else {
                    lAddress = Strings.Replace(rs.Fields("Company_PhysicalAddress").Value, Constants.vbCrLf, ", ");
                    if (Strings.Right(lAddress, 2) == ", ") {
                        lAddress = Strings.Left(lAddress, Strings.Len(lAddress) - 2);
                    }
                }
                Report.SetParameterValue("txtCompanyDetails1", lAddress);
                if (Information.IsDBNull(rs.Fields("Company_Telephone").Value)) {
                } else {
                    Report.SetParameterValue("txtCompanyDetails2", rs.Fields("Company_Telephone"));
                }
                if (Information.IsDBNull(rs.Fields("Company_TaxNumber").Value)) {
                } else {
                    Report.SetParameterValue("txtCompanyDetails4", "TAX NO :" + rs.Fields("Company_TaxNumber").Value);
                }
                //If lTransaction.heading2 <> "" Then
                //    Report.txtCompanyDetails2.SetText lTransaction.heading2
                //    If lTransaction.heading3 <> "" Then
                //        Report.txtCompanyDetails3.SetText lTransaction.heading3
                //
                //    Else
                //        If lTransaction.taxNumber <> "" Then
                //            Report.txtCompanyDetails4.SetText "TAX NO :" & lTransaction.taxNumber
                //        End If
                //    End If
                //Else
                //    If lTransaction.heading3 <> "" Then
                //        Report.txtCompanyDetails2.SetText lTransaction.heading3
                //    Else
                //        If lTransaction.taxNumber <> "" Then
                //            Report.txtCompanyDetails2.SetText "TAX NO :" & lTransaction.taxNumber
                //        End If
                //    End If
                //End If
                rs.Close();
                Report.SetParameterValue("txtCustomer", _txtFields_2.Text);
                if (!string.IsNullOrEmpty(_txtFields_6.Text)) {
                    lArray = Strings.Split(_txtFields_6.Text, Constants.vbCrLf);
                    Report.SetParameterValue("txtCustAddress1", lArray[0]);
                    if (Information.UBound(lArray) >= 1)
                        Report.SetParameterValue("txtCustAddress2", lArray[1]);
                    if (Information.UBound(lArray) >= 2)
                        Report.SetParameterValue("txtCustAddress3", lArray[2]);
                    if (Information.UBound(lArray) >= 3)
                        Report.SetParameterValue("txtCustAddress4", lArray[3]);

                }
                if (!string.IsNullOrEmpty(_txtFields_0.Text))
                    Report.SetParameterValue("txtCustAddress5", "TAX NO: " + _txtFields_0.Text);

                //If LCase(databaseName) = "pricing.mdb" Then
                //    sql = "SELECT Sale.SaleID, POS.POS_Name, Person.Person_FirstName, Person.Person_LastName, Sale.Sale_Date, Sale.Sale_DatePOS, Sale.Sale_Reference, Sale.Sale_Total, Sale.Sale_Tender FROM (Sale INNER JOIN POS ON Sale.Sale_PosID = POS.POSID) INNER JOIN Person ON Sale.Sale_PersonID = Person.PersonID WHERE (((Sale.SaleID)=" & lID & "));"
                //Else
                //    sql = "SELECT Sale.SaleID, POS.POS_Name, M_Person.Person_FirstName, M_Person.Person_LastName, Sale.Sale_Date, Sale.Sale_DatePOS, Sale.Sale_Reference, Sale.Sale_Total, Sale.Sale_Tender FROM (Sale INNER JOIN POS ON Sale.Sale_PosID = POS.POSID) INNER JOIN M_Person ON Sale.Sale_PersonID = M_Person.PersonID WHERE (((Sale.SaleID)=" & lID & "));"
                //End If
                //sql = "SELECT Sale.SaleID, POS.POS_Name, Person.Person_FirstName, Person.Person_LastName, Sale.Sale_Date, Sale.Sale_DatePOS, Sale.Sale_Reference, Sale.Sale_Total, Sale.Sale_Tender FROM (Sale INNER JOIN POS ON Sale.Sale_PosID = POS.POSID) INNER JOIN Person ON Sale.Sale_PersonID = Person.PersonID WHERE (((Sale.SaleID)=" & lID & "));"
                sql = "SELECT Sale.* From Sale WHERE (((SaleID)=" + lID + "));";
                rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);

                if (rs.RecordCount) {
                    posID = rs.Fields("Sale_PosID").Value;
                    personID = rs.Fields("Sale_PersonID").Value;
                    Report.SetParameterValue("txtInvoiceNumber", rs.Fields("Sale_Reference"));
                    Report.SetParameterValue("txtInvoiceDate", Strings.Format(rs.Fields("Sale_DatePOS").Value, "dd mmm yyyy hh:mm"));
                    //Report.txtPOS.SetText rs("POS_Name")
                    //Report.txtCashier.SetText rs("Person_FirstName") & rs("Person_LastName")
                    Report.SetParameterValue("txtAmount", Strings.FormatNumber(rs.Fields("Sale_Total").Value, 2));
                    Report.SetParameterValue("txtChange", Strings.FormatNumber(rs.Fields("Sale_Tender").Value - rs.Fields("Sale_Total").Value, 2));
                    // lTransaction.paymentTotal - lTransaction.paymentTender, 2)
                    Report.SetParameterValue("txtTender", Strings.FormatNumber(rs.Fields("Sale_Tender").Value, 2));
                    //  lTransaction.paymentTender, 2)
                    //Report.txtPaidBy.SetText lTransaction.customer.signed
                    Report.ReportDefinition.Sections("txtPaidBy").SectionFormat.EnableSuppress = true;
                    rs.Close();

                    sql = "SELECT [Person_FirstName] & ' ' & [Person_LastName] AS personName From Person WHERE (((PersonID)=" + personID + "));";
                    rs = modRecordSet.getRS(ref sql);
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtCashier", rs.Fields("personName").Value + "");
                    }
                    rs.Close();

                    sql = "SELECT POS_Name From POS WHERE (((POS.POSID)=" + posID + "));";
                    rs = modRecordSet.getRS(ref sql);
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtPOS", rs.Fields("POS_Name").Value + "");
                    }
                    rs.Close();

                    sql = "SELECT CustomerTransaction.CustomerTransaction_TransactionTypeID, CustomerTransaction.CustomerTransaction_Amount, CustomerTransaction.CustomerTransaction_ReferenceID From CustomerTransaction WHERE (((CustomerTransaction.CustomerTransaction_TransactionTypeID)=8) AND ((CustomerTransaction.CustomerTransaction_ReferenceID)=" + lID + "));";
                    Debug.Print(sql);
                    rs.Open(sql, cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
                    if (rs.RecordCount) {
                        Report.SetParameterValue("txtSettlement", Strings.FormatNumber(rs.Fields("CustomerTransaction_Amount").Value, 2));
                    } else {
                        Report.SetParameterValue("txtSettlement", Strings.FormatNumber("0.00", 2));
                    }

                    My.MyProject.Forms.frmReportShow.Text = "Customer Statement";
                    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();
                } else {
                    ReportNone.Load("cryNoRecords.rpt");
                    ReportNone.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
                    ReportNone.SetParameterValue("txtTitle", "Customer Statement");
                    //UPGRADE_WARNING: Couldn't resolve default property of object ReportNone.txtTitle. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                    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;
                }

            }
        }
Beispiel #36
0
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            string sql = null;

            ADODB.Connection lConn      = default(ADODB.Connection);
            ADODB.Recordset  rs         = default(ADODB.Recordset);
            ADODB.Recordset  rsPurchase = default(ADODB.Recordset);
            ADODB.Recordset  rsSales    = default(ADODB.Recordset);
            ADODB.Recordset  rsStock    = default(ADODB.Recordset);
            ADODB.Recordset  rsCompany  = default(ADODB.Recordset);
            //Dim Report As New cryIncomeExpense
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryIncomeExpense.rpt");
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            if (cmbMonthEnd.SelectedIndex)
            {
                lConn = modRecordSet.openConnectionInstance(ref "month" + gMonth - cmbMonthEnd.SelectedIndex + ".mdb");
                if (lConn == null)
                {
                    return;
                }
                rsStock = new ADODB.Recordset();
                rsStock.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                sql = "SELECT DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]+[DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS total, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]) AS opening, Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]) AS sales, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]) AS shrink, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS grv From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;";

                rsStock.Open(sql, lConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
                rsSales = new ADODB.Recordset();
                rsSales.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                //UPGRADE_WARNING: Couldn't resolve default property of object sql. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                sql = "SELECT [M_DayEnd].[DayEndID], [M_DayEnd].[DayEnd_Date], Sum([Declaration].[Declaration_Total]) AS SumOfSale_Total FROM Declaration INNER JOIN M_DayEnd ON [Declaration].[Declaration_DayEndID]=[M_DayEnd].[DayEndID] GROUP BY [M_DayEnd].[DayEndID], [M_DayEnd].[DayEnd_Date];";

                rsSales.Open(sql, lConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
            }
            else
            {
                modApplication.modUpdate = 3;

                modApplication.updateStockMovement();

                sql     = "SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum(Declaration.Declaration_Total) AS SumOfSale_Total FROM Company, Declaration INNER JOIN DayEnd ON Declaration.Declaration_DayEndID = DayEnd.DayEndID Where (((DayEnd.DayEndID) <> [Company]![Company_DayEndID])) GROUP BY DayEnd.DayEndID, DayEnd.DayEnd_Date Union SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum([SaleItem_Price]*[SaleItem_Quantity]) AS SumOfSale_Total FROM Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN ((Sale INNER JOIN (Company INNER JOIN DayEnd ON Company.Company_DayEndID = DayEnd.DayEndID) ON Sale.Sale_DayEndID = DayEnd.DayEndID) INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = 0)) GROUP BY Consignment.ConsignmentID, Consignment_1.ConsignmentID, DayEnd.DayEndID, DayEnd.DayEnd_Date  ";
                sql     = sql + "HAVING (((Consignment.ConsignmentID) Is Null) AND ((Consignment_1.ConsignmentID) Is Null));";
                rsSales = modRecordSet.getRS(ref sql);

                rsStock = modRecordSet.getRS(ref "SELECT DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]+[DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS total, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]) AS opening, Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]) AS sales, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]) AS shrink, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS grv From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;");
            }

            rsPurchase = modRecordSet.getRS(ref "SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum(grvPosted.GRV_InvoiceInclusive) AS SumOfGRV_InvoiceInclusive, ([MonthEnd_BudgetSales]/[MonthEnd_Days]) AS saleBudget, ([MonthEnd_BudgetPurchases]/[MonthEnd_Days]) AS purchaseBudget FROM [SELECT GRV.* From GRV WHERE (((GRV.GRV_GRVStatusID)=3))]. AS grvPosted RIGHT JOIN (DayEnd INNER JOIN MonthEnd ON DayEnd.DayEnd_MonthEndID = MonthEnd.MonthEndID) ON grvPosted.GRV_DayEndID = DayEnd.DayEndID Where (((MonthEnd.MonthEndID) = " + gMonth - cmbMonthEnd.SelectedIndex + ")) GROUP BY DayEnd.DayEndID, DayEnd.DayEnd_Date, ([MonthEnd_BudgetSales]/[MonthEnd_Days]), ([MonthEnd_BudgetPurchases]/[MonthEnd_Days]);");



            rsCompany = modRecordSet.getRS(ref "SELECT MonthEnd.* From MonthEnd WHERE (((MonthEnd.MonthEndID)=" + gMonth - cmbMonthEnd.SelectedIndex + "));");

            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            if (rsPurchase.BOF | rsPurchase.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;
            }
            //Report.Database.SetDataSource(rs)
            Report.Database.Tables(1).SetDataSource(rsPurchase);
            Report.Database.Tables(2).SetDataSource(rsSales);
            Report.Database.Tables(3).SetDataSource(rsStock);
            Report.Database.Tables(4).SetDataSource(rsCompany);
            //UPGRADE_WARNING: Couldn't resolve default property of object Report.VerifyOnEveryPrint. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            //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();


            if (lConn == null)
            {
            }
            else
            {
                lConn.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();
        }
Beispiel #38
0
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs     = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As New cryItemGroupCompare
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report     = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryItemGroupCompare.rpt");
            ReportNone.Load("cryNoRecords.rpt");
            modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where Link_SectionID=3");
            while (!(rs.EOF))
            {
                if (!string.IsNullOrEmpty(rs.Fields("Link_SQL").Value))
                {
                    if (_optDataType_0.Checked)
                    {
                        modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT " + rs.Fields("LinkID").Value + ", DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID WHERE " + rs.Fields("Link_SQL").Value + ";");
                    }
                    else
                    {
                        modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT " + rs.Fields("LinkID").Value + ", Sale.Sale_DayEndID, Sum([SaleItem_Quantity]*[SaleItem_Price]) FROM (SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID) INNER JOIN Sale ON SaleItem.SaleItem_SaleID = Sale.SaleID Where " + rs.Fields("Link_SQL").Value + " GROUP BY Sale.Sale_DayEndID;");
                    }
                }
                rs.MoveNext();
            }
            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT theJoin.LinkID, theJoin.DayEndID, 0 FROM LinkItem RIGHT JOIN [SELECT Link.LinkID, DayEnd.DayEndID From Link, DayEnd WHERE (((Link.Link_SQL)<>'') AND ((Link.Link_SectionID)=3))]. AS theJoin ON (LinkItem.LinkItem_DayEndID = theJoin.DayEndID) AND (LinkItem.LinkItem_LinkID = theJoin.LinkID) WHERE (((LinkItem.LinkItem_LinkID) Is Null));");


            return;

            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 "SELECT Link.* From Link Where (((Link.Link_SectionID) = 1)) ORDER BY Link.Link_SectionID;");
            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;
            }
            rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'ddd dd mmm\", \"yyyy') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID;");
            if (rsData.BOF | rsData.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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            //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();
        }
Beispiel #39
0
        private static void report_Deposit()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryDeposit
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryDeposit.rpt");
            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 "SELECT aDeposit.Deposit_Name, aDeposit.Deposit_Quantity, Sum((IIf([SaleItem_DepositType]=3,[Deposit_Quantity],0)+IIf([SaleItem_DepositType]=1,1,0))*[SaleItem_Quantity]) AS bottle, Sum((IIf([SaleItem_DepositType]=3,1,0)+IIf([SaleItem_DepositType]=2,1,0))*[SaleItem_Quantity]) AS crate, Sum([SaleItem_Price]*[SaleItem_Quantity]) AS amount, aDeposit.Deposit_UnitCost, aDeposit.Deposit_CaseCost FROM SaleItem INNER JOIN aDeposit ON SaleItem.SaleItem_StockItemID = aDeposit.DepositID Where (((SaleItem.SaleItem_DepositType) <> 0) And ((SaleItem.SaleItem_Reversal) = False) And ((SaleItem.SaleItem_Revoke) = False)) GROUP BY aDeposit.Deposit_Name, aDeposit.Deposit_Quantity, aDeposit.Deposit_UnitCost, aDeposit.Deposit_CaseCost;");
            //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;
            }

            Report.Database.Tables(1).SetDataSource(rs);

            //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();
        }
        private void doSearch()
        {
            string lString = null;

            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            ADODB.Recordset rs  = default(ADODB.Recordset);
            string          sql = null;

            Report.Load("cryPriceComparison.rpt");
            string lHeading = null;

            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            Report.SetParameterValue("txtTitle", this.Text);
            Report.SetParameterValue("txtFilter", this.lblHeading.Text);
            rs.Close();
            lString = "((CatalogueChannelLnk.CatalogueChannelLnk_ChannelID) = " + this.cmbChannel.BoundText + ") And (Catalogue.Catalogue_Disabled <> -1) AND ([Catalogue_Content]<>0)";
            if (string.IsNullOrEmpty(gFilterSQL))
            {
                lString = " WHERE " + lString;
            }
            else
            {
                lString = gFilterSQL + " AND " + lString;
            }
            if (cmbShrink.Enabled)
            {
                lString  = lString + " AND (Catalogue.Catalogue_Quantity = " + this.cmbShrink.BoundText + ") ";
                lHeading = " and Quantity = " + this.cmbShrink.BoundText;
            }
            if (chkDifferent.CheckState)
            {
                lString = lString + " AND (([CatalogueChannelLnk_PriceSystem]-[CatalogueChannelLnk_Price])<>0) ";
            }
            if (chkAbove.CheckState)
            {
                lString  = lString + " AND (((1 - (([Catalogue_Content]) * (1 + [vat_amount] / 100)) / [CatalogueChannelLnk_Price]) * 100) > " + this.txtAbove.Text + ") ";
                lHeading = " and Markup > " + this.txtAbove.Text;
            }
            if (chkBelow.CheckState)
            {
                lString  = lString + " AND (((1 - (([Catalogue_Content]) * (1 + [vat_amount] / 100)) / [CatalogueChannelLnk_Price]) * 100) < " + this.txtAbove.Text + ") ";
                lHeading = " and Markup < " + this.txtAbove.Text;
            }

            sql = "SELECT StockItem.StockItem_Name, Catalogue.*, ([Catalogue_Content]+[Catalogue_Deposit])*(1+[vat_amount]/100) AS cost, CatalogueChannelLnk.CatalogueChannelLnk_Location, CatalogueChannelLnk.CatalogueChannelLnk_Markup, CatalogueChannelLnk.CatalogueChannelLnk_PriceOriginal, CatalogueChannelLnk.CatalogueChannelLnk_PriceSystem, CatalogueChannelLnk.CatalogueChannelLnk_Price, [CatalogueChannelLnk_Price]-[CatalogueChannelLnk_PriceSystem] AS difference, 100*(([CatalogueChannelLnk_Price]/(1+([Vat_Amount]/100))-[Catalogue_Deposit])/[Catalogue_Content]-1) AS MarkupPrice, 100*(([CatalogueChannelLnk_PriceSystem]/(1+([Vat_Amount]/100))-[Catalogue_Deposit])/[Catalogue_Content]-1) AS MarkupSystem, (1-(([Catalogue_Content])*(1+[vat_amount]/100))/[CatalogueChannelLnk_Price])*100 AS grossPercentage, ([CatalogueChannelLnk_Price]/([Catalogue_Content]*(1+[vat_amount]/100))-1)*100 AS markupPercentage ";
            sql = sql + "FROM ((StockItem INNER JOIN Catalogue ON StockItem.StockItemID = Catalogue.Catalogue_StockItemID) INNER JOIN CatalogueChannelLnk ON (Catalogue.Catalogue_StockItemID = CatalogueChannelLnk.CatalogueChannelLnk_StockItemID) AND (Catalogue.Catalogue_Quantity = CatalogueChannelLnk.CatalogueChannelLnk_Quantity)) INNER JOIN Vat ON StockItem.StockItem_VatID = Vat.VatID ";
            sql = sql + lString;
            sql = sql + "ORDER BY StockItem.StockItem_Name, Catalogue.Catalogue_Quantity;";

            Report.SetParameterValue("txtTitle", "Where Sales Channel = " + cmbChannel.CtlText + lHeading);

            rs = modRecordSet.getRS(ref sql);
            //Report.Database.SetDataSource(rs, 3)
            Report.Database.Tables(1).SetDataSource(rs);
            //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();
        }
        private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsQty = default(ADODB.Recordset);
            ADODB.Recordset RSitem = default(ADODB.Recordset);
            bool ltype = false;
            //Dim Report As New cryCashTransaction
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryCashTransaction.rpt");
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            //UPGRADE_WARNING: Couldn't resolve default property of object Report.txtCompanyName. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT * FROM Channel ORDER BY ChannelID");
            while (!(rs.EOF)) {
                switch (rs.Fields("ChannelID").Value) {
                    case 1:
                        Report.SetParameterValue("txtCS1", rs.Fields("Channel_Code"));
                        break;
                    case 2:
                        Report.SetParameterValue("txtCS2", rs.Fields("Channel_Code"));
                        break;
                    case 3:
                        Report.SetParameterValue("txtCS3", rs.Fields("Channel_Code"));
                        break;
                    case 4:
                        Report.SetParameterValue("txtCS4", rs.Fields("Channel_Code"));
                        break;
                    case 5:
                        Report.SetParameterValue("txtCS5", rs.Fields("Channel_Code"));
                        break;
                    case 6:
                        Report.SetParameterValue("txtCS6", rs.Fields("Channel_Code"));
                        break;
                    case 7:
                        Report.SetParameterValue("txtCS7", rs.Fields("Channel_Code"));
                        break;
                    case 8:
                        Report.SetParameterValue("txtCS8", rs.Fields("Channel_Code"));
                        break;
                }
                rs.moveNext();
            }
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT CashTransaction.*, StockItem.StockItem_Name FROM StockItem INNER JOIN CashTransaction ON StockItem.StockItemID = CashTransaction.CashTransaction_StockItemID;");
            //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();
                //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            //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();
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
Beispiel #42
0
        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();
        }
Beispiel #43
0
        private void loadValue()
        {
            ADODB.Recordset rs     = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As New cryItemItemCompareValue
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report     = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryItemItemCompareValue.rpt");
            ReportNone.Load("cryNoRecords.rpt");
            modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where Link_SectionID=3");
            while (!(rs.EOF))
            {
                if (!string.IsNullOrEmpty(rs.Fields("Link_SQL").Value))
                {
                    modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT " + rs.Fields("LinkID").Value + ", Sale.Sale_DayEndID, Sum([SaleItem_Quantity]*[SaleItem_Price]) FROM (SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID) INNER JOIN Sale ON SaleItem.SaleItem_SaleID = Sale.SaleID Where " + rs.Fields("Link_SQL").Value + " GROUP BY Sale.Sale_DayEndID;");
                }
                rs.moveNext();
            }

            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT theJoin.LinkID, theJoin.DayEndID, 0 FROM LinkItem RIGHT JOIN [SELECT Link.LinkID, DayEnd.DayEndID From Link, DayEnd WHERE (((Link.Link_SQL)<>'') AND ((Link.Link_SectionID)=3))]. AS theJoin ON (LinkItem.LinkItem_DayEndID = theJoin.DayEndID) AND (LinkItem.LinkItem_LinkID = theJoin.LinkID) WHERE (((LinkItem.LinkItem_LinkID) Is Null));");
            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 "SELECT [Link].[LinkID], [Link].[Link_Name], Sum([LinkItem].[LinkItem_Value]) AS SumOfLinkItem_Value FROM Link INNER JOIN LinkItem ON [Link].[LinkID]=[LinkItem].[LinkItem_LinkID] WHERE ((([Link].[Link_SQL])<>'') And (([Link].[Link_SectionID])=3)) GROUP BY [Link].[LinkID], [Link].[Link_Name] ORDER BY [Link].[LinkID];");

            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;
            }
            rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'yyyy mm dd ddd') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID ORDER BY DayEnd.DayEnd_Date;");
            if (rsData.BOF | rsData.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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            System.Windows.Forms.Application.DoEvents();
            //Report.VerifyOnEveryPrint = True
            System.Windows.Forms.Application.DoEvents();
            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();
        }
        private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            update_Renamed();
            ADODB.Recordset rs     = default(ADODB.Recordset);
            ADODB.Recordset rsQty  = default(ADODB.Recordset);
            ADODB.Recordset RSitem = default(ADODB.Recordset);
            bool            ltype  = false;

            //Dim Report As New cryIncrement
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryIncrement.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT * FROM Channel ORDER BY ChannelID");
            while (!(rs.EOF))
            {
                switch (rs.Fields("ChannelID").Value)
                {
                case 1:
                    Report.SetParameterValue("txtCS1", rs.Fields("Channel_Code"));
                    break;

                case 2:
                    Report.SetParameterValue("txtCS2", rs.Fields("Channel_Code"));
                    break;

                case 3:
                    Report.SetParameterValue("txtCS3", rs.Fields("Channel_Code"));
                    break;

                case 4:
                    Report.SetParameterValue("txtCS4", rs.Fields("Channel_Code"));
                    break;

                case 5:
                    Report.SetParameterValue("txtCS5", rs.Fields("Channel_Code"));
                    break;

                case 6:
                    Report.SetParameterValue("txtCS6", rs.Fields("Channel_Code"));
                    break;

                case 7:
                    Report.SetParameterValue("txtCS7", rs.Fields("Channel_Code"));
                    break;

                case 8:
                    Report.SetParameterValue("txtCS8", rs.Fields("Channel_Code"));
                    break;
                }
                rs.moveNext();
            }

            rs.Close();
            rs = modRecordSet.getRS(ref "SELECT Increment.* FROM Increment;");
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.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;
            }
            rsQty  = modRecordSet.getRS(ref "SELECT IncrementQuantity.* From IncrementQuantity ORDER BY IncrementQuantity.IncrementQuantity_Quantity;");
            RSitem = modRecordSet.getRS(ref "SELECT IncrementStockItemLnk.IncrementStockItemLnk_IncrementID, StockItem.StockItem_Name FROM IncrementStockItemLnk INNER JOIN StockItem ON IncrementStockItemLnk.IncrementStockItemLnk_StockItemID = StockItem.StockItemID ORDER BY StockItem.StockItem_Name;");

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsQty);
            Report.Database.Tables(3).SetDataSource(RSitem);
            //UPGRADE_WARNING: Couldn't resolve default property of object Report.VerifyOnEveryPrint. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            //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();
        }
Beispiel #45
0
        private void loadStockSales(ref short ltype)
        {
            object rs = null;

            ADODB.Recordset rsSales = default(ADODB.Recordset);
            ADODB.Recordset rsStock = default(ADODB.Recordset);
            ADODB.Recordset rsGroup = default(ADODB.Recordset);
            string          sql     = null;

            ADODB.Recordset rsData = default(ADODB.Recordset);
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report     = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            ReportNone.Load("cryNoRecords.rpt");
            string lOrder = null;

            switch (reportType)
            {
            case 0:
                Report.Load("cryStockSales.rpt");
                break;

            case 1:
                Report.Load("cryStockSalesCompare.rpt");
                break;
            }
            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("Company_Name"));
            Report.SetParameterValue("txtDayEnd", rs("Report_Heading"));
            rs.Close();
            rs  = modReport.getRSreport(ref "SELECT * FROM Link Where LinkID=2 AND Link_SectionID=1");
            sql = "SELECT aStockItem.StockItemID, aStockItem.StockItem_Name, StockList.inclusiveSum AS inclusive, StockList.exclusiveSum AS exclusive, [exclusiveSum]-[depositSum] AS price, [exclusiveSum]-[depositSum] AS content, [exclusiveSum]-[depositSum]-[listCostSum] AS listProfit, [exclusiveSum]-[depositSum]-[actualCostSum] AS actualProfit, StockList.quantitySum AS quantity FROM aStockItem INNER JOIN (SELECT SaleItem.SaleItem_StockItemID, Sum([SaleItem_Price]*[SaleItem_Quantity]) AS inclusiveSum, Sum(([SaleItem_Price]/(1+([SaleItem_Vat]/100))*[SaleItem_Quantity])) AS exclusiveSum, Sum([SaleItem_DepositCost]*[SaleItem_Quantity]) AS depositSum, Sum(IIf([SaleItem_Reversal],0-[SaleItem_Quantity],[SaleItem_Quantity])*[SaleItem_ShrinkQuantity]) AS quantitySum, Sum([SaleItem_ListCost]*[SaleItem_Quantity]) AS listCostSum, Sum([SaleItem_actualCost]*[SaleItem_Quantity]) AS actualCostSum ";
            sql = sql + "FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN (Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID ";
            switch (ltype)
            {
            case 0:
                Report.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString + " by Stock Item");
                Report.SetParameterValue("txtFilter", Strings.Replace(rs("Link_Name"), "''", "'"));
                Report.SetParameterValue("txtGroup", "Stock Item");

                sql = "SELECT aStockItem.StockItemID AS GroupID, Sum(stockSales.inclusive) AS inclusive, Sum(stockSales.exclusive) AS exclusive, Sum(stockSales.content) AS content, Sum(stockSales.listProfit) AS listProfit, Sum(stockSales.actualProfit) AS actualProfit, Sum(stockSales.quantity) AS quantity, Sum(stockSales.listCost) AS listCost, Sum(stockSales.actualCost) AS actualCost, Sum(stockSales.depositSum) AS depositSum, Sum(stockSales.listGP) AS listGP, Sum(stockSales.actualGP) AS actualGP ";
                sql = sql + "FROM aStockItem INNER JOIN (SELECT SaleItem.SaleItem_StockItemID, Sum([SaleItem_Price]*[SaleItem_Quantity]) AS inclusive, Sum(([SaleItem_Price]/(1+([SaleItem_Vat]/100))*[SaleItem_Quantity])) AS exclusive, Sum((([SaleItem_Price]/(1+([SaleItem_Vat]/100))-[SaleItem_DepositCost])*[SaleItem_Quantity])) AS content, Sum((([SaleItem_Price]/(1+([SaleItem_Vat]/100))-[SaleItem_DepositCost]-[SaleItem_ListCost])*[SaleItem_Quantity])) AS listProfit, Sum((([SaleItem_Price]/(1+([SaleItem_Vat]/100))-[SaleItem_DepositCost]-[SaleItem_ActualCost])*[SaleItem_Quantity])) AS actualProfit, Sum(IIf([SaleItem_Reversal],0-[SaleItem_Quantity],[SaleItem_Quantity])*[SaleItem_ShrinkQuantity]) AS quantity, Sum([SaleItem_ListCost]*[SaleItem_Quantity]) AS listCost, Sum([SaleItem_actualCost]*[SaleItem_Quantity]) AS actualCost, Sum([SaleItem_DepositCost]*[SaleItem_Quantity]) AS depositSum, Sum(0) AS listGP, Sum(0) AS actualGP FROM aConsignment AS aConsignment_1 RIGHT JOIN (aConsignment RIGHT JOIN ";
                sql = sql + "(Sale INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON aConsignment.Consignment_SaleID = Sale.SaleID) ON aConsignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_DepositType) = 0) And ((SaleItem.SaleItem_Revoke) = False) And ((aConsignment.ConsignmentID) Is Null) And ((aConsignment_1.ConsignmentID) Is Null)) GROUP BY SaleItem.SaleItem_StockItemID) AS stockSales ON aStockItem.StockItemID = stockSales.SaleItem_StockItemID GROUP BY aStockItem.StockItemID;";
                sql = "SELECT aStockItem.StockItemID AS GroupID, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]) AS content, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![listCostSum]) AS listProfit, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost, Sum(StockList.depositSum) AS depositSum FROM StockList INNER JOIN aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItemID;";

                rsSales = modReport.getRSreport(ref sql);

                sql = "SELECT stockOpen.StockItemID AS GroupID, Sum(stockOpen.openQty) AS openQty, Sum(stockOpen.openList) AS openList, Sum(stockOpen.openActual) AS openActual, Sum(stockClose.closeList) AS closeList, Sum(stockClose.closeActual) AS closeActual, Sum(stockClose.closeQty) AS closeQty, Sum(stockMovement.listSales) AS listSales, Sum(stockMovement.listShrink) AS listShrink, Sum(stockMovement.listGRV) AS listGRV, Sum(stockMovement.actualSales) AS actualSales, Sum(stockMovement.actualShrink) AS actualShrink, Sum(stockMovement.actualGRV) AS actualGRV, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV ";
                sql = sql + "FROM (SELECT aStockItem.StockItemID, IIf(IsNull([openQtyTot]),0,[openQtyTot]) AS openQty, IIf(IsNull([openListTot]),0,[openListTot]) AS openList, IIf(IsNull([openActualTot]),0 ";
                sql = sql + ",[openActualTot]) AS openActual FROM aStockItem LEFT JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, DayEndStockItemLnk.DayEndStockItemLnk_Quantity AS openQtyTot, [DayEndStockItemLnk.DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ListCost] AS openListTot, [DayEndStockItemLnk!DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ActualCost] AS openActualTot FROM DayEndStockItemLnk INNER JOIN Report ON DayEndStockItemLnk.DayEndStockItemLnk_DayEndID = Report.Report_DayEndStartID) AS [%$##@_Alias] ON aStockItem.StockItemID = [%$##@_Alias].DayEndStockItemLnk_StockItemID) AS stockOpen RIGHT JOIN ((aStockItem INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost])) AS listSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost])) AS listShrink, ";
                sql = sql + "Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost])) AS listGRV, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_actualCost])) AS actualSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_actualCost])) AS actualShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_actualCost])) AS actualGRV, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_StockItemID) AS stockMovement ON aStockItem.StockItemID = stockMovement.DayEndStockItemLnk_StockItemID) INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, ";
                sql = sql + "([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ListCost] AS closeList, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ActualCost] AS closeActual, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV]) AS closeQty FROM Report INNER JOIN DayEndStockItemLnk ON Report.Report_DayEndEndID = DayEndStockItemLnk.DayEndStockItemLnk_DayEndID) AS stockClose ON aStockItem.StockItemID = stockClose.DayEndStockItemLnk_StockItemID) ON stockOpen.StockItemID = aStockItem.StockItemID GROUP BY stockOpen.StockItemID;";

                rsStock = modReport.getRSreport(ref sql);

                if (string.IsNullOrEmpty(rs("Link_SQL")))
                {
                    Report.ReportDefinition.Sections("Section2").SectionFormat.EnableSuppress = true;
                    sql = "";
                }
                else
                {
                    sql = rs("Link_SQL");
                }

                rsGroup = modReport.getRSreport(ref "SELECT aStockItem.StockItemID AS groupID, aStockItem.StockItem_Name AS groupName From aStockItem " + sql + " ORDER BY aStockItem.StockItem_Name;");
                break;

            case 4:
                Report.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString + " by Shrink");
                Report.SetParameterValue("txtGroup", "Shrink");
                Report.ReportDefinition.Sections("Section2").SectionFormat.EnableSuppress = true;
                sql     = "SELECT aStockItem.StockItem_ShrinkID AS GroupID, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]) AS content, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![listCostSum]) AS listProfit, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost, Sum(StockList.depositSum) AS depositSum FROM StockList INNER JOIN aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItem_ShrinkID;";
                rsSales = modReport.getRSreport(ref sql);

                sql = "SELECT aStockItem.StockItem_ShrinkID AS GroupID, Sum(stockOpen.openQty) AS openQty, Sum(stockOpen.openList) AS openList, Sum(stockOpen.openActual) AS openActual, Sum(stockClose.closeList) AS closeList, Sum(stockClose.closeActual) AS closeActual, Sum(stockClose.closeQty) AS closeQty, Sum(stockMovement.listSales) AS listSales, Sum(stockMovement.listShrink) AS listShrink, Sum(stockMovement.listGRV) AS listGRV, Sum(stockMovement.actualSales) AS actualSales, Sum(stockMovement.actualShrink) AS actualShrink, Sum(stockMovement.actualGRV) AS actualGRV, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV ";
                sql = sql + "FROM (SELECT aStockItem.StockItemID, IIf(IsNull([openQtyTot]),0,[openQtyTot]) AS openQty, IIf(IsNull([openListTot]),0,[openListTot]) AS openList, IIf(IsNull([openActualTot]),0,[openActualTot]) AS openActual ";
                sql = sql + "FROM aStockItem LEFT JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, DayEndStockItemLnk.DayEndStockItemLnk_Quantity AS openQtyTot, [DayEndStockItemLnk.DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ListCost] AS openListTot, [DayEndStockItemLnk!DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ActualCost] AS openActualTot FROM DayEndStockItemLnk ";
                sql = sql + "INNER JOIN Report ON DayEndStockItemLnk.DayEndStockItemLnk_DayEndID = Report.Report_DayEndStartID) AS [%$##@_Alias] ON aStockItem.StockItemID = [%$##@_Alias].DayEndStockItemLnk_StockItemID) AS stockOpen RIGHT JOIN ((aStockItem INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost])) AS listSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost])) AS listShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost])) AS listGRV, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_actualCost])) AS actualSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_actualCost])) AS actualShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_actualCost])) AS actualGRV, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, ";
                sql = sql + "Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_StockItemID) AS stockMovement ON aStockItem.StockItemID = stockMovement.DayEndStockItemLnk_StockItemID) INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ListCost] AS closeList, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ActualCost] AS closeActual, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV]) AS closeQty FROM Report INNER JOIN DayEndStockItemLnk ON ";
                sql = sql + "Report.Report_DayEndEndID = DayEndStockItemLnk.DayEndStockItemLnk_DayEndID) AS stockClose ON aStockItem.StockItemID = stockClose.DayEndStockItemLnk_StockItemID) ON stockOpen.StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItem_ShrinkID;";

                rsStock = modReport.getRSreport(ref sql);

                rsGroup = modReport.getRSreport(ref "SELECT aShrink.ShrinkID AS groupID, aShrink.Shrink_Name AS groupName From aShrink ORDER BY aShrink.Shrink_Name;");
                break;

            case 3:
                Report.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString + " by Stock Group");
                Report.SetParameterValue("txtGroup", "Stock Group");
                Report.ReportDefinition.Sections("Section2").SectionFormat.EnableSuppress = true;
                sql     = "SELECT aStockItem.StockItem_StockGroupID AS GroupID, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]) AS content, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![listCostSum]) AS listProfit, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost, Sum(StockList.depositSum) AS depositSum FROM StockList INNER JOIN aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItem_StockGroupID;";
                rsSales = modReport.getRSreport(ref sql);

                sql = "SELECT aStockItem.StockItem_StockGroupID AS GroupID, Sum(stockOpen.openQty) AS openQty, Sum(stockOpen.openList) AS openList, Sum(stockOpen.openActual) AS openActual, Sum(stockClose.closeList) AS closeList, Sum(stockClose.closeActual) AS closeActual, Sum(stockClose.closeQty) AS closeQty, Sum(stockMovement.listSales) AS listSales, Sum(stockMovement.listShrink) AS listShrink, Sum(stockMovement.listGRV) AS listGRV, Sum(stockMovement.actualSales) AS actualSales, Sum(stockMovement.actualShrink) AS actualShrink, Sum(stockMovement.actualGRV) AS actualGRV, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV ";
                sql = sql + "FROM (SELECT aStockItem.StockItemID, IIf(IsNull([openQtyTot]),0,[openQtyTot]) AS openQty, IIf(IsNull([openListTot]),0,[openListTot]) AS openList, IIf(IsNull([openActualTot]),0,[openActualTot]) AS openActual ";
                sql = sql + "FROM aStockItem LEFT JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, DayEndStockItemLnk.DayEndStockItemLnk_Quantity AS openQtyTot, [DayEndStockItemLnk.DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ListCost] AS openListTot, [DayEndStockItemLnk!DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ActualCost] AS openActualTot FROM DayEndStockItemLnk ";
                sql = sql + "INNER JOIN Report ON DayEndStockItemLnk.DayEndStockItemLnk_DayEndID = Report.Report_DayEndStartID) AS [%$##@_Alias] ON aStockItem.StockItemID = [%$##@_Alias].DayEndStockItemLnk_StockItemID) AS stockOpen RIGHT JOIN ((aStockItem INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost])) AS listSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost])) AS listShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost])) AS listGRV, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_actualCost])) AS actualSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_actualCost])) AS actualShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_actualCost])) AS actualGRV, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, ";
                sql = sql + "Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_StockItemID) AS stockMovement ON aStockItem.StockItemID = stockMovement.DayEndStockItemLnk_StockItemID) INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ListCost] AS closeList, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ActualCost] AS closeActual, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV]) AS closeQty FROM Report INNER JOIN DayEndStockItemLnk ON ";
                sql = sql + "Report.Report_DayEndEndID = DayEndStockItemLnk.DayEndStockItemLnk_DayEndID) AS stockClose ON aStockItem.StockItemID = stockClose.DayEndStockItemLnk_StockItemID) ON stockOpen.StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItem_StockGroupID;";

                rsStock = modReport.getRSreport(ref sql);

                rsGroup = modReport.getRSreport(ref "SELECT aStockGroup.StockGroupID AS groupID, aStockGroup.StockGroup_Name AS groupName From aStockGroup ORDER BY aStockGroup.StockGroup_Name;");
                break;

            case 2:
                Report.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString + " by Pricing Group");
                Report.SetParameterValue("txtGroup", "Pricing Group");
                Report.ReportDefinition.Sections("Section2").SectionFormat.EnableSuppress = true;
                sql     = "SELECT aStockItem.StockItem_PricingGroupID AS GroupID, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]) AS content, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![listCostSum]) AS listProfit, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost, Sum(StockList.depositSum) AS depositSum FROM StockList INNER JOIN aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItem_PricingGroupID;";
                rsSales = modReport.getRSreport(ref sql);

                sql = "SELECT aStockItem.StockItem_PricingGroupID AS GroupID, Sum(stockOpen.openQty) AS openQty, Sum(stockOpen.openList) AS openList, Sum(stockOpen.openActual) AS openActual, Sum(stockClose.closeList) AS closeList, Sum(stockClose.closeActual) AS closeActual, Sum(stockClose.closeQty) AS closeQty, Sum(stockMovement.listSales) AS listSales, Sum(stockMovement.listShrink) AS listShrink, Sum(stockMovement.listGRV) AS listGRV, Sum(stockMovement.actualSales) AS actualSales, Sum(stockMovement.actualShrink) AS actualShrink, Sum(stockMovement.actualGRV) AS actualGRV, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV ";
                sql = sql + "FROM (SELECT aStockItem.StockItemID, IIf(IsNull([openQtyTot]),0,[openQtyTot]) AS openQty, IIf(IsNull([openListTot]),0,[openListTot]) AS openList, IIf(IsNull([openActualTot]),0,[openActualTot]) AS openActual ";
                sql = sql + "FROM aStockItem LEFT JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, DayEndStockItemLnk.DayEndStockItemLnk_Quantity AS openQtyTot, [DayEndStockItemLnk.DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ListCost] AS openListTot, [DayEndStockItemLnk!DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ActualCost] AS openActualTot FROM DayEndStockItemLnk ";
                sql = sql + "INNER JOIN Report ON DayEndStockItemLnk.DayEndStockItemLnk_DayEndID = Report.Report_DayEndStartID) AS [%$##@_Alias] ON aStockItem.StockItemID = [%$##@_Alias].DayEndStockItemLnk_StockItemID) AS stockOpen RIGHT JOIN ((aStockItem INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost])) AS listSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost])) AS listShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost])) AS listGRV, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_actualCost])) AS actualSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_actualCost])) AS actualShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_actualCost])) AS actualGRV, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, ";
                sql = sql + "Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_StockItemID) AS stockMovement ON aStockItem.StockItemID = stockMovement.DayEndStockItemLnk_StockItemID) INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ListCost] AS closeList, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ActualCost] AS closeActual, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV]) AS closeQty FROM Report INNER JOIN DayEndStockItemLnk ON ";
                sql = sql + "Report.Report_DayEndEndID = DayEndStockItemLnk.DayEndStockItemLnk_DayEndID) AS stockClose ON aStockItem.StockItemID = stockClose.DayEndStockItemLnk_StockItemID) ON stockOpen.StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItem_PricingGroupID;";

                rsStock = modReport.getRSreport(ref sql);

                rsGroup = modReport.getRSreport(ref "SELECT aPricingGroup.PricingGroupID AS groupID, aPricingGroup.PricingGroup_Name AS groupName From aPricingGroup ORDER BY aPricingGroup.PricingGroup_Name;");
                break;

            case 1:
                Report.SetParameterValue("txtTitle", Report.ParameterFields("txtTitle").ToString + " by Supplier");
                Report.SetParameterValue("txtGroup", "Supplier");
                Report.ReportDefinition.Sections("Section2").SectionFormat.EnableSuppress = true;
                sql     = "SELECT aStockItem.StockItem_SupplierID AS GroupID, Sum(StockList.inclusiveSum) AS inclusive, Sum(StockList.exclusiveSum) AS exclusive, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]) AS content, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![listCostSum]) AS listProfit, Sum([StockList]![exclusiveSum]-[StockList]![depositSum]-[StockList]![actualCostSum]) AS actualProfit, Sum(StockList.quantitySum) AS quantity, Sum(StockList.listCostSum) AS listCost, Sum(StockList.actualCostSum) AS actualCost, Sum(StockList.depositSum) AS depositSum FROM StockList INNER JOIN aStockItem ON StockList.SaleItem_StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItem_SupplierID;";
                rsSales = modReport.getRSreport(ref sql);

                sql = "SELECT aStockItem.StockItem_SupplierID AS GroupID, Sum(stockOpen.openQty) AS openQty, Sum(stockOpen.openList) AS openList, Sum(stockOpen.openActual) AS openActual, Sum(stockClose.closeList) AS closeList, Sum(stockClose.closeActual) AS closeActual, Sum(stockClose.closeQty) AS closeQty, Sum(stockMovement.listSales) AS listSales, Sum(stockMovement.listShrink) AS listShrink, Sum(stockMovement.listGRV) AS listGRV, Sum(stockMovement.actualSales) AS actualSales, Sum(stockMovement.actualShrink) AS actualShrink, Sum(stockMovement.actualGRV) AS actualGRV, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(stockMovement.SumOfDayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV ";
                sql = sql + "FROM (SELECT aStockItem.StockItemID, IIf(IsNull([openQtyTot]),0,[openQtyTot]) AS openQty, IIf(IsNull([openListTot]),0,[openListTot]) AS openList, IIf(IsNull([openActualTot]),0,[openActualTot]) AS openActual ";
                sql = sql + "FROM aStockItem LEFT JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, DayEndStockItemLnk.DayEndStockItemLnk_Quantity AS openQtyTot, [DayEndStockItemLnk.DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ListCost] AS openListTot, [DayEndStockItemLnk!DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk!DayEndStockItemLnk_ActualCost] AS openActualTot FROM DayEndStockItemLnk ";
                sql = sql + "INNER JOIN Report ON DayEndStockItemLnk.DayEndStockItemLnk_DayEndID = Report.Report_DayEndStartID) AS [%$##@_Alias] ON aStockItem.StockItemID = [%$##@_Alias].DayEndStockItemLnk_StockItemID) AS stockOpen RIGHT JOIN ((aStockItem INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost])) AS listSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost])) AS listShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost])) AS listGRV, Sum(([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_actualCost])) AS actualSales, Sum(([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_actualCost])) AS actualShrink, Sum(([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_actualCost])) AS actualGRV, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales) AS SumOfDayEndStockItemLnk_QuantitySales, ";
                sql = sql + "Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityShrink) AS SumOfDayEndStockItemLnk_QuantityShrink, Sum(DayEndStockItemLnk.DayEndStockItemLnk_QuantityGRV) AS SumOfDayEndStockItemLnk_QuantityGRV From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_StockItemID) AS stockMovement ON aStockItem.StockItemID = stockMovement.DayEndStockItemLnk_StockItemID) INNER JOIN (SELECT DayEndStockItemLnk.DayEndStockItemLnk_StockItemID, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ListCost] AS closeList, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV])*[DayEndStockItemLnk_ActualCost] AS closeActual, ([DayEndStockItemLnk_Quantity]-[DayEndStockItemLnk_QuantitySales]-[DayEndStockItemLnk_QuantityShrink]+[DayEndStockItemLnk_QuantityGRV]) AS closeQty FROM Report INNER JOIN DayEndStockItemLnk ON ";
                sql = sql + "Report.Report_DayEndEndID = DayEndStockItemLnk.DayEndStockItemLnk_DayEndID) AS stockClose ON aStockItem.StockItemID = stockClose.DayEndStockItemLnk_StockItemID) ON stockOpen.StockItemID = aStockItem.StockItemID GROUP BY aStockItem.StockItem_SupplierID;";

                rsStock = modReport.getRSreport(ref sql);

                rsGroup = modReport.getRSreport(ref "SELECT Supplier.SupplierID AS groupID, Supplier.Supplier_Name AS groupName From Supplier ORDER BY Supplier.Supplier_Name;");
                break;
            }

            if (rsSales.BOF | rsSales.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();
                //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }

            if (rsStock.BOF | rsStock.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();
                //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }

            if (rsGroup.BOF | rsGroup.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();
                //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }

            Report.Database.Tables(1).SetDataSource(rsSales);
            Report.Database.Tables(2).SetDataSource(rsStock);
            Report.Database.Tables(3).SetDataSource(rsGroup);
            //Report.VerifyOnEveryPrint = True
            //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();
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
        private void SupplierStatement(ref int id)
        {
            ADODB.Connection lConn         = new ADODB.Connection();
            ADODB.Recordset  rs            = default(ADODB.Recordset);
            ADODB.Recordset  rsCompany     = default(ADODB.Recordset);
            ADODB.Recordset  rsTransaction = default(ADODB.Recordset);
            string           lAddress      = null;
            string           lNumber       = null;

            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            Report.Load("crySupplierStatement.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;

            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            lAddress = Strings.Replace(rs.Fields("Company_PhysicalAddress").Value, Constants.vbCrLf, ", ");
            if (Strings.Right(lAddress, 2) == ", ")
            {
                lAddress = Strings.Left(lAddress, Strings.Len(lAddress) - 2);
            }
            Report.Database.Tables(1).SetDataSource(rs);
            Report.SetParameterValue("txtAddress", lAddress);
            lNumber = "";
            if (!string.IsNullOrEmpty(rs.Fields("Company_Telephone").Value))
            {
                lNumber = lNumber + "Tel: " + rs.Fields("Company_Telephone").Value;
            }
            if (!string.IsNullOrEmpty(rs.Fields("Company_Fax").Value))
            {
                if (!string.IsNullOrEmpty(lNumber))
                {
                    lNumber = lNumber + " / ";
                }
                lNumber = lNumber + "Fax: " + rs.Fields("Company_Fax").Value;
            }
            if (!string.IsNullOrEmpty(rs.Fields("Company_Email").Value))
            {
                if (!string.IsNullOrEmpty(lNumber))
                {
                    lNumber = lNumber + " / ";
                }
                lNumber = lNumber + "Email: " + rs.Fields("Company_Email").Value;
            }
            Report.SetParameterValue("txtNumbers", lNumber);
            lConn = modRecordSet.openConnectionInstance(ref "month" + gMonth - this.cmbMonth.SelectedIndex + ".mdb");
            if (lConn == null)
            {
                return;
            }
            rsCompany = new ADODB.Recordset();
            rsCompany.Open("SELECT * FROM Supplier Where SupplierID = " + id, lConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
            Report.Database.Tables(1).SetDataSource(rsCompany);


            rsTransaction = new ADODB.Recordset();
            rsTransaction.Open("SELECT SupplierTransaction.SupplierTransaction_SupplierID, SupplierTransaction.SupplierTransaction_Date, SupplierTransaction.SupplierTransaction_Reference, TransactionType.TransactionType_Name, IIf([SupplierTransaction_Amount]<0,[SupplierTransaction_Amount],0) AS credit, IIf([SupplierTransaction_Amount]>=0,[SupplierTransaction_Amount],0) AS debit, SupplierTransaction.SupplierTransaction_Amount FROM SupplierTransaction INNER JOIN TransactionType ON SupplierTransaction.SupplierTransaction_TransactionTypeID = TransactionType.TransactionTypeID WHERE (((SupplierTransaction.SupplierTransaction_SupplierID)=" + id + "));", lConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockReadOnly, ADODB.CommandTypeEnum.adCmdText);
            Report.Database.Tables(2).SetDataSource(rsTransaction);

            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            ReportNone.Load("cryNoRecords.rpt");
            if (rsTransaction.BOF | rsTransaction.EOF)
            {
                ReportNone.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
                ReportNone.SetParameterValue("txtTitle", "Statement");
                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;
            }


            My.MyProject.Forms.frmReportShow.Text = "Supplier Statement";
            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();
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            My.MyProject.Forms.frmReportShow.ShowDialog();
        }
Beispiel #47
0
        private void loadValue()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As New cryItemItemCompareValue
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryItemItemCompareValue.rpt");
            ReportNone.Load("cryNoRecords.rpt");
            modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where Link_SectionID=3");
            while (!(rs.EOF)) {
                if (!string.IsNullOrEmpty(rs.Fields("Link_SQL").Value)) {
                    modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT " + rs.Fields("LinkID").Value + ", Sale.Sale_DayEndID, Sum([SaleItem_Quantity]*[SaleItem_Price]) FROM (SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID) INNER JOIN Sale ON SaleItem.SaleItem_SaleID = Sale.SaleID Where " + rs.Fields("Link_SQL").Value + " GROUP BY Sale.Sale_DayEndID;");
                }
                rs.moveNext();
            }

            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT theJoin.LinkID, theJoin.DayEndID, 0 FROM LinkItem RIGHT JOIN [SELECT Link.LinkID, DayEnd.DayEndID From Link, DayEnd WHERE (((Link.Link_SQL)<>'') AND ((Link.Link_SectionID)=3))]. AS theJoin ON (LinkItem.LinkItem_DayEndID = theJoin.DayEndID) AND (LinkItem.LinkItem_LinkID = theJoin.LinkID) WHERE (((LinkItem.LinkItem_LinkID) Is Null));");
            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 "SELECT [Link].[LinkID], [Link].[Link_Name], Sum([LinkItem].[LinkItem_Value]) AS SumOfLinkItem_Value FROM Link INNER JOIN LinkItem ON [Link].[LinkID]=[LinkItem].[LinkItem_LinkID] WHERE ((([Link].[Link_SQL])<>'') And (([Link].[Link_SectionID])=3)) GROUP BY [Link].[LinkID], [Link].[Link_Name] ORDER BY [Link].[LinkID];");

            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;
            }
            rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'yyyy mm dd ddd') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID ORDER BY DayEnd.DayEnd_Date;");
            if (rsData.BOF | rsData.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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            System.Windows.Forms.Application.DoEvents();
            //Report.VerifyOnEveryPrint = True
            System.Windows.Forms.Application.DoEvents();
            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();
        }
Beispiel #48
0
        private static void report_Discount()
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            string sql = null;
            //Dim Report As New cryDiscount
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryDiscount.rpt");
            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 "SELECT [Person_FirstName]+' '+[Person_LastName] AS person_Name, aPOS.POS_Name, Sale.* FROM (Sale INNER JOIN aPerson ON Sale.Sale_PersonID = aPerson.PersonID) INNER JOIN aPOS ON Sale.Sale_PosID = aPOS.POSID Where (((Sale.Sale_Discount) <> 0)) ORDER BY Sale.Sale_Discount DESC;");
            //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();
                //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                My.MyProject.Forms.frmReportShow.ShowDialog();
                return;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            //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();
        }
Beispiel #49
0
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            string sql = null;
            ADODB.Connection lConn = default(ADODB.Connection);
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsPurchase = default(ADODB.Recordset);
            ADODB.Recordset rsSales = default(ADODB.Recordset);
            ADODB.Recordset rsStock = default(ADODB.Recordset);
            ADODB.Recordset rsCompany = default(ADODB.Recordset);
            //Dim Report As New cryIncomeExpense
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryIncomeExpense.rpt");
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            if (cmbMonthEnd.SelectedIndex) {
                lConn = modRecordSet.openConnectionInstance(ref "month" + gMonth - cmbMonthEnd.SelectedIndex + ".mdb");
                if (lConn == null)
                    return;
                rsStock = new ADODB.Recordset();
                rsStock.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                sql = "SELECT DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]+[DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS total, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]) AS opening, Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]) AS sales, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]) AS shrink, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS grv From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;";

                rsStock.Open(sql, lConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
                rsSales = new ADODB.Recordset();
                rsSales.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
                //UPGRADE_WARNING: Couldn't resolve default property of object sql. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
                sql = "SELECT [M_DayEnd].[DayEndID], [M_DayEnd].[DayEnd_Date], Sum([Declaration].[Declaration_Total]) AS SumOfSale_Total FROM Declaration INNER JOIN M_DayEnd ON [Declaration].[Declaration_DayEndID]=[M_DayEnd].[DayEndID] GROUP BY [M_DayEnd].[DayEndID], [M_DayEnd].[DayEnd_Date];";

                rsSales.Open(sql, lConn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockOptimistic);
            } else {

                modApplication.modUpdate = 3;

                modApplication.updateStockMovement();

                sql = "SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum(Declaration.Declaration_Total) AS SumOfSale_Total FROM Company, Declaration INNER JOIN DayEnd ON Declaration.Declaration_DayEndID = DayEnd.DayEndID Where (((DayEnd.DayEndID) <> [Company]![Company_DayEndID])) GROUP BY DayEnd.DayEndID, DayEnd.DayEnd_Date Union SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum([SaleItem_Price]*[SaleItem_Quantity]) AS SumOfSale_Total FROM Consignment AS Consignment_1 RIGHT JOIN (Consignment RIGHT JOIN ((Sale INNER JOIN (Company INNER JOIN DayEnd ON Company.Company_DayEndID = DayEnd.DayEndID) ON Sale.Sale_DayEndID = DayEnd.DayEndID) INNER JOIN SaleItem ON Sale.SaleID = SaleItem.SaleItem_SaleID) ON Consignment.Consignment_SaleID = Sale.SaleID) ON Consignment_1.Consignment_ReversalSaleID = Sale.SaleID Where (((SaleItem.SaleItem_Revoke) = 0)) GROUP BY Consignment.ConsignmentID, Consignment_1.ConsignmentID, DayEnd.DayEndID, DayEnd.DayEnd_Date  ";
                sql = sql + "HAVING (((Consignment.ConsignmentID) Is Null) AND ((Consignment_1.ConsignmentID) Is Null));";
                rsSales = modRecordSet.getRS(ref sql);

                rsStock = modRecordSet.getRS(ref "SELECT DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]-[DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]+[DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS total, Sum([DayEndStockItemLnk_Quantity]*[DayEndStockItemLnk_ListCost]) AS opening, Sum([DayEndStockItemLnk_QuantitySales]*[DayEndStockItemLnk_ListCost]) AS sales, Sum([DayEndStockItemLnk_QuantityShrink]*[DayEndStockItemLnk_ListCost]) AS shrink, Sum([DayEndStockItemLnk_QuantityGRV]*[DayEndStockItemLnk_ListCost]) AS grv From DayEndStockItemLnk GROUP BY DayEndStockItemLnk.DayEndStockItemLnk_DayEndID;");

            }

            rsPurchase = modRecordSet.getRS(ref "SELECT DayEnd.DayEndID, DayEnd.DayEnd_Date, Sum(grvPosted.GRV_InvoiceInclusive) AS SumOfGRV_InvoiceInclusive, ([MonthEnd_BudgetSales]/[MonthEnd_Days]) AS saleBudget, ([MonthEnd_BudgetPurchases]/[MonthEnd_Days]) AS purchaseBudget FROM [SELECT GRV.* From GRV WHERE (((GRV.GRV_GRVStatusID)=3))]. AS grvPosted RIGHT JOIN (DayEnd INNER JOIN MonthEnd ON DayEnd.DayEnd_MonthEndID = MonthEnd.MonthEndID) ON grvPosted.GRV_DayEndID = DayEnd.DayEndID Where (((MonthEnd.MonthEndID) = " + gMonth - cmbMonthEnd.SelectedIndex + ")) GROUP BY DayEnd.DayEndID, DayEnd.DayEnd_Date, ([MonthEnd_BudgetSales]/[MonthEnd_Days]), ([MonthEnd_BudgetPurchases]/[MonthEnd_Days]);");

            rsCompany = modRecordSet.getRS(ref "SELECT MonthEnd.* From MonthEnd WHERE (((MonthEnd.MonthEndID)=" + gMonth - cmbMonthEnd.SelectedIndex + "));");

            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            ReportNone.Load("cryNoRecords.rpt");
            if (rsPurchase.BOF | rsPurchase.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;
            }
            //Report.Database.SetDataSource(rs)
            Report.Database.Tables(1).SetDataSource(rsPurchase);
            Report.Database.Tables(2).SetDataSource(rsSales);
            Report.Database.Tables(3).SetDataSource(rsStock);
            Report.Database.Tables(4).SetDataSource(rsCompany);
            //UPGRADE_WARNING: Couldn't resolve default property of object Report.VerifyOnEveryPrint. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            //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();

            if (lConn == null) {
            } else {
                lConn.Close();
            }
        }
Beispiel #50
0
        private void cmdLoad_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsData = default(ADODB.Recordset);
            //Dim Report As New cryItemGroupCompare
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryItemGroupCompare.rpt");
            ReportNone.Load("cryNoRecords.rpt");
            modReport.cnnDBreport.Execute("DELETE LinkItem.* FROM LinkItem;");
            rs = modReport.getRSreport(ref "SELECT * FROM Link Where Link_SectionID=3");
            while (!(rs.EOF)) {
                if (!string.IsNullOrEmpty(rs.Fields("Link_SQL").Value)) {
                    if (_optDataType_0.Checked) {
                        modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT " + rs.Fields("LinkID").Value + ", DayEndStockItemLnk.DayEndStockItemLnk_DayEndID, DayEndStockItemLnk.DayEndStockItemLnk_QuantitySales FROM DayEndStockItemLnk INNER JOIN aStockItem ON DayEndStockItemLnk.DayEndStockItemLnk_StockItemID = aStockItem.StockItemID WHERE " + rs.Fields("Link_SQL").Value + ";");
                    } else {
                        modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT " + rs.Fields("LinkID").Value + ", Sale.Sale_DayEndID, Sum([SaleItem_Quantity]*[SaleItem_Price]) FROM (SaleItem INNER JOIN aStockItem ON SaleItem.SaleItem_StockItemID = aStockItem.StockItemID) INNER JOIN Sale ON SaleItem.SaleItem_SaleID = Sale.SaleID Where " + rs.Fields("Link_SQL").Value + " GROUP BY Sale.Sale_DayEndID;");
                    }

                }
                rs.MoveNext();
            }
            modReport.cnnDBreport.Execute("INSERT INTO LinkItem ( LinkItem_LinkID, LinkItem_DayEndID, LinkItem_Value ) SELECT theJoin.LinkID, theJoin.DayEndID, 0 FROM LinkItem RIGHT JOIN [SELECT Link.LinkID, DayEnd.DayEndID From Link, DayEnd WHERE (((Link.Link_SQL)<>'') AND ((Link.Link_SectionID)=3))]. AS theJoin ON (LinkItem.LinkItem_DayEndID = theJoin.DayEndID) AND (LinkItem.LinkItem_LinkID = theJoin.LinkID) WHERE (((LinkItem.LinkItem_LinkID) Is Null));");

            return;
            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 "SELECT Link.* From Link Where (((Link.Link_SectionID) = 1)) ORDER BY Link.Link_SectionID;");
            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;
            }
            rsData = modReport.getRSreport(ref "SELECT LinkItem.*, Format([DayEnd_Date],'ddd dd mmm\", \"yyyy') AS dateName, DayEnd.DayEnd_Date FROM DayEnd INNER JOIN LinkItem ON DayEnd.DayEndID = LinkItem.LinkItem_DayEndID;");
            if (rsData.BOF | rsData.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;
            }

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsData);
            //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();
        }
        private void cmdPrintNew_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            string sql = null;

            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = default(CrystalDecisions.CrystalReports.Engine.ReportDocument);
            ADODB.Recordset rs    = default(ADODB.Recordset);
            bool            ltype = false;

            Report.Load("cryPOSupdate.rpt");
            //UPGRADE_WARNING: Screen property Screen.MousePointer has a new behavior. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6BA9B8D2-2A32-4B6E-8D36-44949974A5B4"'
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            //UPGRADE_WARNING: Couldn't resolve default property of object Report.txtCompanyName. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();

            Report.SetParameterValue("txtTitle", "New Catalogue Updates");
            Report.SetParameterValue("txtTitle1", _lbl_0.Text + " " + this.lblInstruction.Text + ". the new POS update Instruction will be " + this.lblInstructionNew.Text + ".");
            rs = modRecordSet.getRS(ref "SELECT * FROM Channel WHERE ChannelID <> 9 ORDER BY ChannelID");
            while (!(rs.EOF))
            {
                switch (rs.Fields("ChannelID").Value)
                {
                case 1:
                    Report.SetParameterValue("txtChannel1", rs.Fields("Channel_Code"));
                    break;

                case 2:
                    Report.SetParameterValue("txtChannel2", rs.Fields("Channel_Code"));
                    break;

                case 3:
                    Report.SetParameterValue("txtChannel3", rs.Fields("Channel_Code"));
                    break;

                case 4:
                    Report.SetParameterValue("txtChannel4", rs.Fields("Channel_Code"));
                    break;

                case 5:
                    Report.SetParameterValue("txtChannel5", rs.Fields("Channel_Code"));
                    break;

                case 6:
                    Report.SetParameterValue("txtChannel6", rs.Fields("Channel_Code"));
                    break;

                case 7:
                    Report.SetParameterValue("txtChannel7", rs.Fields("Channel_Code"));
                    break;

                case 8:
                    Report.SetParameterValue("txtChannel8", rs.Fields("Channel_Code"));
                    break;
                }
                rs.moveNext();
            }

            rs.Close();
            sql = "TRANSFORM Sum(newItems.CatalogueChannelLnk_Price) AS SumOfCatalogueChannelLnk_Price SELECT newItems.StockItemID, newItems.StockItem_Name, newItems.CatalogueChannelLnk_Quantity FROM [SELECT StockItem.StockItemID, StockItem.StockItem_Name, POSUpdate_PriceNewSummary.CatalogueChannelLnk_ChannelID, POSUpdate_PriceNewSummary.CatalogueChannelLnk_Quantity, CatalogueChannelLnk.CatalogueChannelLnk_Price FROM CatalogueChannelLnk INNER JOIN (POSUpdate_PriceNewSummary INNER JOIN StockItem ON POSUpdate_PriceNewSummary.CatalogueChannelLnk_StockItemID = StockItem.StockItemID) ON (CatalogueChannelLnk.CatalogueChannelLnk_Quantity = POSUpdate_PriceNewSummary.CatalogueChannelLnk_Quantity) AND (CatalogueChannelLnk.CatalogueChannelLnk_ChannelID = POSUpdate_PriceNewSummary.CatalogueChannelLnk_ChannelID) AND (CatalogueChannelLnk.CatalogueChannelLnk_StockItemID = POSUpdate_PriceNewSummary.CatalogueChannelLnk_StockItemID) ";
            sql = sql + "ORDER BY StockItem.StockItem_Name, POSUpdate_PriceNewSummary.CatalogueChannelLnk_ChannelID, POSUpdate_PriceNewSummary.CatalogueChannelLnk_Quantity]. AS newItems GROUP BY newItems.StockItemID, newItems.StockItem_Name, newItems.CatalogueChannelLnk_Quantity PIVOT newItems.CatalogueChannelLnk_ChannelID;";

            rs = modRecordSet.getRS(ref sql);
            if (rs.BOF | rs.EOF)
            {
                System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
                Interaction.MsgBox("No items in report", MsgBoxStyle.Exclamation, _4PosBackOffice.NET.My.MyProject.Application.Info.Title);
                return;
            }
            //Report.Database.SetDataSource(rs, 3)
            //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();
        }
Beispiel #52
0
        private void cmdPrint_Click(System.Object eventSender, System.EventArgs eventArgs)
        {
            update_Renamed();
            ADODB.Recordset rs = default(ADODB.Recordset);
            ADODB.Recordset rsQty = default(ADODB.Recordset);
            ADODB.Recordset RSitem = default(ADODB.Recordset);
            bool ltype = false;
            //Dim Report As New cryIncrement
            CrystalDecisions.CrystalReports.Engine.ReportDocument Report = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.Load("cryIncrement.rpt");
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
            rs = modRecordSet.getRS(ref "SELECT * FROM Company");
            Report.SetParameterValue("txtCompanyName", rs.Fields("Company_Name"));
            rs.Close();

            rs = modRecordSet.getRS(ref "SELECT * FROM Channel ORDER BY ChannelID");
            while (!(rs.EOF)) {
                switch (rs.Fields("ChannelID").Value) {
                    case 1:
                        Report.SetParameterValue("txtCS1", rs.Fields("Channel_Code"));
                        break;
                    case 2:
                        Report.SetParameterValue("txtCS2", rs.Fields("Channel_Code"));
                        break;
                    case 3:
                        Report.SetParameterValue("txtCS3", rs.Fields("Channel_Code"));
                        break;
                    case 4:
                        Report.SetParameterValue("txtCS4", rs.Fields("Channel_Code"));
                        break;
                    case 5:
                        Report.SetParameterValue("txtCS5", rs.Fields("Channel_Code"));
                        break;
                    case 6:
                        Report.SetParameterValue("txtCS6", rs.Fields("Channel_Code"));
                        break;
                    case 7:
                        Report.SetParameterValue("txtCS7", rs.Fields("Channel_Code"));
                        break;
                    case 8:
                        Report.SetParameterValue("txtCS8", rs.Fields("Channel_Code"));
                        break;
                }
                rs.moveNext();
            }

            rs.Close();
            rs = modRecordSet.getRS(ref "SELECT Increment.* FROM Increment;");
            //ReportNone.Load("cryNoRecords.rpt")
            CrystalDecisions.CrystalReports.Engine.ReportDocument ReportNone = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
            Report.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;
            }
            rsQty = modRecordSet.getRS(ref "SELECT IncrementQuantity.* From IncrementQuantity ORDER BY IncrementQuantity.IncrementQuantity_Quantity;");
            RSitem = modRecordSet.getRS(ref "SELECT IncrementStockItemLnk.IncrementStockItemLnk_IncrementID, StockItem.StockItem_Name FROM IncrementStockItemLnk INNER JOIN StockItem ON IncrementStockItemLnk.IncrementStockItemLnk_StockItemID = StockItem.StockItemID ORDER BY StockItem.StockItem_Name;");

            Report.Database.Tables(1).SetDataSource(rs);
            Report.Database.Tables(2).SetDataSource(rsQty);
            Report.Database.Tables(3).SetDataSource(RSitem);
            //UPGRADE_WARNING: Couldn't resolve default property of object Report.VerifyOnEveryPrint. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
            //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();
        }