SVN r1136
SVN-Revision: r1136
This commit is contained in:
@@ -141,69 +141,67 @@ namespace Lskj.PubGetChipInfo
|
|||||||
if (!string.IsNullOrEmpty(functionName))
|
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;");
|
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(',');
|
string parameterName = parameterRow["PARAMETER_NAME"] + "";
|
||||||
foreach (DataRow parameterRow in sqlParametersTab.Rows)
|
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"] + "";
|
sqlParameter = new SqlParameter(parameterName, SqlDbType.Int);
|
||||||
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();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SqlParameter outSqlParameter = command.Parameters.Cast<SqlParameter>().Where(n => n.Direction == ParameterDirection.Output).FirstOrDefault();
|
sqlParameter = new SqlParameter(parameterName, SqlDbType.VarChar, dataLength);
|
||||||
if (outSqlParameter != null)
|
}
|
||||||
|
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<SqlParameter>().Where(n => n.Direction == ParameterDirection.Output).FirstOrDefault();
|
||||||
|
if (outSqlParameter != null)
|
||||||
|
{
|
||||||
|
string outMessage = outSqlParameter.Value + "";
|
||||||
|
if (!string.IsNullOrEmpty(outMessage))
|
||||||
{
|
{
|
||||||
string outMessage = outSqlParameter.Value + "";
|
MessageUtil.Show(outSqlParameter.Value + "");
|
||||||
if (!string.IsNullOrEmpty(outMessage))
|
|
||||||
{
|
|
||||||
MessageUtil.Show(outSqlParameter.Value + "");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user