Пример #1
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;
        }
Пример #2
0
        /// <summary>
        /// 取得一筆資料 (DataRow)
        /// </summary>
        /// <param name="Title">要查詢的條件 (如果是:SqlDataTable 就是SQLCommandName,如果是SqlConnectionTable 就使用DataSourceName)</param>
        /// <returns></returns>
        public DataRow GetOne(string Title)
        {
            DataRow result = null;

            if (SqlTabData is SQLStoreDataSet.SqlConnectionTableDataTable) //如果是:SqlConnectionTableDataTable 就是DataSourceName
            {
                SQLStoreDataSet.SqlConnectionTableDataTable c = SqlTabData as SQLStoreDataSet.SqlConnectionTableDataTable;
                DataRow[] dr = c.Select(string.Format("DataSourceName='{0}'", Title));
                if (dr.Length > 0)
                {
                    result = dr[0];
                }
            }
            else if (SqlTabData is SQLStoreDataSet.SQLTableDataTable) //如果是SQLTableDataTable 就使用SQLCommandName
            {
                SQLStoreDataSet.SQLTableDataTable dt = SqlTabData as SQLStoreDataSet.SQLTableDataTable;
                DataRow[] dr = dt.Select(string.Format("SQLCommandName='{0}'", Title));
                if (dr.Length > 0)
                {
                    result = dr[0];
                }
            }
            return(result);
        }