Exemplo n.º 1
0
        // Use the button's click event to retrieve the next available document
        // numbers for Microsoft Dynamics GP documents.
        private void btnGetNextNumber_Click(object sender, System.EventArgs e)
        {
            try
            {
                // Instantiate a GetNextDocNumbers object
                GetNextDocNumbers myDocNumbers = new GetNextDocNumbers();

                // Instantiate a GetSopNumber object
                GetSopNumber mySopNumber = new GetSopNumber();

                // Create a string that specifies the Microsoft Dynamics GP server and database
                // The server name and database will use the values supplied by the user through the UI textboxes.
                string connString = string.Empty;
                connString = "data source=" + txtSqlServer.Text + ";" + "initial catalog=" + txtDataBase.Text + ";" + "Integrated Security=SSPI;";

                // Use the GetNextSopNumber method of the GetSopNumber object to retrieve the next
                // number for a Microsoft Dynamics GP invoice document
                lblSOPNUMBER.Text = mySopNumber.GetNextSopNumber(3, "STDINV", connString);

                // Use each method of the GetNextDocNumber object to retrieve the next document number
                // for the available Microsoft Dynamics GP document types
                lblPMNUMBER.Text    = myDocNumbers.GetNextPMPaymentNumber(GetNextDocNumbers.IncrementDecrement.Increment, connString);
                lblSOPPAYMENT.Text  = myDocNumbers.GetNextRMNumber(GetNextDocNumbers.IncrementDecrement.Increment, GetNextDocNumbers.RMPaymentType.RMPayments, connString);
                lblIVDOCNUMBER.Text = myDocNumbers.GetNextIVNumber(GetNextDocNumbers.IncrementDecrement.Increment, GetNextDocNumbers.IVDocType.IVAdjustment, connString);
                lblPONUMBER.Text    = myDocNumbers.GetNextPONumber(GetNextDocNumbers.IncrementDecrement.Increment, connString);
            }
            catch (Exception ex)
            {            // If an error occurs, diplay the error information to the user
                MessageBox.Show(ex.ToString());
            }
        }
        /// <summary>
        /// Create RM transaction
        /// <param name="transaction">Header of RM transaction</param>
        /// <param name="Distribution">Distribution Account of RM Transaction</param>
        /// <param name="Taxes">Taxes of RM transaction</param>
        /// <param name="company">COMPANY SHORT NAME</param>
        /// <returns>Response Class</returns>
        /// </summary>
        // Log4NetMR.classClsRegistrarLog logW = new Log4NetMR.classClsRegistrarLog();
        public Response TransactionCreate(RMTransactionHeader transaction, RMTransactionDist[] Distribution, RMDocumentTaxes[] Taxes, string company)
        {
            Response          response;
            string            server         = ConfigKey.ReadSetting("SERVER");
            string            transactionXML = string.Empty;
            string            CNX            = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var               eConnect       = new eConnectRequest();
            RMTransactionType rmTranType     = new RMTransactionType();

            var getnext = new GetNextDocNumbers();

            getnext.RequireServiceProxy = false;

            try
            {
                string DOCNUMBR = string.Empty;

                if (string.IsNullOrEmpty(transaction.DOCNUMBR))
                {
                    DOCNUMBR = getnext.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMCreditMemo, CNX);
                }
                else
                {
                    DOCNUMBR = transaction.DOCNUMBR;
                }

                rmTranType.taRMTransaction = SetTransactionValues(transaction, DOCNUMBR);

                if (transaction.CREATEDIST == 0)
                {
                    rmTranType.taRMDistribution_Items = SetDistributionValues(Distribution, DOCNUMBR);
                }
                if (transaction.CreateTaxes == 1)
                {
                    rmTranType.taRMTransactionTaxInsert_Items = SetTaxValues(Taxes, DOCNUMBR);
                }

                transactionXML = SerializeRMTransaction(rmTranType);

                response = eConnect.CreateGPTransaction(CNX, transactionXML);
                return(response);
            }
            catch (Exception ex)
            {
                //logW.LogExeption("Econnect", 2, ex);
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
            finally
            {
                getnext.Dispose();
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="Cashreceipt"></param>
        /// <param name="Distribution"></param>
        /// <param name="company"></param>
        /// <returns></returns>
        public Response CashReceiptCreate(RMCashReceipt Cashreceipt, RMTransactionDist[] Distribution, string company)
        {
            Response           response;
            string             server            = ConfigKey.ReadSetting("SERVER");
            string             transactionXML    = string.Empty;
            string             CNX               = "data source=" + server + ";initial catalog=" + company + ";integrated security=SSPI;persist security info=False;packet size=4096";
            var                eConnect          = new eConnectRequest();
            RMCashReceiptsType rmcashreceipttype = new RMCashReceiptsType();

            var getnext = new GetNextDocNumbers();

            getnext.RequireServiceProxy = false;

            try
            {
                string DOCNUMBR = string.Empty;
                DOCNUMBR = getnext.GetNextRMNumber(IncrementDecrement.Increment, RMPaymentType.RMPayments, CNX);

                rmcashreceipttype.taRMCashReceiptInsert = SetReceiptValues(Cashreceipt, DOCNUMBR);

                if (Cashreceipt.CREATEDIST == 0)
                {
                    rmcashreceipttype.taRMDistribution_Items = SetPaymentDistributionValues(Distribution, DOCNUMBR);
                }

                transactionXML    = SerializeRMCashReceipts(rmcashreceipttype);
                response          = eConnect.CreateGPTransaction(CNX, transactionXML);
                response.DOCUMENT = DOCNUMBR.Trim();
                return(response);
            }
            catch (Exception ex)
            {
                response         = new Response();
                response.SUCCESS = false;
                response.MESSAGE = ex.Message;
                response.STACK   = ex.StackTrace;
                return(response);
            }
            finally
            {
                getnext.Dispose();
            }
        }