예제 #1
0
        public Type248Detail ParseDetail(XElement element, IDictionary <string, XNamespace> namespaces)
        {
            XNamespace empty;

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

            var model = new Type248Detail
            {
                BalanceAmount      = element.GetChildText(empty + "BalanceAmount"),
                CustomerName       = element.GetChildText(empty + "CustomerName"),
                CustomerTelephone1 = element.GetChildText(empty + "CustomerTelephone1"),
                CustomerTelephone2 = element.GetChildText(empty + "CustomerTelephone2"),
                ESIID                         = element.GetChildText(empty + "ESIID"),
                ESPAccountNbr                 = element.GetChildText(empty + "ESPAccountNbr"),
                HierarchicalID                = element.GetChildText(empty + "HierarchicalID"),
                HierarchicalLevelCode         = element.GetChildText(empty + "HierarchicalLevelCode"),
                InvoiceAmount                 = element.GetChildText(empty + "InvoiceAmount"),
                InvoiceDate                   = element.GetChildText(empty + "InvoiceDate"),
                InvoiceNbr                    = element.GetChildText(empty + "InvoiceNbr"),
                MarketerCustomerAccountNumber = element.GetChildText(empty + "MarketerCustomerAccountNumber"),
                OldLdcAccountNbr              = element.GetChildText(empty + "OldLdcAccountNbr"),
                ReinstatementDate             = element.GetChildText(empty + "ReinstatementDate"),
                ServiceTypeCode               = element.GetChildText(empty + "ServiceTypeCode"),
                WriteOffAccountNbr            = element.GetChildText(empty + "WriteOffAccountNbr"),
                WriteOffDate                  = element.GetChildText(empty + "WriteOffDate"),
            };

            return(model);
        }
예제 #2
0
        public int InsertDetail(Type248Detail model)
        {
            using (var connection = new SqlConnection(connectionString))
                using (var command = connection.CreateCommand("csp248DetailInsert"))
                {
                    SqlParameter keyParameter;

                    command.AddWithValue("@248_Key", model.HeaderKey)
                    .AddIfNotEmptyOrDbNull("@HierarchicalID", model.HierarchicalID)
                    .AddIfNotEmptyOrDbNull("@HierarchicalLevelCode", model.HierarchicalLevelCode)
                    .AddIfNotEmptyOrDbNull("@CustomerName", model.CustomerName)
                    .AddIfNotEmptyOrDbNull("@ESPAccountNumber", model.ESPAccountNbr)
                    .AddIfNotEmptyOrDbNull("@OldLdcAccountNumber", model.OldLdcAccountNbr)
                    .AddIfNotEmptyOrDbNull("@WriteOffAccountNbr", model.WriteOffAccountNbr)
                    .AddIfNotEmptyOrDbNull("@MarketerCustomerAccountNumber", model.MarketerCustomerAccountNumber)
                    .AddIfNotEmptyOrDbNull("@ServiceTypeCode", model.ServiceTypeCode)
                    .AddIfNotEmptyOrDbNull("@CustomerTelephone1", model.CustomerTelephone1)
                    .AddIfNotEmptyOrDbNull("@CustomerTelephone2", model.CustomerTelephone2)
                    .AddIfNotEmptyOrDbNull("@BalanceAmount", model.BalanceAmount)
                    .AddIfNotEmptyOrDbNull("@WriteOffDate", model.WriteOffDate)
                    .AddIfNotEmptyOrDbNull("@ReinstatementDate", model.ReinstatementDate)
                    .AddIfNotEmptyOrDbNull("@InvoiceDate", model.InvoiceDate)
                    .AddIfNotEmptyOrDbNull("@InvoiceAmount", model.InvoiceAmount)
                    .AddIfNotEmptyOrDbNull("@InvoiceNbr", model.InvoiceNbr)
                    .AddOutParameter("@Detail_Key", SqlDbType.Int, out keyParameter);

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

                    command.ExecuteNonQuery();

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

                    var detailKey = (int)keyParameter.Value;
                    model.DetailKey = detailKey;

                    return(detailKey);
                }
        }