Esempio n. 1
0
        private void FormSupportStatus_Load(object sender, EventArgs e)
        {
            Cursor          = Cursors.WaitCursor;
            _regKey         = PrefC.GetString(PrefName.RegistrationKey);
            textRegKey.Text = _regKey;
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = ("    ");
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, settings)) {
                writer.WriteStartElement("RegistrationKey");
                writer.WriteString(_regKey);
                writer.WriteEndElement();
            }
            OpenDentBusiness.localhost.Service1 updateService = CustomerUpdatesProxy.GetWebServiceInstance();
            string result = "";

            try {
                result = updateService.RequestRegKeyStatus(strbuild.ToString());
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show("Error: " + ex.Message);
                this.Close();
                return;
            }
            Cursor = Cursors.Default;
            XmlDocument doc = new XmlDocument();

            doc.LoadXml(result);
            XmlNode node = doc.SelectSingleNode("//Error");

            if (node != null)
            {
                MessageBox.Show(node.InnerText, "Error");
                return;
            }
            node = doc.SelectSingleNode("//KeyDisabled");
            if (node != null)
            {
                if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, true))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                labelStatusValue.Text      = "DISABLED " + node.InnerText;
                labelStatusValue.ForeColor = Color.Red;
            }
            //Checking all three statuses in case RequestRegKeyStatus changes in the future
            node = doc.SelectSingleNode("//KeyEnabled");
            if (node != null)
            {
                if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, false))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                labelStatusValue.Text      = "ENABLED";
                labelStatusValue.ForeColor = Color.Green;
            }
            node = doc.SelectSingleNode("//KeyEnded");
            if (node != null)
            {
                if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, true))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                labelStatusValue.Text      = "EXPIRED " + node.InnerText;
                labelStatusValue.ForeColor = Color.Red;
            }
        }
Esempio n. 2
0
        //private void butTreatProv_Click(object sender, System.EventArgs e) {
        //	listBillProv.SelectedIndex=-1;
        //}

        private void butOK_Click(object sender, System.EventArgs e)
        {
            string phone = textPhone.Text;

            if (Application.CurrentCulture.Name == "en-US" ||
                CultureInfo.CurrentCulture.Name.Substring(3) == "CA")
            {
                phone = phone.Replace("(", "");
                phone = phone.Replace(")", "");
                phone = phone.Replace(" ", "");
                phone = phone.Replace("-", "");
                if (phone.Length != 0 && phone.Length != 10)
                {
                    MessageBox.Show(Lan.g(this, "Invalid phone"));
                    return;
                }
            }
            if (radioInsBillingProvSpecific.Checked && comboInsBillingProv.SelectedIndex == -1)
            {
                MsgBox.Show(this, "You must select a provider.");
                return;
            }
            bool changed = false;

            if (Prefs.UpdateString("PracticeTitle", textPracticeTitle.Text)
                | Prefs.UpdateString("PracticeAddress", textAddress.Text)
                | Prefs.UpdateString("PracticeAddress2", textAddress2.Text)
                | Prefs.UpdateString("PracticeCity", textCity.Text)
                | Prefs.UpdateString("PracticeST", textST.Text)
                | Prefs.UpdateString("PracticeZip", textZip.Text)
                | Prefs.UpdateString("PracticePhone", phone)
                | Prefs.UpdateBool("UseBillingAddressOnClaims", checkUseBillingAddressOnClaims.Checked)
                | Prefs.UpdateString("PracticeBillingAddress", textBillingAddress.Text)
                | Prefs.UpdateString("PracticeBillingAddress2", textBillingAddress2.Text)
                | Prefs.UpdateString("PracticeBillingCity", textBillingCity.Text)
                | Prefs.UpdateString("PracticeBillingST", textBillingST.Text)
                | Prefs.UpdateString("PracticeBillingZip", textBillingZip.Text)
                | Prefs.UpdateString("PracticeBankNumber", textBankNumber.Text))
            {
                changed = true;
            }
            if (CultureInfo.CurrentCulture.Name.EndsWith("CH"))             //CH is for switzerland. eg de-CH
            {
                if (Prefs.UpdateString("BankRouting", textBankRouting.Text)
                    | Prefs.UpdateString("BankAddress", textBankAddress.Text))
                {
                    changed = true;
                }
            }
            if (listProvider.SelectedIndex == -1 &&      //practice really needs a default prov
                Providers.List.Length > 0)
            {
                listProvider.SelectedIndex = 0;
            }
            if (listProvider.SelectedIndex != -1)
            {
                if (Prefs.UpdateInt("PracticeDefaultProv", Providers.List[listProvider.SelectedIndex].ProvNum))
                {
                    changed = true;
                }
            }
            if (listBillType.SelectedIndex != -1)
            {
                if (Prefs.UpdateInt("PracticeDefaultBillType"
                                    , DefB.Short[(int)DefCat.BillingTypes][listBillType.SelectedIndex].DefNum))
                {
                    changed = true;
                }
            }
            if (Prefs.UpdateInt("DefaultProcedurePlaceService", listPlaceService.SelectedIndex))
            {
                changed = true;
            }
            if (radioInsBillingProvDefault.Checked)            //default=0
            {
                if (Prefs.UpdateInt("InsBillingProv", 0))
                {
                    changed = true;
                }
            }
            else if (radioInsBillingProvTreat.Checked)            //treat=-1
            {
                if (Prefs.UpdateInt("InsBillingProv", -1))
                {
                    changed = true;
                }
            }
            else
            {
                if (Prefs.UpdateInt("InsBillingProv", Providers.List[comboInsBillingProv.SelectedIndex].ProvNum))
                {
                    changed = true;
                }
            }
            if (changed)
            {
                DataValid.SetInvalid(InvalidTypes.Prefs);
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 3
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textDays.errorProvider1.GetError(textDays) != "")
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            if (listElectBilling.SelectedIndex.In(2, 3, 4) && !Directory.Exists(textStatementURL.Text))
            {
                MsgBox.Show(this, "Please choose a valid Output Path.");
                return;
            }
            if (checkSinglePatient.Checked && checkIntermingled.Checked)
            {
                MsgBox.Show(this, "Cannot select both 'Intermingle family members' and 'Single patient only' as defaults.");
                return;
            }
            string cc = "";

            if (checkMC.Checked)
            {
                cc = "MC";
            }
            if (checkV.Checked)
            {
                if (cc != "")
                {
                    cc += ",";
                }
                cc += "V";
            }
            if (checkD.Checked)
            {
                if (cc != "")
                {
                    cc += ",";
                }
                cc += "D";
            }
            if (checkAmEx.Checked)
            {
                if (cc != "")
                {
                    cc += ",";
                }
                cc += "A";
            }
            string billingUseElectronic = listElectBilling.SelectedIndex.ToString();

            SaveEbill(_eBillCur);
            if (listElectBilling.SelectedIndex == 1 && string.IsNullOrEmpty(textStatementURL.Text))
            {
                textStatementURL.Text = @"https://claimconnect.dentalxchange.com/dci/upload.svl";              //default value from before 16.2.19
            }
            string modesToText = string.Join(",", listModesToText.GetListSelected <StatementMode>().Select(x => POut.Int((int)x)));

            if (Prefs.UpdateLong(PrefName.BillingDefaultsLastDays, PIn.Long(textDays.Text))
                | Prefs.UpdateBool(PrefName.BillingDefaultsIntermingle, checkIntermingled.Checked)
                | Prefs.UpdateString(PrefName.BillingDefaultsNote, textNote.Text)
                | Prefs.UpdateString(PrefName.BillingUseElectronic, billingUseElectronic)
                | Prefs.UpdateString(PrefName.BillingEmailSubject, textBillingEmailSubject.Text)
                | Prefs.UpdateString(PrefName.BillingEmailBodyText, textBillingEmailBody.Text)
                | Prefs.UpdateString(PrefName.BillingElectVendorId, textVendorId.Text)
                | Prefs.UpdateString(PrefName.BillingElectVendorPMSCode, textVendorPMScode.Text)
                | Prefs.UpdateString(PrefName.BillingElectCreditCardChoices, cc)
                | Prefs.UpdateString(PrefName.BillingDefaultsInvoiceNote, textInvoiceNote.Text)
                | Prefs.UpdateBool(PrefName.BillingElectCreatePDF, checkCreatePDF.Checked)
                | (listElectBilling.SelectedIndex == 1 && Prefs.UpdateString(PrefName.BillingElectStmtUploadURL, textStatementURL.Text))
                | (listElectBilling.SelectedIndex == 2 && Prefs.UpdateString(PrefName.BillingElectStmtOutputPathPos, textStatementURL.Text))
                | (listElectBilling.SelectedIndex == 3 && Prefs.UpdateString(PrefName.BillingElectStmtOutputPathClaimX, textStatementURL.Text))
                | (listElectBilling.SelectedIndex == 4 && Prefs.UpdateString(PrefName.BillingElectStmtOutputPathEds, textStatementURL.Text))
                | Prefs.UpdateBool(PrefName.BillingDefaultsSinglePatient, checkSinglePatient.Checked)
                | Prefs.UpdateString(PrefName.BillingDefaultsModesToText, modesToText)
                | Prefs.UpdateString(PrefName.BillingDefaultsSmsTemplate, textSmsTemplate.Text)
                | Prefs.UpdateBool(PrefName.BillingShowTransSinceBalZero, checkBoxBillShowTransSinceZero.Checked))
            {
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            if (Ebills.Sync(_listEbills, _listEbillsOld))            //Includes the default Ebill
            {
                DataValid.SetInvalid(InvalidType.Ebills);            //Also updates cache.
            }
            DialogResult = DialogResult.OK;
        }
Esempio n. 4
0
 private void FormMedLabs_Load(object sender, EventArgs e)
 {
     _selectedPat = PatCur;
     if (_selectedPat == null)
     {
         checkIncludeNoPat.Checked = true;
         checkOnlyNoPat.Checked    = true;
     }
     textDateStart.Text = DateTime.Today.AddMonths(-3).ToShortDateString();          //default list to start with showing the last three months
     //One time reconcile may need to be run to create embedded PDFs for MedLabs that are not attached to a patient.
     if (!PrefC.GetBool(PrefName.MedLabReconcileDone) && PrefC.AtoZfolderUsed != DataStorageType.InDatabase)
     {
         int countMedLabs = MedLabs.GetCountForPatient(0);
         if (MessageBox.Show(this, Lan.g(this, "There are MedLabs in the database that have not been associated with a patient.\r\nA one time "
                                         + "reconciliation must be performed that will reprocess the HL7 messages for these MedLabs.  This can take some time.\r\nDo you want to "
                                         + "continue?\r\nNumber of MedLabs not associated with a patient") + ": " + countMedLabs + ".", "", MessageBoxButtons.YesNo) == DialogResult.No)
         {
             Close();
             return;
         }
         Cursor = Cursors.WaitCursor;
         int reconcileFailedCount = MedLabs.Reconcile();
         Cursor = Cursors.Default;
         if (reconcileFailedCount > 0)
         {
             MessageBox.Show(this, Lan.g(this, "Some of the MedLab objects in the database could not be reconciled.\r\nThis may be due to an issue "
                                         + "processing the original HL7 message text file.\r\nNumber failed") + ": " + reconcileFailedCount);
         }
         Prefs.UpdateBool(PrefName.MedLabReconcileDone, true);
         DataValid.SetInvalid(InvalidType.Prefs);
     }
     _dictLabAcctClinic = new Dictionary <string, string>();
     _listUserClinics   = new List <Clinic>();
     if (PrefC.HasClinicsEnabled)
     {
         _listUserClinics.Add(new Clinic()
         {
             ClinicNum = -1, Description = Lan.g(this, "All")
         });                                                                                               //ClinicNum will be -1 at index 0, "All" means all the user has access to
         if (!Security.CurUser.ClinicIsRestricted)
         {
             //ClinicNum 0 at index==1, "Headquarters" means any where MedLab.PatAccountNum does not match any clinic.MedLabAccountNum
             _listUserClinics.Add(new Clinic()
             {
                 ClinicNum = 0, Description = Lan.g(this, "Unassigned")
             });
         }
         _listUserClinics.AddRange(Clinics.GetForUserod(Security.CurUser));
         _listUserClinics.ForEach(x => comboClinic.Items.Add(x.Description));
         _dictLabAcctClinic = _listUserClinics.Where(x => !string.IsNullOrEmpty(x.MedLabAccountNum))
                              .ToDictionary(x => x.MedLabAccountNum, x => x.Description);
         if (!Security.CurUser.ClinicIsRestricted && Clinics.ClinicNum == 0) //if unrestricted and the currently selected clinic is HQ
         {
             comboClinic.SelectedIndex = 1;                                  //all users will have the "All" clinic, unrestricted users will also have the "Unassigned" clinic, so index==1
         }
         else
         {
             comboClinic.SelectedIndex = _listUserClinics.FindIndex(x => x.ClinicNum == Clinics.ClinicNum);
         }
         if (comboClinic.SelectedIndex < 0)
         {
             comboClinic.SelectedIndex = 0;
         }
     }
     else
     {
         comboClinic.Visible = false;
         labelClinic.Visible = false;
         FillGrid();                //if clinics are enabled, comboClinic.SelectedIndexChanged event handler will fill the grid, no need to call FillGrid
     }
 }
Esempio n. 5
0
        private void butClose_Click(object sender, System.EventArgs e)
        {
            if (textReportComputerName.Text.Trim().ToLower() == "localhost" || textReportComputerName.Text.Trim() == "127.0.0.1")
            {
                MsgBox.Show(this, "Computer name to fetch new reports from cannot be localhost or 127.0.0.1 or any other loopback address.");
                return;
            }
            int reportCheckIntervalMinuteCount = 0;

            try {
                reportCheckIntervalMinuteCount = PIn.Int(textReportCheckInterval.Text);
                if (textReportCheckInterval.Enabled && (reportCheckIntervalMinuteCount < 5 || reportCheckIntervalMinuteCount > 60))
                {
                    throw new ApplicationException("Invalid value.");                    //User never sees this message.
                }
            }
            catch {
                MsgBox.Show(this, "Report check interval must be between 5 and 60 inclusive.");
                return;
            }
            if (radioTime.Checked && (textReportCheckTime.Text == "" || !textReportCheckTime.IsValid))
            {
                MsgBox.Show(this, "Please enter a time to receive reports.");
                return;
            }
            bool doRestartToShowChanges = false;
            bool doInvalidateCache      = false;

            if (Prefs.UpdateString(PrefName.ClaimReportComputerName, textReportComputerName.Text))
            {
                doRestartToShowChanges = true;
                //No point in invalidating prefs since this only affects a workstation on startup.
            }
            if (Prefs.UpdateInt(PrefName.ClaimReportReceiveInterval, reportCheckIntervalMinuteCount))
            {
                doInvalidateCache = true;
            }
            if (radioTime.Checked)
            {
                if (Prefs.UpdateDateT(PrefName.ClaimReportReceiveTime, PIn.DateT(textReportCheckTime.Text)))
                {
                    doInvalidateCache = true;
                }
            }
            else if (textReportCheckTime.Text == "" && Prefs.UpdateDateT(PrefName.ClaimReportReceiveTime, DateTime.MinValue))
            {
                doInvalidateCache = true;
            }
            if (Prefs.UpdateBool(PrefName.ClaimReportReceivedByService, checkReceiveReportsService.Checked))
            {
                if (checkReceiveReportsService.Checked)
                {
                    doInvalidateCache = true;
                }
                else
                {
                    doRestartToShowChanges = true;
                }
            }
            if (doRestartToShowChanges)
            {
                MsgBox.Show(this, "You will need to restart the program for changes to take effect.");
            }
            if (doInvalidateCache)
            {
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            Close();
        }
Esempio n. 6
0
 ///<summary>Validates that PrefName.EasyNoClinics is ok to be changed and changes it when necessary. Tells HQ about changes and re-syncs with new HQ clinic preference for this practice.
 ///If fails then restores checkEnableClinics to original value when form was opened.</summary>
 private bool IsClinicCheckBoxOk()
 {
     try {
         if (!_hasClinicsEnabledChanged)                  //No change.
         {
             return(true);
         }
         //Make sure signup info was retrieved from HQ.
         ValidateHqValidationComplete();
         //Find any eServices that HQ says are enabled.
         var clinicsEnabled = _signupOut.EServices
                              .FindAll(x => x.IsEnabled)
                              .GroupBy(x => x.ClinicNum)
                              .ToList();
         //Build the prompt.
         string prompt = "";
         foreach (var clinicEnabled in clinicsEnabled)
         {
             if (clinicEnabled.Key != 0)
             {
                 prompt += ODMethodsT.Coalesce(Clinics.GetFirstOrDefault(x => x.ClinicNum == clinicEnabled.Key)
                                               , new Clinic()
                 {
                     Abbr = "Undefined Clinic"
                 }).Abbr + "\r\n";
             }
             else
             {
                 prompt += Lan.g(this, "Practice") + "\r\n";
             }
             //If bundle then don't show others.
             if (clinicEnabled.Any(x => x.EService == eServiceCode.Bundle))
             {
                 prompt += "  - " + eServiceCode.Bundle.GetDescription() + "\r\n";
             }
             else                       //Show all enabled eServices.
             {
                 foreach (var eService in clinicEnabled.ToList())
                 {
                     prompt += "  - " + eService.EService.GetDescription() + "\r\n";
                 }
             }
         }
         //Prompt and take action when necessary.
         if (!string.IsNullOrEmpty(prompt))
         {
             if (checkEnableClinics.Checked)                      //Will be switching clinics on.
             {
                 prompt =
                     Lan.g(this, "Your eServices will need to be reassigned to your clinics once you have created at least one clinic.") + "\r\n\r\n" +
                     Lan.g(this, "Once have created at least one clinic, please visit the Signup Portal using eServices | Signup in order to make the appropriate changes to your service agreement.") + "\r\n\r\n" +
                     Lan.g(this, "You are currently subscribed to the following eServices. Click OK to continue.") + "\r\n\r\n" + prompt;
             }
             else                       //Will be switching clinics off.
             {
                 prompt =
                     Lan.g(this, "Your eServices will all be transferred from individual clinics to your practice.") + "\r\n\r\n" +
                     Lan.g(this, "Once you approve this change, please visit the Signup Portal using eServices | Signup in order to verify the changes to your service agreement are correct.") + "\r\n\r\n" +
                     Lan.g(this, "You are currently subscribed to the following eServices. Click OK to approve this change.") + "\r\n\r\n" + prompt;
             }
             if (MessageBox.Show(prompt, "", MessageBoxButtons.OKCancel) != DialogResult.OK)
             {
                 throw new Exception(Lan.g(this, "Clinic feature modification canceled"));
             }
         }
         //Turn clinics on/off locally and send the signal to other workstations. This must happen before we call HQ so we tell HQ the new value.
         Prefs.UpdateBool(PrefName.EasyNoClinics, !checkEnableClinics.Checked);
         DataValid.SetInvalid(InvalidType.Prefs);
         //This call will perform the changes to the local clinic pref at HQ. It will also re-sync local prefs and table infor HQ's info.
         WebServiceMainHQProxy.GetEServiceSetupFull(SignupPortalPermission.FullPermission, true);
         return(true);
     }
     catch (Exception ex) {
         //Change it back to what the db has.
         RestoreClinicCheckBox();
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Esempio n. 7
0
 private void checkWebSchedNewPatForcePhoneFormatting_Click(object sender, EventArgs e)
 {
     Prefs.UpdateBool(PrefName.WebSchedNewPatApptForcePhoneFormatting, checkWebSchedNewPatForcePhoneFormatting.Checked);
 }
        ///<summary>Return false to indicate exit app.  Only called when program first starts up at the beginning of FormOpenDental.PrefsStartup.</summary>
        public bool Convert(string fromVersion, string toVersion, bool isSilent, Form currentForm, bool useDynamicMode)
        {
            FromVersion = new Version(fromVersion);
            ToVersion   = new Version(toVersion);
            if (FromVersion >= new Version("3.4.0") && PrefC.GetBool(PrefName.CorruptedDatabase))
            {
                FormOpenDental.ExitCode = 201;              //Database was corrupted due to an update failure
                if (!isSilent)
                {
                    MsgBox.Show(this, "Your database is corrupted because an update failed.  Please contact us.  This database is unusable and you will need to restore from a backup.");
                }
                return(false);               //shuts program down.
            }
            //There was a 19.3.0 convert method released in the 19.2.3 version.
            //We have to treat 19.3.0 as 19.2.3 so newer convert methods will run.
            if (!ODBuild.IsDebug() && FromVersion.ToString() == "19.3.0.0")
            {
                FromVersion = new Version("19.2.3.0");
                ODException.SwallowAnyException(() => Prefs.UpdateString(PrefName.DataBaseVersion, "19.2.3.0"));
            }
            if (FromVersion == ToVersion)
            {
                return(true);                         //no conversion necessary
            }
            if (FromVersion.CompareTo(ToVersion) > 0) //"Cannot convert database to an older version."
            //no longer necessary to catch it here.  It will be handled soon enough in CheckProgramVersion
            {
                return(true);
            }
            if (FromVersion < new Version("2.8.0"))
            {
                FormOpenDental.ExitCode = 130;              //Database must be upgraded to 2.8 to continue
                if (!isSilent)
                {
                    MsgBox.Show(this, "This database is too old to easily convert in one step. Please upgrade to 2.1 if necessary, then to 2.8.  Then you will be able to upgrade to this version. We apologize for the inconvenience.");
                }
                return(false);
            }
            if (FromVersion < new Version("6.6.2"))
            {
                FormOpenDental.ExitCode = 131;              //Database must be upgraded to 11.1 to continue
                if (!isSilent)
                {
                    MsgBox.Show(this, "This database is too old to easily convert in one step. Please upgrade to 11.1 first.  Then you will be able to upgrade to this version. We apologize for the inconvenience.");
                }
                return(false);
            }
            if (FromVersion < new Version("3.0.1"))
            {
                if (!isSilent)
                {
                    MsgBox.Show(this, "This is an old database.  The conversion must be done using MySQL 4.1 (not MySQL 5.0) or it will fail.");
                }
            }
            if (FromVersion.ToString() == "2.9.0.0" || FromVersion.ToString() == "3.0.0.0" || FromVersion.ToString() == "4.7.0.0")
            {
                FormOpenDental.ExitCode = 190;              //Cannot convert this database version which was only for development purposes
                if (!isSilent)
                {
                    MsgBox.Show(this, "Cannot convert this database version which was only for development purposes.");
                }
                return(false);
            }
            if (FromVersion > new Version("4.7.0") && FromVersion.Build == 0)
            {
                FormOpenDental.ExitCode = 190;              //Cannot convert this database version which was only for development purposes
                if (!isSilent)
                {
                    MsgBox.Show(this, "Cannot convert this database version which was only for development purposes.");
                }
                return(false);
            }
            if (FromVersion >= ConvertDatabases.LatestVersion)
            {
                return(true);               //no conversion necessary
            }
            //Trial users should never be able to update a database.
            if (ODBuild.IsTrial() && PrefC.GetString(PrefName.RegistrationKey) != "") //Allow databases with no reg key to update.  Needed by our conversion department.
            {
                FormOpenDental.ExitCode = 191;                                        //Trial versions cannot connect to live databases
                if (!isSilent)
                {
                    MsgBox.Show(this, "Trial versions cannot connect to live databases.  Please run the Setup.exe in the AtoZ folder to reinstall your original version.");
                }
                return(false);
            }
            string webServiceServerName = PrefC.GetString(PrefName.WebServiceServerName);

            //If the WebServiceServerName name is not set and they are using dynamic mode, continue on to download the binaries in CheckProgramVersion.
            //Or, if they do have the WebServiceServerName set and this is not the computer, continue on to CheckProgramVersion.
            if ((webServiceServerName == "" && useDynamicMode) ||
                (webServiceServerName != "" && !ODEnvironment.IdIsThisComputer(webServiceServerName.ToLower())))
            {
                if (isSilent)
                {
                    FormOpenDental.ExitCode = 141;   //Updates are only allowed from a designated web server
                    return(false);                   //if you are in debug mode and you really need to update the DB, you can manually clear the WebServiceServerName preference.
                }
                //This will be handled in CheckProgramVersion, giving the user option to downgrade or exit program.
                return(true);
            }
            //At this point, the current instance of the program has the ability to execute an upgrade.
            if (RemotingClient.RemotingRole == RemotingRole.ClientWeb)
            {
                FormOpenDental.ExitCode = 140;              //Web client cannot convert database
                if (!isSilent)
                {
                    MsgBox.Show(this, "Web client cannot convert database.  Must be using a direct connection.");
                }
                return(false);
            }
            if (ReplicationServers.ServerIsBlocked())
            {
                FormOpenDental.ExitCode = 150;              //Replication server is blocked from performing updates
                if (!isSilent)
                {
                    MsgBox.Show(this, "This replication server is blocked from performing updates.");
                }
                return(false);
            }
            //If MyISAM and InnoDb mix, then try to fix
            string namesInnodb = "";

            if (DataConnection.DBtype == DatabaseType.MySql)           //not for Oracle
            {
                namesInnodb = InnoDb.GetInnodbTableNames();            //Or possibly some other format.
                int numMyisam = DatabaseMaintenances.GetMyisamTableCount();
                if (namesInnodb != "" && numMyisam > 0)
                {
                    if (!isSilent)
                    {
                        MessageBox.Show(Lan.g(this, "A mixture of database tables in InnoDB and MyISAM format were found.  A database backup will now be made, and then the following InnoDB tables will be converted to MyISAM format: ") + namesInnodb);
                    }
                    if (!Shared.MakeABackup(isSilent, BackupLocation.ConvertScript, false))
                    {
                        Cursor.Current          = Cursors.Default;
                        FormOpenDental.ExitCode = 101;                      //Database Backup failed
                        return(false);
                    }
                    if (!DatabaseMaintenances.ConvertTablesToMyisam())
                    {
                        FormOpenDental.ExitCode = 102;                      //Failed to convert InnoDB tables to MyISAM format
                        if (!isSilent)
                        {
                            MessageBox.Show(Lan.g(this, "Failed to convert InnoDB tables to MyISAM format. Please contact support."));
                        }
                        return(false);
                    }
                    if (!isSilent)
                    {
                        MessageBox.Show(Lan.g(this, "All tables converted to MyISAM format successfully."));
                    }
                    namesInnodb = "";
                }
                if (namesInnodb == "" && numMyisam > 0)             //if all tables are myisam
                //but default storage engine is innodb, then kick them out.
                {
                    if (DatabaseMaintenances.GetStorageEngineDefaultName().ToUpper() != "MYISAM") //Probably InnoDB but could be another format.
                    {
                        FormOpenDental.ExitCode = 103;                                            //Default database .ini setting is innoDB
                        if (!isSilent)
                        {
                            MessageBox.Show(Lan.g(this, "The database tables are in MyISAM format, but the default database engine format is InnoDB. You must change the default storage engine within the my.ini (or my.cnf) file on the database server and restart MySQL in order to fix this problem. Exiting."));
                        }
                        return(false);
                    }
                }
            }
            if (ODBuild.IsDebug())
            {
                if (!isSilent && MessageBox.Show("You are in Debug mode.  Your database can now be converted" + "\r"
                                                 + "from version" + " " + FromVersion.ToString() + "\r"
                                                 + "to version" + " " + ToVersion.ToString() + "\r"
                                                 + "You can click Cancel to skip conversion and attempt to run the newer code against the older database."
                                                 , "", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return(true);                   //If user clicks cancel, then do nothing
                }
            }
            else              //release
            {
                if (!isSilent && MessageBox.Show(Lan.g(this, "Your database will now be converted") + "\r"
                                                 + Lan.g(this, "from version") + " " + FromVersion.ToString() + "\r"
                                                 + Lan.g(this, "to version") + " " + ToVersion.ToString() + "\r"
                                                 + Lan.g(this, "The conversion works best if you are on the server.  Depending on the speed of your computer, it can be as fast as a "
                                                         + "few seconds, or it can take as long as 10 minutes.")
                                                 + (namesInnodb != "" ? "\r" + Lan.g(this, "The backup tables will be MyISAM format instead of InnoDB.") : "")
                                                 , "", MessageBoxButtons.OKCancel) != DialogResult.OK)
                {
                    return(false);                   //If user clicks cancel, then close the program
                }
            }
            Cursor.Current = Cursors.WaitCursor;
#if !DEBUG
            if (!isSilent)
            {
                if (DataConnection.DBtype != DatabaseType.MySql &&
                    !MsgBox.Show(this, true, "If you have not made a backup, please Cancel and backup before continuing.  Continue?"))
                {
                    return(false);
                }
            }
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                if (!Shared.MakeABackup(isSilent, BackupLocation.ConvertScript, false))
                {
                    Cursor.Current          = Cursors.Default;
                    FormOpenDental.ExitCode = 101;                  //Database Backup failed
                    return(false);
                }
            }
            //We've been getting an increasing number of phone calls with databases that have duplicate preferences which is impossible
            //unless a user has gotten this far and another computer in the office is in the middle of an update as well.
            //The issue is most likely due to the blocking messageboxes above which wait indefinitely for user input right before upgrading the database.
            //This means that the cache for this computer could be stale and we need to manually refresh our cache to double check
            //that the database isn't flagged as corrupt, an update isn't in progress, or that the database version hasn't changed (someone successfully updated already).
            Prefs.RefreshCache();
            //Now check the preferences that should stop this computer from executing an update.
            if (PrefC.GetBool(PrefName.CorruptedDatabase) ||
                (PrefC.GetString(PrefName.UpdateInProgressOnComputerName) != "" && PrefC.GetString(PrefName.UpdateInProgressOnComputerName) != Environment.MachineName))
            {
                //At this point, the pref "corrupted database" being true means that a computer is in the middle of running the upgrade script.
                //There will be another corrupted database check on start up which will take care of the scenario where this is truly a corrupted database.
                //Also, we need to make sure that the update in progress preference is set to this computer because we JUST set it to that value before entering this method.
                //If it has changed, we absolutely know without a doubt that another computer is trying to update at the same time.
                FormOpenDental.ExitCode = 142;              //Update is already in progress from another computer
                if (!isSilent)
                {
                    MsgBox.Show(this, "An update is already in progress from another computer.");
                }
                return(false);
            }
            //Double check that the database version has not changed.  This check is here just in case another computer has successfully updated the database already.
            Version versionDatabase = new Version(PrefC.GetString(PrefName.DataBaseVersion));
            if (FromVersion != versionDatabase)
            {
                FormOpenDental.ExitCode = 143;              //Database has already been updated from another computer
                if (!isSilent)
                {
                    MsgBox.Show(this, "The database has already been updated from another computer.");
                }
                return(false);
            }
            try {
#endif
            if (FromVersion < new Version("7.5.17"))                     //Insurance Plan schema conversion
            {
                if (isSilent)
                {
                    FormOpenDental.ExitCode = 139;                          //Update must be done manually to fix Insurance Plan Schema
                    Application.Exit();
                    return(false);
                }
                Cursor.Current = Cursors.Default;
                YN InsPlanConverstion_7_5_17_AutoMergeYN = YN.Unknown;
                if (FromVersion < new Version("7.5.1"))
                {
                    FormInsPlanConvert_7_5_17 form = new FormInsPlanConvert_7_5_17();
                    if (PrefC.GetBoolSilent(PrefName.InsurancePlansShared, true))
                    {
                        form.InsPlanConverstion_7_5_17_AutoMergeYN = YN.Yes;
                    }
                    else
                    {
                        form.InsPlanConverstion_7_5_17_AutoMergeYN = YN.No;
                    }
                    form.ShowDialog();
                    if (form.DialogResult == DialogResult.Cancel)
                    {
                        MessageBox.Show("Your database has not been altered.");
                        return(false);
                    }
                    InsPlanConverstion_7_5_17_AutoMergeYN = form.InsPlanConverstion_7_5_17_AutoMergeYN;
                }
                ConvertDatabases.Set_7_5_17_AutoMerge(InsPlanConverstion_7_5_17_AutoMergeYN);                        //does nothing if this pref is already present for some reason.
                Cursor.Current = Cursors.WaitCursor;
            }
            if (!isSilent && FromVersion > new Version("16.3.0") && FromVersion < new Version("16.3.29") && ApptReminderRules.UsesApptReminders())
            {
                //16.3.29 is more strict about reminder rule setup. Prompt the user and allow them to exit the update if desired.
                //Get all currently enabled reminder rules.
                List <bool> listReminderFlags = ApptReminderRules.Get_16_3_29_ConversionFlags();
                if (listReminderFlags?[0] ?? false)                        //2 reminders scheduled for same day of appointment. 1 will be converted to future day reminder.
                {
                    MsgBox.Show(this, "You have multiple appointment reminders set to send on the same day of the appointment. One of these will be converted to send 1 day prior to the appointment.  Please review automated reminder rule setup after update has finished.");
                }
                if (listReminderFlags?[1] ?? false)                        //2 reminders scheduled for future day of appointment. 1 will be converted to same day reminder.
                {
                    MsgBox.Show(this, "You have multiple appointment reminders set to send 1 or more days prior to the day of the appointment. One of these will be converted to send 1 hour prior to the appointment.  Please review automated reminder rule setup after update has finished.");
                }
            }
            if (FromVersion >= new Version("17.3.1") && FromVersion < new Version("17.3.23") && DataConnection.DBtype == DatabaseType.MySql &&
                (Tasks.HasAnyLongDescripts() || TaskNotes.HasAnyLongNotes() || Commlogs.HasAnyLongNotes()))
            {
                if (isSilent)
                {
                    FormOpenDental.ExitCode = 138;                          //Update must be done manually in order to get data loss notification(s).
                    Application.Exit();
                    return(false);
                }
                if (!MsgBox.Show(this, true, "Data will be lost during this update."
                                 + "\r\nContact support in order to retrieve the data from a backup after the update."
                                 + "\r\n\r\nContinue?"))
                {
                    MessageBox.Show("Your database has not been altered.");
                    return(false);
                }
            }
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, true);
            }
            ConvertDatabases.FromVersion = FromVersion;
#if !DEBUG
            //Typically the UpdateInProgressOnComputerName preference will have already been set within FormUpdate.
            //However, the user could have cancelled out of FormUpdate after successfully downloading the Setup.exe
            //OR the Setup.exe could have been manually sent to our customer (during troubleshooting with HQ).
            //For those scenarios, the preference will be empty at this point and we need to let other computers know that an update going to start.
            //Updating the string (again) here will guarantee that all computers know an update is in fact in progress from this machine.
            Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName, Environment.MachineName);
#endif
            //Show a progress window that will indecate to the user that there is an active update in progress. Currently okay to show during isSilent.
            ODProgress.ShowAction(() => ConvertDatabases.InvokeConvertMethods(),
                                  hasMinimize: false,
                                  odEventType: ODEventType.ConvertDatabases);
            Cursor.Current = Cursors.Default;
            if (FromVersion >= new Version("3.4.0"))
            {
                //CacheL.Refresh(InvalidType.Prefs);//or it won't know it has to update in the next line.
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false, true);                      //more forceful refresh in order to properly change flag
            }
            Cache.Refresh(InvalidType.Prefs);
            if (!isSilent)
            {
                MsgBox.Show(this, "Database update successful");
            }
            return(true);

#if !DEBUG
        }

        catch (System.IO.FileNotFoundException e) {
            FormOpenDental.ExitCode = 160;                  //File not found exception
            if (!isSilent)
            {
                MessageBox.Show(e.FileName + " " + Lan.g(this, "could not be found. Your database has not been altered and is still usable if you uninstall this version, then reinstall the previous version."));
            }
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false);
            }
            return(false);
        }
        catch (System.IO.DirectoryNotFoundException) {
            FormOpenDental.ExitCode = 160;                  //ConversionFiles folder could not be found
            if (!isSilent)
            {
                MessageBox.Show(Lan.g(this, "ConversionFiles folder could not be found. Your database has not been altered and is still usable if you uninstall this version, then reinstall the previous version."));
            }
            if (FromVersion >= new Version("3.4.0"))
            {
                Prefs.UpdateBool(PrefName.CorruptedDatabase, false);
            }
            return(false);
        }
        catch (Exception ex) {
            FormOpenDental.ExitCode = 201;                  //Database was corrupted due to an update failure
            if (!isSilent)
            {
                MessageBox.Show(ex.Message + "\r\n\r\n"
                                + Lan.g(this, "Conversion unsuccessful. Your database is now corrupted and you cannot use it.  Please contact us."));
            }
            //Then, application will exit, and database will remain tagged as corrupted.
            return(false);
        }
#endif
        }
        private void butOK_Click(object sender, System.EventArgs e)
        {
            string compName = SystemInformation.ComputerName;

            if (checkSimple.Checked && !PrefB.GetBool("EasyHidePrinters"))
            {
                //if user clicked the simple option
                if (!MsgBox.Show(this, true, "Warning! You have selected the easy view option.  This will clear all printing preferences for all computers.  Are you sure you wish to continue?"))
                {
                    return;
                }
                Printers.ClearAll();
                Printers.Refresh();
                string printerName = "";
                if (comboDefault.SelectedIndex == 0)
                {
                    printerName = "";
                }
                else
                {
                    printerName = PrinterSettings.InstalledPrinters[comboDefault.SelectedIndex - 1];
                }
                Printers.PutForSit(PrintSituation.Default, compName, printerName, true);
            }
            else
            {
                for (int i = 0; i < Enum.GetValues(typeof(PrintSituation)).Length; i++)
                {
                    //loop through each printSituation
                    string printerName = "";
                    bool   isChecked   = false;
                    //PrintSituation sit=PrintSituation.Default;
                    //first: main Default, since not in panel Simple
                    if (i == 0)          //printSituation.Default
                    {
                        if (comboDefault.SelectedIndex == 0)
                        {
                            printerName = "";
                        }
                        else
                        {
                            printerName = PrinterSettings.InstalledPrinters[comboDefault.SelectedIndex - 1];
                        }
                    }
                    foreach (Control control in panelSimple.Controls)
                    {
                        if (control.GetType() != typeof(ComboBox) &&          //skip anything but comboBoxes and CheckBoxes
                            control.GetType() != typeof(CheckBox))
                        {
                            continue;
                        }
                        //so only two controls out of all will be used in each Enum loop
                        if (GetSit(control) != (PrintSituation)i)
                        {
                            continue;
                        }
                        if (control.GetType() == typeof(ComboBox))
                        {
                            if (((ComboBox)control).SelectedIndex == 0)
                            {
                                printerName = "";
                            }
                            else
                            {
                                printerName = PrinterSettings.InstalledPrinters[((ComboBox)control).SelectedIndex - 1];
                            }
                        }
                        else                 //checkBox
                        {
                            isChecked = ((CheckBox)control).Checked;
                        }
                    }
                    Printers.PutForSit((PrintSituation)i, compName, printerName, isChecked);
                }
            }
            DataValid.SetInvalid(InvalidTypes.Computers);
            if (checkSimple.Checked != PrefB.GetBool("EasyHidePrinters"))
            {
                Prefs.UpdateBool("EasyHidePrinters", checkSimple.Checked);
                DataValid.SetInvalid(InvalidTypes.Prefs);
            }
            DialogResult = DialogResult.OK;
        }
 private void FormRpProcNotBilledIns_FormClosing(object sender, FormClosingEventArgs e)
 {
     Prefs.UpdateBool(PrefName.ClaimProcsNotBilledToInsAutoGroup, checkAutoGroupProcs.Checked);
 }
Esempio n. 11
0
        private void FillGrid()
        {
            //if(textSearch.Text.Length<3){
            //	MsgBox.Show(this,"Please enter a search term with at least three letters in it.");
            //	return;
            //}
            Cursor = Cursors.WaitCursor;
            //Yes, this would be slicker if it were asynchronous, but no time right now.
            //prepare the xml document to send--------------------------------------------------------------------------------------
            XmlWriterSettings settings = new XmlWriterSettings();

            settings.Indent      = true;
            settings.IndentChars = ("    ");
            StringBuilder strbuild = new StringBuilder();

            using (XmlWriter writer = XmlWriter.Create(strbuild, settings)){
                writer.WriteStartElement("FeatureRequestGetList");
                writer.WriteStartElement("RegistrationKey");
                writer.WriteString(PrefC.GetString(PrefName.RegistrationKey));
                writer.WriteEndElement();
                writer.WriteStartElement("SearchString");
                writer.WriteString(textSearch.Text);
                writer.WriteEndElement();
                writer.WriteEndElement();
            }
                        #if DEBUG
            OpenDental.localhost.Service1 updateService = new OpenDental.localhost.Service1();
                        #else
            OpenDental.customerUpdates.Service1 updateService = new OpenDental.customerUpdates.Service1();
            updateService.Url = PrefC.GetString(PrefName.UpdateServerAddress);
                        #endif
            //Send the message and get the result-------------------------------------------------------------------------------------
            string result = "";
            try {
                result = updateService.FeatureRequestGetList(strbuild.ToString());
            }
            catch (Exception ex) {
                Cursor = Cursors.Default;
                MessageBox.Show("Error: " + ex.Message);
                return;
            }
            //textConnectionMessage.Text=Lan.g(this,"Connection successful.");
            //Application.DoEvents();
            Cursor = Cursors.Default;
            //MessageBox.Show(result);
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(result);
            //Process errors------------------------------------------------------------------------------------------------------------
            XmlNode node = doc.SelectSingleNode("//Error");
            if (node != null)
            {
                //textConnectionMessage.Text=node.InnerText;
                MessageBox.Show(node.InnerText, "Error");
                return;
            }
            node = doc.SelectSingleNode("//KeyDisabled");
            if (node == null)
            {
                //no error, and no disabled message
                if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, false))                //this is one of two places in the program where this happens.
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
            }
            else
            {
                //textConnectionMessage.Text=node.InnerText;
                MessageBox.Show(node.InnerText);
                if (Prefs.UpdateBool(PrefName.RegistrationKeyIsDisabled, true))                //this is one of two places in the program where this happens.
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
                return;
            }
            //Admin mode----------------------------------------------------------------------------------------------------------------
            node = doc.SelectSingleNode("//IsAdminMode");
            if (node.InnerText == "true")
            {
                isAdminMode = true;
            }
            else
            {
                isAdminMode = false;
            }
            //Process a valid return value------------------------------------------------------------------------------------------------
            node  = doc.SelectSingleNode("//ResultTable");
            table = new ODDataTable(node.InnerXml);
            table.Rows.Sort(FeatureRequestSort);            //Sort user submited/voted features to the top.
            //FillGrid used to start here------------------------------------------------
            long selectedRequestId = 0;
            int  selectedIndex     = gridMain.GetSelectedIndex();
            if (selectedIndex != -1)
            {
                if (table.Rows.Count > selectedIndex)
                {
                    selectedRequestId = PIn.Long(table.Rows[gridMain.GetSelectedIndex()]["RequestId"]);
                }
            }
            gridMain.BeginUpdate();
            gridMain.Columns.Clear();
            ODGridColumn col = new ODGridColumn(Lan.g("TableRequest", "Req#"), 40, GridSortingStrategy.AmountParse);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRequest", "Mine"), 40, GridSortingStrategy.StringCompare);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRequest", "My Votes"), 60, GridSortingStrategy.StringCompare);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRequest", "Total Votes"), 70, GridSortingStrategy.StringCompare);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRequest", "Diff"), 40, GridSortingStrategy.AmountParse);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRequest", "Weight"), 45, GridSortingStrategy.AmountParse);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRequest", "Approval"), 90, GridSortingStrategy.StringCompare);
            gridMain.Columns.Add(col);
            col = new ODGridColumn(Lan.g("TableRequest", "Description"), 500, GridSortingStrategy.StringCompare);
            gridMain.Columns.Add(col);
            gridMain.Rows.Clear();
            ODGridRow row;
            for (int i = 0; i < table.Rows.Count; i++)
            {
                row = new ODGridRow();
                row.Cells.Add(table.Rows[i]["RequestId"]);
                row.Cells.Add(table.Rows[i]["isMine"]);
                row.Cells.Add(table.Rows[i]["myVotes"]);
                row.Cells.Add(table.Rows[i]["totalVotes"]);
                row.Cells.Add(table.Rows[i]["Difficulty"]);
                row.Cells.Add(table.Rows[i]["Weight"]);
                row.Cells.Add(table.Rows[i]["approval"]);
                row.Cells.Add(table.Rows[i]["Description"]);
                //If they voted or pledged on this feature, mark it so they can see. Can be re-added when/if they need to be more visible.
                if (table.Rows[i]["isMine"].ToString() != "" &&
                    table.Rows[i]["personalVotes"].ToString() == "0" &&
                    table.Rows[i]["personalCrit"].ToString() == "0" &&
                    table.Rows[i]["personalPledged"].ToString() == "0" &&
                    table.Rows[i]["approval"].ToString() != "Complete")
                {
                    row.ColorBackG = Color.FromArgb(255, 255, 230);                //light yellow.
                }
                gridMain.Rows.Add(row);
                row.Tag = table.Rows[i];
            }
            gridMain.EndUpdate();
            for (int i = 0; i < table.Rows.Count; i++)
            {
                if (selectedRequestId.ToString() == table.Rows[i]["RequestId"])
                {
                    gridMain.SetSelected(i, true);
                }
            }
        }