Esempio n. 1
0
        private void EnableMainRepositorie(string Language)
        {
            if (!Enum.IsDefined(typeof(HardwareTypeEnum), Settings.Default.HardwareType))
            {
                return;
            }

            HardwareDetails det = HardwareDetailsFactory.CreateDetails((HardwareTypeEnum)Enum.Parse(typeof(HardwareTypeEnum), Settings.Default.HardwareType));

            bool found = false;
            int  i     = 0;

            while ((i < _repositoryLocations.MainRepositories.Count) && (!found))
            {
                if (_repositoryLocations.MainRepositories[i].Name.Equals("Main_Type" + det.RepositoryType + "_" + Language, StringComparison.CurrentCultureIgnoreCase))
                {
                    found = true;
                }
                else
                {
                    i++;
                }
            }

            if (found)
            {
                foreach (RepositoryLocationInfo info in _repositoryLocations.MainRepositories)
                {
                    if (info.Name.StartsWith("Main_Type" + det.RepositoryType + "_" + Language, StringComparison.CurrentCultureIgnoreCase))
                    {
                        info.Enabled = true;
                    }
                    else
                    if (info.Name.StartsWith("Main_", StringComparison.CurrentCultureIgnoreCase))
                    {
                        info.Enabled = false;
                    }
                }

                _repositoryLocations.SaveRepository();
            }
            else
            {
                foreach (RepositoryLocationInfo info in _repositoryLocations.MainRepositories)
                {
                    if (info.Name.StartsWith("Main_Type" + det.RepositoryType + "_English", StringComparison.CurrentCultureIgnoreCase))
                    {
                        info.Enabled = true;
                    }
                    else
                    if (info.Name.StartsWith("Main_", StringComparison.CurrentCultureIgnoreCase))
                    {
                        info.Enabled = false;
                    }
                }

                _repositoryLocations.SaveRepository();
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            string result = string.Empty;

            if (DataIsValid(out result))
            {
                if (mainRepositoryBindingSource.DataSource != null)
                {
                    RepositoryLocations reps = (RepositoryLocations)mainRepositoryBindingSource.DataSource;
                    reps.SaveRepository();

                    btnSave.Enabled = btnCancel.Enabled = false;

                    if (MessageBox.Show(Resources.MessageBox_RepositoryRestartConfirm, Resources.MessageBox_RepositoryRestartCaption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Application.Restart();
                    }
                }
            }
            else
            {
                MessageBox.Show(Resources.MessageBox_RepositoryInfoInvalid + result, Resources.MessageBox_RepositoryInfoInvalidCaption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }