Exemplo n.º 1
0
        /// <summary>
        /// Handles the Click event of the ToolStripButtonAddCode control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ToolStripButtonAddCode_Click(object sender, System.EventArgs e)
        {
            if (this.ListBoxCodeList.SelectedIndex > -1)
            {
                using (SqlCodeRepositoryUpdate form = new SqlCodeRepositoryUpdate("Add", this.ListBoxCodeList.SelectedItem.ToString(), this.RichTextBoxQueryData.Text))
                {
                    DialogResult result = form.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        SqlQuery item = new SqlQuery();
                        item.SqlName = form.SqlCodeDescription;
                        item.SqlCode = form.SqlCode;

                        this.SqlCodeRepositoryQueries.QueryItems.Add(item);
                        this.LoadListBoxCodeList();
                        this.ListBoxCodeList.SelectedItem = item.SqlName;
                        this.SaveSqlRepositoryQueries();
                    }
                }
            }
            else
            {
                MessageBox.Show(
                    "No code item selected!",
                    "Information",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
            }
        }
Exemplo n.º 2
0
        public SqlCodeRepositoryUpdate Constructor(
            string action,
            string sqlCodeDescription,
            string sqlCode
            )
        {
            SqlCodeRepositoryUpdate target
                = new SqlCodeRepositoryUpdate(action, sqlCodeDescription, sqlCode);

            return(target);
            // TODO: add assertions to method SqlCodeRepositoryUpdateTest.Constructor(String, String, String)
        }
Exemplo n.º 3
0
        /// <summary>
        /// Handles the Click event of the ToolStripButtonUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        private void ToolStripButtonUpdate_Click(object sender, System.EventArgs e)
        {
            if (this.ListBoxCodeList.SelectedIndex > -1)
            {
                SqlQuery itemOriginal = this.SqlCodeRepositoryQueries.QueryItems.Find(
                    delegate(SqlQuery query)
                {
                    return(query.SqlName == this.ListBoxCodeList.SelectedItem.ToString());
                });

                if (itemOriginal != null)
                {
                    using (SqlCodeRepositoryUpdate form = new SqlCodeRepositoryUpdate(
                               "Update",
                               this.ListBoxCodeList.SelectedItem.ToString(),
                               this.RichTextBoxQueryData.Text))
                    {
                        DialogResult result = form.ShowDialog();
                        if (result == DialogResult.OK)
                        {
                            SqlQuery item = new SqlQuery();
                            item.SqlName = form.SqlCodeDescription;
                            item.SqlCode = form.SqlCode;

                            this.SqlCodeRepositoryQueries.QueryItems.Remove(itemOriginal);
                            this.SqlCodeRepositoryQueries.QueryItems.Add(item);

                            this.LoadListBoxCodeList();
                            this.ListBoxCodeList.SelectedItem = item.SqlName;
                            this.SaveSqlRepositoryQueries();
                        }
                    }
                }
                else
                {
                    MessageBox.Show(
                        "Selected item not found!",
                        "Error!",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show(
                    "No code item selected!",
                    "Information",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Exclamation);
            }
        }