//Ctrl + F Find Column public void FindColumn(Window frmParent) { PromptForm._frmParent = frmParent; string tableName = ""; MessageBoxResult result = PromptForm.ShowCombobox("FindColumn", "Table Name", ref tableName); if (result == MessageBoxResult.Cancel) { return; } string colName = ""; result = PromptForm.ShowText("FindColumn", "Column Name", ref colName); if (result == MessageBoxResult.Cancel) { return; } DataSet ds = SQLDBUtil.GetAllTableColumns(tableName, colName); DataTable dtData = SQLDBUtil.GetDataTableByDataSet(ds); if (dtData == null) { return; } dtData.TableName = tableName; ShowResultData(frmParent, dtData, ""); }
public void AddIndex() { string str = MethodInfo.GetCurrentMethod().Name; string strTblName = ""; MessageBoxResult result = PromptForm.ShowCombobox(str, "Table Name", ref strTblName); if (result == MessageBoxResult.Cancel) { return; } string strColName = ""; result = PromptForm.ShowText(str, "Column Name", ref strColName); if (result == MessageBoxResult.Cancel) { return; } string strIdxName = ""; result = PromptForm.ShowText(str, "Index Name", ref strIdxName); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("CREATE INDEX {0} ON {1}({2})", strIdxName, strTblName, strColName)); ShowMessenger(iResult); }
public void AlterColumn() { string str = MethodInfo.GetCurrentMethod().Name; string strTblName = ""; MessageBoxResult result = PromptForm.ShowText("Table Name", "Table Name", ref strTblName); if (result == MessageBoxResult.Cancel) { return; } string strColName = ""; result = PromptForm.ShowText("Column Name", "Column Name", ref strColName); if (result == MessageBoxResult.Cancel) { return; } string strColType = SQLDBUtil.GetColumnDBType(strTblName, strColName); result = PromptForm.ShowText("Column Type", "Column Type", ref strColType); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("ALTER TABLE {0} ALTER COLUMN {1} {2}", strTblName, strColName, strColType)); ShowMessenger(iResult); }
public void RenameColumn() { string str = MethodInfo.GetCurrentMethod().Name; string strTblName = ""; MessageBoxResult result = PromptForm.ShowText(str, "Table Name", ref strTblName); if (result == MessageBoxResult.Cancel) { return; } string strColOld = ""; result = PromptForm.ShowText(str, "Column Name", ref strColOld); if (result == MessageBoxResult.Cancel) { return; } string strColNew = ""; result = PromptForm.ShowText(str, "New Column Name", ref strColNew); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("ALTER TABLE {0} RENAME COLUMN {1} TO {2}", strTblName, strColOld, strColNew)); ShowMessenger(iResult); }
//Ctrl + Shift + A : Create Module public void CreateMoudle() { string str = MethodInfo.GetCurrentMethod().Name; string strModuleName = ""; MessageBoxResult result = PromptForm.ShowText(str, "Module Name", ref strModuleName); if (result == MessageBoxResult.Cancel) { return; } string strModuleDesc = ""; result = PromptForm.ShowText(str, "Module Descreiption", ref strModuleDesc); if (result == MessageBoxResult.Cancel) { return; } string strModuleCode = ""; result = PromptForm.ShowText(str, "Module Code", ref strModuleCode); if (result == MessageBoxResult.Cancel) { return; } if (!string.IsNullOrEmpty(strModuleName) && !string.IsNullOrEmpty(strModuleDesc) && !string.IsNullOrEmpty(strModuleCode)) { string strQuery = SQLApp.GetFile(strPath + "CreateModule.sql"); strQuery = strQuery.Replace("@ModuleName@", strModuleName); strQuery = strQuery.Replace("@ModuleCode@", strModuleCode); strQuery = strQuery.Replace("@ModuleDesc@", strModuleDesc); int iResult = SQLDBUtil.ExecuteNonQuery(strQuery); ShowMessenger(iResult); } }
//Alt + 1 View Data by No public void GetViewDataByNo(Window frmParent) { PromptForm._frmParent = frmParent; string tableName = ""; MessageBoxResult result = PromptForm.ShowCombobox("ViewDataByNo", "Table Name", ref tableName); if (result == MessageBoxResult.Cancel) { return; } string colName = ""; result = PromptForm.ShowText("ViewDataByNo", "Column Name", ref colName); if (result == MessageBoxResult.Cancel) { return; } if (string.IsNullOrEmpty(colName)) { colName = "*"; } string strWhere = string.Empty; if (SQLDBUtil.ColumnIsExistInTable(tableName, "AAStatus")) { strWhere = "AAStatus = 'Alive'"; } string strQuery = SQLDBUtil.GenerateQuery(tableName, strWhere, colName); //DataTable dtData = SQLDBUtil.GetDataByTable(tableName, strWhere, colName); //if (dtData == null) return; //dtData.TableName = tableName; ShowResultData(frmParent, null, strQuery); }
public void DropForeignKey() { string str = MethodInfo.GetCurrentMethod().Name; string strTblName = ""; MessageBoxResult result = PromptForm.ShowText("Table Name", "Table Name", ref strTblName); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("ALTER TABLE {0} DROP CONSTRAINT FK_{1}", strTblName)); ShowMessenger(iResult); }
public void DropDatabase() { string str = MethodInfo.GetCurrentMethod().Name; string strDBName = ""; MessageBoxResult result = PromptForm.ShowText("Database Name", "Database Name", ref strDBName); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("DROP DATABASE {0}", strDBName)); ShowMessenger(iResult); }
public void RenameTable() { string str = MethodInfo.GetCurrentMethod().Name; string strTblName = ""; MessageBoxResult result = PromptForm.ShowText(str, "Table Name", ref strTblName); if (result == MessageBoxResult.Cancel) { return; } string strToTblName = ""; result = PromptForm.ShowText(str, "New Table Name", ref strToTblName); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("RENAME TABLE {0} TO {1}", strTblName, strToTblName)); ShowMessenger(iResult); }
public void DropIndex() { string str = MethodInfo.GetCurrentMethod().Name; string strTblName = ""; MessageBoxResult result = PromptForm.ShowText("Table Name", "Table Name", ref strTblName); if (result == MessageBoxResult.Cancel) { return; } string strIdxName = ""; result = PromptForm.ShowText("Index Name", "Index Name", ref strIdxName); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("DROP INDEX {0}.{1}", strTblName, strIdxName)); ShowMessenger(iResult); }
public void AddPrimaryKey() { string str = MethodInfo.GetCurrentMethod().Name; string strTblName = ""; MessageBoxResult result = PromptForm.ShowText("Table Name", "Table Name", ref strTblName); if (result == MessageBoxResult.Cancel) { return; } string strColName = ""; result = PromptForm.ShowText("Column Name", "Column Name", ref strColName); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("ALTER TABLE {0} ADD CONSTRAINT PK_{0} PRIMARY KEY({1})", strTblName, strColName)); ShowMessenger(iResult); }
public void AddColumn() { string str = MethodInfo.GetCurrentMethod().Name; string strTblName = ""; MessageBoxResult result = PromptForm.ShowCombobox(str, "Table Name", ref strTblName); if (result == MessageBoxResult.Cancel) { return; } string strColName = ""; result = PromptForm.ShowText(str, "Column Name", ref strColName); if (result == MessageBoxResult.Cancel) { return; } int iResult = SQLDBUtil.ExecuteNonQuery(string.Format("ALTER TABLE {0} ADD {1}", strTblName, strColName)); ShowMessenger(iResult); }
//Ctrl + 1 tìm module public void FindModule(Window frmParent) { PromptForm._frmParent = frmParent; string moduleName = ""; MessageBoxResult result = PromptForm.ShowText("Find Module", "ModuleName", ref moduleName); if (result == MessageBoxResult.Cancel) { return; } string strQuery = SQLApp.GetFile(strPath + "FindModule.sql"); strQuery = strQuery.Replace("@ModuleName@", moduleName); DataTable dt = SQLDBUtil.GetDataTable(strQuery); if (dt == null) { return; } dt.TableName = "STModules"; ShowResultData(frmParent, dt, strQuery); }
public void GetConfigConnectSQL(string status, int idx = 0) { string cnt = SQLApp.GetIniFile(strFileName, section, serverCnt); int index = Convert.ToInt32(cnt); switch (status) { case "Add": case "Edit": string strDesc = SQLApp.GetIniFile(strFileName, section, ServerDesc + idx); MessageBoxResult result = PromptForm.ShowText("Description", "Description", ref strDesc); if (result == MessageBoxResult.Cancel) { return; } string strServer = SQLApp.GetIniFile(strFileName, section, ServerName + idx); result = PromptForm.ShowText("Server", "Server", ref strServer); if (result == MessageBoxResult.Cancel) { return; } string strUser = SQLApp.GetIniFile(strFileName, section, ServerUID + idx); result = PromptForm.ShowText("User", "User", ref strUser); if (result == MessageBoxResult.Cancel) { return; } string strPass = SQLApp.GetIniFile(strFileName, section, ServerPWD + idx); result = PromptForm.ShowText("Pass", "Pass", ref strPass); if (result == MessageBoxResult.Cancel) { return; } if (!string.IsNullOrEmpty(strDesc) && !string.IsNullOrEmpty(strServer) && !string.IsNullOrEmpty(strUser)) { if (status == "Add") { index += 1; SQLApp.SetIniFile(strFileName, section, serverCnt, index.ToString()); } else { index = idx; } SQLApp.SetIniFile(strFileName, section, ServerDesc + index, strDesc); SQLApp.SetIniFile(strFileName, section, ServerName + index, strServer); SQLApp.SetIniFile(strFileName, section, ServerUID + index, strUser); SQLApp.SetIniFile(strFileName, section, ServerPWD + index, strPass); SQLApp.SetIniFile(strFileName, section, ServerDBOld + index, ""); } break; case "Del": SQLApp.SetIniFile(strFileName, section, serverCnt, (index - 1).ToString()); SQLApp.SetIniFile(strFileName, section, ServerDesc + idx, null); SQLApp.SetIniFile(strFileName, section, ServerName + idx, null); SQLApp.SetIniFile(strFileName, section, ServerUID + idx, null); SQLApp.SetIniFile(strFileName, section, ServerPWD + idx, null); SQLApp.SetIniFile(strFileName, section, ServerDBOld + idx, null); break; } }
private void KeyBindingActionCommand(object x) { HotKeyInfo hotKey = HotKeyGenerate.GenerateHotKeyByString(Convert.ToString(x)); object focusVal = this.GetFocusedValue(); switch (hotKey.modifierKey) { case ModifierKeys.Alt: switch (hotKey.key) { case Key.C: Clipboard.SetDataObject(focusVal); break; } break; case ModifierKeys.Control: TableView objTableView = (this.View as TableView); switch (hotKey.key) { case Key.M: string strColumn = string.Empty; PromptForm.ShowText("Find Column", "Find Column", ref strColumn); if (!string.IsNullOrEmpty(strColumn)) { this.Columns.ToList().ForEach(col => { if (!col.FieldName.Equals("id")) { col.Visible = false; } strColumn.Split(',').ToList().ForEach(c => { if (col.FieldName.Equals(c)) { col.Visible = true; } }); }); } break; case Key.H: int idx = this.Columns.ToList().FindIndex(c => c.FieldName.Equals(objTableView.FocusedColumn.FieldName)); DevExpress.Xpf.Grid.GridColumn column = this.Columns.ToList().ElementAtOrDefault(idx + 1); objTableView.FocusedColumn.Visible = false; if (column != null) { objTableView.FocusedColumn = column; } break; case Key.I: objTableView.ShowColumnChooser(); break; } break; case ModifierKeys.Shift: break; } }