private void OpenSOPInvoiceInquiry(RMTransaction rmTrx)
 {
     if (string.IsNullOrEmpty(rmTrx.CUSTNMBR) || string.IsNullOrEmpty(rmTrx.DOCNUMBR))
     {
         return;
     }
 }
        private void OpenRMTransactionInquiry(RMTransaction rmTrx)
        {
            if (string.IsNullOrEmpty(rmTrx.CUSTNMBR) || string.IsNullOrEmpty(rmTrx.DOCNUMBR))
            {
                return;
            }

            if (rmTrx.RMDTYPAL < 1 || rmTrx.RMDTYPAL > 8)
            {
                return;
            }
            else
            {
                if (rmTrx.BCHSOURC.ToUpper().Contains("RM_SALES"))
                {
                    //Set flag to return focus to Search window after GP inquiry window is closed
                    Controller.Instance.Model.RMSearchFocus = true;
                    Dynamics.Forms.RmSalesInquiry.Procedures.OpenWindow.Invoke(rmTrx.RMDTYPAL, rmTrx.DOCNUMBR, rmTrx.DCSTATUS, 1, 8806);
                }
                else if (rmTrx.BCHSOURC.ToUpper().Contains("SALES ENTRY"))
                {
                    //Set flag to return focus to Search window after GP inquiry window is closed
                    Controller.Instance.Model.RMSearchFocus = true;
                    Dynamics.Forms.SopInquiry.Procedures.Open.Invoke(rmTrx.RMDTYPAL, rmTrx.DOCNUMBR, rmTrx.DCSTATUS, 9, 1, 8806);  //9 = RM
                }
            }
        }
        private void ViewTransaction()
        {
            //If View Transaction was clicked or row was double clicked
            try
            {
                if (dataGrid.Rows.Count > 0)
                {
                    string fieldName = Controller.Instance.Model.RMCustomerLabel + "ID";
                    string docNumber = dataGrid.Rows[dataGrid.SelectedRows[0].Index].Cells["DocNum"].Value.ToString();

                    int    docType  = Convert.ToInt32(dataGrid.Rows[dataGrid.SelectedRows[0].Index].Cells["RMDTYPAL"].Value);
                    string masterID = dataGrid.Rows[dataGrid.SelectedRows[0].Index].Cells[fieldName].Value.ToString();

                    if (!string.IsNullOrEmpty(docNumber) && docType > 0 && !string.IsNullOrEmpty(masterID))
                    {
                        RMTransaction rmTrx = Controller.Instance.GetRMTransaction(docNumber, docType, masterID);

                        OpenRMDocumentInquiry(rmTrx);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred in ViewTransaction: " + ex.Message, "Error", MessageBoxButtons.OK);
            }
        }
        private void OpenRMDocumentInquiry(RMTransaction rmTrx)
        {
            if (string.IsNullOrEmpty(rmTrx.CUSTNMBR) || string.IsNullOrEmpty(rmTrx.DOCNUMBR) || rmTrx.RMDTYPAL == 0)
            {
                return;
            }

            if (rmTrx.RMDTYPAL == 9)
            {
                OpenRMPaymentInquiry(rmTrx);
            }
            else
            {
                OpenRMTransactionInquiry(rmTrx);
            }
        }
        private void OpenRMPaymentInquiry(RMTransaction rmTrx)
        {
            if (string.IsNullOrEmpty(rmTrx.CUSTNMBR) || string.IsNullOrEmpty(rmTrx.DOCNUMBR))
            {
                return;
            }

            if (rmTrx.RMDTYPAL != 9)
            {
                return;
            }
            else
            {
                //Set flag to return focus to Search window after GP inquiry window is closed
                Controller.Instance.Model.RMSearchFocus = true;
                Dynamics.Forms.RmCashInquiry.Procedures.OpenWindow.Invoke(rmTrx.DOCNUMBR, rmTrx.DCSTATUS, 1, 8806);
            }
        }
        public RMTransaction GetRMTransaction(string docNumber, int docType, string customerID)
        {
            RMTransaction rmTrx = new RMTransaction();

            try
            {
                DataTable dataTable = DataAccess.GetRMTransactionInfo(docNumber, docType, customerID);
                if (dataTable.Rows.Count == 1)
                {
                    rmTrx = ObjectMapper.DataRowToObject <RMTransaction>(dataTable.Rows[0]);
                }

                return(rmTrx);
            }
            catch (Exception ex)
            {
                MessageBox.Show("An error occurred in Controller.GetRMTransaction: " + ex.Message);
                return(rmTrx);
            }
        }