public static ConfirmInvoiceResult ConfirmInvoice(string invoiceNumber) { if (string.IsNullOrEmpty(invoiceNumber)) { throw new System.ArgumentNullException("invoiceNumber"); } ConfirmInvoiceResult result = new ConfirmInvoiceResult(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString)) { using (SqlCommand command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "invoicesforbank.dbo.up_ConfirmInvoiceByINumber"; command.Parameters.Add("INumber", SqlDbType.VarChar).Value = invoiceNumber; using (OperationDurationLimit.ShortOperation(command)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { int[] fields = new int[] { reader.GetOrdinal("ret"), reader.GetOrdinal("message") }; result.Error = new int?(reader.ReadInt(fields[0])); result.ErrorMessage = reader.ReadNullableTrimmedString(fields[1]); } } } } } return(result); }
public static ConfirmInvoiceResult ConfirmInvoice(string invoiceNumber) { if (string.IsNullOrEmpty(invoiceNumber)) { throw new System.ArgumentNullException("invoiceNumber"); } ConfirmInvoiceResult result = new ConfirmInvoiceResult(); using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["db"].ConnectionString)) { using (SqlCommand command = connection.CreateCommand()) { command.CommandType = CommandType.StoredProcedure; command.CommandText = "invoicesforbank.dbo.up_ConfirmInvoiceByINumber"; command.Parameters.Add("INumber", SqlDbType.VarChar).Value = invoiceNumber; using (OperationDurationLimit.ShortOperation(command)) { connection.Open(); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { int[] fields = new int[] { reader.GetOrdinal("ret"), reader.GetOrdinal("message") }; result.Error = new int?(reader.ReadInt(fields[0])); result.ErrorMessage = reader.ReadNullableTrimmedString(fields[1]); } } } } } return result; }