Ejemplo n.º 1
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!textAmount.IsValid)
            {
                MsgBox.Show(this, "Please fix debt amount.");
                return;
            }
            double amtDebt = PIn.Double(textAmount.Text);

            if (!textDate.IsValid)
            {
                MsgBox.Show(this, "Date is not valid.");
                return;
            }
            DateTime dateDelinquency = PIn.Date(textDate.Text);

            if (dateDelinquency.Year < 1950)
            {
                MessageBox.Show("Date is not valid.");
                return;
            }
            if (dateDelinquency > DateTime.Today)
            {
                MsgBox.Show(this, "Date cannot be a future date.");
                return;
            }
            long   programNum = Programs.GetProgramNum(ProgramName.TrojanExpressCollect);
            string password   = ProgramProperties.GetPropVal(programNum, "Password");

            if (!Regex.IsMatch(password, @"^[A-Z]{2}\d{4}$"))
            {
                MsgBox.Show(this, "Password is not in correct format. Must be like this: AB1234");
                return;
            }
            string folderPath = ProgramProperties.GetPropVal(programNum, "FolderPath");

            if (string.IsNullOrEmpty(folderPath))
            {
                MsgBox.Show(this, "Export folder has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            long billingType = PIn.Long(ProgramProperties.GetPropVal(programNum, "BillingType"));

            if (billingType == 0)
            {
                MsgBox.Show(this, "Billing type has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            Cursor = Cursors.WaitCursor;
            if (!File.Exists(ODFileUtils.CombinePaths(folderPath, "TROBEN.HB")))
            {
                Cursor = Cursors.Default;
                MessageBox.Show(Lan.g(this, "The Trojan Communicator is not installed or is not configured for the folder") + ": "
                                + folderPath + ".  " + Lan.g(this, "Please contact Trojan Software Support at 800-451-9723 x1 or x2"));
                return;
            }
            try {
                File.Delete(ODFileUtils.CombinePaths(folderPath, "TROBEN.HB"));
            }
            catch (Exception ex) {
                ex.DoNothing();
                Cursor = Cursors.Default;
                MsgBox.Show(this, "There was an error attempting to delete a file from the export folder path.  Check folder permissions and/or try running as administrator.");
                return;
            }
            using (FileSystemWatcher watcher = new FileSystemWatcher(folderPath, "TROBEN.HB")) {
                if (watcher.WaitForChanged(WatcherChangeTypes.Created, 10000).TimedOut)
                {
                    Cursor = Cursors.Default;
                    MsgBox.Show(this, "The Trojan Communicator is not running. Please check it.");
                    return;
                }
            }
            StringBuilder str = new StringBuilder();

            if (radioDiplomatic.Checked)
            {
                str.Append("D*");
            }
            else if (radioFirm.Checked)
            {
                str.Append("F*");
            }
            else if (radioSkip.Checked)
            {
                str.Append("S*");
            }
            str.Append(Clip(_patCur.LName, 18) + "*");
            str.Append(Clip(_patCur.FName, 18) + "*");
            str.Append(Clip(_patCur.MiddleI, 1) + "*");
            str.Append(Clip(_guarCur.LName, 18) + "*");                                                                               //validated
            str.Append(Clip(_guarCur.FName, 18) + "*");                                                                               //validated
            str.Append(Clip(_guarCur.MiddleI, 1) + "*");
            str.Append(_guarCur.SSN.Substring(0, 3) + "-" + _guarCur.SSN.Substring(3, 2) + "-" + _guarCur.SSN.Substring(5, 4) + "*"); //validated
            if (_guarCur.Birthdate.Year >= 1880)
            {
                str.Append(_guarCur.Birthdate.ToShortDateString());
            }
            str.Append("*");
            str.Append(Clip(_guarCur.HmPhone, 13) + "*");
            str.Append(Clip(_empCur?.EmpName, 35) + "*");
            str.Append(Clip(_empCur?.Phone, 13) + "*");
            string address = _guarCur.Address;          //validated

            if (!string.IsNullOrEmpty(_guarCur.Address2))
            {
                address += ", " + _guarCur.Address2;
            }
            str.Append(Clip(address, 30) + "*");
            str.Append(Clip(_guarCur.City, 20) + "*");             //validated
            str.Append(Clip(_guarCur.State, 2) + "*");             //validated
            str.Append(Clip(_guarCur.Zip, 5) + "*");               //validated
            str.Append(amtDebt.ToString("F2") + "*");              //validated
            str.Append(dateDelinquency.ToShortDateString() + "*"); //validated
            str.Append(password + "*");                            //validated
            str.AppendLine(Clip(Security.CurUser.UserName, 25));   //There is always a logged in user
            int    thisNum    = TrojanQueries.GetUniqueFileNum();
            string outputFile = "CT" + thisNum.ToString().PadLeft(6, '0') + ".TRO";

            try {
                File.AppendAllText(ODFileUtils.CombinePaths(folderPath, outputFile), str.ToString());
            }
            catch (Exception ex) {
                ex.DoNothing();
                Cursor = Cursors.Default;
                MsgBox.Show(this, "There was an error writing to the export file.  Check folder permissions and/or try running as administrator.");
                return;
            }
            using (FileSystemWatcher watcher = new FileSystemWatcher(folderPath, outputFile)) {
                if (watcher.WaitForChanged(WatcherChangeTypes.Deleted, 10000).TimedOut)
                {
                    Cursor = Cursors.Default;
                    MsgBox.Show(this, "Warning!! Request was not sent to Trojan within the 10 second limit.");
                    return;
                }
            }
            Patients.UpdateFamilyBillingType(billingType, _patCur.Guarantor);
            Cursor       = Cursors.Default;
            DialogResult = DialogResult.OK;
        }
Ejemplo n.º 2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            double amtDebt = PIn.Double(textAmount.Text);

            if (amtDebt == 0)
            {
                MessageBox.Show("Please fill in an amount.");
                return;
            }
            if (amtDebt < 25)
            {
                MessageBox.Show("Amount of debt must be at least $25.00.");
                return;
            }
            if (amtDebt > 9999999.00)           //limit 10 char
            {
                MessageBox.Show("Amount of debt is unreasonably large.");
                return;
            }
            DateTime dateDelinquency = PIn.Date(textDate.Text);

            if (dateDelinquency.Year < 1950)
            {
                MessageBox.Show("Date is not valid.");
                return;
            }
            if (dateDelinquency > DateTime.Today)
            {
                MessageBox.Show("Date cannot be a future date.");
                return;
            }
            if (!Regex.IsMatch(textPassword.Text, @"^[A-Z]{2}\d{4}$"))
            {
                MessageBox.Show("Password is not in correct format. Must be like this: AB1234");
                return;
            }
            if (textPassword.Text != PrefC.GetString(PrefName.TrojanExpressCollectPassword))          //user changed password
            {
                Prefs.UpdateString(PrefName.TrojanExpressCollectPassword, textPassword.Text);
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            Cursor = Cursors.WaitCursor;
            string folderPath = PrefC.GetString(PrefName.TrojanExpressCollectPath);

            if (folderPath == "")
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Export folder has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            if (!folderPath.EndsWith("\\"))
            {
                folderPath += "\\";
            }
            if (!File.Exists(folderPath + "TROBEN.HB"))
            {
                Cursor = Cursors.Default;
                MessageBox.Show("The Trojan Communicator is not installed or is not configured for the folder: "
                                + folderPath + ".  Please contact Trojan Software Support at 800-451-9723 x1 or x2");
                return;
            }
            File.Delete(folderPath + "TROBEN.HB");
            FileSystemWatcher    watcher    = new FileSystemWatcher(folderPath, "TROBEN.HB");
            WaitForChangedResult waitResult = watcher.WaitForChanged(WatcherChangeTypes.Created, 10000);

            if (waitResult.TimedOut)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("The Trojan Communicator is not running. Please check it.");
                return;
            }
            long billingType = PrefC.GetLong(PrefName.TrojanExpressCollectBillingType);

            if (billingType == 0)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Billing type has not been setup yet.  Please go to Setup at the top of this window.");
                return;
            }
            StringBuilder str = new StringBuilder();

            if (radioDiplomatic.Checked)
            {
                str.Append("D*");
            }
            else if (radioFirm.Checked)
            {
                str.Append("F*");
            }
            else if (radioSkip.Checked)
            {
                str.Append("S*");
            }
            str.Append(Clip(patCur.LName, 18) + "*");
            str.Append(Clip(patCur.FName, 18) + "*");
            str.Append(Clip(patCur.MiddleI, 1) + "*");
            str.Append(Clip(guarCur.LName, 18) + "*");                                                                             //validated
            str.Append(Clip(guarCur.FName, 18) + "*");                                                                             //validated
            str.Append(Clip(guarCur.MiddleI, 1) + "*");
            str.Append(guarCur.SSN.Substring(0, 3) + "-" + guarCur.SSN.Substring(3, 2) + "-" + guarCur.SSN.Substring(5, 4) + "*"); //validated
            if (guarCur.Birthdate.Year < 1880)
            {
                str.Append("*");
            }
            else
            {
                str.Append(guarCur.Birthdate.ToString("MM/dd/yyyy") + "*");
            }
            str.Append(Clip(guarCur.HmPhone, 13) + "*");
            if (empCur == null)
            {
                str.Append("**");
            }
            else
            {
                str.Append(Clip(empCur.EmpName, 35) + "*");
                str.Append(Clip(empCur.Phone, 13) + "*");
            }
            string address = guarCur.Address;          //validated

            if (guarCur.Address2 != "")
            {
                address += ", " + guarCur.Address2;
            }
            str.Append(Clip(address, 30) + "*");
            str.Append(Clip(guarCur.City, 20) + "*");                 //validated
            str.Append(Clip(guarCur.State, 2) + "*");                 //validated
            str.Append(Clip(guarCur.Zip, 5) + "*");                   //validated
            str.Append(amtDebt.ToString("F2") + "*");                 //validated
            str.Append(dateDelinquency.ToString("MM/dd/yyyy") + "*"); //validated
            str.Append(textPassword.Text + "*");                      //validated
            str.Append(Clip(Security.CurUser.UserName, 25) + "\r\n"); //There is always a logged in user
            int    thisNum    = TrojanQueries.GetUniqueFileNum();
            string outputFile = "CT" + thisNum.ToString().PadLeft(6, '0') + ".TRO";

            File.AppendAllText(folderPath + outputFile, str.ToString());
            watcher    = new FileSystemWatcher(folderPath, outputFile);
            waitResult = watcher.WaitForChanged(WatcherChangeTypes.Deleted, 10000);
            if (waitResult.TimedOut)
            {
                Cursor = Cursors.Default;
                MessageBox.Show("Warning!! Request was not sent to Trojan within the 10 second limit.");
                return;
            }
            Patients.UpdateFamilyBillingType(billingType, patCur.Guarantor);
            Cursor       = Cursors.Default;
            DialogResult = DialogResult.OK;
        }