Example #1
0
        public SalesReceiptRet AddSalesReceipt(SalesReceipt salesreceipt)
        {
            //Create the message set request object to hold our request

            if (sessionManager != null)
            {
                IMsgSetRequest SalesReceiptRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0);
                SalesReceiptRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
                SalesReceiptViewModel SalesReceiptVM = new SalesReceiptViewModel();
                SalesReceiptVM.BuildSalesReceiptAddRq(SalesReceiptRequestMsgSet,
                                                      SalesReceiptVM.BuildSalesReceipt(salesreceipt));

                try
                {
                    return(GetQBSalesReceipt(salesreceipt, SalesReceiptRequestMsgSet, SalesReceiptVM));
                }
                catch (COMException ce)
                {
                    // MessageBox.Show("QuickBooks Problem: " + ce.Message);
                    return(new SalesReceiptRet()
                    {
                        Comments = "QuickBooks Problem: " + ce.Message
                    });
                }
            }
            return(new SalesReceiptRet());
        }
Example #2
0
        public static QBResult AddSalesReceipt(SalesReceipt salesreceipt, string QBCompanyFile)
        {
            var saleXml     = SalesReceiptViewModel.BuildSalesReceiptAddRq(salesreceipt);
            var responseXml = QBPosContext.ProcessXML(saleXml.OuterXml, QBCompanyFile);

            return(GetQBResult(responseXml));
        }
Example #3
0
        private SalesReceiptRet GetQBSalesReceipt(SalesReceipt salesreceipt, IMsgSetRequest SalesReceiptRequestMsgSet, SalesReceiptViewModel SalesReceiptVM)
        {
            BeginSession();

            IMsgSetResponse SalesReceiptResponseMsgSet = sessionManager.DoRequests(SalesReceiptRequestMsgSet);

            CloseSession();

            return(SalesReceiptVM.WalkSalesReceiptAddRs(SalesReceiptResponseMsgSet, salesreceipt));
        }
Example #4
0
        public static QBResult AddSalesReceipt(SalesReceipt salesreceipt, string QBCompanyFile)
        {
            bool             sessionBegun   = false;
            bool             connectionOpen = false;
            QBSessionManager sessionManager = null;

            try
            {
                //Create the session Manager object
                sessionManager = new QBSessionManager();

                //Create the message set request object to hold our request
                IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 3, 0);
                requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;

                BuildSalesReceiptAddRq(requestMsgSet);

                //Connect to QuickBooks and begin a session
                sessionManager.OpenConnection("", "Sample Code from OSR");
                connectionOpen = true;
                sessionManager.BeginSession("", ENOpenMode.omDontCare);
                sessionBegun = true;

                //Send the request and get the response from QuickBooks
                IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);

                //End the session and close the connection to QuickBooks
                sessionManager.EndSession();
                sessionBegun = false;
                sessionManager.CloseConnection();
                connectionOpen = false;

                WalkSalesReceiptAddRs(responseMsgSet);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error");
                if (sessionBegun)
                {
                    sessionManager.EndSession();
                }
                if (connectionOpen)
                {
                    sessionManager.CloseConnection();
                }
            }
            //var saleXml = SalesReceiptViewModel.BuildSalesReceiptAddRq(salesreceipt);
            //if (saleXml != null)
            //{
            //    var responseXml = QBPosContext.ProcessXML(saleXml.OuterXml, QBCompanyFile);

            //    return GetQBResult(responseXml);
            //}
            //return null;
        }
Example #5
0
        private SalesReceiptRet GetQBSalesReceipt(SalesReceipt salesreceipt, IMsgSetRequest SalesReceiptRequestMsgSet, SalesReceiptViewModel SalesReceiptVM)
        {
            //if(sessionBegun == false)
            //BeginSession();

            IMsgSetResponse SalesReceiptResponseMsgSet = sessionManager.DoRequests(SalesReceiptRequestMsgSet);

            //if(sessionBegun == true)


            return(SalesReceiptVM.WalkSalesReceiptAddRs(SalesReceiptResponseMsgSet, salesreceipt));
        }
        private void AddSalesReceiptBtn_Click(object sender, RoutedEventArgs e)
        {
            SalesReceipt s = new SalesReceipt();

            s.TxnDate            = DateTime.Parse("1/4/2013");
            s.TxnState           = "1";
            s.Workstation        = "02";
            s.StoreNumber        = "1";
            s.SalesReceiptNumber = "RX2353";
            s.Comments           = "Joseph Bartholomew \n RX# 2353 \n Doctor: T.A. Marryshow";
            s.Associate          = "Dispensary";
            s.SalesReceiptType   = "0";

            s.SalesReceiptDetails.Add(new SalesReceiptDetail {
                ItemListID = "-5038534191369780991", QtySold = 10
            });                                                                                                     //340

            qb.AddSalesReceipt(s);
        }
Example #7
0
        public SalesReceiptRet AddSalesReceipt(SalesReceipt salesreceipt)
        {
            //Create the message set request object to hold our request
            IMsgSetRequest SalesReceiptRequestMsgSet = sessionManager.CreateMsgSetRequest(3, 0);

            SalesReceiptRequestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
            SalesReceiptViewModel SalesReceiptVM = new SalesReceiptViewModel();

            SalesReceiptVM.BuildSalesReceiptAddRq(SalesReceiptRequestMsgSet,
                                                  SalesReceiptVM.BuildSalesReceipt(salesreceipt));

            try
            {
                return(GetQBSalesReceipt(salesreceipt, SalesReceiptRequestMsgSet, SalesReceiptVM));
            }
            catch (COMException ce)
            {
                MessageBox.Show("Connection to QuickBooks failed, please retry");
                return(null);
            }
        }