private void ExportBatches(object sender, EventArgs e)
        {
            if (FPetraUtilsObject.HasChanges && !((TFrmGLBatch)this.ParentForm).SaveChanges())
            {
                // saving failed, therefore do not try to post
                MessageBox.Show(Catalog.GetString("Please correct and save changed data before the export!"),
                                Catalog.GetString("Export Error"));
                return;
            }

            TFrmGLBatchExport gl = new TFrmGLBatchExport(FPetraUtilsObject.GetForm());

            gl.LedgerNumber = FLedgerNumber;
            gl.MainDS       = FMainDS;
            gl.Show();
        }
Example #2
0
        public void TestImportExportGLBatch()
        {
            // create two test batches, with some strange figures, to test problem with double values
            // export the 2 test batches, with summarize option
            // compare the exported text file

            string TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchImportFloatTest.csv";

            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);

            TFrmGLBatch frmBatch = new TFrmGLBatch(null);

            frmBatch.LedgerNumber = FLedgerNumber;
            frmBatch.Show();

            ModalFormHandler = delegate(string name, IntPtr hWnd, Form form)
            {
                OpenFileDialogTester tester = new OpenFileDialogTester(hWnd);

                ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
                {
                    TDlgSelectCSVSeparatorTester tester2 = new TDlgSelectCSVSeparatorTester(hWnd2);
                    TextBoxTester txtDateFormat = new TextBoxTester("txtDateFormat");
                    txtDateFormat.Properties.Text = "MM/dd/yyyy";
                    RadioButtonTester rbtSemicolon = new RadioButtonTester("rbtSemicolon");
                    rbtSemicolon.Properties.Checked = true;

                    ButtonTester btnOK = new ButtonTester("btnOK", tester2.Properties.Name);
                    btnOK.Click();
                };

                tester.OpenFile(TestFile);
            };

            ToolStripButtonTester btnImport = new ToolStripButtonTester("tbbImportBatches");
            btnImport.Click();

            ToolStripButtonTester btnSave = new ToolStripButtonTester("tbbSave");
            Assert.IsTrue(btnSave.Properties.Enabled, "Save button has not been activated");
            btnSave.Click();

            // go to Journal tab
            TabControlTester tabGLBatch = new TabControlTester("tabGLBatch");
            tabGLBatch.SelectTab(1);
            TextBoxTester txtBatchNumber = new TextBoxTester("ucoJournals.txtBatchNumber");

            // get the batch number from the journal tab
            int ImportedBatchNumber = Convert.ToInt32(txtBatchNumber.Properties.Text);

            TFrmGLBatchExport frmBatchExport = new TFrmGLBatchExport(null);

            frmBatch.Close();

            // export that batch, summarize the transactions
            // compare the result with the expected file
            frmBatchExport.LedgerNumber = FLedgerNumber;
            frmBatchExport.Show();

            CheckBoxTester chkIncludeUnposted = new CheckBoxTester("chkIncludeUnposted");
            chkIncludeUnposted.Properties.Checked = true;

            RadioButtonTester rbtSummary = new RadioButtonTester("rbtSummary");
            rbtSummary.Properties.Checked = false;

            RadioButtonTester rbtBatchNumberSelection = new RadioButtonTester("rbtBatchNumberSelection");
            rbtBatchNumberSelection.Properties.Checked = true;

            TextBoxTester txtFilename = new TextBoxTester("txtFilename");

            ToolStripButtonTester tbbExportBatches = new ToolStripButtonTester("tbbExportBatches");

            TTxtNumericTextBoxTester txtBatchNumberStart = new TTxtNumericTextBoxTester("txtBatchNumberStart");
            txtBatchNumberStart.Properties.NumberValueInt = ImportedBatchNumber;
            TTxtNumericTextBoxTester txtBatchNumberEnd = new TTxtNumericTextBoxTester("txtBatchNumberEnd");
            txtBatchNumberEnd.Properties.NumberValueInt = ImportedBatchNumber;

            // Test simple export of batches, no summary
            TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchExportFloatTest.csv";
            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);
            txtFilename.Properties.Text = TestFile + ".new";

            ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
            {
                MessageBoxTester tester2 = new MessageBoxTester(hWnd2);
                // Assert.AreEqual("Success", tester.Title);
                tester2.SendCommand(MessageBoxTester.Command.OK);
            };

            tbbExportBatches.Click();

            Assert.AreEqual(true, TTextFile.SameContent(TestFile,
                    TestFile + ".new"), "the files should be the same: " + TestFile);
            System.IO.File.Delete(TestFile + ".new");

            // Test export of batches, summarizing the transactions
            TestFile = TAppSettingsManager.GetValue("Testing.Path") + "/MFinance/GLForm/TestData/BatchExportFloatTestSummary.csv";
            TestFile = Path.GetFullPath(TestFile);
            Assert.IsTrue(File.Exists(TestFile), "File does not exist: " + TestFile);
            txtFilename.Properties.Text = TestFile + ".new";
            rbtSummary.Properties.Checked = true;

            ModalFormHandler = delegate(string name2, IntPtr hWnd2, Form form2)
            {
                MessageBoxTester tester2 = new MessageBoxTester(hWnd2);
                // Assert.AreEqual("Success", tester.Title);
                tester2.SendCommand(MessageBoxTester.Command.OK);
            };

            tbbExportBatches.Click();

            Assert.AreEqual(true, TTextFile.SameContent(TestFile,
                    TestFile + ".new"), "the files should be the same: " + TestFile);
            System.IO.File.Delete(TestFile + ".new");

            frmBatchExport.Close();
        }
        private void ExportBatches(object sender, EventArgs e)
        {
            if (FPetraUtilsObject.HasChanges && !((TFrmGLBatch) this.ParentForm).SaveChanges())
            {
                // saving failed, therefore do not try to post
                MessageBox.Show(Catalog.GetString("Please correct and save changed data before the export!"),
                    Catalog.GetString("Export Error"));
                return;
            }

            TFrmGLBatchExport gl = new TFrmGLBatchExport(FPetraUtilsObject.GetForm());
            gl.LedgerNumber = FLedgerNumber;
            gl.MainDS = FMainDS;
            gl.Show();
        }