Commerce Server General - Code to Create Orders

This is Interesting: Free IT Magazines  
Home > Archive > Commerce Server General > April 2006 > Code to Create Orders





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Code to Create Orders
Davidlev

2006-04-01, 2:39 pm

Ok, I am going crazy.. I have built a script to importing orders into CS2002
FP1. For some reason, I cannot get the newly created Profile to be the
profile the order gets attached to. I have attached the code.. Please help!!!

#region Namespaces

using System;
using System.Collections;
using System.ComponentModel;
using System.Globalization;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Threading;

using Microsoft.CommerceServer.Runtime;
using Microsoft.CommerceServer.Runtime.Orders;
using Microsoft.CommerceServer.Runtime.Profiles;

using Microsoft.Solutions.Framework;
using Microsoft.Solutions.Applications.OrderManagement;

#endregion

namespace Microsoft.Solutions.Applications.RetailExtensions.AutomatedScripts
{
/// <summary>
/// Summary description for Order Import
/// </summary>
public class MercentOrderScript : System.Web.UI.Page
{
#region Data Member

string first_name = "";
string last_name = "";

#endregion

private void Page_Load(object sender, System.EventArgs e)
{

Response.Write("Processing Orders...<br><br>");

// get orders and items
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_PCgetUnprocessedOrders";

DataSet Shoppers = DatabaseManager.ExecuteSqlCommand(cmd);

// Relate the Orders and Order Items
DataTable MasterTable = Shoppers.Tables[0];
DataTable BillingTable = Shoppers.Tables[1];
DataTable ShippingTable = Shoppers.Tables[2];
DataTable DetailTable = Shoppers.Tables[3];
DataTable AddressTable = Shoppers.Tables[4];

DataColumn dcM = MasterTable.Columns["ChannelOrderID"];
DataColumn dcB = BillingTable.Columns["ChannelOrderID"];
DataColumn dcS = ShippingTable.Columns["ChannelOrderID"];
DataColumn dcD = DetailTable.Columns["ChannelOrderID"];
DataColumn dcA = AddressTable.Columns["ChannelOrderID"];

//Build the relation between master and detail tables.
DataRelation dr1 = new DataRelation("OrderMBRelation", dcM, dcB, false);
DataRelation dr2 = new DataRelation("OrderMSRelation", dcM, dcS, false);
DataRelation dr3 = new DataRelation("OrderMDRelation", dcM, dcD, false);
DataRelation dr4 = new DataRelation("OrderMARelation", dcM, dcA, false);

Shoppers.Relations.Add(dr1);
Shoppers.Relations.Add(dr2);
Shoppers.Relations.Add(dr3);
Shoppers.Relations.Add(dr4);

CommerceContext csContext = CommerceContext.Current;
Cart shoppingCart = new Cart();

foreach(DataRow ShopperDr in MasterTable.Rows)
{
Response.Write("Doing Order -> " + ShopperDr["ChannelOrderID"] + "<br>");

/* clear baskset */
shoppingCart.ClearAll();
shoppingCart.Basket.OrderForms.Add(new OrderForm("default"));

CultureInfo currencyDisplayCulture =
DataCollectionHelper.GetSiteCurrencyDisplayCulture();
string currencyCode = DataCollectionHelper.GetSiteCurrencyCode();
shoppingCart.Basket["billing_display_culture"] =
currencyDisplayCulture.Name;
shoppingCart.Basket.OrderForms[0]["billing_display_culture"] =
currencyDisplayCulture.Name;
shoppingCart.Basket["billing_currency"] = currencyCode;
shoppingCart.Basket.OrderForms[0]["billing_currency"] = currencyCode;

DataRow[] billingRow = ShopperDr.GetChildRows("OrderMBRelation");
DataRow[] shippingRow = ShopperDr.GetChildRows("OrderMSRelation");
DataRow[] addressRow = ShopperDr.GetChildRows("OrderMARelation");
DataRow[] itemRows = ShopperDr.GetChildRows("OrderMDRelation");

string username =
String.Format("Order_User_{0}_{1}",ShopperDr["ChannelOrderID"].ToString(),DateTime.Now.Second) ;
string password = ShopperDr["ChannelOrderID"].ToString();

first_name = billingRow[0]["FirstName"].ToString();
last_name = billingRow[0]["LastName"].ToString();

// Create User
UserObject userProfile = UserObject.CreateUserProfile (username);
Response.Write("New ProfileID is: " + userProfile.UserID.ToString());
userProfile.Password = password;
userProfile.LastName = last_name;
userProfile.FirstName = first_name;
userProfile.EmailAddress = billingRow[0]["EmailAddress"].ToString();
userProfile.Status = UserObject.AccountStatus.Active;
userProfile.PasswordQuestion = "pwdQn5_original";
userProfile.PasswordQuestionAnswer =
ShopperDr["ChannelOrderID"].ToString();
userProfile[MyAccount.UserProfilePropertyTelephoneNumber] =
billingRow[0]["PhoneNumber"].ToString();
userProfile[MyAccount.UserProfilePropertyTelephoneExtension] = "";
userProfile[MyAccount.UserProfilePropertyFaxNumber] = "";
userProfile[MyAccount.UserProfilePropertyFaxExtension] = "";
userProfile.Activate();
userProfile.PartnerServiceRole = UserObject.UserRole.NormalUser;
userProfile.ChangedBy = "OrderScript";
userProfile.UserType = UserObject.UserAccess.Registered;
userProfile.Language = Thread.CurrentThread.CurrentUICulture.Name;

/* save all information in shopper profile */
//userProfile.PreferredAddress = billTo;
userProfile.Update();

csContext.UserID = userProfile.UserID;
csContext.UserProfile = userProfile.ProfileObject;
csContext.AuthenticationInfo.SetProfileTicket(userProfile.UserID,false);
csContext.AuthenticationInfo.SetAuthTicket(userProfile.UserID,false);

string theID = csContext.UserID;


// Create Billing Address Object
Address billTo;
billTo = Address.CreateAddress(String.Format("Billing
Address_{0}_{1}",ShopperDr["ChannelOrderID"].ToString(),DateTime.Now.Second));
SetAddressProperties (billTo, addressRow[0], billingRow[0]);
billTo.Update();

// Create Shipping Address Object
Address shipTo;
shipTo = Address.CreateAddress(String.Format("Shipping
Address_{0}_{1}",ShopperDr["ChannelOrderID"].ToString(),DateTime.Now.Second));
SetAddressProperties (shipTo, addressRow[0], shippingRow[0] );
shipTo.Update();

Address userAddress;
userAddress = Address.GetAddressByName (billTo.AddressName);

//userProfile.PreferredAddress = userAddress;
//userProfile.Save();

// const string preferredAddressProfilePropertyFullName =
"GeneralInfo.preferred_address";
// string currentUserPreferredAddressName = String.Empty;
// object currentUserPreferredAddressPropertyValue
=
UserObject.CurrentUser[ preferredAddressProfilePropertyFullName ];
//
// currentUserPreferredAddressName =
currentUserPreferredAddressPropertyValue
.ToString();

// UserObject.CurrentUser.PreferredAddress = userAddress;
// UserObject.CurrentUser.Save();


shoppingCart.Basket.SetBillingAddress(billTo.AddressName);
//shoppingCart.Basket.SetShippingAddress(shipTo.AddressName);
shoppingCart.BillingAddress = new OrderAddress(billTo.AddressName,
billTo.ProfileObject);
//shoppingCart.ShippingAddress = new OrderAddress(shipTo.AddressName,
shipTo.ProfileObject);

//Guid newBasketID = Guid.NewGuid();

Basket curBasket = csContext.OrderSystem.GetBasket(new
System.Guid(userProfile.UserID));

curBasket.OrderForms.Add(new OrderForm("default"));
curBasket.SetBillingAddress( billTo.AddressName );
//curBasket.SetShippingAddress( shipTo.AddressName );

int itmIndex = 0;
foreach( DataRow itemRow in itemRows)
{
shoppingCart.AddItem("Petcare_Products",itemRow["ProductID"].ToString(),itemRow["VariantID"].ToString(),"Petcare_products","",(int)itemRow["quantity"],"",true);
shoppingCart.SetShippingAddress(itmIndex,new
OrderAddress(shipTo.AddressName, shipTo.ProfileObject));
shoppingCart. SetShippingMethod(itmIndex,TransactionCo
ntext.GetIdWithCurlyBraces("00000000-0000-0000-0000-004121001511"));

itmIndex++;
}

shoppingCart.RunBasketPipeline();
shoppingCart.RunTotalPipeline();

shoppingCart.Basket["billing_display_culture"] =
currencyDisplayCulture.Name;
shoppingCart.Basket.OrderForms[0]["billing_display_culture"] =
currencyDisplayCulture.Name;
shoppingCart.Basket["billing_currency"] = currencyCode;
shoppingCart.Basket.OrderForms[0]["billing_currency"] = currencyCode;
shoppingCart.Basket.OrderForms[0]["order_status"] = "IP";
shoppingCart.Basket.OrderForms[0]["user_id"] = userProfile.UserID;

PurchaseOrder po = shoppingCart.SaveAsOrder();

shoppingCart.ClearAll();
shoppingCart.Basket.OrderForms.Add(new OrderForm("default"));

po["user_first_name"] = shipTo.FirstName;
po["user_last_name"] = shipTo.LastName;
po.OrderForms[0]["user_first_name"] = shipTo.FirstName;
po.OrderForms[0]["user_last_name"] = shipTo.LastName;
po.OrderForms[0]["user_email_address"] = billingRow[0]["EmailAddress"];
po.OrderForms[0]["user_tel_number"] = billingRow[0]["PhoneNumber"];
po["order_create_date"] = DateTime.Now;
po["saved_cy_oadjust_subtotal"] = double.Parse("0");
po["saved_cy_shipping_total"] = double.Parse("0");
po["saved_cy_tax_total"] = double.Parse("0");
po["saved_cy_total_total"] = double.Parse("0");
po["order_status_date"] = DateTime.Now;
po.OrderForms[0]["saved_cy_total_total"]= double.Parse("0");
po.OrderForms[0]["payment_method"] = "amazon";
po.OrderForms[0]["payment_auth_code"] = "amazon";
po.OrderForms[0]["transaction_id"] = "0";
po.OrderForms[0]["order_status"] = "IP";
po.OrderForms[0]["user_id"] = userProfile.UserID;;
po.OrderForms[0]["order_status_date"] = DateTime.Now;
po["created_by"] = "order script";;

foreach (object item in (SimpleList)po.OrderForms[0]["_Purchase_Errors"])
{
Response.Write(item.ToString());
}

// processing went fine set default statuses
// if not set error statuses

po.Save();
billTo.Delete();
shipTo.Delete();
userProfile.Delete();

// Initialize ProcessBrain info
int newOrder_id = Int32.Parse(po.TrackingNumber);
Response.Write ("Order Created: " + newOrder_id + "<br>");
//PetCareRXPB.ProcessBrain pb = new PetCareRXPB.ProcessBrain();
//pb.ProcessNewOrder(ref newOrder_id);

// Ok, Now update the Mercent tables to indicate a sucessful import..
// get orders and items
// generate new item_id for this autoship item
SqlCommand cmd11 = new SqlCommand();
cmd11.CommandType = CommandType.StoredProcedure;
cmd11.CommandText = "sp_PCupdateMercentOrder ".ToString();
SqlParameter param11_1 = new SqlParameter();
param11_1.ParameterName = "@p_orderID";
param11_1.Value = newOrder_id;

SqlParameter param11_2 = new SqlParameter();
param11_2.ParameterName = "@channelOrderID";
param11_2.Value = ShopperDr["ChannelOrderID"];

cmd11.Parameters.Add(param11_1);
cmd11.Parameters.Add(param11_2);
string strResult = DatabaseManager.ExecuteSqlScalar(cmd11);

Response.Write ("Execute SP resulted (0 is good): " + strResult + "<br>");

}
}


private Guid getOrderGUID(string orderId)
{

SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "sp_PCgetOrderGUIDFromOrderID ".ToString();

// define parameters used in command object
SqlParameter param1 = new SqlParameter();
param1.ParameterName = "@p_order_id";
param1.Value = orderId;


// add parameters to command object
cmd.Parameters.Add(param1);

DataSet Result = DatabaseManager.ExecuteSqlCommand(cmd);

System.Guid userID = new
System.Guid(Result.Tables[0].Rows[0]["ordergroup_id"].ToString());
return userID;
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);

}
#endregion

#region Private Methods

private void SetProfileProperties (UserObject userProfile, DataRow dr)
{
userProfile.Password = dr["ChannelOrderID"].ToString();
userProfile.LastName = dr["LastName"].ToString();
userProfile.FirstName = dr["FirstName"].ToString();
userProfile.EmailAddress = dr["EmailAddress"].ToString();
userProfile.Status = UserObject.AccountStatus.Active;

userProfile.PasswordQuestion = dr["ChannelOrderID"].ToString();
userProfile.PasswordQuestionAnswer = dr["ChannelOrderID"].ToString();

userProfile[MyAccount.UserProfilePropertyTelephoneNumber] =
dr["PhoneNumber"];
//
// Set the user account to active status by default..
//
userProfile.Activate();
userProfile.PartnerServiceRole = UserObject.UserRole.NormalUser;
userProfile.ChangedBy = "Mercent Script";
userProfile.UserType = UserObject.UserAccess.Registered;
userProfile.Language = Thread.CurrentThread.CurrentUICulture.Name;
}


private void SetAddressProperties (Address userAddress, DataRow dr,
DataRow drBillTo)
{
// Set property values.
userAddress.AddressName = userAddress.AddressName;
userAddress.FirstName = drBillTo["FirstName"].ToString();
userAddress.LastName = drBillTo["LastName"].ToString();
userAddress.Line1 = dr["Address1"].ToString();
userAddress.Line2 = dr["Address2"].ToString();
userAddress.City = dr["City"].ToString();
userAddress.StateProvince = dr["Region"].ToString();
userAddress.ZipPostalCode = dr["PostalCode"].ToString();
userAddress.CountryRegion = dr["CountryCode"].ToString();
}
#endregion


}
}

Davidlev

2006-04-27, 7:27 am

Does no response mean I should forget about trying to use MS Commerce Server?


"Davidlev" wrote:

> Ok, I am going crazy.. I have built a script to importing orders into CS2002
> FP1. For some reason, I cannot get the newly created Profile to be the
> profile the order gets attached to. I have attached the code.. Please help!!!
>
> #region Namespaces
>
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Globalization;
> using System.Data;
> using System.Data.SqlClient;
> using System.Drawing;
> using System.Web;
> using System.Web.SessionState;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
> using System.Threading;
>
> using Microsoft.CommerceServer.Runtime;
> using Microsoft.CommerceServer.Runtime.Orders;
> using Microsoft.CommerceServer.Runtime.Profiles;
>
> using Microsoft.Solutions.Framework;
> using Microsoft.Solutions.Applications.OrderManagement;
>
> #endregion
>
> namespace Microsoft.Solutions.Applications.RetailExtensions.AutomatedScripts
> {
> /// <summary>
> /// Summary description for Order Import
> /// </summary>
> public class MercentOrderScript : System.Web.UI.Page
> {
> #region Data Member
>
> string first_name = "";
> string last_name = "";
>
> #endregion
>
> private void Page_Load(object sender, System.EventArgs e)
> {
>
> Response.Write("Processing Orders...<br><br>");
>
> // get orders and items
> SqlCommand cmd = new SqlCommand();
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.CommandText = "sp_PCgetUnprocessedOrders";
>
> DataSet Shoppers = DatabaseManager.ExecuteSqlCommand(cmd);
>
> // Relate the Orders and Order Items
> DataTable MasterTable = Shoppers.Tables[0];
> DataTable BillingTable = Shoppers.Tables[1];
> DataTable ShippingTable = Shoppers.Tables[2];
> DataTable DetailTable = Shoppers.Tables[3];
> DataTable AddressTable = Shoppers.Tables[4];
>
> DataColumn dcM = MasterTable.Columns["ChannelOrderID"];
> DataColumn dcB = BillingTable.Columns["ChannelOrderID"];
> DataColumn dcS = ShippingTable.Columns["ChannelOrderID"];
> DataColumn dcD = DetailTable.Columns["ChannelOrderID"];
> DataColumn dcA = AddressTable.Columns["ChannelOrderID"];
>
> //Build the relation between master and detail tables.
> DataRelation dr1 = new DataRelation("OrderMBRelation", dcM, dcB, false);
> DataRelation dr2 = new DataRelation("OrderMSRelation", dcM, dcS, false);
> DataRelation dr3 = new DataRelation("OrderMDRelation", dcM, dcD, false);
> DataRelation dr4 = new DataRelation("OrderMARelation", dcM, dcA, false);
>
> Shoppers.Relations.Add(dr1);
> Shoppers.Relations.Add(dr2);
> Shoppers.Relations.Add(dr3);
> Shoppers.Relations.Add(dr4);
>
> CommerceContext csContext = CommerceContext.Current;
> Cart shoppingCart = new Cart();
>
> foreach(DataRow ShopperDr in MasterTable.Rows)
> {
> Response.Write("Doing Order -> " + ShopperDr["ChannelOrderID"] + "<br>");
>
> /* clear baskset */
> shoppingCart.ClearAll();
> shoppingCart.Basket.OrderForms.Add(new OrderForm("default"));
>
> CultureInfo currencyDisplayCulture =
> DataCollectionHelper.GetSiteCurrencyDisplayCulture();
> string currencyCode = DataCollectionHelper.GetSiteCurrencyCode();
> shoppingCart.Basket["billing_display_culture"] =
> currencyDisplayCulture.Name;
> shoppingCart.Basket.OrderForms[0]["billing_display_culture"] =
> currencyDisplayCulture.Name;
> shoppingCart.Basket["billing_currency"] = currencyCode;
> shoppingCart.Basket.OrderForms[0]["billing_currency"] = currencyCode;
>
> DataRow[] billingRow = ShopperDr.GetChildRows("OrderMBRelation");
> DataRow[] shippingRow = ShopperDr.GetChildRows("OrderMSRelation");
> DataRow[] addressRow = ShopperDr.GetChildRows("OrderMARelation");
> DataRow[] itemRows = ShopperDr.GetChildRows("OrderMDRelation");
>
> string username =
> String.Format("Order_User_{0}_{1}",ShopperDr["ChannelOrderID"].ToString(),DateTime.Now.Second) ;
> string password = ShopperDr["ChannelOrderID"].ToString();
>
> first_name = billingRow[0]["FirstName"].ToString();
> last_name = billingRow[0]["LastName"].ToString();
>
> // Create User
> UserObject userProfile = UserObject.CreateUserProfile (username);
> Response.Write("New ProfileID is: " + userProfile.UserID.ToString());
> userProfile.Password = password;
> userProfile.LastName = last_name;
> userProfile.FirstName = first_name;
> userProfile.EmailAddress = billingRow[0]["EmailAddress"].ToString();
> userProfile.Status = UserObject.AccountStatus.Active;
> userProfile.PasswordQuestion = "pwdQn5_original";
> userProfile.PasswordQuestionAnswer =
> ShopperDr["ChannelOrderID"].ToString();
> userProfile[MyAccount.UserProfilePropertyTelephoneNumber] =
> billingRow[0]["PhoneNumber"].ToString();
> userProfile[MyAccount.UserProfilePropertyTelephoneExtension] = "";
> userProfile[MyAccount.UserProfilePropertyFaxNumber] = "";
> userProfile[MyAccount.UserProfilePropertyFaxExtension] = "";
> userProfile.Activate();
> userProfile.PartnerServiceRole = UserObject.UserRole.NormalUser;
> userProfile.ChangedBy = "OrderScript";
> userProfile.UserType = UserObject.UserAccess.Registered;
> userProfile.Language = Thread.CurrentThread.CurrentUICulture.Name;
>
> /* save all information in shopper profile */
> //userProfile.PreferredAddress = billTo;
> userProfile.Update();
>
> csContext.UserID = userProfile.UserID;
> csContext.UserProfile = userProfile.ProfileObject;
> csContext.AuthenticationInfo.SetProfileTicket(userProfile.UserID,false);
> csContext.AuthenticationInfo.SetAuthTicket(userProfile.UserID,false);
>
> string theID = csContext.UserID;
>
>
> // Create Billing Address Object
> Address billTo;
> billTo = Address.CreateAddress(String.Format("Billing
> Address_{0}_{1}",ShopperDr["ChannelOrderID"].ToString(),DateTime.Now.Second));
> SetAddressProperties (billTo, addressRow[0], billingRow[0]);
> billTo.Update();
>
> // Create Shipping Address Object
> Address shipTo;
> shipTo = Address.CreateAddress(String.Format("Shipping
> Address_{0}_{1}",ShopperDr["ChannelOrderID"].ToString(),DateTime.Now.Second));
> SetAddressProperties (shipTo, addressRow[0], shippingRow[0] );
> shipTo.Update();
>
> Address userAddress;
> userAddress = Address.GetAddressByName (billTo.AddressName);
>
> //userProfile.PreferredAddress = userAddress;
> //userProfile.Save();
>
> // const string preferredAddressProfilePropertyFullName =
> "GeneralInfo.preferred_address";
> // string currentUserPreferredAddressName = String.Empty;
> // object currentUserPreferredAddressPropertyValue
=
> UserObject.CurrentUser[ preferredAddressProfilePropertyFullName ];
> //
> // currentUserPreferredAddressName =
> currentUserPreferredAddressPropertyValue
.ToString();
>
> // UserObject.CurrentUser.PreferredAddress = userAddress;
> // UserObject.CurrentUser.Save();
>
>
> shoppingCart.Basket.SetBillingAddress(billTo.AddressName);
> //shoppingCart.Basket.SetShippingAddress(shipTo.AddressName);
> shoppingCart.BillingAddress = new OrderAddress(billTo.AddressName,
> billTo.ProfileObject);
> //shoppingCart.ShippingAddress = new OrderAddress(shipTo.AddressName,
> shipTo.ProfileObject);
>
> //Guid newBasketID = Guid.NewGuid();
>
> Basket curBasket = csContext.OrderSystem.GetBasket(new
> System.Guid(userProfile.UserID));
>
> curBasket.OrderForms.Add(new OrderForm("default"));
> curBasket.SetBillingAddress( billTo.AddressName );
> //curBasket.SetShippingAddress( shipTo.AddressName );
>
> int itmIndex = 0;
> foreach( DataRow itemRow in itemRows)
> {
> shoppingCart.AddItem("Petcare_Products",itemRow["ProductID"].ToString(),itemRow["VariantID"].ToString(),"Petcare_products","",(int)itemRow["quantity"],"",true);
> shoppingCart.SetShippingAddress(itmIndex,new
> OrderAddress(shipTo.AddressName, shipTo.ProfileObject));
> shoppingCart. SetShippingMethod(itmIndex,TransactionCo
ntext.GetIdWithCurlyBraces("00000000-0000-0000-0000-004121001511"));
>
> itmIndex++;
> }
>
> shoppingCart.RunBasketPipeline();
> shoppingCart.RunTotalPipeline();
>
> shoppingCart.Basket["billing_display_culture"] =
> currencyDisplayCulture.Name;
> shoppingCart.Basket.OrderForms[0]["billing_display_culture"] =
> currencyDisplayCulture.Name;
> shoppingCart.Basket["billing_currency"] = currencyCode;
> shoppingCart.Basket.OrderForms[0]["billing_currency"] = currencyCode;
> shoppingCart.Basket.OrderForms[0]["order_status"] = "IP";
> shoppingCart.Basket.OrderForms[0]["user_id"] = userProfile.UserID;
>
> PurchaseOrder po = shoppingCart.SaveAsOrder();
>
> shoppingCart.ClearAll();
> shoppingCart.Basket.OrderForms.Add(new OrderForm("default"));
>
> po["user_first_name"] = shipTo.FirstName;
> po["user_last_name"] = shipTo.LastName;
> po.OrderForms[0]["user_first_name"] = shipTo.FirstName;
> po.OrderForms[0]["user_last_name"] = shipTo.LastName;
> po.OrderForms[0]["user_email_address"] = billingRow[0]["EmailAddress"];
> po.OrderForms[0]["user_tel_number"] = billingRow[0]["PhoneNumber"];
> po["order_create_date"] = DateTime.Now;
> po["saved_cy_oadjust_subtotal"] = double.Parse("0");
> po["saved_cy_shipping_total"] = double.Parse("0");
> po["saved_cy_tax_total"] = double.Parse("0");
> po["saved_cy_total_total"] = double.Parse("0");
> po["order_status_date"] = DateTime.Now;
> po.OrderForms[0]["saved_cy_total_total"]= double.Parse("0");
> po.OrderForms[0]["payment_method"] = "amazon";
> po.OrderForms[0]["payment_auth_code"] = "amazon";
> po.OrderForms[0]["transaction_id"] = "0";
> po.OrderForms[0]["order_status"] = "IP";
> po.OrderForms[0]["user_id"] = userProfile.UserID;;
> po.OrderForms[0]["order_status_date"] = DateTime.Now;
> po["created_by"] = "order script";;
>
> foreach (object item in (SimpleList)po.OrderForms[0]["_Purchase_Errors"])
> {
> Response.Write(item.ToString());
> }
>
> // processing went fine set default statuses
> // if not set error statuses
>
> po.Save();
> billTo.Delete();
> shipTo.Delete();
> userProfile.Delete();
>
> // Initialize ProcessBrain info
> int newOrder_id = Int32.Parse(po.TrackingNumber);
> Response.Write ("Order Created: " + newOrder_id + "<br>");
> //PetCareRXPB.ProcessBrain pb = new PetCareRXPB.ProcessBrain();
> //pb.ProcessNewOrder(ref newOrder_id);
>
> // Ok, Now update the Mercent tables to indicate a sucessful import..
> // get orders and items
> // generate new item_id for this autoship item
> SqlCommand cmd11 = new SqlCommand();
> cmd11.CommandType = CommandType.StoredProcedure;
> cmd11.CommandText = "sp_PCupdateMercentOrder ".ToString();
> SqlParameter param11_1 = new SqlParameter();
> param11_1.ParameterName = "@p_orderID";
> param11_1.Value = newOrder_id;
>
> SqlParameter param11_2 = new SqlParameter();
> param11_2.ParameterName = "@channelOrderID";
> param11_2.Value = ShopperDr["ChannelOrderID"];
>
> cmd11.Parameters.Add(param11_1);
> cmd11.Parameters.Add(param11_2);
> string strResult = DatabaseManager.ExecuteSqlScalar(cmd11);
>
> Response.Write ("Execute SP resulted (0 is good): " + strResult + "<br>");
>
> }
> }
>
>
> private Guid getOrderGUID(string orderId)
> {
>
> SqlCommand cmd = new SqlCommand();
> cmd.CommandType = CommandType.StoredProcedure;
> cmd.CommandText = "sp_PCgetOrderGUIDFromOrderID ".ToString();
>
> // define parameters used in command object
> SqlParameter param1 = new SqlParameter();
> param1.ParameterName = "@p_order_id";
> param1.Value = orderId;
>
>
> // add parameters to command object
> cmd.Parameters.Add(param1);

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com