Пример #1
0
        private void btnUpdateSQL_Click(object sender, RoutedEventArgs e)
        {
            SQLStoreClass <SQLStoreDataSet.SQLTableDataTable> SqlStore =
                new SQLStoreClass <SQLStoreDataSet.SQLTableDataTable>();
            int start = this.Title.IndexOf('(');
            int end   = this.Title.IndexOf(')');

            SqlStore.Edit(
                Title.Substring(start + 1, (end - start) - 1),
                txtSQL.Text,
                string.Empty,
                string.Empty);
            MessageBox.Show("儲存成功!", this.Title, MessageBoxButton.OK, MessageBoxImage.Information);
        }
Пример #2
0
        /// <summary>
        /// 執行 SQL
        /// </summary>
        /// <param name="sender"></param>
        void ExecuteSQL(object sender)
        {
            this.Visibility = Visibility.Visible;

            SQLStoreClass <SQLStoreDataSet.SQLTableDataTable> SqlStore =
                new SQLStoreClass <SQLStoreDataSet.SQLTableDataTable>();
            var SqlObj = SqlStore.GetOneDataByMenuTitle(
                (sender as WindowsForm.MenuItem).Text,
                new { SQL = "", SQLCommandName = "" });

            string SqlStatement = SqlObj.SQL;

            txtSQL.Text = SqlStatement;

            this.Title = this.Title.Replace("(#)", string.Format("({0})", SqlObj.SQLCommandName));

            dataGrid1.ItemsSource = GetData(SqlStatement);
        }
Пример #3
0
        private void btnOK_Click(object sender, RoutedEventArgs e)
        {
            if (txtMenuTitle.Text.Trim() == "")
            {
                MessageBox.Show("請輸入一個易記的名稱。");
                return;
            }

            try
            {
                SQLStoreClass <SQLStoreDataSet.SQLTableDataTable> SqlStore =
                    new SQLStoreClass <SQLStoreDataSet.SQLTableDataTable>();
                SqlStore.Add(this.txtMenuTitle.Text, this.Sql, string.Empty, string.Empty);
            }
            finally
            {
                this.DialogResult = true;
                this.Close();
            }
        }
Пример #4
0
        private void InitializeMenu()
        {
            SQLStoreClass <SQLStoreDataSet.SQLTableDataTable> SqlStore =
                new SQLStoreClass <SQLStoreDataSet.SQLTableDataTable>();
            int iCount = SqlStore.getSQLCount + 5, i = 0;

            SQLStoreDataSet.SQLTableDataTable SqlTable = SqlStore.GetAllData();
            WindowsForm.MenuItem[]            menuItem = new WindowsForm.MenuItem[iCount];
            foreach (DataRow dr in SqlTable.Rows)
            {
                menuItem[i] = new WindowsForm.MenuItem(dr["SQLCommandName"].ToString(), (a, c) => { ClearScreen(); ExecuteSQL(a); });
                i++;
            }
            menuItem[iCount - 5] = new WindowsForm.MenuItem("-");
            menuItem[iCount - 4] = new WindowsForm.MenuItem("連線設定(C&)", (a, c) => { ConnectionWindow cw = new ConnectionWindow(); cw.ShowDialog(); });
            menuItem[iCount - 3] = new WindowsForm.MenuItem("關於此程式(&B)", (a, c) => { AboutWindow win = new AboutWindow(); win.ShowDialog(); });
            menuItem[iCount - 2] = new WindowsForm.MenuItem("-");
            menuItem[iCount - 1] = new WindowsForm.MenuItem("結束(&X)", (a, c) => { this.Close(); });

            this.cm_Menu = new System.Windows.Forms.ContextMenu(menuItem);
            this.m_notifyIcon.ContextMenu = cm_Menu;
        }