Esempio n. 1
0
        //---------------------------------------------------------------------------------------------
        /// <summary>
        /// Returns the Company Path for the specified company. Returns a blank string if no matching
        /// company can be found.
        /// </summary>
        /// <param name="ForCompanyCode"></param>
        /// <returns></returns>
        public string GetCompanyPath(string ForCompanyCode)
        {
            Enterprise04.ICompanyDetail CompanyDetail = null;
            string path    = string.Empty;
            string UNCpath = string.Empty;

            // Cycle through all the companies
            int CompanyCount = tToolkit.Company.cmCount;

            for (int i = 1; i <= CompanyCount; i++)
            {
                try
                {
                    // Point the Toolkit at the company path (getPendingVAT100Entry will
                    // open and close the Toolkit using this path)
                    CompanyDetail = tToolkit.Company.get_cmCompany(i);

                    if (ForCompanyCode == CompanyDetail.coCode)
                    {
                        path = CompanyDetail.coPath;

                        // PKR. 18/09/2015. Only need to do this if it's the company we're looking for.
                        // PKR. 14/09/2015. ABSEXCH-16839. Toolkit must be closed before changing the DataDirectory.
                        if (tToolkit.Status == TToolkitStatus.tkOpen)
                        {
                            tToolkit.CloseToolkit();
                        }

                        tToolkit.Configuration.DataDirectory = CompanyDetail.coPath;

                        // PKR. 14/09/2015.ABSEXCH-16839. Toolkit must be closed before changing the DataDirectory.
                        tToolkit.OpenToolkit();

                        break;
                    }
                }
                catch
                {
                    Log.Add(string.Format("An error occurred getting company path for {0} :\r\n{1}", CompanyDetail.coCode, tToolkit.LastErrorString));
                    lastErrorString = tToolkit.LastErrorString;
                }
            }
            path = path.Trim();
            if (path == "")
            {
                lastErrorString = "Failed to find company path for " + ForCompanyCode;
            }
            return(path);
        }
Esempio n. 2
0
        private void mcmCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            if (mcmCombo.SelectedIndex >= 0)
            {
                // Get the outstanding purchase orders from Exchequer
                transListBox.Items.Clear();

                long Res;
                if (tToolkit.Status != TToolkitStatus.tkOpen)
                {
                    int             index   = mcmCombo.SelectedIndex;
                    MCMComboBoxItem selItem = mcmCombo.Items[index] as MCMComboBoxItem;
                    tToolkit.Configuration.DataDirectory = selItem.companyPath;
                    Res = tToolkit.OpenToolkit();
                    gateway.StartBatch(myCallBack, selItem.companyCode);
                }
                tToolkit.Transaction.Index = Enterprise04.TTransactionIndex.thIdxOurRef;
                string sKey = tToolkit.Transaction.BuildOurRefIndex("POR");
                Res = tToolkit.Transaction.GetGreaterThanOrEqual(sKey);
                while (Res == 0)
                {
                    if (tToolkit.Transaction.thOurRef.StartsWith("POR"))
                    {
                        transListBox.Items.Add(tToolkit.Transaction.thOurRef);
                    }

                    Res = tToolkit.Transaction.GetNext();
                }
                tToolkit.CloseToolkit();

                btnAddTrans.Enabled = true;
            }
            Cursor.Current = Cursors.Default;
        }
Esempio n. 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    // Open the toolkit
                    tToolkit = new Enterprise04.Toolkit() as IToolkit3;

                    //        MessageBox.Show("Start your engines...");

//          ctkDebugLog.StartDebugLog(ref tToolkit);  // Backdoor the toolkit (obfuscated name)
                    tToolkit.Configuration.DataDirectory = textExchDir.Text;
                    int tkRes = tToolkit.OpenToolkit();

                    ITransaction12 theTrans = (tToolkit.Transaction as ITransaction12);
                    int            Res      = theTrans.GetEqual(theTrans.BuildOurRefIndex(textSOR.Text));


                    IOrderPaymentTakePayment oPayment = theTrans.TakePayment();

                    oPayment.oppGLCode           = 2010;
                    oPayment.oppCreditCardAction = TCreditCardAction.ccaPayment;

                    oPayment.oppPaymentReference = textSOR.Text;

                    oPayment.oppCreditCardDetails.ccdAuthorisationNo = "auth number";
                    oPayment.oppCreditCardDetails.ccdCardExpiry      = "0116";
                    oPayment.oppCreditCardDetails.ccdCardNumber      = "0006";
                    oPayment.oppCreditCardDetails.ccdReferenceNo     = "SomeTXCode";
                    oPayment.oppCreditCardDetails.ccdCardType        = "VISA";

                    if (tToolkit.SystemSetup.ssUseCCDept)
                    {
                        oPayment.oppCostCentre = "AAA";
                        oPayment.oppDepartment = "AAA";
                    }

                    oPayment.oppValue = 12.34;



                    (oPayment as IBetaOP).SRCRef       = textSRC.Text;
                    (oPayment as IBetaOP).SRCTransDate = string.Format("{0:yyyyMMdd}", DateTime.Now);
                    (oPayment as IBetaOP).SRCYear      = 115;
                    (oPayment as IBetaOP).SRCPeriod    = 3;

                    MessageBox.Show(string.Format("IBetaOP attributes:\r\nRef   : {0}\r\nYear  : {1}\r\nPeriod: {2}\r\nDate  : {3}",
                                                  (oPayment as IBetaOP).SRCRef, (oPayment as IBetaOP).SRCYear, (oPayment as IBetaOP).SRCPeriod, (oPayment as IBetaOP).SRCTransDate));

                    // Don't really want to do this in here...
                    //      Res = oPayment.Execute();

/*
 *        // Create the OP Refund against this transaction
 *        IOrderPaymentGiveRefund oRefund = theTrans.GiveRefund();
 *
 *        oRefund.oprCreditCardAction = TCreditCardAction.ccaRefund;
 *
 *        oRefund.oprCreditCardDetails.ccdAuthorisationNo = "auth number";
 *        oRefund.oprCreditCardDetails.ccdCardExpiry = "0116";
 *        oRefund.oprCreditCardDetails.ccdCardNumber = "0006";
 *        oRefund.oprCreditCardDetails.ccdCardType = "VISA";
 *        oRefund.oprCreditCardDetails.ccdReferenceNo = "Some Tx Code";
 *
 *        (oRefund as IBetaOP).SRCRef = textSRC.Text;
 *        (oRefund as IBetaOP).SRCYear = 115;
 *        (oRefund as IBetaOP).SRCPeriod = 3;
 *        (oRefund as IBetaOP).SRCTransDate = string.Format("{0:yyyyMMdd}", DateTime.Now);
 *
 *        MessageBox.Show(string.Format("IBetaOP attributes:\r\nRef   : {0}\r\nYear  : {1}\r\nPeriod: {2}\r\nDate  : {3}",
 *                        (oRefund as IBetaOP).SRCRef, (oRefund as IBetaOP).SRCYear, (oRefund as IBetaOP).SRCPeriod, (oRefund as IBetaOP).SRCTransDate));
 */
                }
                catch (Exception ex)
                {
                    MessageBox.Show(string.Format("{0}\r\n\r\nStackTrace:\r\n{1}", ex.Message, ex.StackTrace), "Eeeeww! Nasty!");
                }
            }
            finally
            {
                // Close the toolkit
                tToolkit.CloseToolkit();
            }
        }
Esempio n. 4
0
        //---------------------------------------------------------------------------------------------
        public StatusCodes StartBatch(RCTCallBack aCallback, string MCMCompanyCode)
        {
            // Set up the callback function
            callback = aCallback;

            status = StatusCodes.Success;

            // Create the toolkit if it's not already created
            if (tToolkit == null)
            {
                tToolkit = new Enterprise04.Toolkit() as IToolkit3;
                // Backdoor the toolkit
                int val1 = 0, val2 = 0, val3 = 0;
                ctkDebugLog.StartDebugLog(ref val1, ref val2, ref val3); // Backdoor the toolkit (renamed for obfuscation)
                tToolkit.Configuration.SetDebugMode(val1, val2, val3);
            }

            // Open the toolkit for the selected company
            Enterprise04.ICompanyManager coManager = tToolkit.Company;
            int nCos = coManager.cmCount;

            for (int index = 1; index <= nCos; index++)
            {
                MCMCompany aCompany = new MCMCompany();
                aCompany.name = coManager.cmCompany[index].coName.Trim();
                aCompany.code = coManager.cmCompany[index].coCode.Trim();
                aCompany.path = coManager.cmCompany[index].coPath.Trim();
                MCMCompanyList.Add(aCompany);

                if (MCMCompanyCode.ToUpper() == aCompany.code.ToUpper())
                {
                    selCompany = aCompany;
                    log("Found company " + aCompany.code);
                }
            }

            // Find the selected company and open the toolkit against it
            if (selCompany == null)
            {
                errorString = "Invalid company code : " + MCMCompanyCode;
                status      = StatusCodes.DataError;
            }
            else
            {
                // Open the toolkit against the company
                if (tToolkit.Status == TToolkitStatus.tkOpen)
                {
                    tToolkit.CloseToolkit();
                }
                tToolkit.Configuration.DataDirectory = selCompany.path;
                int Res = tToolkit.OpenToolkit();
                if (Res != 0)
                {
                    errorString = "Couldn't open toolkit for company " + selCompany.code;
                    status      = StatusCodes.ToolkitError;
                }
                else
                {
                    log("Toolkit opened successfully for company " + selCompany.code);
                    status = StatusCodes.Success;
                }
            }

            if (status == StatusCodes.Success)
            {
                rctBatch.Clear();
                batchstatus = BatchStatuses.Initialised;

                log("Empty Batch ready");
            }

            return(status);
        }