Closed tieuquyngok1995 closed 3 years ago
btnExcute.Enabled = true; txtStatus.Text = string.Format(CONSTANTS.CONST_STRING_STATUS, CONSTANTS.CONST_STRING_STATUS_CONNECTION); } else { statusConnection = false; btnExcute.Enabled = false; txtStatus.Text = string.Format(CONSTANTS.CONST_STRING_STATUS, CONSTANTS.CONST_STRING_STATUS_DISCONNECT); } } }
private bool CheckIsConnection() { string connectionString = string.Format("Data Source={0};Initial Catalog={1};User ID={2};Password={3};", ConfigurationManager.AppSettings[CONSTANTS.CONST_STRING_SERVER_NAME], ConfigurationManager.AppSettings[CONSTANTS.CONST_STRING_DATABASE_NAME], ConfigurationManager.AppSettings[CONSTANTS.CONST_STRING_USER_NAME], ConfigurationManager.AppSettings[CONSTANTS.CONST_STRING_PASSWORD]); try { con = new SQLConnection(connectionString); if (con.IsConnection) { statusConnection = true; return true; } } catch (Exception) { statusConnection = false; return false; } statusConnection = false; return false; } #endregion #region Input SQL private void btnFormat_Click(object sender, EventArgs e) { strSQLChar = txtSQLChar.Text.Trim(); var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var settings = configFile.AppSettings.Settings; if (settings.Count == 0) { settings.Add(CONSTANTS.CONST_STRING_SQL_CHAR, strSQLChar); } else { settings[CONSTANTS.CONST_STRING_SQL_CHAR].Value = strSQLChar; } configFile.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name); if (!string.IsNullOrEmpty(txtInputSQL.Text)) { dataSQL.Clear(); dataParam.Clear(); lstDataSQL.Visible = true; lstInputParam.Visible = true; handleStringInput(); } else { dataSQL.Clear(); dataParam.Clear(); lstDataSQL.Visible = false; lstInputParam.Visible = false; btnConvert.Enabled = false; } lstDataSQL.DataSource = dataSQL; if (dataSQL.Rows.Count > 0) { strInputSQL = dataSQL.Rows[0][1].ToString(); if (!string.IsNullOrEmpty(strInputSQL)) { lstParam = new List<string>(); handleInputParam(strInputSQL); btnConvert.Enabled = true; } } string line = txtInputSQL.Text.Replace("\t", " "); while (line.IndexOf(" ") >= 0) { line = line.Replace(" ", " "); } txtInputSQL.Text = line; }
btnExcute.Enabled = true; txtStatus.Text = string.Format(CONSTANTS.CONST_STRING_STATUS, CONSTANTS.CONST_STRING_STATUS_CONNECTION); } else { statusConnection = false; btnExcute.Enabled = false; txtStatus.Text = string.Format(CONSTANTS.CONST_STRING_STATUS, CONSTANTS.CONST_STRING_STATUS_DISCONNECT); } } }