//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)); }
//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); } }
//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); }
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(""); }
//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); }
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 + 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); } } }
//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); }