예제 #1
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();
        }
예제 #2
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (textDescription.Text == "")
            {
                MsgBox.Show(this, "Description cannot be blank.");
                return;
            }
            for (int i = 0; i < textPattern.Text.Length; i++)
            {
                if (textPattern.Text[i] != '/' && textPattern.Text[i] != 'X')
                {
                    MsgBox.Show(this, "Time Pattern may only contain '/' and 'X'.  Please fix to continue.");
                    return;
                }
            }
            if (textYears.errorProvider1.GetError(textYears) != "" ||
                textMonths.errorProvider1.GetError(textMonths) != "" ||
                textWeeks.errorProvider1.GetError(textWeeks) != "" ||
                textDays.errorProvider1.GetError(textDays) != ""
                )
            {
                MsgBox.Show(this, "Please fix data entry errors first.");
                return;
            }
            //if(RecallTypes.List comboSpecial.SelectedIndex

            /*
             * if(listTriggers.Items.Count==0 && comboSpecial.SelectedIndex!=2) {//except child prophy
             *      if(!MsgBox.Show(this,true,"Warning! clearing all triggers for a recall type will cause all patient recalls of that type to be deleted, even those with notes.  Continue anyway?")){
             *              return;
             *      }
             * }*/
            bool changed = false;

            if (comboSpecial.SelectedIndex == 2)          //childProphy
            {
                if (textRecallAgeAdult.errorProvider1.GetError(textRecallAgeAdult) != "")
                {
                    MsgBox.Show(this, "Please fix data entry errors first.");
                    return;
                }
                if (Prefs.UpdateInt(PrefName.RecallAgeAdult, PIn.Int(textRecallAgeAdult.Text)))
                {
                    changed = true;
                }
                TriggerList.Clear(); //triggers for child prophy special type are handled by the prophy special type
            }
            else                     //for child prophy, interval will default to 0, since this special type uses the Prophy default interval
            {
                Interval interval = new Interval(
                    PIn.Int(textDays.Text),
                    PIn.Int(textWeeks.Text),
                    PIn.Int(textMonths.Text),
                    PIn.Int(textYears.Text));
                RecallTypeCur.DefaultInterval = interval;
            }
            RecallTypeCur.Description     = textDescription.Text;
            RecallTypeCur.TimePattern     = textPattern.Text;
            RecallTypeCur.AppendToSpecial = checkAppendToSpecial.Checked;
            if (listProcs.Items.Count == 0)
            {
                RecallTypeCur.Procedures = "";
            }
            //otherwise, already taken care of.
            try{
                if (RecallTypeCur.IsNew)
                {
                    RecallTypes.Insert(RecallTypeCur);
                    SecurityLogs.MakeLogEntry(Permissions.RecallEdit, 0, "Recall type added '" + RecallTypeCur.Description + "'");
                }
                else
                {
                    SecurityLogs.MakeLogEntry(Permissions.RecallEdit, 0, "Recall type having description '" + RecallTypeCur.Description + "' edited");
                    RecallTypes.Update(RecallTypeCur);
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return;
            }
            RecallTriggers.SetForType(RecallTypeCur.RecallTypeNum, TriggerList);
            //The combo for special type is allowed to be changed by user.  But since the field is in the pref table instead of in the RecallType table, there's extra work involved in saving the selection.
            if (comboSpecial.SelectedIndex == 0)                                                    //none:  If this recall type is now not any special type
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum) //and it used to be the special prophy type
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 1)                                                //Prophy: If this recall type is now the prophy type.
            {
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, RecallTypeCur.RecallTypeNum)) //and it was already the prophy type
                {
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)              //but it used to be the childprophy type.
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 2)          //ChildProphy
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, RecallTypeCur.RecallTypeNum))
                {
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialPerio) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, 0);
                    changed = true;
                }
            }
            else if (comboSpecial.SelectedIndex == 3)          //Perio
            {
                if (PrefC.GetLong(PrefName.RecallTypeSpecialProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialProphy, 0);
                    changed = true;
                }
                if (PrefC.GetLong(PrefName.RecallTypeSpecialChildProphy) == RecallTypeCur.RecallTypeNum)
                {
                    Prefs.UpdateLong(PrefName.RecallTypeSpecialChildProphy, 0);
                    changed = true;
                }
                if (Prefs.UpdateLong(PrefName.RecallTypeSpecialPerio, RecallTypeCur.RecallTypeNum))
                {
                    changed = true;
                }
            }
            DataValid.SetInvalid(InvalidType.RecallTypes);
            if (changed)
            {
                DataValid.SetInvalid(InvalidType.Prefs);
            }
            //Ask user to update recalls for patients if they changed the DefaultInterval.
            if (!RecallTypeCur.IsNew && defaultIntervalOld != RecallTypeCur.DefaultInterval)
            {
                if (MsgBox.Show(this, MsgBoxButtons.YesNo, "Default interval has been changed.  "
                                + "Please note that this change will not affect patients with intervals that were set manually.\r\n"
                                + "Reset all other current patient intervals of this type?"))
                {
                    Recalls.UpdateDefaultIntervalForPatients(RecallTypeCur.RecallTypeNum, defaultIntervalOld, RecallTypeCur.DefaultInterval);
                }
            }
            DialogResult = DialogResult.OK;
        }
예제 #3
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textDescript.Text == "")
            {
                //I guess we don't need to force descript to have a value
            }
            if (textServerId.errorProvider1.GetError(textServerId) != "")
            {
                MsgBox.Show(this, "Please fix server_id.");
                return;
            }
            int serverid = PIn.Int(textServerId.Text);

            if (serverid == 0)
            {
                MsgBox.Show(this, "Please enter a server_id number greater than zero.");
                return;
            }
            long rangeStart = 0;

            if (textRangeStart.Text != "")
            {
                try {
                    rangeStart = long.Parse(textRangeStart.Text);
                }
                catch {
                    MsgBox.Show(this, "Please fix range start.");
                    return;
                }
            }
            long rangeEnd = 0;

            if (textRangeEnd.Text != "")
            {
                try {
                    rangeEnd = long.Parse(textRangeEnd.Text);
                }
                catch {
                    MsgBox.Show(this, "Please fix range end.");
                    return;
                }
            }
            if ((textRangeStart.Text != "" || textRangeEnd.Text != "") && rangeEnd - rangeStart < 999999)
            {
                MsgBox.Show(this, "The end of the range must be at least 999,999 greater than the start of the range.");
                return;
            }
            //Disallow a range that ends after 9 quintillion.  This is because the max value of a long is 9,223,372,036,854,775,807
            //and we want to leave room for the convert script, which doesn't implement our random primary key logic.
            //It will instead use the auto-increment number for the table.
            //If the table had a primary key of 9,223,372,036,854,775,807, the auto-increment would be out of bounds and give an error.
            //So now the largest random primary key value for any table will be 9 quintillion, which leaves the convert script 200 quadrillion entries
            //before going out of bounds.
            if (rangeEnd > 9000000000000000000)
            {
                MsgBox.Show(this, "The end of the range must be less than or equal to nine quintillion.");
                return;
            }
            RepServ.Descript      = textDescript.Text;
            RepServ.ServerId      = serverid;     //will be valid and greater than 0.
            RepServ.RangeStart    = rangeStart;
            RepServ.RangeEnd      = rangeEnd;
            RepServ.AtoZpath      = textAtoZpath.Text;
            RepServ.UpdateBlocked = checkUpdateBlocked.Checked;
            RepServ.SlaveMonitor  = textSlaveMonitor.Text;
            if (RepServ.IsNew)
            {
                ReplicationServers.Insert(RepServ);
            }
            else
            {
                ReplicationServers.Update(RepServ);
            }
            //Update the ReplicationUserQueryServer preference as needed.
            if (checkReportServer.Checked)
            {
                if (Prefs.UpdateLong(PrefName.ReplicationUserQueryServer, RepServ.ReplicationServerNum))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
            }
            else if (RepServ.ReplicationServerNum == PrefC.GetLong(PrefName.ReplicationUserQueryServer))           //If this replication server was the original report server, set the current server to 0.
            {
                if (Prefs.UpdateLong(PrefName.ReplicationUserQueryServer, 0))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
            }
            DialogResult = DialogResult.OK;
        }
예제 #4
0
 private void butOverride_Click(object sender, EventArgs e)
 {
     Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName, "");
     MsgBox.Show(this, "You will be allowed access when you restart.");
     DialogResult = DialogResult.Cancel;
 }
예제 #5
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (Defs.IsHidable(DefCur.Category) && checkHidden.Checked)
            {
                if (Defs.IsDefinitionInUse(DefCur))
                {
                    if (DefCur.DefNum == PrefC.GetLong(PrefName.BrokenAppointmentAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeArrivedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeSeatedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.AppointmentTimeDismissedTrigger) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.TreatPlanDiscountAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.BillingChargeAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.FinanceChargeAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.PrepaymentUnearnedType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.SalesTaxAdjustmentType) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.RecurringChargesPayTypeCC) ||
                        DefCur.DefNum == PrefC.GetLong(PrefName.TpUnearnedType))
                    {
                        MsgBox.Show(this, "You cannot hide a definition if it is in use within Module Preferences.");
                        return;
                    }
                    else if (DefCur.DefNum.In(
                                 PrefC.GetLong(PrefName.RecallStatusMailed),
                                 PrefC.GetLong(PrefName.RecallStatusTexted),
                                 PrefC.GetLong(PrefName.RecallStatusEmailed),
                                 PrefC.GetLong(PrefName.RecallStatusEmailedTexted)))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as a status in the Setup Recall window.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.WebSchedNewPatConfirmStatus))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as an appointment confirmation status in Web Sched New Pat Appt.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.WebSchedRecallConfirmStatus))
                    {
                        MsgBox.Show(this, "You cannot hide a definition that is used as an appointment confirmation status in Web Sched Recall Appt.");
                        return;
                    }
                    else if (DefCur.DefNum == PrefC.GetLong(PrefName.PracticeDefaultBillType))
                    {
                        MsgBox.Show(this, "You cannot hide a billing type when it is selected as the practice default billing type.");
                        return;
                    }
                    else
                    {
                        if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: This definition is currently in use within the program."))
                        {
                            return;
                        }
                    }
                }
                //Stop users from hiding the last definition in categories that must have at least one def in them.
                if (!_defsList.Any(x => x.DefNum != DefCur.DefNum && !x.IsHidden))
                {
                    MsgBox.Show(this, "You cannot hide the last definition in this category.");
                    return;
                }
            }
            if (textName.Text == "")
            {
                MsgBox.Show(this, "Name required.");
                return;
            }
            switch (DefCur.Category)
            {
            case DefCat.AccountQuickCharge:
            case DefCat.ApptProcsQuickAdd:
                string[]      procCodes     = textValue.Text.Split(',');
                List <string> listProcCodes = new List <string>();
                for (int i = 0; i < procCodes.Length; i++)
                {
                    ProcedureCode procCode = ProcedureCodes.GetProcCode(procCodes[i]);
                    if (procCode.CodeNum == 0)
                    {
                        //Now check to see if the trimmed version of the code does not exist either.
                        procCode = ProcedureCodes.GetProcCode(procCodes[i].Trim());
                        if (procCode.CodeNum == 0)
                        {
                            MessageBox.Show(Lan.g(this, "Invalid procedure code entered") + ": " + procCodes[i]);
                            return;
                        }
                    }
                    listProcCodes.Add(procCode.ProcCode);
                }
                textValue.Text = String.Join(",", listProcCodes);
                break;

            case DefCat.AdjTypes:
                if (textValue.Text != "+" && textValue.Text != "-" && textValue.Text != "dp")
                {
                    MessageBox.Show(Lan.g(this, "Valid values are +, -, or dp."));
                    return;
                }
                break;

            case DefCat.BillingTypes:
                if (!textValue.Text.ToLower().In("", "e", "c", "ce"))
                {
                    MsgBox.Show(this, "Valid values are blank, E, C, or CE.");
                    return;
                }
                if (checkHidden.Checked && Patients.IsBillingTypeInUse(DefCur.DefNum))
                {
                    if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Warning: Billing type is currently in use by patients, insurance plans, or preferences."))
                    {
                        return;
                    }
                }
                break;

            case DefCat.ClaimCustomTracking:
                int value = 0;
                if (!Int32.TryParse(textValue.Text, out value) || value < 0)
                {
                    MsgBox.Show(this, "Days Suppressed must be a valid non-negative number.");
                    return;
                }
                break;

            case DefCat.CommLogTypes:
                List <string> listCommItemTypes = Commlogs.GetCommItemTypes().Select(x => x.GetDescription(useShortVersionIfAvailable: true)).ToList();
                if (textValue.Text != "" && !listCommItemTypes.Any(x => x == textValue.Text))
                {
                    MessageBox.Show(Lan.g(this, "Valid values are:") + " " + string.Join(", ", listCommItemTypes));
                    return;
                }
                break;

            case DefCat.DiscountTypes:
                int discVal;
                if (textValue.Text == "")
                {
                    break;
                }
                try {
                    discVal = System.Convert.ToInt32(textValue.Text);
                }
                catch {
                    MessageBox.Show(Lan.g(this, "Not a valid number"));
                    return;
                }
                if (discVal < 0 || discVal > 100)
                {
                    MessageBox.Show(Lan.g(this, "Valid values are between 0 and 100"));
                    return;
                }
                textValue.Text = discVal.ToString();
                break;

            /*case DefCat.FeeSchedNames:
             *      if(textValue.Text=="C" || textValue.Text=="c") {
             *              textValue.Text="C";
             *      }
             *      else if(textValue.Text=="A" || textValue.Text=="a") {
             *              textValue.Text="A";
             *      }
             *      else textValue.Text="";
             *      break;*/
            case DefCat.ImageCats:
                textValue.Text = textValue.Text.ToUpper().Replace(",", "");
                if (!Regex.IsMatch(textValue.Text, @"^[XPS]*$"))
                {
                    textValue.Text = "";
                }
                break;

            case DefCat.InsurancePaymentType:
                if (textValue.Text != "" && textValue.Text != "N")
                {
                    MsgBox.Show(this, "Valid values are blank or N.");
                    return;
                }
                break;

            case DefCat.OperatoriesOld:
                if (textValue.Text.Length > 5)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 5."));
                    return;
                }
                break;

            case DefCat.PaySplitUnearnedType:
                if (!textValue.Text.ToLower().In("", "x"))
                {
                    MsgBox.Show(this, "Valid values are blank or 'X'");
                    return;
                }
                List <Def> listDefsForUnearnedType = _defsList.FindAll(x => x.Category == DefCat.PaySplitUnearnedType);
                if (listDefsForUnearnedType.FindAll(x => string.IsNullOrEmpty(x.ItemValue)).Count == 1 && DefCur.ItemValue == "" &&
                    (textValue.Text != "" || checkHidden.Checked))
                {
                    MsgBox.Show(this, "Must have at least one definition that shows in Account.");
                    return;
                }
                else if (listDefsForUnearnedType.FindAll(x => !string.IsNullOrEmpty(x.ItemValue)).Count == 1 && DefCur.ItemValue != "" &&
                         (textValue.Text == "" || checkHidden.Checked))
                {
                    MsgBox.Show(this, "Must have at least one definition that does not show in Account.");
                    return;
                }
                break;

            case DefCat.ProcCodeCats:
                if (checkHidden.Checked)
                {
                    if (IsDefCurLastShowing())
                    {
                        MsgBox.Show(this, "At least one procedure code category must be enabled.");
                        return;
                    }
                }
                break;

            case DefCat.ProviderSpecialties:
                if (checkHidden.Checked &&
                    (Providers.IsSpecialtyInUse(DefCur.DefNum) ||
                     Referrals.IsSpecialtyInUse(DefCur.DefNum)))
                {
                    MsgBox.Show(this, "You cannot hide a specialty if it is in use by a provider or a referral source.");
                    checkHidden.Checked = false;
                    return;
                }
                break;

            case DefCat.RecallUnschedStatus:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length is 7."));
                    return;
                }
                break;

            case DefCat.TaskPriorities:
                if (checkHidden.Checked)
                {
                    if (IsDefCurLastShowing())
                    {
                        MsgBox.Show(this, "You cannot hide the last priority.");
                        return;
                    }
                }
                break;

            case DefCat.TxPriorities:
                if (textValue.Text.Length > 7)
                {
                    MessageBox.Show(Lan.g(this, "Maximum length of abbreviation is 7."));
                    return;
                }
                break;

            default:
                break;
            }            //end switch DefCur.Category
            DefCur.ItemName  = textName.Text;
            DefCur.ItemValue = _selectedValueString;
            if (_defCatOptions.EnableValue && !_defCatOptions.IsValueDefNum)
            {
                DefCur.ItemValue = textValue.Text;
            }
            if (_defCatOptions.EnableColor)
            {
                //If checkNoColor is checked, insert empty into the database. Otherwise, use the color they picked.
                DefCur.ItemColor = (checkNoColor.Checked ? Color.Empty : butColor.BackColor);
            }
            DefCur.IsHidden = checkHidden.Checked;
            if (IsNew)
            {
                Defs.Insert(DefCur);
            }
            else
            {
                Defs.Update(DefCur);
            }
            //Must be after the upsert so that we have access to the DefNum for new Defs.
            if (DefCur.Category == DefCat.ApptConfirmed)
            {
                //==================== EXCLUDE SEND ====================
                if (checkExcludeSend.Checked)
                {
                    _listExcludeSendNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeSendNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string sendString = string.Join(",", _listExcludeSendNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeESend, sendString);
                //==================== EXCLUDE CONFIRM ====================
                if (checkExcludeConfirm.Checked)
                {
                    _listExcludeConfirmNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeConfirmNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string confirmString = string.Join(",", _listExcludeConfirmNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeEConfirm, confirmString);
                //==================== EXCLUDE REMIND ====================
                if (checkExcludeRemind.Checked)
                {
                    _listExcludeRemindNums.Add(DefCur.DefNum);
                }
                else
                {
                    _listExcludeRemindNums.RemoveAll(x => x == DefCur.DefNum);
                }
                string remindString = string.Join(",", _listExcludeRemindNums.Distinct().OrderBy(x => x));
                Prefs.UpdateString(PrefName.ApptConfirmExcludeERemind, remindString);
                Signalods.SetInvalid(InvalidType.Prefs);
            }
            DialogResult = DialogResult.OK;
        }
예제 #6
0
        private void butSend_Click(object sender, EventArgs e)
        {
            //Assuming the use of XCharge.  If adding another vendor (PayConnect for example)
            //make sure to move XCharge validation in FillGrid() to here.
            if (prog == null)           //Gets filled in FillGrid()
            {
                return;
            }
            if (gridMain.SelectedIndices.Length < 1)
            {
                MsgBox.Show(this, "Must select at least one recurring charge.");
                return;
            }
            if (!Security.IsAuthorized(Permissions.PaymentCreate, nowDateTime.Date))
            {
                return;
            }
            string recurringResultFile = "Recurring charge results for " + DateTime.Now.ToShortDateString() + " ran at " + DateTime.Now.ToShortTimeString() + "\r\n\r\n";
            int    failed   = 0;
            int    success  = 0;
            string user     = ProgramProperties.GetPropVal(prog.ProgramNum, "Username");
            string password = ProgramProperties.GetPropVal(prog.ProgramNum, "Password");

            #region Card Charge Loop
            for (int i = 0; i < gridMain.SelectedIndices.Length; i++)
            {
                insertPayment = false;
                ProcessStartInfo info       = new ProcessStartInfo(prog.Path);
                long             patNum     = PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PatNum"].ToString());
                string           resultfile = Path.Combine(Path.GetDirectoryName(prog.Path), "XResult.txt");
                File.Delete(resultfile);                //delete the old result file.
                info.Arguments = "";
                double   amt = PIn.Double(table.Rows[gridMain.SelectedIndices[i]]["ChargeAmt"].ToString());
                DateTime exp = PIn.Date(table.Rows[gridMain.SelectedIndices[i]]["CCExpiration"].ToString());
                info.Arguments += "/AMOUNT:" + amt.ToString("F2") + " /LOCKAMOUNT ";
                info.Arguments += "/TRANSACTIONTYPE:PURCHASE /LOCKTRANTYPE ";
                if (table.Rows[gridMain.SelectedIndices[i]]["XChargeToken"].ToString() != "")
                {
                    info.Arguments += "/XCACCOUNTID:" + table.Rows[gridMain.SelectedIndices[i]]["XChargeToken"].ToString() + " ";
                }
                else
                {
                    info.Arguments += "/ACCOUNT:" + table.Rows[gridMain.SelectedIndices[i]]["CCNumberMasked"].ToString() + " ";
                    info.Arguments += "/EXP:" + exp.ToString("MMyy") + " ";
                    info.Arguments += "\"/ADDRESS:" + table.Rows[gridMain.SelectedIndices[i]]["Address"].ToString() + "\" ";
                    info.Arguments += "\"/ZIP:" + table.Rows[gridMain.SelectedIndices[i]]["Zip"].ToString() + "\" ";
                }
                info.Arguments += "/RECEIPT:Pat" + patNum + " ";          //aka invoice#
                info.Arguments += "\"/CLERK:" + Security.CurUser.UserName + "\" /LOCKCLERK ";
                info.Arguments += "/RESULTFILE:\"" + resultfile + "\" ";
                info.Arguments += "/USERID:" + user + " ";
                info.Arguments += "/PASSWORD:"******" ";
                info.Arguments += "/HIDEMAINWINDOW ";
                info.Arguments += "/AUTOPROCESS ";
                info.Arguments += "/SMALLWINDOW ";
                info.Arguments += "/AUTOCLOSE ";
                info.Arguments += "/NORESULTDIALOG ";
                Cursor          = Cursors.WaitCursor;
                Process process = new Process();
                process.StartInfo           = info;
                process.EnableRaisingEvents = true;
                process.Start();
                while (!process.HasExited)
                {
                    Application.DoEvents();
                }
                Thread.Sleep(200);                //Wait 2/10 second to give time for file to be created.
                Cursor = Cursors.Default;
                string line       = "";
                string resultText = "";
                recurringResultFile += "PatNum: " + patNum + " Name: " + table.Rows[i]["PatName"].ToString() + "\r\n";
                using (TextReader reader = new StreamReader(resultfile)) {
                    line = reader.ReadLine();
                    while (line != null)
                    {
                        if (resultText != "")
                        {
                            resultText += "\r\n";
                        }
                        resultText += line;
                        if (line.StartsWith("RESULT="))
                        {
                            if (line == "RESULT=SUCCESS")
                            {
                                success++;
                                labelCharged.Text = Lan.g(this, "Charged=") + success;
                                insertPayment     = true;
                            }
                            else
                            {
                                failed++;
                                labelFailed.Text = Lan.g(this, "Failed=") + failed;
                            }
                        }
                        line = reader.ReadLine();
                    }
                    recurringResultFile += resultText + "\r\n\r\n";
                }
                if (insertPayment)
                {
                    Patient patCur     = Patients.GetPat(patNum);
                    long    provider   = Patients.GetProvNum(patCur);
                    Payment paymentCur = new Payment();
                    paymentCur.DateEntry = nowDateTime.Date;
                    paymentCur.PayDate   = GetPayDate(PIn.Date(table.Rows[gridMain.SelectedIndices[i]]["LatestPayment"].ToString()),
                                                      PIn.Date(table.Rows[gridMain.SelectedIndices[i]]["DateStart"].ToString()));
                    paymentCur.PatNum        = patCur.PatNum;
                    paymentCur.ClinicNum     = patCur.ClinicNum;
                    paymentCur.PayType       = PIn.Int(ProgramProperties.GetPropVal(prog.ProgramNum, "PaymentType"));
                    paymentCur.PayAmt        = amt;
                    paymentCur.PayNote       = resultText;
                    paymentCur.IsRecurringCC = true;
                    Payments.Insert(paymentCur);
                    DataTable dt         = Patients.GetPaymentStartingBalances(patCur.Guarantor, paymentCur.PayNum);
                    double    highestAmt = 0;
                    for (int j = 0; j < dt.Rows.Count; j++)               //Apply the payment towards the provider that the family owes the most money to.
                    {
                        double afterIns = PIn.Double(dt.Rows[j]["AfterIns"].ToString());
                        if (highestAmt >= afterIns)
                        {
                            continue;
                        }
                        highestAmt = afterIns;
                        provider   = PIn.Long(dt.Rows[j]["ProvNum"].ToString());
                    }
                    PaySplit split = new PaySplit();
                    split.PatNum     = paymentCur.PatNum;
                    split.ClinicNum  = paymentCur.ClinicNum;
                    split.PayNum     = paymentCur.PayNum;
                    split.ProcDate   = paymentCur.PayDate;
                    split.DatePay    = paymentCur.PayDate;
                    split.ProvNum    = provider;
                    split.SplitAmt   = paymentCur.PayAmt;
                    split.PayPlanNum = PIn.Long(table.Rows[gridMain.SelectedIndices[i]]["PayPlanNum"].ToString());
                    PaySplits.Insert(split);
                    if (PrefC.GetBool(PrefName.AgingCalculatedMonthlyInsteadOfDaily))
                    {
                        Ledgers.ComputeAging(patCur.Guarantor, PrefC.GetDate(PrefName.DateLastAging), false);
                    }
                    else
                    {
                        Ledgers.ComputeAging(patCur.Guarantor, DateTime.Today, false);
                        if (PrefC.GetDate(PrefName.DateLastAging) != DateTime.Today)
                        {
                            Prefs.UpdateString(PrefName.DateLastAging, POut.Date(DateTime.Today, false));
                            //Since this is always called from UI, the above line works fine to keep the prefs cache current.
                        }
                    }
                }
            }
            #endregion
            try {
                File.WriteAllText(Path.Combine(Path.GetDirectoryName(prog.Path), "RecurringChargeResult.txt"), recurringResultFile);
            }
            catch { }             //Do nothing cause this is just for internal use.
            FillGrid();
            labelCharged.Text = Lan.g(this, "Charged=") + success;
            labelFailed.Text  = Lan.g(this, "Failed=") + failed;
            MsgBox.Show(this, "Done charging cards.\r\nIf there are any patients remaining in list, print the list and handle each one manually.");
        }
예제 #7
0
        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;
        }
예제 #8
0
        ///<summary>Called in two places.  Once from RefreshLocalData, and also from FormBackups after a restore.</summary>
        public static bool CheckProgramVersion()
        {
            Version storedVersion  = new Version(PrefB.GetString("ProgramVersion"));
            Version currentVersion = new Version(Application.ProductVersion);
            string  database       = "";
            string  command        = "";

            if (FormChooseDatabase.DBtype == DatabaseType.MySql)
            {
                command = "SELECT database()";
                DataTable table = General.GetTable(command);
                database = PIn.PString(table.Rows[0][0].ToString());
            }
            if (storedVersion < currentVersion)
            {
                UpdateString("ProgramVersion", currentVersion.ToString());
                Prefs.Refresh();
            }
            if (storedVersion > currentVersion)
            {
                if (PrefB.UsingAtoZfolder)
                {
                    string setupBinPath = ODFileUtils.CombinePaths(FormPath.GetPreferredImagePath(), "Setup.exe");
                    if (File.Exists(setupBinPath))
                    {
                        if (MessageBox.Show("You are attempting to run version " + currentVersion.ToString(3) + ",\r\n"
                                            + "But the database " + database + "\r\n"
                                            + "is already using version " + storedVersion.ToString(3) + ".\r\n"
                                            + "A newer version must have already been installed on at least one computer.\r\n"
                                            + "The setup program stored in your A to Z folder will now be launched.\r\n"
                                            + "Or, if you hit Cancel, then you will have the option to download again."
                                            , "", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                        {
                            if (MessageBox.Show("Download again?", "", MessageBoxButtons.OKCancel)
                                == DialogResult.OK)
                            {
                                FormUpdate FormU = new FormUpdate();
                                FormU.ShowDialog();
                            }
                            Application.Exit();
                            return(false);
                        }
                        try {
                            Process.Start(setupBinPath);
                        }
                        catch {
                            MessageBox.Show("Could not launch Setup.exe");
                        }
                    }
                    else if (MessageBox.Show("A newer version has been installed on at least one computer," +
                                             "but Setup.exe could not be found in any of the following paths: " +
                                             FormPath.GetPreferredImagePath() + ".  Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        FormUpdate FormU = new FormUpdate();
                        FormU.ShowDialog();
                    }
                }
                else                  //Not using image path.
                                      //perform program update automatically.
                {
                    string patchName        = "Setup.exe";
                    string updateUri        = PrefB.GetString("UpdateWebsitePath");
                    string registrationCode = PrefB.GetString("RegistrationNumber");
                    string updateInfoMajor  = "";
                    string updateInfoMinor  = "";
                    if (FormUpdate.ShouldDownloadUpdate(updateUri, registrationCode, out updateInfoMajor, out updateInfoMinor))
                    {
                        if (MessageBox.Show(updateInfoMajor + Lan.g("Prefs", "Perform program update now?"), "",
                                            MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            string tempFile = ODFileUtils.CombinePaths(Path.GetTempPath(), patchName);             //Resort to a more common temp file name.
                            FormUpdate.DownloadInstallPatchFromURI(updateUri + registrationCode + "/" + patchName, //Source URI
                                                                   tempFile);                                      //Local destination file.
                            File.Delete(tempFile);                                                                 //Cleanup install file.
                        }
                    }
                }
                Application.Exit();                //always exits, whether launch of setup worked or not
                return(false);
            }
            return(true);
        }
예제 #9
0
        private void gridMain_CellDoubleClick(object sender, ODGridClickEventArgs e)
        {
            PrefName prefName = (PrefName)gridMain.ListGridRows[e.Row].Tag;
            string   curPrefValue;

            if (_selectedClinicNum == 0)
            {
                curPrefValue = PrefC.GetString(prefName);
            }
            else
            {
                ClinicPref clinicPref = ClinicPrefs.GetPref(prefName, _selectedClinicNum);
                if (clinicPref == null || string.IsNullOrEmpty(clinicPref.ValueString))
                {
                    curPrefValue = PrefC.GetString(prefName);
                }
                else
                {
                    curPrefValue = clinicPref.ValueString;
                }
            }
            string newPrefValue;
            bool   isHtmlTemplate = prefName == PrefName.WebSchedAsapEmailTemplate;

            if (isHtmlTemplate)
            {
                FormEmailEdit formEmailEdit = new FormEmailEdit {
                    MarkupText           = curPrefValue,
                    DoCheckForDisclaimer = true,
                    IsRawAllowed         = false,
                };
                formEmailEdit.ShowDialog();
                if (formEmailEdit.DialogResult != DialogResult.OK)
                {
                    return;
                }
                newPrefValue = formEmailEdit.MarkupText;
            }
            else
            {
                FormRecallMessageEdit FormR = new FormRecallMessageEdit(prefName);
                FormR.MessageVal = curPrefValue;
                FormR.ShowDialog();
                if (FormR.DialogResult != DialogResult.OK)
                {
                    return;
                }
                newPrefValue = FormR.MessageVal;
            }
            if (_selectedClinicNum == 0)
            {
                if (Prefs.UpdateString(prefName, newPrefValue))
                {
                    DataValid.SetInvalid(InvalidType.Prefs);
                }
            }
            else
            {
                if (ClinicPrefs.Upsert(prefName, _selectedClinicNum, newPrefValue))
                {
                    DataValid.SetInvalid(InvalidType.ClinicPrefs);
                }
            }
            FillPrefs();
        }
예제 #10
0
 private void FormRpProcNotBilledIns_FormClosing(object sender, FormClosingEventArgs e)
 {
     Prefs.UpdateBool(PrefName.ClaimProcsNotBilledToInsAutoGroup, checkAutoGroupProcs.Checked);
 }
예제 #11
0
        ///<summary>Essentially no changes have been made to this since version 6.5.</summary>
        private static bool CheckProgramVersionClassic()
        {
            Version storedVersion  = new Version(PrefC.GetString(PrefName.ProgramVersion));
            Version currentVersion = new Version(Application.ProductVersion);
            string  database       = MiscData.GetCurrentDatabase();

            if (storedVersion < currentVersion)
            {
                Prefs.UpdateString(PrefName.ProgramVersion, currentVersion.ToString());
                Cache.Refresh(InvalidType.Prefs);
            }
            if (storedVersion > currentVersion)
            {
                if (PrefC.AtoZfolderUsed)
                {
                    string setupBinPath = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "Setup.exe");
                    if (File.Exists(setupBinPath))
                    {
                        if (MessageBox.Show("You are attempting to run version " + currentVersion.ToString(3) + ",\r\n"
                                            + "But the database " + database + "\r\n"
                                            + "is already using version " + storedVersion.ToString(3) + ".\r\n"
                                            + "A newer version must have already been installed on at least one computer.\r\n"
                                            + "The setup program stored in your A to Z folder will now be launched.\r\n"
                                            + "Or, if you hit Cancel, then you will have the option to download again."
                                            , "", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                        {
                            if (MessageBox.Show("Download again?", "", MessageBoxButtons.OKCancel)
                                == DialogResult.OK)
                            {
                                FormUpdate FormU = new FormUpdate();
                                FormU.ShowDialog();
                            }
                            Application.Exit();
                            return(false);
                        }
                        try {
                            Process.Start(setupBinPath);
                        }
                        catch {
                            MessageBox.Show("Could not launch Setup.exe");
                        }
                    }
                    else if (MessageBox.Show("A newer version has been installed on at least one computer," +
                                             "but Setup.exe could not be found in any of the following paths: " +
                                             ImageStore.GetPreferredAtoZpath() + ".  Download again?", "", MessageBoxButtons.OKCancel) == DialogResult.OK)
                    {
                        FormUpdate FormU = new FormUpdate();
                        FormU.ShowDialog();
                    }
                }
                else                  //Not using image path.
                                      //perform program update automatically.
                {
                    string patchName       = "Setup.exe";
                    string updateUri       = PrefC.GetString(PrefName.UpdateWebsitePath);
                    string updateCode      = PrefC.GetString(PrefName.UpdateCode);
                    string updateInfoMajor = "";
                    string updateInfoMinor = "";
                    if (FormUpdate.ShouldDownloadUpdate(updateUri, updateCode, out updateInfoMajor, out updateInfoMinor))
                    {
                        if (MessageBox.Show(updateInfoMajor + Lan.g("Prefs", "Perform program update now?"), "",
                                            MessageBoxButtons.YesNo) == DialogResult.Yes)
                        {
                            string tempFile = ODFileUtils.CombinePaths(Path.GetTempPath(), patchName);       //Resort to a more common temp file name.
                            FormUpdate.DownloadInstallPatchFromURI(updateUri + updateCode + "/" + patchName, //Source URI
                                                                   tempFile, true, true, null);              //Local destination file.
                            File.Delete(tempFile);                                                           //Cleanup install file.
                        }
                    }
                }
                Application.Exit();                //always exits, whether launch of setup worked or not
                return(false);
            }
            return(true);
        }
예제 #12
0
        ///<summary>This ONLY runs when first opening the program.  Gets run early in the sequence. Returns false if the program should exit.</summary>
        public static bool CheckMySqlVersion()
        {
            if (DataConnection.DBtype != DatabaseType.MySql)
            {
                return(true);
            }
            bool   hasBackup    = false;
            string thisVersion  = MiscData.GetMySqlVersion();
            float  floatVersion = PIn.Float(thisVersion.Substring(0, 3));

            if (floatVersion < 5.0f)
            {
                //We will force users to upgrade to 5.0, but not yet to 5.5
                MessageBox.Show(Lan.g("Prefs", "Your version of MySQL won't work with this program") + ": " + thisVersion
                                + ".  " + Lan.g("Prefs", "You should upgrade to MySQL 5.0 using the installer on our website."));
                Application.Exit();
                return(false);
            }
            if (!PrefC.ContainsKey("MySqlVersion"))             //db has not yet been updated to store this pref
            //We're going to skip this.  We will recommend that people first upgrade OD, then MySQL, so this won't be an issue.
            {
            }
            else if (Prefs.UpdateString(PrefName.MySqlVersion, floatVersion.ToString("f1")))
            {
                if (!MsgBox.Show("Prefs", MsgBoxButtons.OKCancel, "Tables will now be backed up, optimized, and repaired.  This will take a minute or two.  Continue?"))
                {
                    Application.Exit();
                    return(false);
                }
                try {
                    DatabaseMaintenance.BackupRepairAndOptimize();
                    hasBackup = true;
                }
                catch (Exception e) {
                    if (e.Message != "")
                    {
                        MessageBox.Show(e.Message);
                    }
                    MsgBox.Show("Prefs", "Backup failed. Your database has not been altered.");
                    Application.Exit();
                    return(false);                   //but this should never happen
                }
            }
            if (PrefC.ContainsKey("DatabaseConvertedForMySql41"))
            {
                return(true);               //already converted
            }
            if (!MsgBox.Show("Prefs", true, "Your database will now be converted for use with MySQL 4.1."))
            {
                Application.Exit();
                return(false);
            }
            //ClassConvertDatabase CCD=new ClassConvertDatabase();
            try {
                if (!hasBackup)                 //A backup could have been made if the tables were optimized and repaired above.
                {
                    MiscData.MakeABackup();
                }
            }
            catch (Exception e) {
                if (e.Message != "")
                {
                    MessageBox.Show(e.Message);
                }
                MsgBox.Show("Prefs", "Backup failed. Your database has not been altered.");
                Application.Exit();
                return(false);               //but this should never happen
            }
            MessageBox.Show("Backup performed");
            Prefs.ConvertToMySqlVersion41();
            MessageBox.Show("converted");
            //Refresh();
            return(true);
        }
예제 #13
0
        ///<summary>Called in two places.  Once from FormOpenDental.PrefsStartup, and also from FormBackups after a restore.</summary>
        public static bool CheckProgramVersion()
        {
            if (PrefC.GetBool(PrefName.UpdateWindowShowsClassicView))
            {
                return(CheckProgramVersionClassic());
            }
            Version storedVersion  = new Version(PrefC.GetString(PrefName.ProgramVersion));
            Version currentVersion = new Version(Application.ProductVersion);
            string  database       = "";

            //string command="";
            if (DataConnection.DBtype == DatabaseType.MySql)
            {
                database = MiscData.GetCurrentDatabase();
            }
            if (storedVersion < currentVersion)
            {
                //There are two different situations where this might happen.
                if (PrefC.GetString(PrefName.UpdateInProgressOnComputerName) == "")              //1. Just performed an update from this workstation on another database.
                //This is very common for admins when viewing slighly older databases.
                //There should be no annoying behavior here.  So do nothing.
                {
                                        #if !DEBUG
                    //Excluding this in debug allows us to view slightly older databases without accidentally altering them.
                    Prefs.UpdateString(PrefName.ProgramVersion, currentVersion.ToString());
                    Cache.Refresh(InvalidType.Prefs);
                                        #endif
                    return(true);
                }
                //and 2a. Just performed an update from this workstation on this database.
                //or 2b. Just performed an update from this workstation for multiple databases.
                //In both 2a and 2b, we already downloaded Setup file to correct location for this db, so skip 1 above.
                //This computer just performed an update, but none of the other computers has updated yet.
                //So attempt to stash all files that are in the Application directory.
                if (!CopyFromHereToUpdateFiles(currentVersion))
                {
                    Application.Exit();
                    return(false);
                }
                Prefs.UpdateString(PrefName.ProgramVersion, currentVersion.ToString());
                Prefs.UpdateString(PrefName.UpdateInProgressOnComputerName, "");               //now, other workstations will be allowed to update.
                Cache.Refresh(InvalidType.Prefs);
            }
            if (storedVersion > currentVersion)
            {
                //This is the update sequence for both a direct workstation, and for a ClientWeb workstation.
                string folderUpdate = "";
                if (PrefC.AtoZfolderUsed)
                {
                    folderUpdate = ODFileUtils.CombinePaths(ImageStore.GetPreferredAtoZpath(), "UpdateFiles");
                }
                else                  //images in db
                {
                    folderUpdate = ODFileUtils.CombinePaths(Path.GetTempPath(), "UpdateFiles");
                    if (Directory.Exists(folderUpdate))
                    {
                        Directory.Delete(folderUpdate, true);
                    }
                    DocumentMisc docmisc = DocumentMiscs.GetUpdateFilesZip();
                    if (docmisc != null)
                    {
                        byte[] rawBytes = Convert.FromBase64String(docmisc.RawBase64);
                        using (ZipFile unzipped = ZipFile.Read(rawBytes)) {
                            unzipped.ExtractAll(folderUpdate);
                        }
                    }
                }
                //look at the manifest to see if it's the version we need
                string manifestVersion = "";
                try {
                    manifestVersion = File.ReadAllText(ODFileUtils.CombinePaths(folderUpdate, "Manifest.txt"));
                }
                catch {
                    //fail silently
                }
                if (manifestVersion != storedVersion.ToString(3))               //manifest version is wrong
                //No point trying the Setup.exe because that's probably wrong too.
                //Just go straight to downloading and running the Setup.exe.
                {
                    string manpath = ODFileUtils.CombinePaths(folderUpdate, "Manifest.txt");
                    if (MessageBox.Show(Lan.g("Prefs", "The expected version information was not found in this file: ") + manpath + ".  "
                                        + Lan.g("Prefs", "There is probably a permission issue on that folder which should be fixed. ")
                                        + "\r\n\r\n" + Lan.g("Prefs", "The suggested solution is to return to the computer where the update was just run.  Go to Help | Update | Setup, and click the Recopy button.")
                                        + "\r\n\r\n" + Lan.g("Prefs", "If, instead, you click OK in this window, then a fresh Setup file will be downloaded and run."),
                                        "", MessageBoxButtons.OKCancel) != DialogResult.OK)     //they don't want to download again.
                    {
                        Application.Exit();
                        return(false);
                    }
                    DownloadAndRunSetup(storedVersion, currentVersion);
                    Application.Exit();
                    return(false);
                }
                //manifest version matches
                if (MessageBox.Show(Lan.g("Prefs", "Files will now be copied.") + "\r\n"
                                    + Lan.g("Prefs", "Workstation version will be updated from ") + currentVersion.ToString(3)
                                    + Lan.g("Prefs", " to ") + storedVersion.ToString(3),
                                    "", MessageBoxButtons.OKCancel)
                    != DialogResult.OK)                   //they don't want to update for some reason.
                {
                    Application.Exit();
                    return(false);
                }
                string tempDir = Path.GetTempPath();
                //copy UpdateFileCopier.exe to the temp directory
                File.Copy(ODFileUtils.CombinePaths(folderUpdate, "UpdateFileCopier.exe"), //source
                          ODFileUtils.CombinePaths(tempDir, "UpdateFileCopier.exe"),      //dest
                          true);                                                          //overwrite
                //wait a moment to make sure the file was copied
                Thread.Sleep(500);
                //launch UpdateFileCopier to copy all files to here.
                int    processId     = Process.GetCurrentProcess().Id;
                string appDir        = Application.StartupPath;
                string startFileName = ODFileUtils.CombinePaths(tempDir, "UpdateFileCopier.exe");
                string arguments     = "\"" + folderUpdate + "\""   //pass the source directory to the file copier.
                                       + " " + processId.ToString() //and the processId of Open Dental.
                                       + " \"" + appDir + "\"";     //and the directory where OD is running
                Process.Start(startFileName, arguments);
                Application.Exit();                                 //always exits, whether launch of setup worked or not
                return(false);
            }
            return(true);
        }
예제 #14
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);
     }
 }
예제 #15
0
        ///<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
        }
예제 #16
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;
        }
예제 #17
0
        private void SyncSheetDefDicts()
        {
            bool hasChanged = false;

            foreach (KeyValuePair <long, Dictionary <SheetTypeEnum, SheetDef> > dictSheetsCurForClinic in _dictSheetsCur)
            {
                if (dictSheetsCurForClinic.Key == 0)                                            //Defaults
                {
                    Dictionary <SheetTypeEnum, SheetDef> defaultDefNumsOld = _dictSheetsCur[0]; //Guaranteed to have the key of 0
                    foreach (KeyValuePair <SheetTypeEnum, SheetDef> sheetDef in dictSheetsCurForClinic.Value)
                    {
                        if (defaultDefNumsOld.ContainsKey(sheetDef.Key))                         //Should always happen for defaults
                        {
                            if (Prefs.UpdateLong(Prefs.GetSheetDefPref(sheetDef.Key), sheetDef.Value.SheetDefNum))
                            {
                                hasChanged = true;
                            }
                        }
                    }
                }
                else                  //Clinic specific
                                      //If this clinic had overrides when this window loaded, check to see if any changes were made.
                {
                    if (_dictSheetsOld.ContainsKey(dictSheetsCurForClinic.Key))
                    {
                        foreach (KeyValuePair <SheetTypeEnum, SheetDef> sheetDef in dictSheetsCurForClinic.Value)
                        {
                            //If current sheetdef already exists in the db, update
                            if (_dictSheetsOld[dictSheetsCurForClinic.Key].ContainsKey(sheetDef.Key))
                            {
                                //Delete the clinic override if the current Clinic value same as base default
                                if (sheetDef.Value == null)
                                {
                                    //We know we want to delete because we found this value from _dictSheetsOld which was filled from the database
                                    ClinicPrefs.Delete(ClinicPrefs.GetPref(Prefs.GetSheetDefPref(sheetDef.Key), dictSheetsCurForClinic.Key).ClinicPrefNum);
                                    hasChanged = true;
                                }
                                else if (ClinicPrefs.UpdateLong(Prefs.GetSheetDefPref(sheetDef.Key), dictSheetsCurForClinic.Key, sheetDef.Value.SheetDefNum))
                                {
                                    hasChanged = true;
                                }
                            }
                            else                              //Current sheetdef doesn't exist in db, insert
                            {
                                if (sheetDef.Value != null)   //Clinic value different than base default
                                {
                                    ClinicPrefs.InsertPref(Prefs.GetSheetDefPref(sheetDef.Key), dictSheetsCurForClinic.Key, POut.Long(sheetDef.Value.SheetDefNum));
                                    hasChanged = true;
                                }
                            }
                        }
                    }
                    else                      //No clinicprefs exist for the clinic
                    {
                        foreach (KeyValuePair <SheetTypeEnum, SheetDef> sheetDef in dictSheetsCurForClinic.Value)
                        {
                            //No preferences exist for this clinic, so add all that we have stored from being on on this form.
                            if (sheetDef.Value != null)                           //Clinic value set to use a specific sheet def instead of default
                            {
                                ClinicPrefs.InsertPref(Prefs.GetSheetDefPref(sheetDef.Key), dictSheetsCurForClinic.Key, POut.Long(sheetDef.Value.SheetDefNum));
                                hasChanged = true;
                            }
                        }
                    }
                }
            }
            if (hasChanged)
            {
                DataValid.SetInvalid(InvalidType.Prefs);
                DataValid.SetInvalid(InvalidType.ClinicPrefs);
            }
        }
예제 #18
0
        private void butDownloadClaimform_Click(object sender, EventArgs e)
        {
            Cursor = Cursors.WaitCursor;
            //Application.DoEvents();
            string      remoteUri = textWebsitePath.Text + textRegClaimform.Text + "/";
            WebRequest  wr;
            WebResponse webResp;

            //int fileSize;
            //copy image file-------------------------------------------------------------------------------
            if (BackgroundImg != "")
            {
                myStringWebResource = remoteUri + BackgroundImg;
                WriteToFile         = PrefB.GetString("DocPath") + BackgroundImg;
                if (File.Exists(WriteToFile))
                {
                    File.Delete(WriteToFile);
                }
                wr = WebRequest.Create(myStringWebResource);
                int fileSize;
                try{
                    webResp  = wr.GetResponse();
                    fileSize = (int)webResp.ContentLength / 1024;
                }
                catch (Exception ex) {
                    Cursor = Cursors.Default;
                    MessageBox.Show("Error downloading " + BackgroundImg + ". " + ex.Message);
                    return;
                    //fileSize=0;
                }
                if (fileSize > 0)
                {
                    //start the thread that will perform the download
                    Thread workerThread = new Thread(new ThreadStart(InstanceMethod));
                    workerThread.Start();
                    //display the progress dialog to the user:
                    FormP        = new FormProgress();
                    FormP.MaxVal = (double)fileSize / 1024;
                    FormP.NumberMultiplication = 100;
                    FormP.DisplayText          = "?currentVal MB of ?maxVal MB copied";
                    FormP.NumberFormat         = "F";
                    FormP.ShowDialog();
                    if (FormP.DialogResult == DialogResult.Cancel)
                    {
                        workerThread.Abort();
                        Cursor = Cursors.Default;
                        return;
                    }
                    MsgBox.Show(this, "Image file downloaded successfully.");
                }
            }
            Cursor = Cursors.WaitCursor;          //have to do this again for some reason.
            //Import ClaimForm.xml----------------------------------------------------------------------------------
            myStringWebResource = remoteUri + "ClaimForm.xml";
            WriteToFile         = PrefB.GetString("DocPath") + "ClaimForm.xml";
            if (File.Exists(WriteToFile))
            {
                File.Delete(WriteToFile);
            }
            try{
                InstanceMethod();
            }
            catch {
            }
            int rowsAffected;

            if (File.Exists(WriteToFile))
            {
                int newclaimformnum = 0;
                try{
                    newclaimformnum = FormClaimForms.ImportForm(WriteToFile, true);
                }
                catch (ApplicationException ex) {
                    Cursor = Cursors.Default;
                    MessageBox.Show(ex.Message);
                    return;
                }
                finally{
                    File.Delete(WriteToFile);
                }
                if (newclaimformnum != 0)
                {
                    Prefs.UpdateInt("DefaultClaimForm", newclaimformnum);
                }
                //switch all insplans over to new claimform
                ClaimForm oldform = null;
                for (int i = 0; i < ClaimForms.ListLong.Length; i++)
                {
                    if (ClaimForms.ListLong[i].UniqueID == OldClaimFormID)
                    {
                        oldform = ClaimForms.ListLong[i];
                    }
                }
                if (oldform != null)
                {
                    rowsAffected = InsPlans.ConvertToNewClaimform(oldform.ClaimFormNum, newclaimformnum);
                    MessageBox.Show("Number of insurance plans changed to new form: " + rowsAffected.ToString());
                }
                DataValid.SetInvalid(InvalidTypes.ClaimForms | InvalidTypes.Prefs);
            }
            //Import ProcCodes.xml------------------------------------------------------------------------------------
            myStringWebResource = remoteUri + "ProcCodes.xml";
            WriteToFile         = PrefB.GetString("DocPath") + "ProcCodes.xml";
            if (File.Exists(WriteToFile))
            {
                File.Delete(WriteToFile);
            }
            try {
                InstanceMethod();
            }
            catch {
            }
            if (File.Exists(WriteToFile))
            {
                //move T codes over to a new "Obsolete" category which is hidden
                ProcedureCodes.TcodesMove();
                rowsAffected = 0;
                try {
                    rowsAffected = FormProcCodes.ImportProcCodes(WriteToFile, false);
                }
                catch (ApplicationException ex) {
                    Cursor = Cursors.Default;
                    MessageBox.Show(ex.Message);
                    return;
                }
                finally {
                    File.Delete(WriteToFile);
                }
                ProcedureCodes.Refresh();                //?
                MessageBox.Show("Procedure codes inserted: " + rowsAffected.ToString());
                //Change all procbuttons and autocodes from T to D.
                ProcedureCodes.TcodesAlter();
                DataValid.SetInvalid(InvalidTypes.AutoCodes | InvalidTypes.Defs | InvalidTypes.ProcCodes | InvalidTypes.ProcButtons);
            }
            MsgBox.Show(this, "Done");
            Cursor = Cursors.Default;
        }
예제 #19
0
        private void butOK_Click(object sender, System.EventArgs e)
        {
            if (!Directory.Exists(textLocation.Text))
            {
                MsgBox.Show(this, "Location does not exist.");
                return;
            }
            if (Directory.Exists(ODFileUtils.CombinePaths(textLocation.Text, textName.Text)))
            {
                MsgBox.Show(this, "Folder already exists.");
                return;
            }
            try {
                FileSystemAccessRule fsar = new FileSystemAccessRule("everyone", FileSystemRights.FullControl, AccessControlType.Allow);
                DirectorySecurity    ds   = new DirectorySecurity();
                ds.AddAccessRule(fsar);
                string requestDir     = textLocation.Text;
                string rootFolderName = textName.Text;
                string rootDir        = ODFileUtils.CombinePaths(requestDir, rootFolderName);
                //Enable file sharing for the A to Z folder.
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    //Process.Start("net","usershare add OpenDentImages \""+rootDir+"\"");//for future use.
                }
                else                  //Windows
                {
                    Process.Start("NET", "SHARE OpenDentImages=\"" + rootDir + "\"");
                }
                //All folder names to be created should be put in this list, so that each folder is created exactly
                //the same way.
                string[] aToZFolderNames = new string[] {
                    "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N",
                    "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
                    "EmailAttachments", "Forms", "Reports", "Sounds",
                };
                //Create A to Z folders in root folder.
                for (int i = 0; i < aToZFolderNames.Length; i++)
                {
                    string pathToCreate = ODFileUtils.CombinePaths(rootDir, aToZFolderNames[i]);
                    if (!Directory.Exists(pathToCreate))
                    {
                        // Mono does support Directory.CreateDirectory(string, DirectorySecurity)
#if !LINUX
                        Directory.CreateDirectory(pathToCreate, ds);
#else
                        Directory.CreateDirectory(pathToCreate);
#endif
                    }
                }
                //Save new image path into the DocPath and
                //set "use A to Z folders" check-box to checked.
                Prefs.UpdateString(PrefName.DocPath, rootDir);
                Prefs.UpdateString(PrefName.AtoZfolderNotRequired, "0");
                Cache.Refresh(InvalidType.Prefs);
                //Prefs_client.RefreshClient();
            }
            catch (Exception ex) {
                Logger.openlog.LogMB("Failed to create A to Z folders: " + ex.ToString(), Logger.Severity.ERROR);
            }
            DialogResult = DialogResult.OK;
        }
예제 #20
0
		private bool SaveToDb() {
			if((radioModeTight.Checked || radioModeFull.Checked) && comboDefaultUserGroup.SelectedIndex==-1) {
				MsgBox.Show(this,"Please select a default user group first.");
				return false;
			}
			if(checkEnabled.Checked) {
				if(textProgDesc.Text=="") {
					MsgBox.Show(this,"Description may not be blank.");
					return false;
				}
				if(!HL7Defs.IsExistingHL7Enabled()) {
					if((radioModeTight.Checked || radioModeFull.Checked) && textHL7FolderIn.Text=="") {
						MsgBox.Show(this,"HL7 in folder may not be blank.");
						return false;
					}
					if(textHL7FolderOut.Text=="") {
						MsgBox.Show(this,"HL7 out folder may not be blank.");
						return false;
					}
					if(textHL7Server.Text=="") {
						MsgBox.Show(this,"HL7 Server may not be blank.");
						return false;
					}
					if(textHL7ServiceName.Text=="") {
						MsgBox.Show(this,"HL7 Service Name may not be blank.");
						return false;
					}
				}
			}
			ProgramCur.ProgDesc=textProgDesc.Text;
			ProgramCur.Enabled=checkEnabled.Checked;
			Programs.Update(ProgramCur);
			Prefs.UpdateString(PrefName.HL7FolderOut,textHL7FolderOut.Text);
			ProgramProperties.SetProperty(ProgramCur.ProgramNum,"HL7Server",textHL7Server.Text);//this property will not exist if using Oracle, eCW will never use Oracle
			ProgramProperties.SetProperty(ProgramCur.ProgramNum,"HL7ServiceName",textHL7ServiceName.Text);//this property will not exist if using Oracle, eCW will never use Oracle
			ProgramProperties.SetProperty(ProgramCur.ProgramNum,"MedicalPanelUrl",textMedPanelURL.Text);//this property will not exist if using Oracle, eCW will never use Oracle
			if(checkLBSessionId.Checked) {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"IsLBSessionIdExcluded","1");
			}
			else {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"IsLBSessionIdExcluded","0");
			}
			if(checkQuadAsToothNum.Checked) {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"IsQuadAsToothNum","1");//this property will not exist if using Oracle, eCW will never use Oracle
			}
			else {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"IsQuadAsToothNum","0");//this property will not exist if using Oracle, eCW will never use Oracle
			}
			if(checkHideButChartRx.Checked) {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"HideChartRxButtons","1");//this property will not exist if using Oracle, eCW will never use Oracle
			}
			else {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"HideChartRxButtons","0");//this property will not exist if using Oracle, eCW will never use Oracle
			}
			if(checkProcRequireSignature.Checked) {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"ProcRequireSignature","1");
			}
			else {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"ProcRequireSignature","0");
			}
			if(checkProcNotesNoIncomplete.Checked) {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"ProcNotesNoIncomplete","1");
			}
			else {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"ProcNotesNoIncomplete","0");
			}
			if(radioModeTight.Checked || radioModeFull.Checked) {
				if(radioModeTight.Checked) {
					ProgramProperties.SetProperty(ProgramCur.ProgramNum,"eClinicalWorksMode","0");//Tight
				}
				else {
					ProgramProperties.SetProperty(ProgramCur.ProgramNum,"eClinicalWorksMode","2");//Full
				}
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"eCWServer",textECWServer.Text);//this property will not exist if using Oracle, eCW will never use Oracle
				Prefs.UpdateString(PrefName.HL7FolderIn,textHL7FolderIn.Text);
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"DefaultUserGroup",
					_listUserGroups[comboDefaultUserGroup.SelectedIndex].UserGroupNum.ToString());
				if(checkShowImages.Checked) {
					ProgramProperties.SetProperty(ProgramCur.ProgramNum,"ShowImagesModule","1");
				}
				else {
					ProgramProperties.SetProperty(ProgramCur.ProgramNum,"ShowImagesModule","0");
				}
				if(this.checkFeeSchedules.Checked) {
					ProgramProperties.SetProperty(ProgramCur.ProgramNum,"FeeSchedulesSetManually","1");
				}
				else {
					ProgramProperties.SetProperty(ProgramCur.ProgramNum,"FeeSchedulesSetManually","0");
				}
			}
			else if(radioModeStandalone.Checked) {
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"eClinicalWorksMode","1");
				Prefs.UpdateString(PrefName.HL7FolderIn,"");
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"DefaultUserGroup","0");
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"ShowImagesModule","1");
				ProgramProperties.SetProperty(ProgramCur.ProgramNum,"FeeSchedulesSetManually","0");
			}
			DataValid.SetInvalid(InvalidType.Programs,InvalidType.Prefs);
			return true;
		}
예제 #21
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;
        }
예제 #22
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
     }
 }
예제 #23
0
 private void checkWebSchedNewPatForcePhoneFormatting_Click(object sender, EventArgs e)
 {
     Prefs.UpdateBool(PrefName.WebSchedNewPatApptForcePhoneFormatting, checkWebSchedNewPatForcePhoneFormatting.Checked);
 }
예제 #24
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;
            }
        }
예제 #25
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);
                }
            }
        }