Beispiel #1
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();
            }
        }
        public void AddForeignKey(string strTblName, string strColName, string strReferenTblName, string strReferenColName)
        {
            string str     = MethodInfo.GetCurrentMethod().Name;
            int    iResult = SQLDBUtil.ExecuteNonQuery(string.Format("ALTER TABLE {0} ADD CONSTRAINT FK_{0}_{2}_{1} FOREIGN KEY {1} REFERENCES {2} ({3})", strTblName, strColName, strReferenTblName, strReferenColName));

            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);
        }
        //public void LoadFunction(frmMain frmParent)
        //{
        //    ListViewItem obj = frmParent.lstFunction.SelectedItems.Cast<ListViewItem>().FirstOrDefault();
        //    if (obj == null) return;
        //    string strCnt = SQLApp.GetIniFile(strFileCfgScript, strDynPara, obj.Text + "Cnt");
        //    if (string.IsNullOrEmpty(strCnt)) return;
        //    int idxCnt = Convert.ToInt32(strCnt);
        //    Dictionary<string, string> dicPara = new Dictionary<string, string>();
        //    for (int i = 1; i <= idxCnt; i++)
        //    {
        //        string strName = SQLApp.GetIniFile(strFileCfgScript, strDynPara, obj.Text + "Name" + i);
        //        string strVal = SQLApp.GetIniFile(strFileCfgScript, strDynPara, obj.Text + "Val" + i);
        //        string strValList = SQLApp.GetIniFile(strFileCfgScript, strDynPara, obj.Text + "ValList" + i);
        //        MessageBoxResult result = MessageBoxResult.Cancel;
        //        if (strName.Contains("TableName"))
        //            result = PromptForm.ShowCombobox(obj.Text, strName, ref strVal);
        //        else if(!string.IsNullOrEmpty(strValList))
        //            result = PromptForm.ShowCombobox(obj.Text, strName, strValList.Split('|'), ref strVal);
        //        else
        //            result = PromptForm.ShowText(obj.Text, strName, ref strVal);
        //        if (result == MessageBoxResult.Cancel) return;
        //        dicPara.AddItem(strName, strVal);
        //    }
        //    string strQuery = SQLApp.GetFile(strPath + obj.Text + ".sql");
        //    foreach (KeyValuePair<string,string> item in dicPara)
        //    {
        //        strQuery = strQuery.Replace(item.Key, item.Value);
        //    }
        //    SQLDBUtil.GetDataSet(strQuery);
        //}
        #region Sync DB
        public DataSet SynchronizeTable(int indexFrom, int indexTo, string strDBFrom, string strDBTo)
        {
            int    iResult     = CreateLinkServer(indexFrom, indexTo, strDBFrom, strDBTo);
            string strSrvName  = GetDescriptionConfig(indexFrom);
            string strSrvAdd   = GetServerConfig(indexFrom);
            string strUser     = GetUserNameConfig(indexFrom);
            string strPassWord = GetPassWordConfig(indexFrom);

            string strSrvNameTo  = GetDescriptionConfig(indexTo);
            string strSrvAddTo   = GetServerConfig(indexFrom);
            string strUserTo     = GetUserNameConfig(indexTo);
            string strPassWordTo = GetPassWordConfig(indexTo);

            string strQuery = SQLApp.GetFile(strPath + "SyncDB.sql");

            strQuery = strQuery.Replace("@serverName@", strSrvName);
            strQuery = strQuery.Replace("@serverAddress@", strSrvAdd);
            strQuery = strQuery.Replace("@serverUser@", strUser);
            strQuery = strQuery.Replace("@serverPass@", strPassWord);
            strQuery = strQuery.Replace("@serverDB@", strDBFrom);

            strQuery = strQuery.Replace("@serverNameTo@", strSrvNameTo);
            strQuery = strQuery.Replace("@serverAddressTo@", strSrvAddTo);
            strQuery = strQuery.Replace("@serverUserTo@", strUserTo);
            strQuery = strQuery.Replace("@serverPassTo@", strPassWordTo);
            strQuery = strQuery.Replace("@serverDBTo@", strDBTo);

            return(SQLDBUtil.GetDataSet(strQuery));
        }
        public int CreateLinkServer(int indexFrom, int indexTo, string strDBFrom, string strDBTo)
        {
            string strSrvName  = GetDescriptionConfig(indexFrom);
            string strSrvAdd   = GetServerConfig(indexFrom);
            string strUser     = GetUserNameConfig(indexFrom);
            string strPassWord = GetPassWordConfig(indexFrom);

            string strSrvNameTo  = GetDescriptionConfig(indexTo);
            string strSrvAddTo   = GetServerConfig(indexFrom);
            string strUserTo     = GetUserNameConfig(indexTo);
            string strPassWordTo = GetPassWordConfig(indexTo);

            string strQuery = SQLApp.GetFile(strPath + "LinkServer.sql");

            strQuery = strQuery.Replace("@serverName@", strSrvName);
            strQuery = strQuery.Replace("@serverAddress@", strSrvAdd);
            strQuery = strQuery.Replace("@serverUser@", strUser);
            strQuery = strQuery.Replace("@serverPass@", strPassWord);
            strQuery = strQuery.Replace("@serverDB@", strDBFrom);

            strQuery = strQuery.Replace("@serverNameTo@", strSrvNameTo);
            strQuery = strQuery.Replace("@serverAddressTo@", strSrvAddTo);
            strQuery = strQuery.Replace("@serverUserTo@", strUserTo);
            strQuery = strQuery.Replace("@serverPassTo@", strPassWordTo);
            strQuery = strQuery.Replace("@serverDBTo@", strDBTo);

            return(SQLDBUtil.ExecuteNonQuery(strQuery));
        }
        /// <summary>
        /// ウィンドウ表示状態取得
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="windowName"></param>
        /// <returns></returns>
        public DataTable GetWindowState(string loginId, string windowName)
        {
            SQLDBUtil           db    = new SQLDBUtil(_logger);
            DataTable           ret   = null;
            DataSet             tmp   = null;
            List <SqlParameter> param = new List <SqlParameter>();

            try {
                db.Open(_connectString);

                param.Add(new SqlParameter("@window_name", windowName));
                param.Add(new SqlParameter("@login_id", ""));
                tmp = db.ExecSelect(SQLSrc.t_window_state.SELECT_STATE, param.ToArray());
                ret = tmp.Tables[0].Clone();
                foreach (DataRow dr in tmp.Tables[0].Rows)
                {
                    string    ctlName = dr[CommonConsts.control_name].ToString();
                    DataTable tmpTbl  = GetWindowState(loginId, windowName, ctlName);
                    DataRow   newRow  = ret.NewRow();
                    newRow.ItemArray = tmpTbl.Rows[0].ItemArray;
                    ret.Rows.Add(newRow);
                }
                ret.TableName = "WindowState";

                return(ret);
            } finally {
                db.Close();
            }
        }
        //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, "");
        }
        //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);
            }
        }
        /// <summary>
        /// ウィンドウ表示状態取得
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="windowName"></param>
        /// <param name="ctlName"></param>
        /// <returns></returns>
        public DataTable GetWindowState(string loginId, string windowName, string ctlName)
        {
            SQLDBUtil           db    = new SQLDBUtil(_logger);
            DataSet             ret   = null;
            List <SqlParameter> param = new List <SqlParameter>();

            try {
                db.Open(_connectString);

                param.Add(new SqlParameter("@window_name", windowName));
                param.Add(new SqlParameter("@control_name", ctlName));
                param.Add(new SqlParameter("@login_id", loginId));
                ret = db.ExecSelect(SQLSrc.t_window_state.SELECT_STATE_ONE, param.ToArray());
                if (ret.Tables[0].Rows.Count == 0)
                {
                    List <SqlParameter> param2 = new List <SqlParameter>();
                    param2.Add(new SqlParameter("@window_name", windowName));
                    param2.Add(new SqlParameter("@control_name", ctlName));
                    param2.Add(new SqlParameter("@login_id", ""));
                    ret = db.ExecSelect(SQLSrc.t_window_state.SELECT_STATE_ONE, param2.ToArray());
                }
                ret.Tables[0].TableName = "WindowState";

                return((DataTable)_dcu.DeepCopy(ret.Tables[0]));
            } finally {
                db.Close();
            }
        }
        //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);
        }
        //Ctrl + 0 View Connect Sql
        public void GetViewConnectToSQL(Window frmParent)
        {
            string    strQuery = SQLApp.GetFile(strPath + "ViewConnectSql.sql");
            DataTable dtSource = SQLDBUtil.GetDataTable(strQuery);

            ShowResultData(frmParent, dtSource, strQuery);
        }
        /// <summary>
        /// グリッド設定情報を取得
        /// </summary>
        /// <param name="windowName"></param>
        /// <param name="gridName"></param>
        /// <param name="loginId"></param>
        /// <returns></returns>
        public DataSet GetGridConfig(string windowName, string gridName, string loginId)
        {
            DataSet             ret   = null;
            List <SqlParameter> param = new List <SqlParameter>();
            SQLDBUtil           db    = new SQLDBUtil(_logger);

            try {
                db.Open(_connectString);

                param.Add(new SqlParameter("@window_name", windowName));
                param.Add(new SqlParameter("@grid_name", gridName));
                param.Add(new SqlParameter("@login_id", loginId));
                ret = db.ExecSelect(SQLSrc.t_grid_config.SELECT_CONDITION, param.ToArray());
                if (ret.Tables[0].Rows.Count == 0)
                {
                    //自分の設定がない場合は、デフォルト設定を取得
                    List <SqlParameter> param2 = new List <SqlParameter>();
                    param2.Add(new SqlParameter("@window_name", windowName));
                    param2.Add(new SqlParameter("@grid_name", gridName));
                    param2.Add(new SqlParameter("@login_id", ""));
                    ret = db.ExecSelect(SQLSrc.t_grid_config.SELECT_CONDITION, param2.ToArray());
                }
                ret.Tables[0].TableName = "GridConfig";

                return(ret);
            } finally {
                db.Close();
            }
        }
Beispiel #13
0
        public void ExecuteScriptFile(Window frmParent)
        {
            OpenFileDialog openFile = new OpenFileDialog();

            if (openFile.ShowDialog() == DialogResult.OK)
            {
                string   allLines = File.ReadAllText(openFile.FileName);
                string[] allChar  = new string[] { ";" + Environment.NewLine };
                string[] arrLines = allLines.Split(allChar, StringSplitOptions.None);
                SQLAppWaitingDialog.ShowDialog();
                foreach (string line in arrLines)
                {
                    try
                    {
                        SQLDBUtil.ExecuteNonQuery(line);
                    }
                    catch (Exception ex)
                    {
                        SQLAppWaitingDialog.HideDialog();
                        ShowMessengeWarning("Có lỗi xảy ra");
                    }
                }
                SQLAppWaitingDialog.HideDialog();
                ShowMessengeInfo("Thành công");
            }
        }
        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);
        }
        /// <summary>
        /// グリッド設定情報を取得
        /// </summary>
        /// <returns></returns>
        public DataSet GetGridConfig(HttpRequestMessage req, string loginId)
        {
            List <SqlParameter> param = new List <SqlParameter>();
            SQLDBUtil           db    = new SQLDBUtil(_logger);
            DataSet             ds    = JsonConvert.DeserializeObject <DataSet>(req.Content.ReadAsStringAsync().Result);
            DataTable           dt    = ds.Tables[0];
            string windowName         = StringUtil.NullToBlank(dt.Rows[0][CommonConsts.window_name]);
            string gridName           = StringUtil.NullToBlank(dt.Rows[0][CommonConsts.grid_name]);

            return(GetGridConfig(windowName, gridName, loginId));
        }
        /// <summary>
        /// グリッド設定を更新(Delete-Insert)
        /// </summary>
        /// <param name="dt"></param>
        public void UpdateGridConfigInfo(DataTable dt, string loginId)
        {
            SQLDBUtil db = new SQLDBUtil(_logger);

            SetNewDispOrder(dt);

            lock (_lockObj) {
                try {
                    db.Open(_connectString);
                    db.BeginTransaction();

                    //Delete
                    DataRow             r        = dt.Rows[0];
                    List <SqlParameter> delParam = new List <SqlParameter>();
                    delParam.Add(new SqlParameter("@window_name", r[CommonConsts.window_name]));
                    delParam.Add(new SqlParameter("@grid_name", r[CommonConsts.grid_name]));
                    delParam.Add(new SqlParameter("@login_id", loginId));
                    db.ExecuteNonQuery(SQLSrc.t_grid_config.DELETE, delParam.ToArray());

                    //Insert
                    foreach (DataRow dr in dt.Rows)
                    {
                        List <SqlParameter> insParam = new List <SqlParameter>();
                        insParam.Add(new SqlParameter("@window_name", dr[CommonConsts.window_name]));
                        insParam.Add(new SqlParameter("@grid_name", dr[CommonConsts.grid_name]));
                        insParam.Add(new SqlParameter("@db_name", dr[CommonConsts.db_name]));
                        insParam.Add(new SqlParameter("@login_id", loginId));
                        insParam.Add(new SqlParameter("@width", dr[CommonConsts.width]));
                        insParam.Add(new SqlParameter("@height", dr[CommonConsts.height]));
                        insParam.Add(new SqlParameter("@conf_editable", dr[CommonConsts.conf_editable]));
                        insParam.Add(new SqlParameter("@visible", dr[CommonConsts.visible]));
                        insParam.Add(new SqlParameter("@editable", dr[CommonConsts.editable]));
                        insParam.Add(new SqlParameter("@disp_order", dr[CommonConsts.disp_order]));
                        insParam.Add(new SqlParameter("@col_fixed", dr[CommonConsts.col_fixed]));
                        insParam.Add(new SqlParameter("@data_type", dr[CommonConsts.data_type]));
                        insParam.Add(new SqlParameter("@max_length", dr[CommonConsts.max_length]));
                        insParam.Add(new SqlParameter("@required", dr[CommonConsts.required]));
                        insParam.Add(new SqlParameter("@primary_key", dr[CommonConsts.primary_key]));
                        insParam.Add(new SqlParameter("@password_char", dr[CommonConsts.password_char]));
                        insParam.Add(new SqlParameter("@note", dr[CommonConsts.note]));

                        db.ExecuteNonQuery(SQLSrc.t_grid_config.INSERT, insParam.ToArray());
                    }

                    db.Commit();
                } catch (Exception) {
                    db.Rollback();
                    throw;
                } finally {
                    db.Close();
                }
            }
        }
Beispiel #18
0
        protected void CompareDifferrentData(Dictionary <string, SqlDbConnection> lstCons, string strQuery, string tblName)
        {
            SQLDBUtil.CurrentDatabase = lstCons[CtrlFrom];
            DataTable dtSource = SQLDBUtil.GetDataTable(string.Format(strQuery, SQLDBUtil.CurrentDatabase.Connection.Database));

            SQLDBUtil.CurrentDatabase = lstCons[CtrlTo];
            DataTable             dtTarget     = SQLDBUtil.GetDataTable(string.Format(strQuery, SQLDBUtil.CurrentDatabase.Connection.Database));
            IEnumerable <DataRow> lstSameTable = dtSource.AsEnumerable().Except(dtTarget.AsEnumerable(), DataRowComparer.Default);
            DataTable             dtSame       = ConvertDataRowToTable(lstSameTable, tblName);

            ShowCompareResultView(dtSame);
        }
 /// <summary>
 /// プルダウンの候補をセット
 /// </summary>
 /// <param name="db"></param>
 /// <param name="ds"></param>
 protected virtual void SetPulldownCandidate(SQLDBUtil db, DataSet ds)
 {
     foreach (DataRow r in ds.Tables[CommonConsts.SearchItemTbl].Rows)
     {
         if (r[CommonConsts.ctl_type].ToString() == CommonConsts.CtlTypePulldownlist)
         {
             //プルダウンリストの候補を取得
             DataSet dsTmp = db.ExecSelect(r[CommonConsts.value1].ToString());
             dsTmp.Tables[0].TableName = r[CommonConsts.db_name].ToString();
             ds.Tables.Add(dsTmp.Tables[r[CommonConsts.db_name].ToString()].Copy());
         }
     }
 }
Beispiel #20
0
        public DataTable LoadDatabaseByServer(string keySection, int idx)
        {
            if (idx == -1)
            {
                return(new DataTable());
            }
            strServer   = GetServerConfig(keySection, idx);
            strUserName = GetUserNameConfig(keySection, idx);
            strPassWord = GetPassWordConfig(keySection, idx);
            //strDBOld = SQLApp.GetIniFile(strFileName, section, _serverDBOld + (cboServer.SelectedIndex + 1));

            SQLDBUtil.ChangeConnection((SqlDbConnectionType)Enum.Parse(typeof(SqlDbConnectionType), keySection), strServer, strUserName, strPassWord);
            return(SQLDBUtil.GetDataTableByDataSet(SQLDBUtil.GetAllDatabases()));
        }
        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 string GetScriptCreateTable(string strDBName, string strTable)
        {
            string strQuery = SQLApp.GetFile(strPath + "CreateTable.sql");

            strQuery = strQuery.Replace("@tablename@", strTable);
            strQuery = strQuery.Replace("@schemaname@", strDBName);
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            if (dt != null && dt.Rows.Count > 0)
            {
                return(string.Format("{0}", dt.Rows[0][0]));
            }
            return("");
        }
        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);
        }
        /// <summary>
        /// データディクショナリ情報取得
        /// </summary>
        /// <returns></returns>
        public DataSet GetDataDictionary(ILog logger, string connectString)
        {
            List <SqlParameter> param = new List <SqlParameter>();
            SQLDBUtil           db    = new SQLDBUtil(logger);

            try {
                db.Open(connectString);

                DataSet ret = db.ExecSelect(SQLSrc.m_data_dictionary.SELECT_ALL);
                ret.Tables[0].TableName = CommonConsts.TableNameMDataDictionary;

                return(ret);
            } finally {
                db.Close();
            }
        }
        /// <summary>
        /// 共通設定情報取得
        /// </summary>
        /// <returns></returns>
        public DataSet GetCommonConf()
        {
            List <SqlParameter> param = new List <SqlParameter>();
            SQLDBUtil           db    = new SQLDBUtil(_logger);

            try {
                db.Open(_connectString);

                DataSet ret = db.ExecSelect(SQLSrc.m_common_conf.SELECT_ALL);
                ret.Tables[0].TableName = CommonConsts.TableNameMCommonConf;

                return(ret);
            } finally {
                db.Close();
            }
        }
        /// <summary>
        /// メッセージ情報取得
        /// </summary>
        /// <returns></returns>
        public DataSet GetMessageInfo()
        {
            SQLDBUtil           db    = new SQLDBUtil(_logger);
            DataSet             ret   = null;
            List <SqlParameter> param = new List <SqlParameter>();

            try {
                db.Open(_connectString);

                ret = db.ExecSelect(SQLSrc.m_message.SELECT_ALL, param.ToArray());
                ret.Tables[0].TableName = "MessageInfo";

                return(ret);
            } finally {
                db.Close();
            }
        }
        public void LoadQueryPath(FunctionListObject obj, Window frmParent)
        {
            string strQuery = SQLApp.GetFile(obj.Path);

            strQuery = GenerateScriptWithParameters(obj, strQuery, frmParent);
            if (string.IsNullOrEmpty(strQuery))
            {
                return;
            }
            DataTable dt = SQLDBUtil.GetDataTable(strQuery);

            if (dt == null)
            {
                return;
            }
            ShowResultData(frmParent, dt, strQuery);
        }
        //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);
        }
        /// <summary>
        /// 共通設定情報取得(1項目)
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public DataSet GetCommonConfItem(string key)
        {
            List <SqlParameter> param = new List <SqlParameter>();
            SQLDBUtil           db    = new SQLDBUtil(_logger);

            try {
                db.Open(_connectString);

                param.Add(new SqlParameter("@key", key));
                DataSet ret = db.ExecSelect(SQLSrc.m_common_conf.SELECT_ITEM, param.ToArray());
                ret.Tables[0].TableName = CommonConsts.TableNameMCommonConf;

                return(ret);
            } finally {
                db.Close();
            }
        }
        //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);
                }
            }
        }