Пример #1
0
        private void SaveBillingMethodList(BillingMethodList billingMethodList, Int32 customerId)
        {
            DbCommand command = m_CustomerDb.GetStoredProcCommand("usp_BillingMethod_Save");

            m_CustomerDb.AddInParameter(command, "CustomerId", DbType.Int32);
            m_CustomerDb.AddInParameter(command, "NetTermDays", DbType.Int32);
            m_CustomerDb.AddInParameter(command, "CreditCardBillingAddressId", DbType.Int32);
            m_CustomerDb.AddInParameter(command, "CreditCardExpiration", DbType.Date);
            m_CustomerDb.AddInParameter(command, "CreditCardNumber", DbType.String);
            m_CustomerDb.AddInParameter(command, "PaymentMethodId", DbType.Int32);
            m_CustomerDb.AddInParameter(command, "IsActive", DbType.Boolean);
            m_CustomerDb.AddParameter(command, "BillingMethodId", DbType.Int32, 4,
                                      ParameterDirection.InputOutput, true, 0, 0, String.Empty,
                                      DataRowVersion.Default, DBNull.Value);

            foreach (BillingMethod billingMethod in billingMethodList)
            {
                m_CustomerDb.SetParameterValue(command,
                                               "BillingMethodId", billingMethod.BillingMethodId);

                m_CustomerDb.SetParameterValue(command,
                                               "CustomerId", customerId);

                m_CustomerDb.SetParameterValue(command,
                                               "PaymentMethodId", billingMethod.PaymentMethodId);

                if (billingMethod.NetTermDays.HasValue)
                {
                    m_CustomerDb.SetParameterValue(command,
                                                   "NetTermDays", billingMethod.NetTermDays.Value);
                }

                if (billingMethod.CreditCardBillingAddressId.HasValue)
                {
                    m_CustomerDb.SetParameterValue(command,
                                                   "CreditCardBillingAddressId", billingMethod.CreditCardBillingAddressId.Value);
                }

                if (billingMethod.CreditCardExpiration.HasValue)
                {
                    m_CustomerDb.SetParameterValue(command,
                                                   "CreditCardExpiration", billingMethod.CreditCardExpiration.Value);
                }

                m_CustomerDb.SetParameterValue(command,
                                               "CreditCardNumber", billingMethod.CreditCardNumber);

                m_CustomerDb.SetParameterValue(command,
                                               "IsActive", billingMethod.IsActive);

                m_CustomerDb.ExecuteNonQuery(command);

                if (billingMethod.BillingMethodId < 1)
                {
                    billingMethod.BillingMethodId = (int)m_CustomerDb.GetParameterValue(command, "BillingMethodId");
                }
            }
        }
Пример #2
0
        public static BillingMethodList BillingMethodTranslate(DataTypes.BillingMethod[] billingMethods)
        {
            BillingMethodList list = new BillingMethodList();

            BusinessEntities.BillingMethod billingMethod;

            for (int i = 0; i < billingMethods.Length; i++)
            {
                billingMethod = new BusinessEntities.BillingMethod();
                billingMethod.BillingMethodId = billingMethods[i].BillingMethodId;
                billingMethod.CustomerId      = billingMethods[i].CustomerId;
                billingMethod.PaymentMethodId = billingMethods[i].PaymentMethodId;
                billingMethod.IsActive        = billingMethods[i].IsActive;

                if (billingMethods[i].PaymentMethodId == 1)
                { //credit card
                    if (billingMethods[i].CreditCardBillingAddressId < 0)
                    {
                        billingMethod.CreditCardBillingAddressId = null;
                    }
                    else
                    {
                        billingMethod.CreditCardBillingAddressId =
                            billingMethods[i].CreditCardBillingAddressId;
                    }


                    if (billingMethods[i].CreditCardExpiration == DateTime.MinValue)
                    {
                        billingMethod.CreditCardExpiration = null;
                    }
                    else
                    {
                        billingMethod.CreditCardExpiration = billingMethods[i].CreditCardExpiration;
                    }

                    billingMethod.CreditCardNumber = billingMethods[i].CreditCardNumber;
                }
                else
                {//net term
                    if (billingMethods[i].NetTermDays < 0)
                    {
                        billingMethod.NetTermDays = null;
                    }
                    else
                    {
                        billingMethod.NetTermDays = billingMethods[i].NetTermDays;
                    }
                }

                list.Add(billingMethod);
            }

            return(list);
        }
Пример #3
0
        public static DataTypes.BillingMethod[] BillingMethodTranslate(BillingMethodList billingMethodList)
        {
            DataTypes.BillingMethod[] billingMethods = new DataTypes.BillingMethod[billingMethodList.Count];
            DataTypes.BillingMethod   billingMethod;
            for (Int32 i = 0; i < billingMethodList.Count; i++)
            {
                billingMethod = new DataTypes.BillingMethod();
                billingMethod.BillingMethodId = billingMethodList[i].BillingMethodId;
                billingMethod.PaymentMethodId = billingMethodList[i].PaymentMethodId;
                billingMethod.IsActive        = billingMethodList[i].IsActive;
                billingMethod.CustomerId      = billingMethodList[i].CustomerId;

                if (billingMethodList[i].PaymentMethodId == 1)
                { //credit card
                    if (billingMethodList[i].CreditCardBillingAddressId.HasValue)
                    {
                        billingMethod.CreditCardBillingAddressId = billingMethodList[i].CreditCardBillingAddressId.Value;
                    }
                    else
                    {
                        billingMethod.CreditCardBillingAddressId = -1;
                    }

                    billingMethod.CreditCardNumber = billingMethodList[i].CreditCardNumber;

                    if (billingMethodList[i].CreditCardExpiration.HasValue)
                    {
                        billingMethod.CreditCardExpiration = billingMethodList[i].CreditCardExpiration.Value;
                    }
                    else
                    {
                        billingMethod.CreditCardExpiration = DateTime.MinValue;
                    }
                }
                else
                {// net term
                    if (billingMethodList[i].NetTermDays.HasValue)
                    {
                        billingMethod.NetTermDays = billingMethodList[i].NetTermDays.Value;
                    }
                    else
                    {
                        billingMethod.NetTermDays = 0;
                    }
                }

                billingMethods[i] = billingMethod;
            }

            return(billingMethods);
        }
Пример #4
0
        private BillingMethodList GetBillingMethodList(Int32 customerId)
        {
            BillingMethodList billingMethodList = new BillingMethodList();
            DbCommand         command           = m_CustomerDb.GetStoredProcCommand("usp_BillingMethod_List");

            m_CustomerDb.AddInParameter(command, "CustomerId", DbType.Int32);
            m_CustomerDb.SetParameterValue(command, "CustomerId", customerId);

            using (IDataReader reader = m_CustomerDb.ExecuteReader(command))
            {
                BillingMethod billingMethod;

                Int32 billingMethodIdOrdinal            = reader.GetOrdinal("BillingMethodId");
                Int32 paymentMethodIdOrdinal            = reader.GetOrdinal("PaymentMethodId");
                Int32 netTermDaysOrdinal                = reader.GetOrdinal("NetTermDays");
                Int32 creditCardBillingAddressIdOrdinal = reader.GetOrdinal("CreditCardBillingAddressId");
                Int32 creditCardExpirationOrdinal       = reader.GetOrdinal("CreditCardExpiration");
                Int32 creditCardNumberOrdinal           = reader.GetOrdinal("CreditCardNumber");

                while (reader.Read())
                {
                    if (!reader.IsDBNull(billingMethodIdOrdinal) &&
                        !reader.IsDBNull(paymentMethodIdOrdinal))
                    {
                        billingMethod                 = new BillingMethod();
                        billingMethod.CustomerId      = customerId;
                        billingMethod.BillingMethodId = reader.GetInt32(billingMethodIdOrdinal);
                        billingMethod.PaymentMethodId = reader.GetInt32(paymentMethodIdOrdinal);

                        if (!reader.IsDBNull(netTermDaysOrdinal))
                        {
                            billingMethod.NetTermDays = reader.GetInt32(netTermDaysOrdinal);
                        }
                        else
                        {
                            billingMethod.NetTermDays = null;
                        }

                        if (!reader.IsDBNull(creditCardBillingAddressIdOrdinal))
                        {
                            billingMethod.CreditCardBillingAddressId = reader.GetInt32(creditCardBillingAddressIdOrdinal);
                        }
                        else
                        {
                            billingMethod.CreditCardBillingAddressId = null;
                        }

                        if (!reader.IsDBNull(creditCardExpirationOrdinal))
                        {
                            billingMethod.CreditCardExpiration = reader.GetDateTime(creditCardExpirationOrdinal);
                        }
                        else
                        {
                            billingMethod.CreditCardExpiration = null;
                        }

                        if (!reader.IsDBNull(creditCardNumberOrdinal))
                        {
                            billingMethod.CreditCardNumber = reader.GetString(creditCardNumberOrdinal);
                        }
                        else
                        {
                            billingMethod.CreditCardNumber = null;
                        }

                        billingMethod.IsActive = true;
                        billingMethodList.Add(billingMethod);
                    }
                }
            }

            return(billingMethodList);
        }