Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Model model = modelCRUD1.Model;

            try
            {
                if (!ModelHelper.Validate(model))
                {
                    CustomMessageBox.ShowError(ResourceHelper.GetResourceText("RequiredName"));
                    return;
                }
                List <ModelFactor> factors = modelCRUD1.ModelFactors;
                if (factors.Count == 0)
                {
                    CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("AtLeastOneFactor"));
                    return;
                }

                model = ModelHelper.Save(model);
                foreach (ModelFactor mf in factors)
                {
                    mf.IDModel = model.IDModel;
                    ModelFactorHelper.Save(mf);
                }
                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelSavedOk"));
                ViewManager.ShowStart();
                ViewManager.LoadModelsMenu();
            }
            catch (Exception exception)
            {
                CustomMessageBox.ShowError(ResourceHelper.GetResourceText("ModelSavingError") + exception.Message);
            }
        }
Exemple #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!ValidateScreen())
            {
                return;
            }

            try
            {
                User user = userCRUD.User;
                UserHelper.Validate(user);
                if ((from u in UserHelper.GetAll() where (user.Username.ToLower() == u.Username.ToLower() && user.IDUser != u.IDUser) select u).Any())
                {
                    CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("UserNameAlreadyExists"),
                                                 CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.OKOnly);
                    return;
                }
                UserHelper.Save(user);
                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("UserSavedOk"),
                                             CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.OKOnly);
                Clear();
                LoadUserCombo();
            }
            catch (Exception ex)
            {
                CustomMessageBox.ShowError(ex.Message);
            }
        }
Exemple #3
0
 private void txtLatitude_Leave(object sender, EventArgs e)
 {
     try
     {
         float.Parse(txtLatitude.Text);
         _validFormData = true;
     }
     catch (Exception)
     {
         CustomMessageBox.ShowError(ResourceHelper.GetResourceText("LatitudeLongitudeFormatError"));
         _validFormData = false;
     }
 }
Exemple #4
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (ModelFactor f in OrderedModelFactors)
                {
                    ModelFactorHelper.Save(f);
                }

                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelSavedOk"));
                ViewManager.CloseView();
            }
            catch (Exception exception)
            {
                CustomMessageBox.ShowError(exception.Message);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtNewName.Text.Trim() == string.Empty)
            {
                CustomMessageBox.ShowError(ResourceHelper.GetResourceText("RequiredName"));
                return;
            }

            RegionToChange.RegionName = txtNewName.Text;
            RegionHelper.Save(RegionToChange);

            if (OnRegionNameChanged != null)
            {
                OnRegionNameChanged(this, new EventArgs());
            }

            Close();
        }
Exemple #6
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                if (
                    CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ConfirmDeleteUser"),
                                                 CustomMessageBoxMessageType.Warning, CustomMessageBoxButtonType.YesNo) ==
                    CustomMessageBoxReturnValue.Cancel)
                {
                    return;
                }

                UserHelper.Delete((User)cbUsers.SelectedItem);
                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("UserDeletedOk"));
                ViewManager.ShowStart();
            }
            catch (Exception ex)
            {
                CustomMessageBox.ShowError(ex.Message);
            }
        }
Exemple #7
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (modelCRUD1.FactorsChanged() && CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("FactorsChangedMessage"), CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo) == CustomMessageBoxReturnValue.Cancel)
            {
                return;
            }

            try
            {
                Model model = modelCRUD1.Model;
                if (!ModelHelper.Validate(model))
                {
                    CustomMessageBox.ShowError(ResourceHelper.GetResourceText("RequiredName"));
                    return;
                }
                List <ModelFactor> factors = modelCRUD1.ModelFactors;
                if (!factors.Any())
                {
                    CustomMessageBox.ShowError(ResourceHelper.GetResourceText("AtLeastOneFactor"));
                    return;
                }

                model = ModelHelper.Save(model);
                foreach (ModelFactor mf in factors)
                {
                    mf.IDModel = model.IDModel;
                    ModelFactorHelper.Save(mf);
                }
                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("ModelSavedOk"));
                ViewManager.LoadModelsMenu();
                ViewManager.ShowStart();
                EventManager.RaiseModelUpdated();
            }
            catch (Exception exception)
            {
                CustomMessageBox.ShowError(exception.Message);
            }
        }
Exemple #8
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (ValidateScreen())
     {
         User user = userCRUD.User;
         try
         {
             UserHelper.Validate(user);
             if ((from u in UserHelper.GetAll() where user.Username == u.Username select u).Any())
             {
                 CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("UserNameAlreadyExists"));
                 return;
             }
             UserHelper.Save(user);
             CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("UserSavedOk"));
             ViewManager.ShowStart();
         }
         catch (Exception ex)
         {
             CustomMessageBox.ShowError(ex.Message);
         }
     }
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            _phase.Title             = txtPhaseName.Text;
            _phase.Column1Text       = col1HtmlEditorControl.InnerHtml;
            _phase.Column2Text       = col2HtmlEditorControl.InnerHtml;
            _phase.Column3Text       = col3HtmlEditorControl.InnerHtml;
            _phase.PractitionersTips = practitionersTipsHtmlEditorControl.InnerHtml;

            // Reorder bullets (they were ordereded in the control, but need to reorder the underlying list:
            column1BulletList.SortList();
            column2BulletList.SortList();
            column3BulletList.SortList();


            //delete phase bullets removed by the user.
            foreach (int idPhaseBullet in column1BulletList.PhaseBulletsIDsToDelete)
            {
                PhaseBulletHelper.Delete(idPhaseBullet);
            }

            foreach (int idPhaseBullet in column2BulletList.PhaseBulletsIDsToDelete)
            {
                PhaseBulletHelper.Delete(idPhaseBullet);
            }

            foreach (int idPhaseBullet in column3BulletList.PhaseBulletsIDsToDelete)
            {
                PhaseBulletHelper.Delete(idPhaseBullet);
            }

            foreach (PhaseBullet phaseBullet in column1BulletList.Bullets)
            {
                phaseBullet.ColumnNumber = 1;
                phaseBullet.IDPhase      = _phase.IDPhase;
            }

            foreach (PhaseBullet phaseBullet in column2BulletList.Bullets)
            {
                phaseBullet.ColumnNumber = 2;
                phaseBullet.IDPhase      = _phase.IDPhase;
            }

            foreach (PhaseBullet phaseBullet in column3BulletList.Bullets)
            {
                phaseBullet.ColumnNumber = 3;
                phaseBullet.IDPhase      = _phase.IDPhase;
            }

            try
            {
                PhaseHelper.Validate(_phase);
                PhaseHelper.Save(_phase);

                PhaseBulletHelper.SaveColumnBullets(column1BulletList.Bullets);
                PhaseBulletHelper.SaveColumnBullets(column2BulletList.Bullets);
                PhaseBulletHelper.SaveColumnBullets(column3BulletList.Bullets);

                PhaseHelper.GenerateAllFiles(_phase);

                DocumentHelper.DownloadFilesAsync();

                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("PhaseSavedOk"));

                LoadCombo();
            }
            catch (Exception exception)
            {
                CustomMessageBox.ShowError(exception.Message);
            }
        }
Exemple #10
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            bool restoreDataBase   = chkRestoreDataBase.Checked;
            bool restoreFiles      = chkRestoreFiles.Checked;
            bool restoreShapefiles = chkRestoreShapefiles.Checked;

            if (restoreDataBase == false && restoreFiles == false && restoreShapefiles == false)
            {
                CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("MustSelectAtLeastOneOption"));
                return;
            }

            if (Environment.OSVersion.Version.Major == 6)
            {
                if (!IsAdministrator())
                {
                    CustomMessageBoxReturnValue customMessageBoxReturnValue1 = CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("RestoreAsAdministratorWarning"),
                                                                                                            CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo);
                    if (customMessageBoxReturnValue1 == CustomMessageBoxReturnValue.Ok)
                    {
                        // it's windows Vista / 7. UAC requires the user to run as an ADMINISTRATOR to restart the Windows Service.
                        ProcessStartInfo info = new ProcessStartInfo();
                        info.FileName        = Assembly.GetEntryAssembly().Location;
                        info.UseShellExecute = true;
                        info.Verb            = "runas"; // Provides Run as Administrator

                        if (Process.Start(info) != null)
                        {
                            // The user accepted the UAC prompt.
                            Application.Exit();
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }

            CustomMessageBoxReturnValue customMessageBoxReturnValue2 = CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("RestoreTimeWarning"),
                                                                                                    CustomMessageBoxMessageType.Information, CustomMessageBoxButtonType.YesNo);

            if (customMessageBoxReturnValue2 == CustomMessageBoxReturnValue.Cancel)
            {
                return;
            }

            OpenFileDialog ofd = new OpenFileDialog()
            {
                Filter = "Gzipped restore files(*.gz)|*.gz", Title = "Restore backup from..."
            };

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                Boolean backupFailed = false;
                try
                {
                    string noCorrespondingRestorations = DocumentHelper.Restore(Convert.ToBase64String(File.ReadAllBytes(ofd.FileName)), restoreDataBase, restoreFiles, restoreShapefiles);
                    RestartService("IDEA Geo Host Service");
                    if (noCorrespondingRestorations != string.Empty)
                    {
                        if (noCorrespondingRestorations.Contains("invaliddbversion"))
                        {
                            CustomMessageBox.ShowError(ResourceHelper.GetResourceText("DataRestoreInvalidDBVersion"));
                            backupFailed = true;
                        }

                        if (noCorrespondingRestorations.Contains("errorrestoringdb"))
                        {
                            CustomMessageBox.ShowError(ResourceHelper.GetResourceText("DataRestoreError"));
                            backupFailed = true;
                        }

                        noCorrespondingRestorations = noCorrespondingRestorations.Substring(0, noCorrespondingRestorations.Length - 3);
                        noCorrespondingRestorations = " " + ResourceHelper.GetResourceText("SelectedRestoreOptionsWereNotBackupFile") + ": " + noCorrespondingRestorations + ".";
                    }

                    if (!backupFailed)
                    {
                        CustomMessageBox.ShowMessage(ResourceHelper.GetResourceText("DataRestored") + noCorrespondingRestorations);
                        Application.Exit();
                    }
                }
                catch (Exception ex)
                {
                    CustomMessageBox.ShowMessage(ex.Message, CustomMessageBoxMessageType.Error, CustomMessageBoxButtonType.OKOnly);
                }
            }
        }