예제 #1
0
        public void ParseDetailItem(Prism810Context context, string[] marketFields)
        {
            var current = context.Current;

            if (current == null || current.ModelType != Type810Types.Detail)
            {
                throw new InvalidOperationException();
            }

            var detail = current as Type810Detail;

            if (detail == null)
            {
                throw new InvalidOperationException();
            }

            var model = new Type810DetailItem
            {
                AssignedId = marketFields.AtIndex(2),
                ServiceOrderCompleteDate  = marketFields.AtIndex(13),
                UnmeteredServiceDateRange = marketFields.AtIndex(16),
                InvoiceNbr      = marketFields.AtIndex(15),
                ServiceOrderNbr = marketFields.AtIndex(14),
                Consumption     = marketFields.AtIndex(17),
                EffectiveDate   = marketFields.AtIndex(18),
            };

            detail.AddItem(model);
            context.PushModel(model);
        }
예제 #2
0
        public Type810DetailItem ParseDetailItem(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

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

            var model = new Type810DetailItem
            {
                AssignedId                = element.GetChildText(empty + "AssignedId"),
                RelationshipCode          = element.GetChildText(empty + "RelationshipCode"),
                ServiceOrderCompleteDate  = element.GetChildText(empty + "ServiceOrderCompleteDate"),
                UnmeteredServiceDateRange = element.GetChildText(empty + "UnmeteredServiceDateRange"),
                InvoiceNbr                = element.GetChildText(empty + "InvoiceNbr"),
                ServiceOrderNbr           = element.GetChildText(empty + "ServiceOrderNbr"),
                Consumption               = element.GetChildText(empty + "Consumption"),
                EffectiveDate             = element.GetChildText(empty + "EffectiveDate"),
                SequenceId                = element.GetChildText(empty + "SequenceId"),
            };

            var itemChargeLoopElement = element.Element(empty + "DetailItemChargeLoop");

            if (itemChargeLoopElement != null)
            {
                var itemChargeElements = itemChargeLoopElement.Elements(empty + "DetailItemCharge");
                foreach (var itemChargeElement in itemChargeElements)
                {
                    var itemChargeModel = ParseDetailItemCharge(itemChargeElement, namespaces);
                    model.AddCharge(itemChargeModel);
                }
            }

            var detailItemTaxLoopElement = element.Element(empty + "DetailItemTaxLoop");

            if (detailItemTaxLoopElement != null)
            {
                var detailItemTaxElements = detailItemTaxLoopElement.Elements(empty + "DetailItemTax");
                foreach (var detailItemTaxElement in detailItemTaxElements)
                {
                    var detailItemTaxModel = ParseDetailItemTax(detailItemTaxElement, namespaces);
                    model.AddTax(detailItemTaxModel);
                }
            }

            return(model);
        }
예제 #3
0
        public Type810DetailItem[] ListDetailItems(int detailKey)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("esp_810DetailItemList"))
                {
                    command.AddWithValue("@DetailKey", detailKey);

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

                    var collection = new List <Type810DetailItem>();
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new Type810DetailItem
                            {
                                DetailKey = detailKey,
                                ItemKey   = reader.GetInt32("Item_Key"),
                            };

                            reader.TryGetString("AssignedId", x => item.AssignedId             = x);
                            reader.TryGetString("RelationshipCode", x => item.RelationshipCode = x);
                            reader.TryGetString("ServiceOrderCompleteDate", x => item.ServiceOrderCompleteDate   = x);
                            reader.TryGetString("UnmeteredServiceDateRange", x => item.UnmeteredServiceDateRange = x);
                            reader.TryGetString("InvoiceNbr", x => item.InvoiceNbr           = x);
                            reader.TryGetString("ServiceOrderNbr", x => item.ServiceOrderNbr = x);
                            reader.TryGetString("Consumption", x => item.Consumption         = x);
                            reader.TryGetString("EffectiveDate", x => item.EffectiveDate     = x);
                            reader.TryGetString("SequenceId", x => item.SequenceId           = x);

                            collection.Add(item);
                        }

                        return(collection.ToArray());
                    }
                }
        }
예제 #4
0
        public int InsertDetailItem(Type810DetailItem model)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp810DetailItemInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@Detail_Key", model.DetailKey)
                    .AddIfNotEmptyOrDbNull("@AssignedId", model.AssignedId)
                    .AddIfNotEmptyOrDbNull("@RelationshipCode", model.RelationshipCode)
                    .AddIfNotEmptyOrDbNull("@ServiceOrderCompleteDate", model.ServiceOrderCompleteDate)
                    .AddIfNotEmptyOrDbNull("@UnmeteredServiceDateRange", model.UnmeteredServiceDateRange)
                    .AddIfNotEmptyOrDbNull("@InvoiceNbr", model.InvoiceNbr)
                    .AddIfNotEmptyOrDbNull("@ServiceOrderNbr", model.ServiceOrderNbr)
                    .AddWithValue("@Consumption", model.Consumption)
                    .AddWithValue("@EffectiveDate", model.EffectiveDate)
                    .AddOutParameter("@Item_Key", SqlDbType.Int, out keyParameter);

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

                    command.ExecuteNonQuery();

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

                    var itemKey = (int)keyParameter.Value;
                    model.ItemKey = itemKey;

                    return(itemKey);
                }
        }