public void AddOrderDetails(OrderDetailsCollection orderData)
        {
            SQLHandler sqlH = new SQLHandler();
            SqlTransaction tran;
            tran = (SqlTransaction)sqlH.GetTransaction();
            //AspxCommerceSession sn = new AspxCommerceSession();
            if (orderData.ObjOrderDetails.InvoiceNumber == null || orderData.ObjOrderDetails.InvoiceNumber == "")
            {
                orderData.ObjOrderDetails.InvoiceNumber = DateTime.Now.ToString("yyyyMMddhhmmss");
            }
            try
            {
                AspxOrderDetails ObjOrderDetails = new AspxOrderDetails();

                int billingAddressID = 0;
                int shippingAddressId = 0;
                int orderID = 0;
                if (orderData.ObjOrderDetails.IsMultipleCheckOut == false)
                {
                    if (orderData.ObjBillingAddressInfo.IsBillingAsShipping == true)
                    {
                        if (int.Parse(orderData.ObjBillingAddressInfo.AddressID) == 0 &&
                            int.Parse(orderData.ObjShippingAddressInfo.AddressID) == 0)
                        {
                            int addressID = ObjOrderDetails.AddAddress(orderData, tran);
                            billingAddressID = ObjOrderDetails.AddBillingAddress(orderData, tran, addressID);
                            shippingAddressId = ObjOrderDetails.AddShippingAddress(orderData, tran, addressID);
                        }
                    }
                    else
                    {
                        if (int.Parse(orderData.ObjBillingAddressInfo.AddressID) == 0)
                            billingAddressID = ObjOrderDetails.AddBillingAddress(orderData, tran);
                  
                        if (int.Parse(orderData.ObjShippingAddressInfo.AddressID) == 0)
                        {
                            if (!orderData.ObjOrderDetails.IsDownloadable)
                            {
                                shippingAddressId = ObjOrderDetails.AddShippingAddress(orderData, tran);
                            }

                        }
                    }
                }
                int paymentMethodID = ObjOrderDetails.AddPaymentInfo(orderData, tran);

                if (billingAddressID > 0)
                {
                    orderID = ObjOrderDetails.AddOrder(orderData, tran, billingAddressID, paymentMethodID);
                    //sn.SetSessionVariable("OrderID", orderID);
                    SetSessionVariable("OrderID", orderID);
                    orderData.ObjOrderDetails.OrderID = orderID;
                    SetSessionVariable("OrderCollection", orderData);
                }
                else
                {
                    orderID = ObjOrderDetails.AddOrderWithMultipleCheckOut(orderData, tran, paymentMethodID);

                    //sn.SetSessionVariable("OrderID", orderID);
                    SetSessionVariable("OrderID", orderID);
                    orderData.ObjOrderDetails.OrderID = orderID;
                    SetSessionVariable("OrderCollection", orderData);
                }

                if (shippingAddressId > 0)
                    ObjOrderDetails.AddOrderItems(orderData, tran, orderID, shippingAddressId);
                else
                    ObjOrderDetails.AddOrderItemsList(orderData, tran, orderID);

                tran.Commit();
            }
            catch (SqlException sqlEX)
            {

                throw new ArgumentException(sqlEX.Message);
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw ex;
            }
        }
    public void AddOrderDetails(OrderDetailsCollection OrderData)
    {
        SQLHandler sqlH = new SQLHandler();
        SqlTransaction tran;
        tran = (SqlTransaction)sqlH.GetTransaction();
        WcfSession sn = new WcfSession();
        try
        {
            AspxOrderDetails ObjOrderDetails = new AspxOrderDetails();

            int billingAddressID = 0;
            int shippingAddressId = 0;
            int orderID = 0;
            if (OrderData.ObjOrderDetails.IsMultipleCheckOut == false)
            {
                if (OrderData.ObjBillingAddressInfo.IsBillingAsShipping == true)
                {
                    if (int.Parse(OrderData.ObjBillingAddressInfo.AddressID) == 0 &&
                        int.Parse(OrderData.ObjShippingAddressInfo.AddressID) == 0)
                    {
                        int addressID = ObjOrderDetails.AddAddress(OrderData, tran);
                        billingAddressID = ObjOrderDetails.AddBillingAddress(OrderData, tran, addressID);
                        shippingAddressId = ObjOrderDetails.AddShippingAddress(OrderData, tran, addressID);
                    }
                }
                else
                {
                    if (int.Parse(OrderData.ObjBillingAddressInfo.AddressID) == 0)
                        billingAddressID = ObjOrderDetails.AddBillingAddress(OrderData, tran);
                    if (int.Parse(OrderData.ObjShippingAddressInfo.AddressID) == 0)
                        shippingAddressId = ObjOrderDetails.AddShippingAddress(OrderData, tran);
                }
            }
            int paymentMethodID = ObjOrderDetails.AddPaymentInfo(OrderData, tran);

            if (billingAddressID > 0)
            {
                orderID = ObjOrderDetails.AddOrder(OrderData, tran, billingAddressID, paymentMethodID);

                sn.SetSessionVariable("OrderID", orderID);

            }
            else
            {
                orderID = ObjOrderDetails.AddOrderWithMultipleCheckOut(OrderData, tran, paymentMethodID);

                sn.SetSessionVariable("OrderID", orderID);
            }

            if (shippingAddressId > 0)
                ObjOrderDetails.AddOrderItems(OrderData, tran, orderID, shippingAddressId);
            else
                ObjOrderDetails.AddOrderItemsList(OrderData, tran, orderID);

            tran.Commit();
        }
        catch (SqlException sqlEX)
        {

            throw new ArgumentException(sqlEX.Message);
        }
        catch (Exception ex)
        {
            tran.Rollback();
            throw ex;
        }
    }