Пример #1
0
        private void LoadDataSet(bool forceLoad)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                if (forceLoad || bufferedDataSet == null)
                {
                    LocalizedCategoryTableAdapter categoryAdapter = new LocalizedCategoryTableAdapter();
                    categoryAdapter.Fill(this.symbolDataSet.LocalizedCategory, cultureName);

                    LocalizedSymbolTableAdapter symbolAdapter = new LocalizedSymbolTableAdapter();
                    symbolAdapter.Fill(this.symbolDataSet.LocalizedSymbol, cultureName);

                    bufferedDataSet = symbolDataSet.Copy() as SymbolDataSet;
                }
                else
                {
                    symbolDataSet.Merge(bufferedDataSet);
                }
            }
            catch (Exception ex)
            {
                ReportError(ex.Message.ToString());
            }

            pickedSymbol = symbolDataSet.LocalizedSymbol.FindBySymbolId(this.currentSymbolId);

            RefreshCategoryListView();

            this.EnableButtons();

            Cursor.Current = Cursors.Default;
        }
Пример #2
0
        private void buttonDeleteCategory_Click(object sender, EventArgs e)
        {
            ListView.SelectedListViewItemCollection selectedItems      = this.listViewCategory.SelectedItems;
            SymbolDataSet.LocalizedCategoryRow      currentCategoryRow = selectedItems[0].Tag as SymbolDataSet.LocalizedCategoryRow;

            // Initializes the variables to pass to the MessageBox.Show method.

            string            message = string.Format(Resources.ConfirmDeletionMessage, currentCategoryRow.Name);
            string            caption = Resources.ConfirmDeletionCaption;
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult      result;

            // Displays the MessageBox.

            result = MessageBox.Show(this, message, caption, buttons,
                                     MessageBoxIcon.Question);

            if (result == DialogResult.Yes)
            {
                try
                {
                    LocalizedCategoryTableAdapter categoryAdapter = new LocalizedCategoryTableAdapter();
                    categoryAdapter.Connection.Open();

                    SqlCommand sqlUpdateCommand = new SqlCommand();
                    sqlUpdateCommand.Connection  = categoryAdapter.Connection;
                    sqlUpdateCommand.CommandText = @"UPDATE Symbol SET IsActive = 'false' WHERE (CategoryId = @CategoryId) ";

                    sqlUpdateCommand.Parameters.Add(new SqlParameter("@CategoryId", System.Data.SqlDbType.Int, 0, "CategoryId"));
                    sqlUpdateCommand.Parameters["@CategoryId"].Value = currentCategoryRow.CategoryId;
                    sqlUpdateCommand.ExecuteNonQuery();

                    sqlUpdateCommand.CommandText = @"UPDATE Category SET IsActive = 'false' WHERE (CategoryId = @CategoryId) ";
                    sqlUpdateCommand.ExecuteNonQuery();

                    categoryAdapter.Connection.Close();

                    this.LoadDataSet();
                }
                catch (Exception ex)
                {
                    ReportError(ex.Message.ToString());
                }
            }
        }
Пример #3
0
        private void LoadDataSet()
        {
            Cursor.Current = Cursors.WaitCursor;

            int selectedCategory = 0;

            if (this.listViewCategory.SelectedIndices.Count > 0)
            {
                selectedCategory = this.listViewCategory.SelectedIndices[0];
            }

            int selectedSymbol = 0;

            if (this.listViewSymbol.SelectedIndices.Count > 0)
            {
                selectedSymbol = this.listViewSymbol.SelectedIndices[0];
            }

            try
            {
                LocalizedCategoryTableAdapter cultureAdapter = new LocalizedCategoryTableAdapter();
                cultureAdapter.Fill(this.symbolDataSet.LocalizedCategory, cultureName);

                LocalizedSymbolTableAdapter symbolAdapter = new LocalizedSymbolTableAdapter();
                symbolAdapter.Fill(this.symbolDataSet.LocalizedSymbol, cultureName);
            }
            catch (Exception ex)
            {
                ReportError(ex.Message.ToString());
            }

            RefreshCategoryListView();

            this.listViewSymbol.Clear();
            this.imageListSymbol.Images.Clear();

            if (this.listViewCategory.Items.Count > 0)
            {
                if (selectedCategory >= this.listViewCategory.Items.Count)
                {
                    selectedCategory = this.listViewCategory.Items.Count - 1;
                }

                this.listViewCategory.SelectedIndices.Clear();
                this.listViewCategory.SelectedIndices.Add(selectedCategory);
            }

            if (this.listViewSymbol.Items.Count > 0)
            {
                if (selectedSymbol >= this.listViewSymbol.Items.Count)
                {
                    selectedSymbol = this.listViewSymbol.Items.Count - 1;
                }

                this.listViewSymbol.SelectedIndices.Clear();
                this.listViewSymbol.SelectedIndices.Add(selectedSymbol);
            }

            this.EnableButtons();

            Cursor.Current = Cursors.Default;
        }