diff --git a/插件库/Lskj.PubGetChipInfo/FrmMain.cs b/插件库/Lskj.PubGetChipInfo/FrmMain.cs index 989fc9f..378dcb6 100644 --- a/插件库/Lskj.PubGetChipInfo/FrmMain.cs +++ b/插件库/Lskj.PubGetChipInfo/FrmMain.cs @@ -141,69 +141,67 @@ namespace Lskj.PubGetChipInfo if (!string.IsNullOrEmpty(functionName)) { DataTable sqlParametersTab = BaseImpl.GetDataTableResult($"SELECT PARAMETER_NAME,PARAMETER_MODE,CHARACTER_MAXIMUM_LENGTH,DATA_TYPE FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_NAME = '{functionName}' ORDER BY ORDINAL_POSITION;"); - using (SqlConnection sqlConnection = new SqlConnection(SqlHelper._connection.ConnectionString)) + + using (SqlCommand command = new SqlCommand(functionName, (SqlConnection)SqlHelper._connection)) { - using (SqlCommand command = new SqlCommand(functionName, sqlConnection)) + string[] parametersArray = parameters.Split(','); + foreach (DataRow parameterRow in sqlParametersTab.Rows) { - string[] parametersArray = parameters.Split(','); - foreach (DataRow parameterRow in sqlParametersTab.Rows) + string parameterName = parameterRow["PARAMETER_NAME"] + ""; + string parameterMode = parameterRow["PARAMETER_MODE"] + ""; + int.TryParse(parameterRow["CHARACTER_MAXIMUM_LENGTH"] + "", out int dataLength); + string dataType = parameterRow["DATA_TYPE"] + ""; + SqlParameter sqlParameter = null; + if (parameterMode.Equals("int")) { - string parameterName = parameterRow["PARAMETER_NAME"] + ""; - string parameterMode = parameterRow["PARAMETER_MODE"] + ""; - int.TryParse(parameterRow["CHARACTER_MAXIMUM_LENGTH"] + "", out int dataLength); - string dataType = parameterRow["DATA_TYPE"] + ""; - SqlParameter sqlParameter = null; - if (parameterMode.Equals("int")) - { - sqlParameter = new SqlParameter(parameterName, SqlDbType.Int); - } - else - { - sqlParameter = new SqlParameter(parameterName, SqlDbType.VarChar, dataLength); - } - if (parameterMode.Equals("IN")) - { - sqlParameter.Direction = ParameterDirection.Input; - } - else - { - sqlParameter.Direction = ParameterDirection.Output; - } - command.Parameters.Add(sqlParameter); - } - for (int i = 0; i < command.Parameters.Count; i++) - { - SqlParameter sqlParameter = command.Parameters[i]; - if (parametersArray.Length > i) - { - string commandParameter = parametersArray[i]; - string field = commandParameter.Replace("@", "").Replace("{", "").Replace("}", ""); - string value = sourceRow.Table.Columns.Contains(field) ? sourceRow[field] + "" : commandParameter.Replace("@", ""); - value = value.Replace("{result}", txtEdit_info.Text); - value = value.Replace("@", "").Replace("{", "").Replace("}", ""); - sqlParameter.Value = value; - } - } - SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4); - returnValue.Direction = ParameterDirection.ReturnValue; - command.Parameters.Add(returnValue); - command.CommandType = CommandType.StoredProcedure; - command.ExecuteNonQuery(); - if ((returnValue.Value + "").Equals("1")) - { - DialogResult = DialogResult.OK; - Close(); + sqlParameter = new SqlParameter(parameterName, SqlDbType.Int); } else { - SqlParameter outSqlParameter = command.Parameters.Cast().Where(n => n.Direction == ParameterDirection.Output).FirstOrDefault(); - if (outSqlParameter != null) + sqlParameter = new SqlParameter(parameterName, SqlDbType.VarChar, dataLength); + } + if (parameterMode.Equals("IN")) + { + sqlParameter.Direction = ParameterDirection.Input; + } + else + { + sqlParameter.Direction = ParameterDirection.Output; + } + command.Parameters.Add(sqlParameter); + } + for (int i = 0; i < command.Parameters.Count; i++) + { + SqlParameter sqlParameter = command.Parameters[i]; + if (parametersArray.Length > i) + { + string commandParameter = parametersArray[i]; + string field = commandParameter.Replace("@", "").Replace("{", "").Replace("}", ""); + string value = sourceRow.Table.Columns.Contains(field) ? sourceRow[field] + "" : commandParameter.Replace("@", ""); + value = value.Replace("{result}", txtEdit_info.Text); + value = value.Replace("@", "").Replace("{", "").Replace("}", ""); + sqlParameter.Value = value; + } + } + SqlParameter returnValue = new SqlParameter("@return", SqlDbType.Int, 4); + returnValue.Direction = ParameterDirection.ReturnValue; + command.Parameters.Add(returnValue); + command.CommandType = CommandType.StoredProcedure; + command.ExecuteNonQuery(); + if ((returnValue.Value + "").Equals("1")) + { + DialogResult = DialogResult.OK; + Close(); + } + else + { + SqlParameter outSqlParameter = command.Parameters.Cast().Where(n => n.Direction == ParameterDirection.Output).FirstOrDefault(); + if (outSqlParameter != null) + { + string outMessage = outSqlParameter.Value + ""; + if (!string.IsNullOrEmpty(outMessage)) { - string outMessage = outSqlParameter.Value + ""; - if (!string.IsNullOrEmpty(outMessage)) - { - MessageUtil.Show(outSqlParameter.Value + ""); - } + MessageUtil.Show(outSqlParameter.Value + ""); } } }