예제 #1
0
        private void Save()
        {
            try
            {
                //throws ArgumentException if any fields are invalid
                var newConfig = GetConfigFromUi();
                newConfig.Validate();
                //throws ArgumentException if config has a duplicate name
                if (_action == ConfigAction.Edit)
                {
                    _mainControl.EditSelectedConfiguration(newConfig);
                }
                else
                {
                    _mainControl.AddConfiguration(newConfig);
                }
            }
            catch (ArgumentException e)
            {
                ShowErrorDialog(e.Message);
                return;
            }

            Close();
        }
예제 #2
0
        private void Save()
        {
            AutoQcConfig newConfig;

            try
            {
                newConfig = GetConfigFromUi();
            }
            catch (ArgumentException e)
            {
                ShowErrorDialog(e.Message);
                return;
            }

            if (!ValidateConfigName(newConfig) || !ValidateConfig(newConfig))
            {
                return;
            }

            if (string.IsNullOrEmpty(_config.Name))
            {
                // If the original configuration that we started with does not have a name,
                // it means this is a brand new configuration
                newConfig.Created  = DateTime.Now;
                newConfig.Modified = DateTime.Now;

                _mainControl.AddConfiguration(newConfig);
            }

            else if (!newConfig.Equals(_config))
            {
                // If the original configuration has a name it means the user is editing an existing configuration
                // and some changes have been made.
                newConfig.Created  = _config.Created;
                newConfig.Modified = DateTime.Now;

                _mainControl.UpdateConfiguration(_config, newConfig);
            }

            Close();
        }