Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public void ChangeDbLaravel(Window frmParent)
        {
            if (!CheckSelectedDB())
            {
                return;
            }

            string sourceUrl = GetSourceCodePath();
            string filePath  = Directory.GetFiles(sourceUrl, "*.env").FirstOrDefault();

            string[] lines  = File.ReadAllLines(filePath);
            string[] lstDBs = SQLDBUtil.GetDataTableByDataSet(SQLDBUtil.GetAllDatabases()).Select().Select(x => x[0].ToString()).ToArray();
            string   DBVal  = lines.ToList().Find(x => x.StartsWith("DB_DATABASE")).Split('=').LastOrDefault();

            if (PromptForm.ShowCombobox("Change Database Name", "Database Name", lstDBs, ref DBVal) == MessageBoxResult.OK)
            {
                SQLAppWaitingDialog.ShowDialog();
                int idx = lines.ToList().FindIndex(x => x.StartsWith("DB_DATABASE"));
                lines[idx] = string.Format("{0}={1}", "DB_DATABASE", DBVal);
                File.WriteAllLines(filePath, lines);
                FunctionListObject functionObj = new FunctionListObject();
                functionObj.FuncName = "CmdLaravelConfigCache";
                ExecutedScriptCommand(functionObj, frmParent);
                SQLAppWaitingDialog.HideDialog();
            }
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        //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, "");
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        //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);
            }
        }
Ejemplo n.º 7
0
        //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);
        }
Ejemplo n.º 8
0
        public void ShowFunctionList(string strFuncName, Window frmParent)
        {
            string sourceUrl = SQLApp.GetIniFile(strFileName, "SourceCode", "SourceUrl");
            bool   isReturn  = false;

            if (string.IsNullOrEmpty(sourceUrl) || !Directory.Exists(sourceUrl))
            {
                isReturn = true;
                FolderBrowserDialog folder = new FolderBrowserDialog();
                if (folder.ShowDialog() == DialogResult.OK)
                {
                    SQLApp.SetIniFile(strFileName, "SourceCode", "SourceUrl", folder.SelectedPath);
                    isReturn = false;
                }
            }
            if (isReturn)
            {
                return;
            }
            List <string>             lstFuncs       = SQLApp.GetKeysIniFile(strCfgScriptName, strFuncName, 3000);
            List <FunctionListObject> lstObjectFuncs = new List <FunctionListObject>();

            lstFuncs.ForEach(x =>
            {
                string caption = SQLApp.GetIniFile(strCfgScriptName, "Captions", x);
                if (string.IsNullOrEmpty(caption))
                {
                    caption = string.Join(" ", x.ToUpper().Split('_'));
                }
                lstObjectFuncs.Add(new FunctionListObject {
                    Name = x, Text = caption
                });
            });
            PromptForm._frmParent = frmParent;
            string           value         = string.Empty;
            MessageBoxResult messageResult = PromptForm.ShowCombobox("Function List In Source", "Function Name", lstObjectFuncs.Select(x => x.Text).ToArray(), ref value);

            if (messageResult == MessageBoxResult.OK)
            {
                FunctionListObject functionObj  = lstObjectFuncs.Find(x => x.Text.Equals(value));
                string             strKey       = (functionObj != null) ? functionObj.Name : string.Empty;
                string             functionName = SQLApp.GetIniFile(strCfgScriptName, strFuncName, strKey);
                if (functionName.StartsWith("Cmd"))
                {
                    functionObj.FuncName = functionName;
                    ExecutedScriptCommand(functionObj, frmParent);
                }
                else
                {
                    CallMethodName(functionName, frmParent);
                }
            }
        }
Ejemplo n.º 9
0
        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);
        }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        public void ShowChangeTheme()
        {
            string _themeName = ApplicationThemeHelper.ApplicationThemeName;

            if (PromptForm.ShowCombobox("Change Theme", "Theme Name", Theme.Themes.Select(x => x.Name).ToArray(), ref _themeName) == MessageBoxResult.Cancel)
            {
                return;
            }

            SetThemeName(_themeName);

            //System.Diagnostics.Process.Start(System.Windows.Forms.Application.ExecutablePath);
            //Environment.Exit(Environment.ExitCode);

            ApplicationThemeHelper.ApplicationThemeName = _themeName;
        }
Ejemplo n.º 12
0
        //Ctrl + Alt + T : Gen Script Create Table
        public void GenScriptCreateTable(Window frmParent)
        {
            string           str          = MethodInfo.GetCurrentMethod().Name;
            string           strTableName = "";
            MessageBoxResult result       = PromptForm.ShowCombobox(str, "Table Name", ref strTableName);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strQuery = SQLApp.GetFile(strPath + "GenCreateTable.sql");

            strQuery = strQuery.Replace("@TableName@", strTableName);
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            ShowResultData(frmParent, dt, strQuery);
        }
Ejemplo n.º 13
0
        //Ctrl + 6: Gen Info / Controller
        public void GenInfoController()
        {
            string           str          = MethodInfo.GetCurrentMethod().Name;
            string           strTableName = "";
            MessageBoxResult result       = PromptForm.ShowCombobox(str, "Table Name", ref strTableName);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strType = string.Empty;

            result = PromptForm.ShowCombobox(str, "Gen Controller", new string[] { "YES", "NO" }, ref strType);
            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            string strQuery = SQLApp.GetFile(strPath + "GenInfo.sql");

            strQuery = strQuery.Replace("@TableName@", strTableName);
            strQuery = strQuery.Replace("@Version@", System.Windows.Forms.Application.ProductName + " - " + System.Windows.Forms.Application.ProductVersion);
            strQuery = strQuery.Replace("@CreatedDate@", DateTime.Now.ToShortDateString());
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            if (dt != null)
            {
                string strContent = Convert.ToString(dt.Rows[0][0]);
                SQLApp.WriteFile("D:\\" + strTableName + "Info.cs", strContent);
                //NotifycationAler aler = new NotifycationAler();
                //aler.ShowDialog();
            }
            if (strType == "YES")
            {
                strQuery = SQLApp.GetFile(strPath + "GenController.sql");
                strQuery = strQuery.Replace("@TableName@", strTableName);
                strQuery = strQuery.Replace("@Version@", System.Windows.Forms.Application.ProductName + " - " + System.Windows.Forms.Application.ProductVersion);
                strQuery = strQuery.Replace("@CreatedDate@", DateTime.Now.ToShortDateString());
                dt       = SQLDBUtil.GetDataTable(strQuery);
                if (dt != null)
                {
                    string strContent = Convert.ToString(dt.Rows[0][0]);
                    SQLApp.WriteFile("D:\\" + strTableName + "Controller.cs", strContent);
                }
            }
        }
Ejemplo n.º 14
0
        public void ShowFunctionList()
        {
            GetFunctionList();
            string[]         lstSource = lstFuncLst.Keys.ToArray();
            string           value     = "";
            MessageBoxResult result    = PromptForm.ShowCombobox("Action", "Action", lstSource, ref value);

            if (result == MessageBoxResult.Cancel)
            {
                return;
            }
            //switch (value)
            //{
            EnterFunctionList lstThis = new EnterFunctionList();
            MethodInfo        mi      = lstThis.GetType().GetMethod(lstFuncLst[value]);

            mi.Invoke(lstThis, null);
            //MethodInfo miConstructed = mi.MakeGenericMethod(type[0]);
            //}
        }
Ejemplo n.º 15
0
        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);
        }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
        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);
        }
Ejemplo n.º 18
0
        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);
        }
Ejemplo n.º 19
0
        //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);
        }
Ejemplo n.º 20
0
        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;
            }
        }
Ejemplo n.º 21
0
        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;
            }
        }