public void PrintTerminalReport()
        {
            DialogResult loginresult = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.PrintTerminalReport);

            if (loginresult == DialogResult.None)
            {
                LogInWnd login = new LogInWnd();

                login.AccessType = AccessTypes.PrintTerminalReport;
                login.Header = "Print Terminal Report";
                login.TerminalDetails = mclsTerminalDetails;
                login.ShowDialog(this);
                loginresult = login.Result;
                login.Close();
                login.Dispose();
            }

            if (loginresult == DialogResult.OK)
            {
                Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
                mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

                Data.TerminalReportDetails Details = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
                Details.InitializedBy = mclsSalesTransactionDetails.CashierName;
                clsTerminalReport.CommitAndDispose();
                
                // always set to zero for BIR purposes
                Details.TrustFund = 0;

                DialogResult result = DialogResult.OK;

                if (mclsTerminalDetails.PreviewTerminalReport)
                {
                    TerminalReportWnd clsTerminalReportWnd = new TerminalReportWnd();
                    clsTerminalReportWnd.SysConfigDetails = mclsSysConfigDetails;
                    clsTerminalReportWnd.TerminalDetails = mclsTerminalDetails;
                    clsTerminalReportWnd.Details = Details;
                    clsTerminalReportWnd.CashierName = mCashierName;
                    clsTerminalReportWnd.TerminalReportType = TerminalReportType.TerminalReport;
                    clsTerminalReportWnd.ShowDialog(this);
                    result = clsTerminalReportWnd.Result;
                    clsTerminalReportWnd.Close();
                    clsTerminalReportWnd.Dispose();
                }
                if (result == DialogResult.OK)
                {
                    //PrintTerminalReportDelegate terminalreportDel = new PrintTerminalReportDelegate(PrintTerminalReport);
                    //terminalreportDel.BeginInvoke(Details, null, null);
                    PrintTerminalReport(Details);
                }
            }
        }
        public void ReprintZRead()
        {
            DialogResult result = GetWriteAccess(mclsSalesTransactionDetails.CashierID, AccessTypes.ReprintZRead);

            if (result == DialogResult.None)
            {
                LogInWnd login = new LogInWnd();

                login.AccessType = AccessTypes.PrintZRead;
                login.Header = "Re-Print ZREAD Report";
                login.TerminalDetails = mclsTerminalDetails;
                login.ShowDialog(this);
                result = login.Result;
                login.Close();
                login.Dispose();
            }

            if (result == DialogResult.OK)
            {
                bool boWithTF = true;

                TerminalHistoryDateWnd clsTerminalHistoryDateWnd = new TerminalHistoryDateWnd();
                clsTerminalHistoryDateWnd.TerminalDetails = mclsTerminalDetails;
                clsTerminalHistoryDateWnd.WithTF = boWithTF;
                clsTerminalHistoryDateWnd.ShowDialog(this);
                DialogResult clsTerminalHistoryDateWndresult = clsTerminalHistoryDateWnd.Result;
                DateTime dtDateLastInitialized = clsTerminalHistoryDateWnd.DateLastInitialized;
                Keys keyCommand = clsTerminalHistoryDateWnd.keyCommand;
                clsTerminalHistoryDateWnd.Close();
                clsTerminalHistoryDateWnd.Dispose();

                if (clsTerminalHistoryDateWndresult == System.Windows.Forms.DialogResult.OK)
                {
                    Data.TerminalReportHistory clsTerminalReportHistory = new Data.TerminalReportHistory(mConnection, mTransaction);
                    mConnection = clsTerminalReportHistory.Connection; mTransaction = clsTerminalReportHistory.Transaction;

                    if (keyCommand == Keys.F12) //override boWithTF, so that it will get the actual if it is an F12
                    {
                        boWithTF = false;
                    }

                    // get the details, boWithTF will determine if it will be selected from esales or from actual
                    Data.TerminalReportDetails Details = clsTerminalReportHistory.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo, dtDateLastInitialized, boWithTF);
                    clsTerminalReportHistory.CommitAndDispose();

                    decimal OldTrustFund = mclsTerminalDetails.TrustFund;

                    if (keyCommand == Keys.F12) //override even if boWithTF=true
                    {
                        mclsTerminalDetails.TrustFund = 0; Details.TrustFund = 0; 
                    }
                    else {
                        mclsTerminalDetails.TrustFund = Details.TrustFund; 
                    }

                    AceSoft.Common.SYSTEMTIME st = new AceSoft.Common.SYSTEMTIME();
                    // set the sytem date to NextDetails DateLastInitialized
                    st = AceSoft.Common.ConvertToSystemTime(Details.DateLastInitialized.AddSeconds(-2).ToUniversalTime());
                    mdtCurrentDateTime = DateTime.Now;
                    tmr.Enabled = true;
                    tmr.Start();
                    AceSoft.Common.SetSystemTime(ref st);

                    TerminalReportWnd clsTerminalReportWnd = new TerminalReportWnd();
                    clsTerminalReportWnd.SysConfigDetails = mclsSysConfigDetails;
                    clsTerminalReportWnd.TerminalDetails = mclsTerminalDetails;
                    clsTerminalReportWnd.Details = Details;
                    clsTerminalReportWnd.CashierName = mCashierName;
                    clsTerminalReportWnd.TerminalReportType = TerminalReportType.ZRead;
                    clsTerminalReportWnd.ShowDialog(this);
                    result = clsTerminalReportWnd.Result;
                    clsTerminalReportWnd.Close();
                    clsTerminalReportWnd.Dispose();

                    if (result == DialogResult.OK)
                    {
                        //PrintZReadDelegate printzreadDel = new PrintZReadDelegate(PrintZRead);
                        //printzreadDel.BeginInvoke(Details, null, null);
                        RePrintZRead(Details);
                        InsertAuditLog(AccessTypes.ReprintZRead, "Re-Print ZRead report: TerminalNo=" + mclsTerminalDetails.TerminalNo + " DateLastInitialized=" + dtDateLastInitialized.ToString("yyyy-MM-dd hh:mm") + " @ Branch: " + mclsTerminalDetails.BranchDetails.BranchCode);
                    }

                    // set the sytem date to NextDetails DateLastInitialized
                    st = AceSoft.Common.ConvertToSystemTime(mdtCurrentDateTime.ToUniversalTime());
                    AceSoft.Common.SetSystemTime(ref st);
                    tmr.Stop();
                    tmr.Enabled = false;

                    mclsTerminalDetails.TrustFund = OldTrustFund;
                }
            }
        }
        public void PrintXRead()
        {
            mclsTerminalDetails.TrustFund = 0;

            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
            mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

            clsTerminalReport.UpdateTrustFund(mclsTerminalDetails.BranchID, mclsTerminalDetails.TerminalNo, 0, mclsSalesTransactionDetails.CashierName, Constants.TRUSTFUND_UPDATE_REASON_XREAD);

            Data.TerminalReportDetails Details = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
            Details.InitializedBy = mclsSalesTransactionDetails.CashierName;
            clsTerminalReport.CommitAndDispose();

            DialogResult result = DialogResult.OK;

            if (mclsTerminalDetails.PreviewTerminalReport)
            {
                TerminalReportWnd clsTerminalReportWnd = new TerminalReportWnd();
                clsTerminalReportWnd.SysConfigDetails = mclsSysConfigDetails;
                clsTerminalReportWnd.TerminalDetails = mclsTerminalDetails;
                clsTerminalReportWnd.Details = Details;
                clsTerminalReportWnd.CashierName = mCashierName;
                clsTerminalReportWnd.TerminalReportType = TerminalReportType.XRead;
                clsTerminalReportWnd.ShowDialog(this);
                result = clsTerminalReportWnd.Result;
                clsTerminalReportWnd.Close();
                clsTerminalReportWnd.Dispose();
            }

            if (result == DialogResult.OK)
            {
                //PrintXReadDelegate printxreadDel = new PrintXReadDelegate(PrintXRead);
                PrintXRead(Details);
            }
        }
        public void PrintZRead(bool pvtWillPreviewReport)
        {
            Data.TerminalReport clsTerminalReport = new Data.TerminalReport(mConnection, mTransaction);
            mConnection = clsTerminalReport.Connection; mTransaction = clsTerminalReport.Transaction;

            Data.TerminalReportDetails Details = clsTerminalReport.Details(mclsTerminalDetails.BranchDetails.BranchID, mclsTerminalDetails.TerminalNo);
            Details.InitializedBy = mclsSalesTransactionDetails.CashierName;
            clsTerminalReport.CommitAndDispose();

            //put the trustfund as zero during zread 
            //to show the correct zread
            Details.TrustFund = 0;

            DialogResult result = DialogResult.OK;

            if (pvtWillPreviewReport)
            {
                TerminalReportWnd clsTerminalReportWnd = new TerminalReportWnd();
                clsTerminalReportWnd.SysConfigDetails = mclsSysConfigDetails;
                clsTerminalReportWnd.TerminalDetails = mclsTerminalDetails;
                clsTerminalReportWnd.Details = Details;
                clsTerminalReportWnd.CashierName = mCashierName;
                clsTerminalReportWnd.TerminalReportType = TerminalReportType.ZRead;
                clsTerminalReportWnd.ShowDialog(this);
                result = clsTerminalReportWnd.Result;
                clsTerminalReportWnd.Close();
                clsTerminalReportWnd.Dispose();
            }

            if (result == DialogResult.OK)
            {
                PrintZRead(true, Details);
            }
        }