Esempio n. 1
0
        private void ParseUnmeterDetail(Prism867Context context, string servicePeriodStart, string servicePeriodEnd, string serviceType, string description)
        {
            var current = context.Current;

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

            var header = current as Type867Header;

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

            var model = new Type867UnMeterDetail
            {
                TypeCode           = context.RecordType,
                ServicePeriodStart = servicePeriodStart,
                ServicePeriodEnd   = servicePeriodEnd,
                ServiceType        = serviceType,
                Description        = description
            };

            context.PushModel(model);
            header.AddUnMeterDetail(model);
        }
Esempio n. 2
0
        public Type867UnMeterDetail ParseUnMeterDetail(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

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

            var model = new Type867UnMeterDetail
            {
                TypeCode                = element.GetChildText(empty + "TypeCode"),
                CommodityCode           = element.GetChildText(empty + "CommodityCode"),
                ServicePeriodStart      = element.GetChildText(empty + "ServicePeriodStart"),
                ServicePeriodEnd        = element.GetChildText(empty + "ServicePeriodEnd"),
                ServiceType             = element.GetChildText(empty + "ServiceType"),
                Description             = element.GetChildText(empty + "Description"),
                UtilityRateServiceClass = element.GetChildText(empty + "UtilityRateServiceClass"),
                RateSubClass            = element.GetChildText(empty + "RateSubClass")
            };

            var quantitiesLoopElement = element.Element(empty + "UnmeterDetailQtyLoop");

            if (quantitiesLoopElement != null)
            {
                var quantityElements = quantitiesLoopElement.Elements(empty + "UnmeterDetailQty");
                foreach (var quantityElement in quantityElements)
                {
                    var quantityModel = ParseUnMeterDetailQty(quantityElement, namespaces);
                    model.AddQuantity(quantityModel);
                }
            }

            return(model);
        }
Esempio n. 3
0
        public int InsertUnMeterDetail(Type867UnMeterDetail model)
        {
            using (var connection = new SqlConnection(_connectionString))
                using (var command = connection.CreateCommand("csp867UnmeterDetailInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@867_Key", model.HeaderKey)
                    .AddIfNotEmptyOrDbNull("@TypeCode", model.TypeCode)
                    .AddIfNotEmptyOrDbNull("@ServicePeriodStart", model.ServicePeriodStart)
                    .AddIfNotEmptyOrDbNull("@ServicePeriodEnd", model.ServicePeriodEnd)
                    .AddIfNotEmptyOrDbNull("@ServiceType", model.ServiceType)
                    .AddIfNotEmptyOrDbNull("@Description", model.Description)
                    .AddWithValue("@CommodityCode", model.CommodityCode)
                    .AddWithValue("@UtilityRateServiceClass", model.UtilityRateServiceClass)
                    .AddWithValue("@RateSubClass", model.RateSubClass)
                    .AddOutParameter("@UnmeterDetail_Key", SqlDbType.Int, out keyParameter);

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

                    command.ExecuteNonQuery();

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

                    var key = (int)keyParameter.Value;
                    model.UnMeterDetailKey = key;

                    return(key);
                }
        }