Exemplo n.º 1
0
        public Type824Reference[] ListReferences(int headerKey)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("esp_824ReferenceList"))
                {
                    command.AddWithValue("@HeaderKey", headerKey);

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

                    var collection = new List <Type824Reference>();
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new Type824Reference
                            {
                                HeaderKey    = headerKey,
                                ReferenceKey = reader.GetInt32("Reference_Key"),
                            };

                            reader.TryGetString("AppAckCode", x => item.AppAckCode = x);
                            reader.TryGetString("ReferenceQualifier", x => item.ReferenceQualifier = x);
                            reader.TryGetString("ReferenceNbr", x => item.ReferenceNbr             = x);
                            reader.TryGetString("TransactionSetId", x => item.TransactionSetId     = x);
                            reader.TryGetString("CrossReferenceNbr", x => item.CrossReferenceNbr   = x);
                            reader.TryGetString("PurchaseOrderNbr", x => item.PurchaseOrderNbr     = x);
                            reader.TryGetString("PaymentsAppliedThroughDate", x => item.PaymentsAppliedThroughDate = x);
                            reader.TryGetString("TotalPaymentsApplied", x => item.TotalPaymentsApplied             = x);
                            reader.TryGetString("PaymentDueDate", x => item.PaymentDueDate = x);
                            reader.TryGetString("TotalAmountDue", x => item.TotalAmountDue = x);

                            collection.Add(item);
                        }

                        return(collection.ToArray());
                    }
                }
        }
Exemplo n.º 2
0
        public int InsertReference(Type824Reference model)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp824ReferenceInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@824_Key", model.HeaderKey)
                    .AddWithValue("@AppAckCode", model.AppAckCode)
                    .AddWithValue("@ReferenceQualifier", model.ReferenceQualifier)
                    .AddWithValue("@ReferenceNbr", model.ReferenceNbr)
                    .AddWithValue("@TransactionSetId", model.TransactionSetId)
                    .AddWithValue("@CrossReferenceNbr", model.CrossReferenceNbr)
                    .AddWithValue("@PurchaseOrderNbr", model.PurchaseOrderNbr)
                    .AddWithValue("@PaymentsAppliedThroughDate", model.PaymentsAppliedThroughDate)
                    .AddWithValue("@TotalPaymentsApplied", model.TotalPaymentsApplied)
                    .AddWithValue("@PaymentDueDate", model.PaymentDueDate)
                    .AddWithValue("@TotalAmountDue", model.TotalAmountDue)
                    .AddOutParameter("@Reference_Key", SqlDbType.Int, out keyParameter);

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

                    command.ExecuteNonQuery();

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

                    var referenceKey = (int)keyParameter.Value;
                    model.ReferenceKey = referenceKey;

                    return(referenceKey);
                }
        }
Exemplo n.º 3
0
        public Type824Reference ParseReference(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

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

            var model = new Type824Reference
            {
                AppAckCode                 = element.GetChildText(empty + "AppAckCode"),
                ReferenceQualifier         = element.GetChildText(empty + "ReferenceQualifier"),
                ReferenceNbr               = element.GetChildText(empty + "ReferenceNbr"),
                TransactionSetId           = element.GetChildText(empty + "TransactionSetId"),
                CrossReferenceNbr          = element.GetChildText(empty + "CrossReferenceNbr"),
                PurchaseOrderNbr           = element.GetChildText(empty + "PurchaseOrderNbr"),
                PaymentsAppliedThroughDate = element.GetChildText(empty + "PaymentsAppliedThroughDate"),
                TotalPaymentsApplied       = element.GetChildText(empty + "TotalPaymentsApplied"),
                PaymentDueDate             = element.GetChildText(empty + "PaymentDueDate"),
                TotalAmountDue             = element.GetChildText(empty + "TotalAmountDue"),
            };

            var errorLoopElement = element.Element(empty + "TechErrorLoop");

            if (errorLoopElement != null)
            {
                var errorElements = errorLoopElement.Elements(empty + "TechError");
                foreach (var errorElement in errorElements)
                {
                    var errorModel = ParseTechError(errorElement, namespaces);
                    model.AddTechError(errorModel);
                }
            }

            return(model);
        }