Пример #1
0
        public Type997ResponseNote ParseResponseNote(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

            if (!namespaces.TryGetValue(string.Empty, out empty))
            {
                empty = XNamespace.None;
            }

            var model = new Type997ResponseNote
            {
                ElementCopy            = element.GetChildText(empty + "ElementCopy"),
                ElementPosition        = element.GetChildText(empty + "ElementPosition"),
                ElementReferenceNbr    = element.GetChildText(empty + "ElementReferenceNbr"),
                ElementSyntaxErrorCode = element.GetChildText(empty + "ElementSyntaxErrorCode"),
                LoopIdentifierCode     = element.GetChildText(empty + "LoopIdentifierCode"),
                SegmentIdCode          = element.GetChildText(empty + "SegmentIdCode"),
                SegmentPosition        = element.GetChildText(empty + "SegmentPosition"),
                SegmentSyntaxErrorCode = element.GetChildText(empty + "SegmentSyntaxErrorCode"),
            };

            return(model);
        }
Пример #2
0
        public int InsertResponseNote(Type997ResponseNote model)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp997ResponseNoteInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@Response_Key", model.ResponseKey)
                    .AddIfNotEmptyOrDbNull("@SegmentIdCode", model.SegmentIdCode)
                    .AddIfNotEmptyOrDbNull("@SegmentPosition", model.SegmentPosition)
                    .AddIfNotEmptyOrDbNull("@LoopIdentifierCode", model.LoopIdentifierCode)
                    .AddIfNotEmptyOrDbNull("@SegmentSyntaxErrorCode", model.SegmentSyntaxErrorCode)
                    .AddIfNotEmptyOrDbNull("@ElementPosition", model.ElementPosition)
                    .AddIfNotEmptyOrDbNull("@ElementReferenceNbr", model.ElementReferenceNbr)
                    .AddIfNotEmptyOrDbNull("@ElementSyntaxErrorCode", model.ElementSyntaxErrorCode)
                    .AddIfNotEmptyOrDbNull("@ElementCopy", model.ElementCopy)
                    .AddOutParameter("@Note_Key", SqlDbType.Int, out keyParameter);

                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    command.ExecuteNonQuery();

                    if (keyParameter.Value == null)
                    {
                        throw new Exception();
                    }

                    var noteKey = (int)keyParameter.Value;
                    model.ResponseNoteKey = noteKey;

                    return(noteKey);
                }
        }