web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics GP (Archived)

Econnect sample for Bank deposit without Receipt

(1) ShareShare
ReportReport
Posted on by

Need your help on Bank deposits without receipts using econnect.

 

I building C#.net application which creates Bank deposits without receipts in GP using econnect. I did not get any sample code for bank deposits on internet. 2years back we build application for importing bank transactions. Based on bank transactions, I wrote the code for  bank deposits without receipts and it is not working for me. system throwing an error “The program '[6516] .exe' has exited with code -2147023895 (0x800703e9). “ and exception is stackoutofexception in System.data.dll.

Request you to review the same and let me know what mistake I did in below code.

 Below is my code.

It would be great help to me if you send the sample code for Bank deposits without receipts.

 

Bank deposits without receipts :

 

public int SerializeImportBankDeposit(List<BankDeposits> ListBankDeposits, Logs objLogs)

        {

            string xmlobject = string.Empty;

            int taxnumber = 0;

            try

            {

                using (eConnectMethods objEconCall = new eConnectMethods())

                {

                    try

                    {

                        objEconCall.RequireProxyService = false;

                        eConnectType objEconnectType = new eConnectType();

                        BRBankDepositsType[] objBRBankDepositsTypeAll = new BRBankDepositsType[ListBankDeposits.Count];

                        string gpConnectionString = string.Empty;

                        for (int Count = 0; Count < ListBankDeposits.Count; Count++)

                        {

                            BRBankDepositsType objBankDeposits = new BRBankDepositsType();

                            taBRBankDepositsHeader objBankDepositsHeader = new taBRBankDepositsHeader();

                            taBRBankDepositsLine_ItemsTaBRBankDepositsLine[] objBankDepHeaderDistributionItemHeader = new taBRBankDepositsLine_ItemsTaBRBankDepositsLine[1];

                            taBRBankDepositsLine_ItemsTaBRBankDepositsLine objBankBankDepHeaderDistributionItem = new taBRBankDepositsLine_ItemsTaBRBankDepositsLine();

                            gpConnectionString= ConfigurationManager.ConnectionStrings["GPConnection"].ToString();

                            if (ListBankDeposits[Count].Amount > 0)

                            {

                                objBankDepositsHeader.Option = 1;

                                objBankDepositsHeader.DEPTYPE = 2;

                                objBankDepositsHeader.CHEKBKID = ListBankDeposits[Count].CheckBookId;

                                objBankDepositsHeader.DSCRIPTN = ListBankDeposits[Count].Description;

                                objBankDepositsHeader.DepAmt = ListBankDeposits[Count].Amount;

                                objBankDeposits.taBRBankDepositsHeader = objBankDepositsHeader;

                                objBankBankDepHeaderDistributionItem.CHEKBKID = ListBankDeposits[Count].CheckBookId;

                                objBankDepHeaderDistributionItemHeader[0] = objBankBankDepHeaderDistributionItem;

                                objBankDeposits.taBRBankDepositsLine_Items = objBankDepHeaderDistributionItemHeader;

                            }

                            objBRBankDepositsTypeAll[Count] = objBankDeposits;

                            //else

                            //{

                            //    gpAccountNumber = ConfigurationManager.AppSettings["BanTrnRtnAccount"].ToString();

                            //}

                        }

                        objEconnectType.BRBankDepositsType = objBRBankDepositsTypeAll;

                        string inMemoryXmlDocument = string.Empty;

                        //convert bank receipt data to inmemory xml format.

                        inMemoryXmlDocument = CreateInMemoryXml(objEconnectType);

                        //import the data GP

                        xmlobject = objEconCall.CreateTransactionEntity(gpConnectionString, inMemoryXmlDocument.Trim());

                    }

                    catch (FaultException<eConnectFault> eFault)

                    {

                        MaintainLogs.ErrorLog(eFault, objLogs);

                    }

                    catch (FaultException<eConnectSqlFault> sqlFault)

                    {

                        MaintainLogs.ErrorLog(sqlFault, objLogs);

                    }

                    catch (Exception Exp)

                    {

                        MaintainLogs.ErrorLog(Exp, objLogs);

                    }

                    finally

                    {

                        if (objEconCall != null)

                        {

                            objEconCall.Dispose();

                        }

                    }

                    if (xmlobject == string.Empty)

                    {

                        taxnumber = 0;

                    }

                }

            }

            catch (Exception Ex)

            {

                MaintainLogs.ErrorLog(Ex, objLogs);

            }

            return taxnumber;

        }

 

Bank transactions(receipts)

 

public int SerializeImportBankTxnReceipt(List<DailyDeposits> ListDeposits, Logs objLogs)
        {
            string xmlobject = string.Empty;
            int taxnumber = 0;
            string strDDReferance = ConfigurationManager.AppSettings["DDReferance"].ToString();
 
            try
            {
                using (eConnectMethods objEconCall = new eConnectMethods())
                {
                    try
                    {
                        objEconCall.RequireProxyService = false;
                        eConnectType objEconnectType = new eConnectType();
                        BRBankTransactionType[] objBankTransctionsAll = new BRBankTransactionType[ListDeposits.Count];
 
                        string gpConnectionString = string.Empty;
 
                        for (int count = 0; count < ListDeposits.Count; count++)
                        {
                            string CheckBookID = string.Empty;
                            CheckBookID = ConfigurationManager.AppSettings["CHECKBOOKID"].ToString();
                            string gpAccountNumber = string.Empty;
                            BRBankTransactionType objBankTransction = new BRBankTransactionType();
                            taBRBankTransactionHeader objBankTransHeader = new taBRBankTransactionHeader();
                            taBRBankTransactionDist_ItemsTaBRBankTransactionDist[] objBankTransHeaderDistributionItemHeader = new taBRBankTransactionDist_ItemsTaBRBankTransactionDist[1];
                            taBRBankTransactionDist_ItemsTaBRBankTransactionDist objBankTransHeaderDistributionItem = new taBRBankTransactionDist_ItemsTaBRBankTransactionDist();
                            if (count == 0)
                            {
                                taxnumber = Convert.ToInt32(ListDeposits[count].RCPTNMBR);
                                taxnumber = taxnumber + 1;
                                gpConnectionString = ListDeposits[count].GpConnection;
                            }
                            else
                            {
                                taxnumber = taxnumber + 1;
                            }
                            string Storeid = string.Empty;
                            string ParentStoreid = string.Empty;
                            Storeid = ListDeposits[count].StoreId.Replace("-", "0");
                            ParentStoreid = ListDeposits[count].ParentStoreId.Replace("-", "0");
                            CheckBookID = CheckBookID.Replace("CCCCCC", Storeid);
                            if (ListDeposits[count].Amount > 0)
                            {
                                gpAccountNumber = ListDeposits[count].AccountCode;
                            }
                            else
                            {
                                gpAccountNumber = ConfigurationManager.AppSettings["BanTrnRtnAccount"].ToString();
                            }
                            gpAccountNumber = gpAccountNumber.Replace("PPPPPP", ParentStoreid);
                            gpAccountNumber = gpAccountNumber.Replace("CCCCCC", Storeid);
                            if (ListDeposits[count].Amount > 0)
                            {
                                objBankTransHeader.Option = 2;
                                objBankTransHeader.RcpType = ListDeposits[count].ReceiptType;
                                if (ListDeposits[count].ReceiptType == 3)
                                {
                                    string cardName = string.Empty;
                                    cardName = ListDeposits[count].MultiStoreReceiptTypeName;
                                    cardName = cardName.Replace("CCC", ListDeposits[count].StoreId.Substring(3, 3));
                                    objBankTransHeader.CARDNAME = cardName;
                                }
                                objBankTransHeader.TRXDATE = ListDeposits[count].XactDate.ToString();
                                objBankTransHeader.CHEKBKID = CheckBookID;//   'Check Book id
                                objBankTransHeader.CMTrxNum = "TAMS" + taxnumber.ToString("000000000");  //'unique number
                                objBankTransHeader.paidtorcvdfrom = ListDeposits[count].Type;
                                objBankTransHeader.DSCRIPTN = strDDReferance;
                                objBankTransHeader.DistRef = ListDeposits[count].Description;
                                objBankTransHeader.TRXAMNT = ListDeposits[count].Amount;
                                objBankTransction.taBRBankTransactionHeader = objBankTransHeader;
                                objBankTransHeaderDistributionItem.Option = 1;
                                objBankTransHeaderDistributionItem.ACTNUMST = gpAccountNumber;
                                objBankTransHeaderDistributionItem.CRDTAMNT = ListDeposits[count].Amount;
                                objBankTransHeaderDistributionItem.DistRef = ListDeposits[count].Description;
                                objBankTransHeaderDistributionItemHeader[0] = objBankTransHeaderDistributionItem;
                                objBankTransction.taBRBankTransactionDist_Items = objBankTransHeaderDistributionItemHeader;
                            }
                            else
                            {
                                objBankTransHeader.Option = 1;
                                objBankTransHeader.CMTrxType = 4;
                                objBankTransHeader.TRXDATE = ListDeposits[count].XactDate.ToString();
                                objBankTransHeader.CHEKBKID = CheckBookID;//   'Check Book id
                                objBankTransHeader.CMTrxNum = "TAMS" + taxnumber.ToString("000000000");  //'unique number
                                objBankTransHeader.paidtorcvdfrom = ListDeposits[count].Type;
                                objBankTransHeader.DSCRIPTN = strDDReferance;
                                objBankTransHeader.DistRef = ListDeposits[count].Description;
                                objBankTransHeader.TRXAMNT = ListDeposits[count].Amount * -1;
                                objBankTransction.taBRBankTransactionHeader = objBankTransHeader;
                                objBankTransHeaderDistributionItem.Option = 1;
                                objBankTransHeaderDistributionItem.ACTNUMST = gpAccountNumber;
                                objBankTransHeaderDistributionItem.DEBITAMT = ListDeposits[count].Amount * -1;
                                objBankTransHeaderDistributionItem.DistRef = ListDeposits[count].Description;
                                objBankTransHeaderDistributionItemHeader[0] = objBankTransHeaderDistributionItem;
                                objBankTransction.taBRBankTransactionDist_Items = objBankTransHeaderDistributionItemHeader;
                            }
                            objBankTransctionsAll[count] = objBankTransction;
                        }
 
                        objEconnectType.BRBankTransactionType = objBankTransctionsAll;
                        string inMemoryXmlDocument = string.Empty;
                        //convert bank receipt data to inmemory xml format.
                        inMemoryXmlDocument = CreateInMemoryXml(objEconnectType);
                        //import the data GP
                        xmlobject = objEconCall.CreateTransactionEntity(gpConnectionString, inMemoryXmlDocument.Trim());
 
                    }
                    catch (FaultException<eConnectFault> eFault)
                    {
                        MaintainLogs.ErrorLog(eFault,objLogs);
                    }
                    catch (FaultException<eConnectSqlFault> sqlFault)
                    {
                        MaintainLogs.ErrorLog(sqlFault, objLogs);
                    }
                    catch (Exception Exp)
                    {
                        MaintainLogs.ErrorLog(Exp, objLogs);
                    }
                    finally
                    {
                        if (objEconCall != null)
                        {
                            objEconCall.Dispose();
                        }
                    }
                    if (xmlobject == string.Empty)
                    {
                        taxnumber = 0;
                    }
                }
            }
            catch (Exception Ex)
            {
                MaintainLogs.ErrorLog(Ex, objLogs);
            }
            return taxnumber;
 
        }

*This post is locked for comments

I have the same question (0)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics GP (Archived)

#1
mtabor Profile Picture

mtabor 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans