예제 #1
0
        /// <summary>
        /// Event handler for configure tab save  button.
        /// </summary>
        /// <param name="sender">The sender object</param>
        /// <param name="e">The event arguments</param>
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (newClicked == true)
                {
                    newClicked = false;
                    CswProfile profile = combProfile.SelectedItem as CswProfile;
                    string url = "";
                    url = txtURL.Text.Trim();
                    string name = "";
                    name = txtDisplayName.Text.Trim();
                    if (url.Length == 0)
                    {
                        MessageBox.Show(resourceManager.GetString("urlEmptyError"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        CswCatalog catalog = new CswCatalog(url, name, profile);
                        _cswManager.addCatalog(catalog);
                        MessageBox.Show(resourceManager.GetString("catalogAdded"), "Success", MessageBoxButtons.OK, MessageBoxIcon.None);
                        cleardata();
                        adddata();
                        catalog.resetConnection();
                        lblCatalogs.Text = resourceManager.GetString("catalogsTxt") + " (" + lstCatalog.Items.Count + ")";
                        _isCatalogListDirty = true;
                    }
                }
                else if (lstCatalog.SelectedItem == null)
                {
                    MessageBox.Show(resourceManager.GetString("resultNotSelected"));
                }
                else
                {
                    CswCatalog catalog = (CswCatalog)lstCatalog.SelectedItem;
                    int index = lstCatalog.SelectedIndex;
                    CswProfile profile = combProfile.SelectedItem as CswProfile;
                    _cswManager.updateCatalog(catalog, txtDisplayName.Text, txtURL.Text, profile);
                    cleardata();
                    adddata();
                    catalog.resetConnection();
                    lstCatalog.SelectedIndex = index;
                    MessageBox.Show(resourceManager.GetString("dataSaved"), "Success", MessageBoxButtons.OK, MessageBoxIcon.None);
                    _isCatalogListDirty = true;
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(resourceManager.GetString("dataSavedFailed"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }
        /// <summary>
        /// Save/Update a catalog
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void SaveCatalogButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (_newClicked == true)
                {
                    CswProfile profile = catalogProfileComboBox.SelectedItem as CswProfile;

                    string url = "";
                    url = catalogUrlTextBox.Text.Trim();
                    string name = "";
                    name = catalogDisplayNameTextBox.Text.Trim();
                    if (url.Length == 0)
                    {
                        ShowErrorMessageBox(StringResources.UrlIsEmpty);
                    }
                    else
                    {
                        CswCatalog catalog = new CswCatalog(url, name, profile);
                        catalog.resetConnection();
                        _cswManager.addCatalog(catalog);
                        ClearData();
                        AddData();
                        catalogListBox.SelectedIndex = catalogListBox.Items.IndexOf(catalog);
                        _newClicked = false;
                        MessageBox.Show(StringResources.CatalogAddedSuccessfully, StringResources.Success, MessageBoxButtons.OK, MessageBoxIcon.None);
                    }
                }
                else if (catalogListBox.SelectedItem == null)
                {
                    MessageBox.Show(StringResources.SelectAnItemToUpdate);
                }
                else
                {
                    CswCatalog catalog = (CswCatalog)catalogListBox.SelectedItem;
                    int index = catalogListBox.SelectedIndex;
                    CswProfile profile = catalogProfileComboBox.SelectedItem as CswProfile;
                    _cswManager.updateCatalog(catalog, catalogDisplayNameTextBox.Text, catalogUrlTextBox.Text, profile);
                    catalog.resetConnection();
                    ClearData();
                    AddData();
                    catalogListBox.SelectedIndex = index;
                    MessageBox.Show(StringResources.CatalogSavedSuccessfully, StringResources.Success, MessageBoxButtons.OK, MessageBoxIcon.None);
                }
                _isCatalogListDirty = true;

            }
            catch (Exception ex)
            {
                ShowErrorMessageBox(ex.Message);
            }
            finally
            {
                UpdateCatalogListLabel();
            }
        }