//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, "");
        }
        //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 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);
        }
Exemple #4
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();
            }
        }
Exemple #5
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);
                }
            }
        }
Exemple #6
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;
        }
        //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);
        }
        //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);
                }
            }
        }
        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]);
            //}
        }
        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);
        }