Exemplo n.º 1
0
        public void ParseCharge(Prism810Context context, string[] marketFields)
        {
            var current = context.Current;

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

            var detailItem = current as Type810DetailItem;

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

            var amount = (marketFields.AtIndexDecimal(6) * 100);
            var model  = new Type810DetailItemCharge
            {
                ChargeIndicator = marketFields.AtIndex(3),
                AgencyCode      = "EU",
                ChargeCode      = marketFields.AtIndex(5),
                Amount          = amount.ToString("0"),
                Rate            = marketFields.AtIndex(7),
                UOM             = marketFields.AtIndex(8),
                Quantity        = marketFields.AtIndex(9),
                Description     = marketFields.AtIndex(11),
            };

            detailItem.AddCharge(model);
        }
Exemplo n.º 2
0
        public int InsertDetailItemCharge(Type810DetailItemCharge model)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp810DetailItemChargeInsert"))
                {
                    command.AddWithValue("@Item_Key", model.ItemKey)
                    .AddIfNotEmptyOrDbNull("@ChargeIndicator", model.ChargeIndicator)
                    .AddIfNotEmptyOrDbNull("@AgencyCode", model.AgencyCode)
                    .AddIfNotEmptyOrDbNull("@ChargeCode", model.ChargeCode)
                    .AddIfNotEmptyOrDbNull("@Amount", model.Amount)
                    .AddIfNotEmptyOrDbNull("@Rate", model.Rate)
                    .AddIfNotEmptyOrDbNull("@UOM", model.UOM)
                    .AddIfNotEmptyOrDbNull("@Quantity", model.Quantity)
                    .AddIfNotEmptyOrDbNull("@Description", model.Description);

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

                    command.ExecuteNonQuery();

                    model.ChargeKey = 1;
                    return(1);
                }
        }
Exemplo n.º 3
0
        public Type810DetailItemCharge ParseDetailItemCharge(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

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

            var model = new Type810DetailItemCharge
            {
                ChargeIndicator = element.GetChildText(empty + "ChargeIndicator"),
                AgencyCode      = element.GetChildText(empty + "AgencyCode"),
                ChargeCode      = element.GetChildText(empty + "ChargeCode"),
                Amount          = element.GetChildText(empty + "Amount"),
                Rate            = element.GetChildText(empty + "Rate"),
                UOM             = element.GetChildText(empty + "UOM"),
                Quantity        = element.GetChildText(empty + "Quantity"),
                Description     = element.GetChildText(empty + "Description"),
                PrintSeqId      = element.GetChildText(empty + "PrintSeqId"),
                EnergyCharges   = element.GetChildText(empty + "EnergyCharges"),
            };

            return(model);
        }
Exemplo n.º 4
0
        public Type810DetailItemCharge[] ListDetailItemCharges(int detailItemKey)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("esp_810DetailItemChargeList"))
                {
                    command.AddWithValue("@ItemKey", detailItemKey);

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

                    var collection = new List <Type810DetailItemCharge>();
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            var item = new Type810DetailItemCharge
                            {
                                ItemKey   = detailItemKey,
                                ChargeKey = reader.GetInt32("Charge_Key"),
                            };

                            reader.TryGetString("ChargeIndicator", x => item.ChargeIndicator = x);
                            reader.TryGetString("AgencyCode", x => item.AgencyCode           = x);
                            reader.TryGetString("ChargeCode", x => item.ChargeCode           = x);
                            reader.TryGetString("Amount", x => item.Amount           = x);
                            reader.TryGetString("Rate", x => item.Rate               = x);
                            reader.TryGetString("UOM", x => item.UOM                 = x);
                            reader.TryGetString("Quantity", x => item.Quantity       = x);
                            reader.TryGetString("Description", x => item.Description = x);
                            reader.TryGetString("PrintSeqId", x => item.PrintSeqId   = x);

                            collection.Add(item);
                        }

                        return(collection.ToArray());
                    }
                }
        }