Esempio n. 1
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textNote.Text == "")
     {
         MsgBox.Show(this, "Please enter a note, or delete this entry.");
         return;
     }
     try {
         TaskNoteCur.DateTimeNote = DateTime.Parse(textDateTime.Text);
     }
     catch {
         MsgBox.Show(this, "Please fix date.");
         return;
     }
     TaskNoteCur.Note = textNote.Text;
     if (TaskNoteCur.IsNew)
     {
         TaskNotes.Insert(TaskNoteCur);
     }
     else
     {
         TaskNotes.Update(TaskNoteCur);
     }
     DialogResult = DialogResult.OK;
 }
Esempio n. 2
0
 private void butOK_Click(object sender, EventArgs e)
 {
     if (textNote.Text == "")
     {
         MsgBox.Show(this, "Please enter a note, or delete this entry.");
         return;
     }
     try {
         TaskNoteCur.DateTimeNote = DateTime.Parse(textDateTime.Text);
     }
     catch {
         MsgBox.Show(this, "Please fix date.");
         return;
     }
     TaskNoteCur.Note = textNote.Text;
     if (TaskNoteCur.IsNew)
     {
         TaskNotes.Insert(TaskNoteCur);
     }
     else
     {
         TaskNotes.Update(TaskNoteCur);
     }
     DialogResult = DialogResult.OK;
     OnEditComplete();
     Close();            //Needed because the window is called as a non-modal window.
 }
Esempio n. 3
0
        public void SendReminder(SendReminderParameterObject param)
        {
            Employee     sender   = Session.GetObjectByKey <Employee>(SecuritySystem.CurrentUserId);
            ViewShortcut shortcut = new ViewShortcut("Task_DetailView", Oid.ToString());
            string       url      = "http://rnd.ntmarein.local/Default.aspx" + "?Shortcut" + shortcut.ToString();
            string       mSubject = string.Format("Reminder: {0}", this.Subject);
            string       mSendTo  = AssignedTo.CorporateEmail;
            string       mBody    = string.Format("Dear {0},<br/>", AssignedTo.FullName);

            mBody += string.Format("<p>This is a reminder from {0} for your task <strong><a href='{1}'>{2}</a></strong>.</p>", sender.FullName, url, Subject);
            mBody += string.Format("<p>The task will due on {0}. Please review detailed task information from Marbid system and complete the task immediately.</p>", DueDate);
            mBody += string.Format("<p>Bellow is an additional comment from {0}:</p>", sender.FullName);
            mBody += string.Format("<quote>{0}</quote>", param.AdditionalMessage);
            mBody += string.Format("<p>To review the task please click following URL:<br/><a href='{0}'>{0}</a>", url);
            Mailer sMailer = new Mailer("*****@*****.**", AssignedTo.CorporateEmail, mSubject, mBody);

            if (param.SendCopyToMySelf)
            {
                sMailer.CC = sender.CorporateEmail;
            }
            sMailer.SendMail();

            Session  session = this.Session;
            TaskNote tnote   = new TaskNote(session);

            tnote.CreateDate   = DateTime.Now;
            tnote.Note         = string.Format("<strong>Reminder is sent:</strong><br/>{0}", param.AdditionalMessage);
            tnote.IsSystemNote = true;
            TaskNotes.Add(tnote);
            tnote.Save();
            Session.CommitTransaction();
            Session.Save(this);
        }
Esempio n. 4
0
        public void AdvanceTask(AndvanceTaskParameterObject parameters)
        {
            Session  session = this.Session;
            TaskNote tnote   = new TaskNote(session);

            tnote.CreateDate   = DateTime.Now;
            tnote.Note         = string.Format("<strong>Task is advanced, current completion :{0}%</strong><br/>", parameters.PercentCompleted);
            tnote.Note        += parameters.Comment;
            tnote.IsSystemNote = true;
            tnote.IsPrivate    = false;
            if (parameters.Attachment != null)
            {
                FileData     tData = new FileData(session);
                MemoryStream ms    = new MemoryStream();
                parameters.Attachment.SaveToStream(ms);
                ms.Position = 0;
                tData.LoadFromStream(parameters.Attachment.FileName, ms);
                tnote.Attachment = tData;
            }
            PercentCompleted = (int)parameters.PercentCompleted;
            TaskNotes.Add(tnote);
            tnote.Save();
            Session.CommitTransaction();
            Session.Save(this);
        }
Esempio n. 5
0
        public void ReassignTask(ReasignParameterObject param)
        {
            Session  session = this.Session;
            TaskNote tnote   = new TaskNote(session);

            tnote.CreateDate = DateTime.Now;
            tnote.Note       = string.Format("<strong>Task is reassigned to: {0}<br/><strong>Reason:</strong><br/>{1}", param.ReassignTo, param.ReassignReason);
            tnote.IsPrivate  = false;
            if (param.Attachment != null)
            {
                FileData     tData = new FileData(session);
                MemoryStream ms    = new MemoryStream();
                param.Attachment.SaveToStream(ms);
                ms.Position = 0;
                tData.LoadFromStream(param.Attachment.FileName, ms);
                tnote.Attachment = tData;
            }
            AssignedTo         = Session.GetObjectByKey <Employee>(param.ReassignTo.Oid);
            DueDate            = param.ChangeDueDate;
            tnote.IsSystemNote = true;
            TaskNotes.Add(tnote);
            tnote.Save();
            MailReassignNewTask();
            Session.CommitTransaction();
            Session.Save(this);
        }
Esempio n. 6
0
        public void Postpone(PostponeParametersObject parameters)
        {
            Session  session = this.Session;
            TaskNote tnote   = new TaskNote(session);

            tnote.CreateDate   = DateTime.Now;
            tnote.Owner        = Session.GetObjectByKey <Employee>(Session.GetKeyValue(SecuritySystem.CurrentUser));
            tnote.Note         = "<strong>Task is postponed.</strong><br />";
            tnote.Note        += parameters.Comment;
            tnote.IsPrivate    = false;
            tnote.IsSystemNote = true;
            if (parameters.Attachment != null)
            {
                FileData     tData = new FileData(session);
                MemoryStream ms    = new MemoryStream();
                parameters.Attachment.SaveToStream(ms);
                ms.Position = 0;
                tData.LoadFromStream(parameters.Attachment.FileName, ms);
                tnote.Attachment = tData;
            }
            TaskNotes.Add(tnote);
            DueDate += TimeSpan.FromDays(parameters.PostponeForDays);
            tnote.Save();
            Session.CommitTransaction();
        }
Esempio n. 7
0
        public void StartTask(StartTaskParameterObject parameters)
        {
            Session  session = this.Session;
            TaskNote tnote   = new TaskNote(session);

            tnote.CreateDate   = DateTime.Now;
            tnote.Owner        = Session.GetObjectByKey <Employee>(Session.GetKeyValue(SecuritySystem.CurrentUser));
            tnote.Note         = "<strong>Task is started.</strong><br/>";
            tnote.Note        += parameters.Comment;
            tnote.IsSystemNote = true;
            StartDate          = DateTime.Now;
            Status             = TaskStatus.InProgress;
            if (parameters.Attachment != null)
            {
                FileData     tData = new FileData(session);
                MemoryStream ms    = new MemoryStream();
                parameters.Attachment.SaveToStream(ms);
                ms.Position = 0;
                tData.LoadFromStream(parameters.Attachment.FileName, ms);
                tnote.Attachment = tData;
            }
            tnote.IsPrivate = false;
            TaskNotes.Add(tnote);
            tnote.Save();
            Session.CommitTransaction();
            Session.Save(this);
        }
Esempio n. 8
0
        public void MarkComplete(CompleteParametersObject parameters)
        {
            Session  session = this.Session;
            TaskNote tnote   = new TaskNote(session);

            tnote.CreateDate   = DateTime.Now;
            tnote.Owner        = Session.GetObjectByKey <Employee>(SecuritySystem.CurrentUserId);
            tnote.Note         = "<strong>Task is completed</strong><br />";
            tnote.Note        += parameters.Comment;
            tnote.IsSystemNote = true;
            if (parameters.Attachment != null)
            {
                FileData     tData = new FileData(session);
                MemoryStream ms    = new MemoryStream();
                parameters.Attachment.SaveToStream(ms);
                ms.Position = 0;
                tData.LoadFromStream(parameters.Attachment.FileName, ms);
                tnote.Attachment = tData;
            }
            Status           = TaskStatus.Completed;
            PercentCompleted = 100;
            DateCompleted    = DateTime.Now;
            tnote.IsPrivate  = false;
            TaskNotes.Add(tnote);
            tnote.Save();
            Session.CommitTransaction();
            Session.Save(this);
        }
Esempio n. 9
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (TaskNoteCur.IsNew)
     {
         DialogResult = DialogResult.Cancel;
         return;
     }
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete?"))
     {
         return;
     }
     TaskNotes.Delete(TaskNoteCur.TaskNoteNum);
     DialogResult = DialogResult.OK;
 }
Esempio n. 10
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete?"))
     {
         return;
     }
     if (TaskNoteCur.IsNew)
     {
         DialogResult = DialogResult.Cancel;
         Close();                //Needed because the window is called as a non-modal window.
         return;
     }
     TaskNotes.Delete(TaskNoteCur.TaskNoteNum);
     DialogResult = DialogResult.OK;
     OnEditComplete();
     Close();            //Needed because the window is called as a non-modal window.
 }
Esempio n. 11
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textNote.Text == "")
            {
                MsgBox.Show(this, "Please enter a note, or delete this entry.");
                return;
            }
            if (Tasks.IsTaskDeleted(TaskNoteCur.TaskNum))               //If this is for a new task we do have a valid TaskNum because of pre-insert
            {
                MsgBox.Show(this, "The task for this note was deleted.");
                return;                //Don't allow user to create orphaned notes, or try to edit a tasknote that was probably deleted too.
            }
            //We need the old datetime to check if the user made any changes.  We overrite TaskNoteCur's date time below so need to get it here.
            DateTime dateTimeNoteOld = TaskNoteCur.DateTimeNote;

            try {
                TaskNoteCur.DateTimeNote = DateTime.Parse(textDateTime.Text);
            }
            catch {
                MsgBox.Show(this, "Please fix date.");
                return;
            }
            if (TaskNoteCur.IsNew)
            {
                TaskNoteCur.Note = textNote.Text;
                TaskNotes.Insert(TaskNoteCur);
                Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Added task note"), Tasks.GetOne(TaskNoteCur.TaskNum));
                DialogResult = DialogResult.OK;
                OnEditComplete();
            }
            else if (TaskNoteCur.Note != textNote.Text || dateTimeNoteOld != TaskNoteCur.DateTimeNote)
            {
                TaskNoteCur.Note = textNote.Text;
                TaskNotes.Update(TaskNoteCur);
                Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Task note changed"), Tasks.GetOne(TaskNoteCur.TaskNum));
                DialogResult = DialogResult.OK;
                OnEditComplete();
            }
            else
            {
                //Intentionally blank, user opened an existing task note and did not change the note but clicked OK.
                //This is effectively equivilent to a Cancel click
                DialogResult = DialogResult.Cancel;
            }
            Close();            //Needed because the window is called as a non-modal window.
        }
Esempio n. 12
0
        private void butOK_Click(object sender, EventArgs e)
        {
            if (textNote.Text == "")
            {
                MsgBox.Show(this, "Please enter a note, or delete this entry.");
                return;
            }
            //We need the old datetime to check if the user made any changes.  We overrite TaskNoteCur's date time below so need to get it here.
            DateTime dateTimeNoteOld = TaskNoteCur.DateTimeNote;

            try {
                TaskNoteCur.DateTimeNote = DateTime.Parse(textDateTime.Text);
            }
            catch {
                MsgBox.Show(this, "Please fix date.");
                return;
            }
            if (TaskNoteCur.IsNew)
            {
                TaskNoteCur.Note = textNote.Text;
                TaskNotes.Insert(TaskNoteCur);
                Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Added task note"), Tasks.GetOne(TaskNoteCur.TaskNum));
                //This refreshes "new" status for the task as appropriate.
                DataValid.SetInvalidTask(TaskNoteCur.TaskNum, true);               //popup
                DialogResult = DialogResult.OK;
                OnEditComplete();
            }
            else if (TaskNoteCur.Note != textNote.Text || dateTimeNoteOld != TaskNoteCur.DateTimeNote)
            {
                //This refreshes "new" status for the task as appropriate.
                DataValid.SetInvalidTask(TaskNoteCur.TaskNum, true);               //popup
                TaskNoteCur.Note = textNote.Text;
                TaskNotes.Update(TaskNoteCur);
                Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Task note changed"), Tasks.GetOne(TaskNoteCur.TaskNum));
                DialogResult = DialogResult.OK;
                OnEditComplete();
            }
            else
            {
                //Intentionally blank, user opened an existing task note and did not change the note but clicked OK.
                //This is effectively equivilent to a Cancel click
                DialogResult = DialogResult.Cancel;
            }
            Close();            //Needed because the window is called as a non-modal window.
        }
Esempio n. 13
0
 private void butDelete_Click(object sender, EventArgs e)
 {
     if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "Delete?"))
     {
         return;
     }
     if (TaskNoteCur.IsNew)
     {
         DialogResult = DialogResult.Cancel;
         Close();                //Needed because the window is called as a non-modal window.
         return;
     }
     TaskNotes.Delete(TaskNoteCur.TaskNoteNum);
     DialogResult = DialogResult.OK;
     OnEditComplete();
     Tasks.TaskEditCreateLog(Permissions.TaskNoteEdit, Lan.g(this, "Deleted note from task"), Tasks.GetOne(TaskNoteCur.TaskNum));
     Close();            //Needed because the window is called as a non-modal window.
 }
Esempio n. 14
0
        public void AddNewNote(AddNewNoteParameterObject parameters)
        {
            Session  session = this.Session;
            TaskNote tnote   = new TaskNote(session);

            tnote.Owner        = Session.GetObjectByKey <Employee>(Session.GetKeyValue(SecuritySystem.CurrentUser));
            tnote.CreateDate   = DateTime.Now;
            tnote.IsSystemNote = false;
            tnote.Note         = parameters.Content;
            tnote.IsPrivate    = parameters.IsPrivate;
            if (parameters.Attachment != null)
            {
                FileData     tData = new FileData(session);
                MemoryStream ms    = new MemoryStream();
                parameters.Attachment.SaveToStream(ms);
                ms.Position = 0;
                tData.LoadFromStream(parameters.Attachment.FileName, ms);
                tnote.Attachment = tData;
            }
            TaskNotes.Add(tnote);
            tnote.Save();
            Session.CommitTransaction();
        }
Esempio n. 15
0
        private void FormJobNew_Load(object sender, EventArgs e)
        {
            textSearch.Text = InitialSearchString;
            listBoxUsers.Items.Add("Any");
            _listUsers = Userods.GetDeepCopy(true);
            _listUsers.ForEach(x => listBoxUsers.Items.Add(x.UserName));
            //Statuses
            listBoxStatus.Items.Add("Any");
            _listJobStatuses = Enum.GetValues(typeof(JobPhase)).Cast <JobPhase>().ToList();
            _listJobStatuses.ForEach(x => listBoxStatus.Items.Add(x.ToString()));
            //Categories
            listBoxCategory.Items.Add("Any");
            _listJobCategory = Enum.GetValues(typeof(JobCategory)).Cast <JobCategory>().ToList();
            _listJobCategory.ForEach(x => listBoxCategory.Items.Add(x.ToString()));
            ODThread thread = new ODThread((o) => {
                //We can reduce these calls to DB by passing in more data from calling class. if available.
                _listJobsAll = Jobs.GetAll();
                Jobs.FillInMemoryLists(_listJobsAll);
                _listTasksAll     = Tasks.GetMany(_listJobsAll.SelectMany(x => x.ListJobLinks).Where(x => x.LinkType == JobLinkType.Task).Select(x => x.FKey).Distinct().ToList());
                _listTaskNotesAll = TaskNotes.GetForTasks(_listTasksAll.Select(x => x.TaskNum).ToList());
                _listPatientAll   = Patients.GetMultPats(_listJobsAll.SelectMany(x => x.ListJobQuotes).Select(x => x.PatNum).Distinct().ToList()).ToList();
                _listPatientAll.AddRange(Patients.GetMultPats(_listTasksAll.FindAll(x => x.ObjectType == TaskObjectType.Patient).Select(x => x.KeyNum).ToList()));
                try {
                    _listFeatureRequestsAll = FeatureRequests.GetAll();
                }
                catch (Exception ex) {
                    ex.DoNothing();
                    _listFeatureRequestsAll = new List <FeatureRequest>();
                }
                _listBugsAll = Bugs.GetAll();
                this.Invoke((Action)ReadyForSearch);
            });

            thread.AddExceptionHandler((ex) => { /*todo*/ });
            thread.Start();
        }
Esempio n. 16
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 = null)
        {
            FromVersion = new Version(fromVersion);
            ToVersion   = new Version(toVersion);        //Application.ProductVersion);
            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.
            }
            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 >= LatestVersion)
            {
                return(true);               //no conversion necessary
            }
            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 TRIALONLY
            //Trial users should never be able to update a database.
            if (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);
            }
#endif
            if (PrefC.GetString(PrefName.WebServiceServerName) != "" &&       //using web service
                !ODEnvironment.IdIsThisComputer(PrefC.GetString(PrefName.WebServiceServerName).ToLower()))                   //and not on web server
            {
                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);
            }
            //If MyISAM and InnoDb mix, then try to fix
            if (DataConnection.DBtype == DatabaseType.MySql)           //not for Oracle
            {
                string 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 DEBUG
            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
            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.")
                                             , "", MessageBoxButtons.OKCancel) != DialogResult.OK)
            {
                return(false);               //If user clicks cancel, then close the program
            }
#endif
            Cursor.Current = Cursors.WaitCursor;
            Action actionCloseConvertProgress = null;
#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.IsReminders)
            {
                //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.
            actionCloseConvertProgress = ODProgressOld.ShowProgressStatus("ConvertDatabases", hasMinimize: false, currentForm: currentForm);
            ConvertDatabases.To2_8_2();                //begins going through the chain of conversion steps
            InvokeConvertMethods();                    //continues going through the chain of conversion steps starting at v17.1.1 via reflection.
            actionCloseConvertProgress();
            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) {
            actionCloseConvertProgress?.Invoke();
            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) {
            actionCloseConvertProgress?.Invoke();
            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) {
            actionCloseConvertProgress?.Invoke();
            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
        }