コード例 #1
0
        private void ChangeNameInExchangeRatesConfig(CountryConfig.SystemRow systemRow, string oldSystemName)
        {
            ExchangeRatesConfigFacade excf = EM_AppContext.Instance.GetExchangeRatesConfigFacade(false); if (excf == null)
            {
                return;
            }
            bool anyChange = false;

            foreach (ExchangeRatesConfig.ExchangeRatesRow exchangeRate in
                     from er in excf.GetExchangeRates() where er.Country.ToLower() == systemRow.CountryRow.ShortName.ToLower() &&
                     ExchangeRate.ValidForToList(er.ValidFor).Contains(oldSystemName.ToLower()) select er)
            {
                if (!anyChange && UserInfoHandler.GetInfo("Do you want to update the system name in the global exchange rate table?" + Environment.NewLine + Environment.NewLine +
                                                          "Note that, if no exchange rate is found for a system name, the exchange rate is assumed to be 1.", MessageBoxButtons.YesNo) == DialogResult.No)
                {
                    return;
                }
                exchangeRate.ValidFor = ExchangeRate.RemoveFromValidFor(exchangeRate.ValidFor, oldSystemName);
                exchangeRate.ValidFor = ExchangeRate.AddToValidFor(exchangeRate.ValidFor, systemRow.Name); anyChange = true;
            }
            if (anyChange)
            {
                excf.WriteXML();
            }
        }
コード例 #2
0
        internal void GenerateInfo(string outputFilePath, List <string> _countries)
        {
            EM_UI_MainForm mainForm = EM_AppContext.Instance.GetActiveCountryMainForm(); if (mainForm != null)

            {
                mainForm.Cursor = Cursors.WaitCursor;
            }

            try
            {
                countries = _countries;
                AssessCountryInfo();
                InitExcelFile(outputFilePath);
                FillExcelFile();
                spreadsheetControl.SaveDocument();
                UserInfoHandler.ShowSuccess(string.Format("Successfully generated Release info file '{0}'.", outputFilePath)); // perhaps open ???
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception, string.Format("Failed to generate Release info file '{0}'.", outputFilePath), false);
            }
            finally { if (mainForm != null)
                      {
                          mainForm.Cursor = Cursors.Default;
                      }
            }
        }
コード例 #3
0
        void btnValidate_Click(object sender, EventArgs e)
        {
            validationItems = new List <string>(); countries = new List <string>();
            foreach (string validationItem in lstValidationItems.CheckedItems)
            {
                validationItems.Add(validationItem);
            }
            if (validationItems.Count == 0)
            {
                UserInfoHandler.ShowInfo("Please select at least one validation item."); return;
            }
            foreach (string country in lstCountries.CheckedItems)
            {
                countries.Add(country);
            }
            if (countries.Count == 0)
            {
                UserInfoHandler.ShowInfo("Please select at least one country."); return;
            }

            selectedFunction = PERFORM_VALIDATION;
            showProblemsOnly = chkShowProblemsOnly.Checked;
            DialogResult     = System.Windows.Forms.DialogResult.OK;
            Close(); // it is important to close this modal dialog otherwise it gets parent of the non-modal dialog showing validation results
                     // with the consequence that the non-modality of the result-dialog would be useless, as this modal dialog does not
                     // allow accessing the UI and if it's closed the non-modal dialog is closed too
                     // explicitly making the main-form parent of the non-modal dialog does not work either, because for whatever reason
                     // one cannot close the main-form anymore once the validation result dialog was started
        }
コード例 #4
0
        void btnExport_Click(object sender, EventArgs e)
        {
            if (chkExportSystemProgress.Checked)
            {
                if (!DeveloperInfoTools.ExportDataGridView(dgvSystems, txtFolder.Text, txtSystemProgress.Text))
                {
                    return;
                }
            }

            if (chkExportDatasetProgress.Checked)
            {
                if (!DeveloperInfoTools.ExportDataGridView(dgvDatasets, txtFolder.Text, txtDatasetProgress.Text))
                {
                    return;
                }
            }

            if (chkExportCombinations.Checked)
            {
                if (!DeveloperInfoTools.ExportDataGridView(dgvCombinations, txtFolder.Text, txtCombinations.Text))
                {
                    return;
                }
            }

            UserInfoHandler.ShowInfo("Exporting files accomplished.");
        }
コード例 #5
0
 private void ShowGridLastError()
 {
     if (dgvRates.lastError != string.Empty)
     {
         UserInfoHandler.ShowError(dgvRates.lastError);
     }
 }
コード例 #6
0
        void btnRemoveUsers_Click(object sender, EventArgs e)
        {
            List <ExtUserRightInfo> usersToRemove = new List <ExtUserRightInfo>(); string userNames = string.Empty;

            foreach (DataGridViewRow row in dgvUsers.SelectedRows)
            {
                ExtUserRightInfo extUserInfo = row.Tag as ExtUserRightInfo;
                VCAdministrator.AddUnitToMessage(ref userNames, extUserInfo.userInfo.username);
                if (!extUserInfo.added)
                {
                    usersToRemove.Add(extUserInfo);                     //user only needs to be removed via API if it wasn't added during this session of the dialog
                }
            }

            if (UserInfoHandler.GetInfo("Are you sure you want to remove user(s) " + userNames + " from project?", MessageBoxButtons.OKCancel)
                == System.Windows.Forms.DialogResult.Cancel)
            {
                return;
            }
            _usersToRemove.AddRange(usersToRemove);
            foreach (DataGridViewRow row in dgvUsers.SelectedRows)
            {
                dgvUsers.Rows.Remove(row);
            }
        }
コード例 #7
0
        void btnDeleteYear_Click(object sender, EventArgs e)
        {
            if (cmbYearToDelete.Text == string.Empty)
            {
                UserInfoHandler.ShowError("Please select a year.");
                return;
            }

            if (MessageBox.Show("Are you sure you want to delete this column?\n\nNote: you will not be able to undo this action or any action before this.", "Delete Year Column", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            for (int index = dgvIndices.Columns.Count - 1; index >= 0; --index)
            {
                if (dgvIndices.Columns[index].HeaderText == cmbYearToDelete.Text)
                {
                    dgvDataTable.Columns.Remove(dgvIndices.Columns[index].Name);
//                    dgvIndices.Columns.RemoveAt(index);
                    break;
                }
            }

            foreach (DataRow row in dgvDataTable.Rows)
            {
                row[0] = row[0];                                        // this is to make sure the deleted column counts as a DataSet change...
            }
            cmbYearToDelete.Items.RemoveAt(cmbYearToDelete.SelectedIndex);

            dgvDataSet.AcceptChanges();
            undoManager.Reset();
            columnsChanged = true;
        }
コード例 #8
0
        void SetAllDatasetsTo(string value)
        {
            try
            {
                int systemColumn = GetHitColumn();

                if (systemColumn == -1)
                {
                    UserInfoHandler.ShowInfo("Please open the menu via a position within the respective system's column.");
                    return;
                }

                foreach (DataGridViewRow row in dgvSwitches.Rows)
                {
                    if (row.Cells[systemColumn].ReadOnly == false)
                    {
                        row.Cells[systemColumn].Value = value;
                    }
                }
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
            }
        }
コード例 #9
0
 internal static void ReportSuccessAndInfo(string successfulAction, string backUpFolder, bool autoRestore = true)
 {
     UserInfoHandler.ShowSuccess(successfulAction + " succeeded!" + Environment.NewLine + Environment.NewLine +
                                 "Please note that a back-up of the version before the action is stored under " + Environment.NewLine +
                                 EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder + "." + Environment.NewLine + Environment.NewLine +
                                 (autoRestore ? "You may restore it via the button 'Restore' in the ribbon 'Country Tools'." : string.Empty));
 }
コード例 #10
0
        void btnOK_Click(object sender, EventArgs e)
        {
            if (txtRemoteVersion.Text == string.Empty)
            {
                UserInfoHandler.ShowError("Please select a Remote Version."); return;
            }
            if (!chkUseLocal.Checked && !chkUseRemote.Checked && txtParentVersion.Text == string.Empty)
            {
                UserInfoHandler.ShowError("Please select a Parent Version or check one of the 'Use ...' boxes."); return;
            }

            //Since users can also paste a path, the paths need to be validated and the remote and parent variables need to be populated

            if (!validateInsertedFields(txtRemoteVersion.Text, true))
            {
                return;
            }
            if (txtParentVersion.Text != string.Empty && !validateInsertedFields(txtParentVersion.Text, false))
            {
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #11
0
        void SetAllSystemsTo(string value)
        {
            try
            {
                int datasetRow = GetHitRow();
                if (datasetRow == -1)
                {
                    UserInfoHandler.ShowInfo("Please open the menu via a position within the respective dataset's row.");
                    return;
                }

                DataGridViewRow row = dgvSwitches.Rows[datasetRow];
                foreach (DataGridViewColumn column in dgvSwitches.Columns)
                {
                    if (row.Cells[column.Index].ReadOnly == false)
                    {
                        row.Cells[column.Index].Value = value;
                    }
                }
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
            }
        }
コード例 #12
0
        private void LinkAdvanced_Click(object sender, EventArgs e)
        {
            if (this.groupAdvancedOptions.Visible)
            {
                if (UserInfoHandler.GetInfo("Advanced settings will not be applied if you close them. Would you like to close them?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                {
                    if (chkSkipCountryLabelCheck.Visible)
                    {
                        chkSkipCountryLabelCheck.Checked = true;
                    }
                    this.groupAdvancedOptions.Visible = false;
                    this.linkAdvancedOptions.Text     = "Display advanced options";
                    txtParentVersion.Text             = string.Empty;
                    chkUseRemote.Checked = false;
                    chkUseLocal.Checked  = true;

                    this.Size = new Size(539, 147);
                }
            }
            else
            {
                this.groupAdvancedOptions.Visible = true;
                this.linkAdvancedOptions.Text     = "Hide advanced options.";
                this.Size = new Size(539, 267);
                txtParentVersion.Enabled       = false;
                btnSelectParentVersion.Enabled = false;
            }
        }
        private static void SetPrivate_BackgroundEventHandler(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker backgroundWorker = sender as BackgroundWorker; if (backgroundWorker.CancellationPending)
            {
                e.Cancel = true; return;
            }
            Tuple <string, bool> settings = e.Argument as Tuple <string, bool>; string extName = settings.Item1; bool set = settings.Item2;

            try
            {
                List <Country> countries = CountryAdministrator.GetCountries();
                for (int i = 0; i < countries.Count; ++i)
                {
                    if (backgroundWorker.CancellationPending)
                    {
                        e.Cancel = true; return;
                    }
                    Country country = countries[i]; CountryConfigFacade ccf = country.GetCountryConfigFacade();
                    ExtensionSetPrivateAction action = new ExtensionSetPrivateAction(extName, countries[i]._shortName, set);
                    action.PerformAction();
                    if (!action.ActionIsCanceled()) // happens if extension has no content
                    {
                        country.WriteXML(); country.SetCountryConfigFacade(null); country.SetDataConfigFacade(null);
                    }
                    backgroundWorker.ReportProgress(Convert.ToInt32((i + 1.0) / (countries.Count * 1.0) * 100.0));
                }
                if (backgroundWorker.CancellationPending)
                {
                    e.Cancel = true; return;
                }
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); e.Cancel = true; }
        }
        private static void SetExtensionPrivateGlobal(string extName, bool set)
        {
            string message = "Setting components of extension '" + extName + "' to " + (set ? "private" : "'not private'");

            if (EM_AppContext.Instance.IsAnythingOpen(false))
            {
                if (UserInfoHandler.GetInfo(message + " requires all countries to be closed." + Environment.NewLine + "All open countries will be closed.",
                                            MessageBoxButtons.OKCancel) == DialogResult.Cancel)
                {
                    return;
                }
                EM_AppContext.Instance.CloseAllMainForms(false, false);
            }
            if (EM_AppContext.Instance.IsAnythingOpen(false))
            {
                return;                                               // user may have refused to save changes for an open country
            }
            using (ProgressIndicator progressIndicator = new ProgressIndicator(SetPrivate_BackgroundEventHandler, message, new Tuple <string, bool>(extName, set)))
            {
                if (progressIndicator.ShowDialog() == DialogResult.OK)
                {
                    UserInfoHandler.ShowSuccess(message + " successfully accomplished.");
                }
            }
        }
コード例 #15
0
        void btnDelete_Click(object sender, EventArgs e)
        {
            if (dgvSwitchablePolicies.SelectedRows.Count != 1)
            {
                return;
            }

            try
            {
                //deleting an existing switchable policy may need to require an update of country files (which is too complex here)
                //example: delete bun*_??: all switches defined for the matching policies of the country would have to be changed from 'switch' to 'toggle'
                //removal in the country files however only takes place on closing the SetPolicySwitchesForm with 'OK' - thus this warning
                VarConfig.SwitchablePolicyRow switchablePolicyRow = (dgvSwitchablePolicies.SelectedRows[0].Tag as VarConfig.SwitchablePolicyRow);
                if (switchablePolicyRow.RowState != DataRowState.Added && UserInfoHandler.GetInfo(_noUpdateInCountriesWarning, MessageBoxButtons.OKCancel) == System.Windows.Forms.DialogResult.Cancel)
                {
                    return;
                }

                switchablePolicyRow.Delete();
                dgvSwitchablePolicies.Rows.Remove(dgvSwitchablePolicies.SelectedRows[0]);
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
            }

            dgvSwitchablePolicies.Update(); //if gridview is not updated it looks weired (text of two rows are displayed in one)
        }
コード例 #16
0
        internal static string StoreFile(string filePath)
        {
            CleanBackupFolder(); //delete all folders which are older than 3 days to avoid that the backup folder gets too big

            try
            {
                FileInfo fileInfo = new FileInfo(filePath);

                //create a backup by copying file to a dated folder (see below) in BackUps-folder
                if (!Directory.Exists(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles)))
                {
                    Directory.CreateDirectory(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles));
                }
                string backUpFolder = fileInfo.Name + "_" + DateTime.Now.ToString("yyyy-MM-dd_H-mm-ss");       //backup-folder is name e.g. VarConfig.xml_2013-12-08_10-30-23
                if (!Directory.Exists(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder)) //is actually rather unlikely
                {
                    Directory.CreateDirectory(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder);
                }

                File.Copy(filePath, EMPath.AddSlash(EMPath.Folder_BackUps(EM_AppContext.FolderEuromodFiles) + backUpFolder) + fileInfo.Name);
                return(backUpFolder);
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
                return(string.Empty);
            }
        }
コード例 #17
0
        void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                foreach (DataGridViewRow row in dgvSwitchablePolicies.Rows)
                {
                    object valueLongName    = row.Cells[colLongName.Name].Value;
                    object valueNamePattern = row.Cells[colNamePattern.Name].Value;
                    if (valueLongName == null || valueLongName.ToString().Trim() == string.Empty ||
                        valueNamePattern == null || valueNamePattern.ToString().Trim() == string.Empty)
                    {
                        UserInfoHandler.ShowError("Row " + row.Index.ToString() + " is not completely defined. Please complete or delete the row.");
                        return;
                    }
                }

                _varConfigFacade._varConfig.AcceptChanges();
                _varConfigFacade.WriteXML();
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception exception)
            {
                UserInfoHandler.ShowException(exception);
            }
        }
コード例 #18
0
        internal IndirectTaxesForm(EM_UI_MainForm _mainForm)
        {
            InitializeComponent();

            try
            {
                mainForm = _mainForm;

                dataSet.Tables.Add(dataTable);
                table.DataSource = dataSet;
                table.DataMember = "IttDataTable";

                LoadTableContent();

                // only after all the data is loaded, add the row numbers and the refresh listeners
                table.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders;
                table.RowsAdded   += new DataGridViewRowsAddedEventHandler(table_RefreshRowNumbers);
                table.RowsRemoved += new DataGridViewRowsRemovedEventHandler(table_RefreshRowNumbers);

                table_RefreshRowNumbers(null, null);
                colName.Frozen = true;
                //colComment.Frozen = true; // this can only happen if it is not the last row!
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); }
        }
コード例 #19
0
        internal VCUsers(VCAPI vcAPI)
        {
            InitializeComponent();

            _vcAPI = vcAPI;

            colRefineRights.Visible  = false;
            colDefaultRight.ReadOnly = false;

            List <UserInfo> userInfos; List <bool> adminRights; List <VCAPI.VC_ACCESS_RIGHTS> defaultRights;

            if (!_vcAPI.GetProjectUserRights(_vcAPI.vc_projectInfo.ProjectId, out userInfos, out adminRights, out defaultRights))
            {
                UserInfoHandler.ShowError(_vcAPI.GetErrorMessage());
                return;
            }

            colDefaultRight.Items.Add(VC_ACCESS_DOWNLOAD); colDefaultRight.Items.Add(VC_ACCESS_UPLOAD);
            for (int i = 0; i < userInfos.Count; ++i)
            {
                ExtUserRightInfo tag = new ExtUserRightInfo {
                    userInfo = userInfos.ElementAt(i)
                };
                tag.defaultUnitRight     = defaultRights.ElementAt(i);
                tag.hasProjectAdminRight = adminRights.ElementAt(i);
                AddUserRow(tag);
            }
        }
コード例 #20
0
        void GetFromClipboard()
        {
            try
            {
                string   clipboardText          = Clipboard.GetText();
                string[] clipboardLines         = clipboardText.Split('\n');
                int      indexRow               = table.CurrentCell.RowIndex;
                bool     addedExtraLine         = (indexRow == dataTable.Rows.Count);
                int      currentCellColumnIndex = table.Columns[table.CurrentCell.ColumnIndex].DisplayIndex;
                foreach (string line in clipboardLines)
                {
                    if (line.Length > 0)
                    {
                        DataRow row;
                        if (indexRow == dataTable.Rows.Count)
                        {
                            row = dataTable.NewRow();
                            dataTable.Rows.Add(row);
                        }
                        else
                        {
                            row = dataTable.Rows[indexRow];
                        }

                        string[] clipboardCells = line.Split('\t').Select(p => p.Trim()).ToArray(); // trim cells to avoid unwanted new lines and spaces at the end
                        for (int indexColumn = 0; indexColumn < clipboardCells.GetLength(0); ++indexColumn)
                        {
                            if (currentCellColumnIndex + indexColumn < table.ColumnCount)
                            {
                                // if one of the default columns
                                if (currentCellColumnIndex + indexColumn == table.Columns[colName.Name].DisplayIndex ||
                                    currentCellColumnIndex + indexColumn == table.Columns[colComment.Name].DisplayIndex)
                                {
                                    row[GetYearColumnIndexByDisplayIndex(currentCellColumnIndex + indexColumn)] = clipboardCells[indexColumn];
                                }
                                else                                                                                                                             // if one of the system columns
                                {
                                    row[GetYearColumnIndexByDisplayIndex(currentCellColumnIndex + indexColumn)] = clipboardCells[indexColumn].Replace(',', '.'); // fix decimal separator
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        (table[0, indexRow].OwningRow.DataBoundItem as DataRowView).Row.EndEdit();
                        indexRow++;
                    }
                    else
                    {
                        break;
                    }
                }
                if (addedExtraLine)
                {
                    table.Rows.RemoveAt(table.Rows.Count - 2);                    // get rid of the extra line added by the grid
                }
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); return; }
        }
        internal bool RefreshExchangeRates(List <ExchangeRate> exRates)
        {
            try
            {
                for (int i = 0; i < exRates.Count; ++i) // "make efficient", i.e. if country, rates and default are equal, gather the concerned systems in one rate
                {
                    for (int j = i - 1; j >= 0; --j)
                    {
                        if (exRates[i].Equals(exRates[j]))
                        {
                            exRates[i].AddToValidFor(exRates[j].ValidFor); exRates[j].ValidFor = string.Empty; break;
                        }
                    }
                }

                _exchangeRatesConfig.ExchangeRates.Rows.Clear();
                _exchangeRatesConfig.AcceptChanges();
                foreach (ExchangeRate exRate in exRates)
                {
                    if (exRate.ValidFor != string.Empty)
                    {
                        _exchangeRatesConfig.ExchangeRates.AddExchangeRatesRow(
                            exRate.Country, exRate.June30, exRate.YearAverage, exRate.FirstSemester, exRate.SecondSemester, exRate.Default, exRate.ValidFor);
                    }
                }
                _exchangeRatesConfig.AcceptChanges();
                return(true);
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); return(false); }
        }
コード例 #22
0
        internal static void CleanLogFile()
        {
            string logFile = new EMPath(EM_AppContext.FolderEuromodFiles).GetEmLogFilePath();

            EM_UI_MainForm mainForm = EM_AppContext.Instance.GetActiveCountryMainForm();

            if (mainForm != null)
            {
                mainForm.Cursor = Cursors.WaitCursor;
            }
            string error = AdaptLogFile(logFile);

            if (mainForm != null)
            {
                mainForm.Cursor = Cursors.Default;
            }

            if (error == string.Empty)
            {
                UserInfoHandler.ShowSuccess("Successfully cleaned " + logFile + ".");
            }
            else
            {
                UserInfoHandler.ShowError("Failed to clean " + logFile + ":" + Environment.NewLine + error);
            }
        }
コード例 #23
0
ファイル: WtApi.cs プロジェクト: UlrichFreiberg/WrapTrack.Stf
        /// <summary>
        /// The end user collection.
        /// </summary>
        /// <param name="userId">
        /// The user id.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public bool EndUserCollection(int userId)
        {
            var handler = new UserInfoHandler(StfLogger, WtApiConfiguration);
            var retVal  = handler.EndUserCollection(userId);

            return(retVal);
        }
コード例 #24
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtImportFolder.Text == string.Empty)
            {
                UserInfoHandler.ShowError("Please select a version to compare with."); return;
            }

            Cursor = Cursors.WaitCursor;
            bool   hasInsertedPath = true;
            string insertedPath    = txtImportFolder.Text;
            string selectedPath    = String.Empty;

            if (CountryAdministrator.ConsiderOldAddOnFileStructure(_fromAddOn))
            {
                _importCountry = ImportExportAdministrator.GetImportAddOn_OldStyle(out selectedPath, hasInsertedPath, insertedPath);
            }
            else
            {
                _importCountry = ImportExportAdministrator.GetImportCountry(out selectedPath, _fromAddOn, hasInsertedPath, insertedPath);
            }
            if (_importCountry == null)
            {
                Cursor = Cursors.Default;
                return;
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #25
0
        private void menuItemDelSys_Click(object sender, EventArgs e = null)
        {
            string system; DataGridViewRow clickedRow; if (!menuItem_GetActionInfo(sender, out system, out clickedRow))

            {
                return;
            }

            try
            { // just try to remove the system from any row of this country, thus move can be realised as del+add
                string country = clickedRow.Cells[colCountry.Name].Value.ToString().ToLower();
                foreach (DataGridViewRow row in dgvRates.Rows)
                {
                    if (row.Cells[colCountry.Name].Value.ToString().ToLower() != country || row.Cells[colValidFor.Name].Value == null)
                    {
                        continue;
                    }
                    bool calledFromMove = e == null; // if called from Move suppress storing undo action, to store it together with the following Add
                    if (!dgvRates.SetCellValue(row, colValidFor.Name,
                                               ExchangeRate.RemoveFromValidFor(row.Cells[colValidFor.Name].Value.ToString(), system),
                                               !calledFromMove))
                    {
                        ShowGridLastError();
                    }
                }
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); }
        }
コード例 #26
0
        void btnOK_Click(object sender, EventArgs e)
        {
            if (!dgvHICP.verifyNumericValues(out string problems))
            {
                UserInfoHandler.ShowError("There are cells with invalid values!" + Environment.NewLine + problems);
                return;
            }

            updatedHICPs = new List <Tuple <string, int, double, string> >();
            DataTable dtHICP = dgvHICP.GetDataTable();

            foreach (DataRow r in dtHICP.Rows)
            {
                foreach (DataColumn c in dtHICP.Columns)
                {
                    if (c.Caption == colCountry || c.Caption == colComment || c.Caption == colID || r.IsNull(c.Caption))
                    {
                        continue;
                    }
                    try
                    {
                        updatedHICPs.Add(new Tuple <string, int, double, string>(
                                             r.Field <string>(colCountry),          // country
                                             Convert.ToInt32(c.Caption),            // year
                                             double.Parse(r[c.Caption].ToString()), // value
                                             r.Field <string>(colComment)));        // comment
                    }
                    catch (Exception exception) { UserInfoHandler.ShowException(exception, $"{r.Field<string>(colCountry)} / {c.Caption}", false); return; }
                }
            }

            DialogResult = DialogResult.OK;
            Close();
        }
コード例 #27
0
 void VariablesForm_KeyUp(object sender, KeyEventArgs keyEventArgs)
 {
     if (keyEventArgs.Control && keyEventArgs.KeyCode == Keys.S)
     {
         if (_isReadOnly)
         {
             UserInfoHandler.ShowInfo("File is in read-only mode.");
         }
         else
         {
             SaveChanges();
         }
     }
     if (keyEventArgs.Control && keyEventArgs.KeyCode == Keys.Z)
     {
         PerformAction(new VariablesUndoAction(_undoManager));
     }
     if (keyEventArgs.Control && keyEventArgs.KeyCode == Keys.Y)
     {
         PerformAction(new VariablesRedoAction(_undoManager));
     }
     if (treeAcronyms.Focused == true)
     {
         _acronymManager.HandleEnterKey(keyEventArgs);
     }
 }
コード例 #28
0
        private bool AddYear(int year = -1)
        {
            try
            {
                bool showWarning = false;
                if (year == -1)
                {
                    showWarning = true;
                    year        = Convert.ToInt32(updwnYearToAdd.Value);
                    if (GetExistingYears().Contains(year))
                    {
                        UserInfoHandler.ShowError(year + " already exits."); return(false);
                    }
                }
                int preCount = GetExistingYears().Where(y => y < year).ToList().Count();

                if (!dgvHICP.AddColumn(showWarning, year.ToString(), typeof(double), preCount + 1))
                {
                    ShowGridLastError(); return(false);
                }
                dgvHICP.pasteableColumns.Add(year.ToString());
                updwnYearToAdd.Value = year + 1;
                cmbYearToDelete.Items.Add(year);

                FormatGridViewColumns(year.ToString());
                return(true);
            }
            catch (Exception exception) { UserInfoHandler.ShowException(exception); return(false); }
        }
コード例 #29
0
        private void lstCountries_SelectedIndexChanged(object sender = null, EventArgs e = null)
        {
            if (radShowYears.Checked)
            {
                return;
            }

            Cursor = Cursors.WaitCursor;
            try
            {
                lstSystems.Items.Clear();
                foreach (string c in lstCountries.SelectedItems)
                {
                    if (!ccSystems.ContainsKey(c))
                    {
                        ccSystems.Add(c, (from s in CountryAdministrator.GetCountryConfigFacade(c).GetSystemRowsOrdered() select s.Name).ToList());
                    }
                    foreach (string s in ccSystems[c])
                    {
                        lstSystems.Items.Add(s);
                    }
                }
            }
            catch (Exception exception) { UserInfoHandler.ShowError(exception.Message); }
            Cursor = Cursors.Default;
        }
コード例 #30
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         string path = Path.Combine(EM_AppContext.FolderOutput, "ReleaseValidation_HHVarInfo.txt");
         using (StreamWriter sw = new StreamWriter(path))
         {
             foreach (DataGridViewRow row in dgvVar.Rows)
             {
                 string line = $"{row.Cells[0].Value.ToString()}\t";
                 string info = row.Cells[1].Value.ToString();
                 if (!info.Contains(SEPARATOR))
                 {
                     line += info;
                 }
                 else
                 {
                     foreach (string i in info.Split(SEPARATOR.First()))
                     {
                         line += $"{i.Trim()}\t";
                     }
                 }
                 sw.WriteLine(line.Trim());
             }
         }
         UserInfoHandler.ShowSuccess($"Saved to {path}");
     }
     catch (Exception exception) { UserInfoHandler.ShowException(exception); }
 }