本文整理汇总了C#中Order.Save方法的典型用法代码示例。如果您正苦于以下问题:C# Order.Save方法的具体用法?C# Order.Save怎么用?C# Order.Save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order.Save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MapsManyToOneUsingConventions
public void MapsManyToOneUsingConventions()
{
var cust = new Customer() { Name = "Jeremy" };
var order = new Order() { Customer = cust };
using(ContextScope.Begin()) {
cust.Save();
order.Save();
}
using(ContextScope.Begin()) {
order = Order.FindById(order.Id);
order.Customer.Name.ShouldEqual("Jeremy");
}
}
示例2: GenerateHtmlForm
public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
{
order.MustNotBeNull( "order" );
settings.MustNotBeNull( "settings" );
settings.MustContainKey( "form_url", "settings" );
PaymentHtmlForm htmlForm = new PaymentHtmlForm {
Action = settings[ "form_url" ]
};
htmlForm.InputFields[ "form_url" ] = settings.ContainsKey( "mode" ) && settings[ "mode" ] == "live" ? LiveTransactionEndpoint : TestTransactionEndpoint;
htmlForm.InputFields[ "cancel_url" ] = teaCommerceCancelUrl;
htmlForm.InputFields[ "communication_url" ] = teaCommerceCommunicationUrl;
order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCallBackUrl", teaCommerceCallBackUrl ) { ServerSideOnly = true } );
order.Save();
return htmlForm;
}
示例3: AgentSaveTest
public void AgentSaveTest()
{
Address address = new Address();
address.Street = "1234 Lorong 2 Taman Bangla";
address.Postal = "12345";
address.State = "Pahang";
Stock stock = new Stock(3);
Nisan nisan = new Nisan(stock);
nisan.Name = "Che Som" + new System.Random().Next(100) + " bin Said";
nisan.Death = RandomDate();
Agent agent = new Agent("W002");
Order target = new Order();
target.Status = TransactionStage.Submit;
target.Agent = agent;
target.Amount = stock.Price;
target.Quantity = 1;
target.Stock = nisan;
target.ShipTo = address;
Assert.IsTrue(target.Save());
}
示例4: Test1
public void Test1()
{
var c = new Company {Name = "NotExist"};
var u = new User {Name = "tom", Type = UserType.Manager, Valid = true}; u.Company.Value = c;
var d = new Department {Name = "Selling"}; d.Company.Value = c;
var e = new Employee {Name = "jerry", Age = 24}; e.Company.Value = c; e.Department.Value = d;
var r = new Resource {Name = "Printer", Count = 2}; r.Company.Value = c; r.Department.Value = d;
var p = new Product { Name = "Tale Story" }; p.Company.Value = c;
var t = new Trade { Name = "20110001", TotalPrice = 192m }; t.Company.Value = c;
var o = new Order { Name = "Tale Story", Count = 10, Price = 19.2m};
o.Description.Value = "test"; o.Trade.Value = t; o.Product.Value = p;
o.Save();
var o1 = Order.FindById(o.Id);
Assert.AreEqual("Tale Story", o1.Name);
Assert.AreEqual(10, o1.Count);
Assert.AreEqual("20110001", o1.Trade.Value.Name);
Assert.AreEqual(192m, o1.Trade.Value.TotalPrice);
Assert.AreEqual("Tale Story", o1.Product.Value.Name);
Assert.IsNotNull(o1.Trade.Value.Company);
Assert.AreEqual("NotExist", o1.Trade.Value.Company.Value.Name);
Assert.AreEqual("tom", o1.Trade.Value.Company.Value.Users[0].Name);
Assert.AreEqual(UserType.Manager, o1.Trade.Value.Company.Value.Users[0].Type);
Assert.AreEqual("Selling", o1.Trade.Value.Company.Value.Departments[0].Name);
Assert.AreEqual("Printer", o1.Trade.Value.Company.Value.Resources[0].Name);
Assert.AreEqual("Printer", o1.Trade.Value.Company.Value.Departments[0].Resources[0].Name);
Assert.AreEqual("jerry", o1.Trade.Value.Company.Value.Departments[0].Employees[0].Name);
}
示例5: GivenAModelWithAnAbstractBehavior_Save_ShouldApplyTheAbstractBehavior
public void GivenAModelWithAnAbstractBehavior_Save_ShouldApplyTheAbstractBehavior()
{
NoRMaticConfig.DropAbstractBehaviors();
NoRMaticConfig.AddBeforeSaveAbstractBehavior<IBoundByAccount>(x => { x.AccountName = "accountA"; return true; });
var order = new Order { Quantity = 20, Sku = "A3EF29" };
order.Save();
Assert.AreEqual("accountA", order.AccountName);
}
示例6: Insert
public void Insert(string OrderCode,DateTime OrderDate,string OrderCard,int OrderMemberID,int OrderSellerID,string OrderProduct,int? OrderQty,decimal? OrderSum,decimal? OrderSumOk,decimal? OrderRateSale,decimal? OrderRate,decimal? OrderPoint,decimal? OrderPay,decimal? OrderPayCash,decimal? OrderPayPoint,DateTime OrderDateUpload,DateTime OrderDateDeliver,int OrderStatus,string OrderMemo,int? OrderType,int? CreatedBy,DateTime? CreatedOn,int? ModifiedBy,DateTime? ModifiedOn,int? MansionId,decimal? ServiceSum,bool? IsNonOut,int? OrderNum,int? OrderOper,int? OrderModel,DateTime? OrderUpdateOn,bool? HasOutOfStock,decimal? OrderPrePoint,int? MsnType)
{
Order item = new Order();
item.OrderCode = OrderCode;
item.OrderDate = OrderDate;
item.OrderCard = OrderCard;
item.OrderMemberID = OrderMemberID;
item.OrderSellerID = OrderSellerID;
item.OrderProduct = OrderProduct;
item.OrderQty = OrderQty;
item.OrderSum = OrderSum;
item.OrderSumOk = OrderSumOk;
item.OrderRateSale = OrderRateSale;
item.OrderRate = OrderRate;
item.OrderPoint = OrderPoint;
item.OrderPay = OrderPay;
item.OrderPayCash = OrderPayCash;
item.OrderPayPoint = OrderPayPoint;
item.OrderDateUpload = OrderDateUpload;
item.OrderDateDeliver = OrderDateDeliver;
item.OrderStatus = OrderStatus;
item.OrderMemo = OrderMemo;
item.OrderType = OrderType;
item.CreatedBy = CreatedBy;
item.CreatedOn = CreatedOn;
item.ModifiedBy = ModifiedBy;
item.ModifiedOn = ModifiedOn;
item.MansionId = MansionId;
item.ServiceSum = ServiceSum;
item.IsNonOut = IsNonOut;
item.OrderNum = OrderNum;
item.OrderOper = OrderOper;
item.OrderModel = OrderModel;
item.OrderUpdateOn = OrderUpdateOn;
item.HasOutOfStock = HasOutOfStock;
item.OrderPrePoint = OrderPrePoint;
item.MsnType = MsnType;
item.Save(UserName);
}
示例7: SaveSaleRate
public static bool SaveSaleRate(Order data, SysMember member,out string message)
{
message = string.Empty;
//赠送积分=(现金支付+储值支付) * 赠送比例
data.OrderPoint = (data.OrderPay + data.OrderPayCash) * data.OrderRate;
if (data.OrderPoint.HasValue && data.OrderPoint > 0)
{
if (CompanyBLL.IsMaxPointLevel(data.OrderSellerID, data.OrderPoint.Value))
{
message = "累计赠送的积分已经超过500,须进行积分结算后才能继续操作系统";
return false;
}
}
data.Save( );
//data.OrderPoint = (AppContextBase.Context.Company.CompanyType == 2) ? (data.OrderPayCash * data.OrderRate) : ((data.OrderPay + data.OrderPayCash) * data.OrderRate);
//推荐好友奖励
RewardBLL.RewardMemberPoint(member, data);
if (data.OrderPoint > 0M)
{
new Payment
{
PaymentDate = data.OrderDate,
PaymentCompanyID = data.OrderSellerID,
PaymentMemberID = data.OrderMemberID,
PaymentMemo = string.Format("在【{0}】消费{1:0.00}元,并获赠{2:0.00}个积分", AppContextBase.Context.Company.CompanyName,data.OrderSumOk, data.OrderPoint.Value.ToString("#####0.00")),
PaymentStatus = 1,
PaymentSum = Convert.ToDecimal(data.OrderPoint),
PaymentType = 1,
PaymentOrderID = data.Id,
PaymentCode = data.OrderCode,
PaymentEmail = string.Empty
}.Save( );
}
if (data.OrderPayPoint > 0M)
{
new Payment
{
PaymentDate = data.OrderDate,
PaymentCompanyID = data.OrderSellerID,
PaymentMemberID = data.OrderMemberID,
PaymentMemo = string.Format("在【{0}】消费{1:0.00}元,其中使用{2:0.00}个积分抵扣", AppContextBase.Context.Company.CompanyName, data.OrderSumOk, Math.Abs(data.OrderPayPoint.Value).ToString("#####0.00")),
PaymentStatus = 1,
PaymentSum = -Convert.ToDecimal(data.OrderPayPoint),
PaymentType = 2,
PaymentOrderID = data.Id,
PaymentCode = data.OrderCode,
PaymentEmail = string.Empty
}.Save( );
}
if (data.OrderPayCash > 0M)
{
#region hot company
if (CompanyBLL.GetCompanyType(AppContextBase.Context.Company.CompanyType) == CompanyType.MealCompany)
{
string queryCode = string.Concat(AreaBLL.GetCompanyCodePrefix(AppContextBase.Context.Company.CompanyCode), "%");
//queryCode = queryCode.Substring(0, queryCode.Length - 2) + "%";
var query = DB.Select("CashCompanyID", "sum(CashSum) as CashSum")
.From<SysMemberCash>( ).InnerJoin(SysCompany.IdColumn, SysMemberCash.CashCompanyIDColumn)
.Where(SysMemberCash.CashMemberIDColumn).IsEqualTo(member.Id)
.And(SysCompany.CompanyCodeColumn).Like(queryCode)
.ConstraintExpression("Group By CashCompanyID");
DataTable result = query.ExecuteDataTable( );
foreach (DataRow row in result.Rows)
{
if (!Utilities.IsNull(row["CashSum"]) && Convert.ToDecimal(row["CashSum"]) > 0M)
{
OrdersCashCompany orders_cashcompany = new OrdersCashCompany
{
CashCompanyID = Convert.ToInt32(row["CashCompanyID"]),
CashOrderID = data.Id,
CashSum = Convert.ToInt32(data.OrderPayCash)
};
if (Convert.ToInt32(row["CashCompanyID"]) != data.OrderSellerID)
{
orders_cashcompany.Save( );
}
new PaymentCash
{
PaymentCashDate = data.OrderDate,
PaymentCashCompanyID = orders_cashcompany.CashCompanyID,
PaymentCashMemberID = data.OrderMemberID,
PaymentMemo = string.Format("在【{0}】消费{1:0.00}元,使用储值支付{2:0.00}元", AppContextBase.Context.Company.CompanyName, data.OrderSumOk, Math.Abs(data.OrderPayCash.Value).ToString("######.##")),
PaymentStatus = 1,
PaymentCashSum = -Convert.ToDecimal(data.OrderPayCash),
PaymentType = 2,
PaymentOrderID = data.Id,
PaymentCashCode = data.OrderCode
}.Save( );
new SysMemberCash
{
CashCompanyID = orders_cashcompany.CashCompanyID,
CashMemberID = data.OrderMemberID,
CashOrderID = data.Id,
CashDate = data.OrderDate,
CashSum = -data.OrderPayCash,
CashRate = 0M,
CashPoint = 0,
CashMemo = "储值支付",
CashRateSale = 0,
//.........这里部分代码省略.........
示例8: SaveOrder
private static int SaveOrder(OrderMealUserData userData,
List<OrderMealData> orderData,
Order order,
SysCompany company,
SysCompanyItem companyItem,
decimal orderSum,
int qty,
bool isNewOrder,
out int orderId,
out string message)
{
orderId = -1;
bool isLogin = AppContextBase.Context.CurrentSubSys != SubSystem.ALL;
decimal servicesSum = company.ServiceSum.HasValue ? company.ServiceSum.Value : 0;
SysMember user = isLogin ? AppContextBase.Context.User : null;
bool isNeedCheckPhone;
if (!isLogin || !Utilities.Compare(user.MemberPhoneNumber, userData.userPhone))
isNeedCheckPhone = true;
else
isNeedCheckPhone = MsnBLL.IsPhoneNumNeedCheck(userData.userPhone);
decimal userOrderAvgSum = 0;
if (isLogin && companyItem != null && !CompanyItemBLL.CanClickCompanyMealItem(company, user, companyItem, userData.orderId, out userOrderAvgSum, out message))
return -1;
bool isNew = false;
using (TransactionScope ts = new TransactionScope( ))
{
using (SharedDbConnectionScope ss = new SharedDbConnectionScope( ))
{
if (isNeedCheckPhone && !MsnBLL.CheckPhoneNumCode(userData.userPhone, userData.checkCode, userData.msnLogId))
{
message = "验证码有误或已超时,请重新验证。";
return -1;
}
user = user ?? UserBLL.GetOrNewMemberByPhoneNumber(userData.userPhone, company, out isNew);
if (isNew)
user.AreaDepth2 = company.AreaDepth; //第一次订快餐的地址,默认该地址所属商圈为其工作圈
else if (!Utilities.Compare(user.AreaDepth2, company.AreaDepth))
{
if (string.IsNullOrEmpty(user.AreaDepth1))
user.AreaDepth1 = company.AreaDepth;
else if (string.IsNullOrEmpty(user.AreaDepth3))
user.AreaDepth3 = company.AreaDepth;
}
if (!isNewOrder)
{
if (order.OrderMemberID != user.Id)
{
message = "你不能修改其他会员的订单.";
return -1;
}
ClearOrderMenuDetail(order.Id);
if (Utilities.ToDecimal(order.OrderPoint) > 0)
RewardBLL.RewardMemberPointForOrderMeal(user, company, order);
order.OrderStatus = (int)OrderStatus.Modified;
}
else
{
order.OrderNum = GetOrderNum( );
order.OrderStatus = (int)OrderStatus.NotStart;
order.OrderPoint = 0;
}
var dtNow = DateTime.Now;
//order.OrderCode = orderCode;
order.OrderCard = string.Empty;
order.OrderDate = dtNow;
order.OrderDateDeliver = dtNow;
order.OrderDateUpload = dtNow;
order.OrderMemberID = user.Id;
order.OrderMemo = userData.memo;
order.OrderProduct = userData.address; //送餐地址
order.OrderQty = qty;
order.OrderRateSale = 0; // 折扣
order.OrderRate = RewardBLL.OrderMealRewardRate(company) / 100M; //赠送比例
order.OrderPrePoint = (RewardBLL.OrderMealRewardRate(company) / 100M) * orderSum; //赠送积分
order.OrderSellerID = company.Id;
order.OrderSum = orderSum; //订单总额
order.OrderSumOk = orderSum + servicesSum; //订单总额
order.OrderPay = orderSum + servicesSum; //现金支付
order.OrderPayCash = 0; //储值支付
order.OrderPayPoint = companyItem != null ? companyItem.ItemPoint : 0;//积分支付
order.OrderType = (int)OrderType.OrderMeal;
order.ServiceSum = servicesSum;
order.MansionId = userData.mansionId;
order.OrderModel = company.IsUseMsg.HasValue && company.IsUseMsg.Value ? (int)OrderModel.Auto : (int)OrderModel.Manual;
order.OrderUpdateOn = DateTime.Now;
order.IsNonOut = false;
order.HasOutOfStock = false;
order.Save( );
//RewardBLL.RewardMemberPointForOrderMeal(user, company, order);
//save detail
List<OrdersDetail> details = new List<OrdersDetail>( );
foreach (var pair in orderData)
{
var d = new OrdersDetail( )
{
MenuId = pair.menudId,
MenuName = pair.menuName,
OrderId = order.Id,
OrderQty = pair.menuAmount,
//.........这里部分代码省略.........
示例9: RefundPayment
public override ApiInfo RefundPayment( Order order, IDictionary<string, string> settings )
{
ApiInfo apiInfo = null;
try {
order.MustNotBeNull( "order" );
settings.MustNotBeNull( "settings" );
settings.MustContainKey( "Vendor", "settings" );
settings.MustContainKey( "Description", "settings" );
Dictionary<string, string> inputFields = new Dictionary<string, string>();
Guid vendorTxCode = Guid.NewGuid();
inputFields[ "VPSProtocol" ] = "2.23";
inputFields[ "TxType" ] = "REFUND";
inputFields[ "Vendor" ] = settings[ "Vendor" ];
inputFields[ "VendorTxCode" ] = vendorTxCode.ToString();
inputFields[ "Amount" ] = order.TransactionInformation.AmountAuthorized.Value.ToString( "0.00", CultureInfo.InvariantCulture );
//Check that the Iso code exists
Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
}
inputFields[ "Currency" ] = currency.IsoCode;
inputFields[ "Description" ] = settings[ "Description" ].Truncate( 100 );
inputFields[ "RelatedVPSTxId" ] = order.TransactionInformation.TransactionId;
inputFields[ "RelatedVendorTxCode" ] = order.Properties[ "vendorTxCode" ];
inputFields[ "RelatedSecurityKey" ] = order.Properties[ "securityKey" ];
inputFields[ "RelatedTxAuthNo" ] = order.Properties[ "txAuthNo" ];
inputFields[ "ApplyAVSCV2" ] = "0";
IDictionary<string, string> responseFields = GetFields( MakePostRequest( GetMethodUrl( "REFUND", settings ), inputFields ) );
if ( responseFields[ "Status" ] == "OK" ) {
order.Properties.AddOrUpdate( new CustomProperty( "vendorTxCode", vendorTxCode.ToString() ) { ServerSideOnly = true } );
order.Properties.AddOrUpdate( new CustomProperty( "txAuthNo", responseFields[ "TxAuthNo" ] ) { ServerSideOnly = true } );
order.Save();
apiInfo = new ApiInfo( responseFields[ "VPSTxId" ], PaymentState.Refunded );
} else {
LoggingService.Instance.Log( "Sage pay(" + order.OrderNumber + ") - Error making API request: " + responseFields[ "StatusDetail" ] );
}
} catch ( Exception exp ) {
LoggingService.Instance.Log( exp, "Sage pay(" + order.OrderNumber + ") - Refund payment" );
}
return apiInfo;
}
示例10: GenerateHtmlForm
//.........这里部分代码省略.........
streetAddress.MustNotBeNullOrEmpty( "streetAddress" );
city.MustNotBeNullOrEmpty( "city" );
zipCode.MustNotBeNullOrEmpty( "zipCode" );
string shippingFirstName = settings.ContainsKey( "shipping_firstNamePropertyAlias" ) ? order.Properties[ settings[ "shipping_firstNamePropertyAlias" ] ] : "";
if ( string.IsNullOrEmpty( shippingFirstName ) ) {
shippingFirstName = order.PaymentInformation.FirstName;
}
string shippingLastName = settings.ContainsKey( "shipping_lastNamePropertyAlias" ) ? order.Properties[ settings[ "shipping_lastNamePropertyAlias" ] ] : "";
if ( string.IsNullOrEmpty( shippingLastName ) ) {
shippingLastName = order.PaymentInformation.LastName;
}
string shippingStreetAddress = settings.ContainsKey( "shipping_streetAddressPropertyAlias" ) ? order.Properties[ settings[ "shipping_streetAddressPropertyAlias" ] ] : "";
if ( string.IsNullOrEmpty( shippingStreetAddress ) ) {
shippingStreetAddress = streetAddress;
}
string shippingCity = settings.ContainsKey( "shipping_cityPropertyAlias" ) ? order.Properties[ settings[ "shipping_cityPropertyAlias" ] ] : "";
if ( string.IsNullOrEmpty( shippingCity ) ) {
shippingCity = city;
}
string shippingZipCode = settings.ContainsKey( "shipping_zipCodePropertyAlias" ) ? order.Properties[ settings[ "shipping_zipCodePropertyAlias" ] ] : "";
if ( string.IsNullOrEmpty( shippingZipCode ) ) {
shippingZipCode = zipCode;
}
#endregion
if ( order.CartNumber.Length > 40 ) {
throw new Exception( "Cart number of the order can not exceed 40 characters." );
}
inputFields[ "VendorTxCode" ] = order.CartNumber;
inputFields[ "Amount" ] = order.TotalPrice.Value.WithVat.ToString( "0.00", CultureInfo.InvariantCulture );
//Check that the Iso code exists
Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
}
inputFields[ "Currency" ] = currency.IsoCode;
inputFields[ "Description" ] = inputFields[ "Description" ].Truncate( 100 );
inputFields[ "SuccessURL" ] = teaCommerceContinueUrl;
inputFields[ "FailureURL" ] = teaCommerceCancelUrl;
inputFields[ "NotificationURL" ] = teaCommerceCallBackUrl;
inputFields[ "BillingSurname" ] = order.PaymentInformation.LastName.Truncate( 20 );
inputFields[ "BillingFirstnames" ] = order.PaymentInformation.FirstName.Truncate( 20 );
inputFields[ "BillingAddress1" ] = streetAddress.Truncate( 100 );
inputFields[ "BillingCity" ] = city.Truncate( 40 );
inputFields[ "BillingPostCode" ] = zipCode.Truncate( 10 );
Country country = CountryService.Instance.Get( order.StoreId, order.PaymentInformation.CountryId );
inputFields[ "BillingCountry" ] = country.RegionCode;
if ( country.RegionCode.ToUpperInvariant() == "US" && order.PaymentInformation.CountryRegionId != null ) {
CountryRegion countryRegion = CountryRegionService.Instance.Get( order.StoreId, order.PaymentInformation.CountryRegionId.Value );
inputFields[ "BillingState" ] = countryRegion.RegionCode.Truncate( 2 );
}
if ( settings.ContainsKey( "phonePropertyAlias" ) ) {
inputFields[ "BillingPhone" ] = order.Properties[ settings[ "phonePropertyAlias" ] ].Truncate( 20 );
}
inputFields[ "DeliverySurname" ] = shippingLastName.Truncate( 20 );
inputFields[ "DeliveryFirstnames" ] = shippingFirstName.Truncate( 20 );
inputFields[ "DeliveryAddress1" ] = shippingStreetAddress.Truncate( 100 );
inputFields[ "DeliveryCity" ] = shippingCity.Truncate( 40 );
inputFields[ "DeliveryPostCode" ] = shippingZipCode.Truncate( 10 );
country = CountryService.Instance.Get( order.StoreId, order.ShipmentInformation.CountryId ?? order.PaymentInformation.CountryId );
inputFields[ "DeliveryCountry" ] = country.RegionCode;
long? shippingCountryRegionId = order.ShipmentInformation.CountryId != null ? order.ShipmentInformation.CountryRegionId : order.PaymentInformation.CountryRegionId;
if ( country.RegionCode.ToUpperInvariant() == "US" && shippingCountryRegionId != null ) {
CountryRegion countryRegion = CountryRegionService.Instance.Get( order.StoreId, shippingCountryRegionId.Value );
inputFields[ "DeliveryState" ] = countryRegion.RegionCode.Truncate( 2 );
}
if ( settings.ContainsKey( "shipping_phonePropertyAlias" ) ) {
inputFields[ "DeliveryPhone" ] = order.Properties[ settings[ "shipping_phonePropertyAlias" ] ].Truncate( 20 );
}
inputFields[ "Apply3DSecure" ] = "2";
IDictionary<string, string> responseFields = GetFields( MakePostRequest( GetMethodUrl( "PURCHASE", settings ), inputFields ) );
string status = responseFields[ "Status" ];
if ( status == "OK" || status == "OK REPEATED" ) {
order.Properties.AddOrUpdate( new CustomProperty( "securityKey", responseFields[ "SecurityKey" ] ) { ServerSideOnly = true } );
order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCancelUrl", teaCommerceCancelUrl ) { ServerSideOnly = true } );
order.Save();
htmlForm.Action = responseFields[ "NextURL" ];
} else {
htmlForm.Action = teaCommerceCancelUrl;
LoggingService.Instance.Log( "Sage Pay(" + order.CartNumber + ") - Generate html form error - status: " + status + " | status details: " + responseFields[ "StatusDetail" ] );
}
return htmlForm;
}
示例11: CreateInvalidOrder
public void CreateInvalidOrder()
{
Order order = new Order();
order.Title = "Blah";
order.Save();
}
示例12: Submit
private void Submit()
{
stockId = Convert.ToInt32(ddlStock.SelectedValue);
HLGranite.Nisan.Stock stock = new HLGranite.Nisan.Stock(stockId);
Nisan nisan = new Nisan(stock);
nisan.Name = txtName.Text.Trim();
nisan.Jawi = txtJawi.Text.Trim();
nisan.Death = ToDate(txtDeath.Text);
nisan.Deathm = new DateTime(Convert.ToInt32(txtYear.Text), ddlMonth.SelectedIndex + 1, Convert.ToInt32(ddlDay.Text));
Order target = new Order();
target.Status = TransactionStage.Submit;
if (user == null)
{
Customer customer = new Customer();
customer.Name = txtCustomer.Text;
customer.Email = txtEmail.Text;
customer.Phone = txtPhone.Text;
target.Customer = customer;
target.Parent.CreatedBy = customer;
}
else
{
if (txtCustomer.Text.Trim() != user.Name)
{
Customer customer = new Customer();
customer.Name = txtCustomer.Text;
customer.Email = txtEmail.Text;
customer.Phone = txtPhone.Text;
target.Customer = customer;
target.Parent.CreatedBy = customer;
}
else if (user is Agent)
{
target.Agent = (user as Agent);
target.Parent.CreatedBy = (user as Agent);
}
}
target.Amount = stock.Price;
target.Quantity = 1;
target.Stock = nisan;
Address address = new Address();
address.Street = txtAddress.Text;
address.Postal = txtPostal.Text;
address.State = ddlState.Text;
target.ShipTo = address;
bool success = target.Save();
if (success)
{
lblMessage.Text = "Your order has been sent to us and we will contact you shortly.";
EnableForm(false);
}
}
示例13: GenerateHtmlForm
public override PaymentHtmlForm GenerateHtmlForm( Order order, string teaCommerceContinueUrl, string teaCommerceCancelUrl, string teaCommerceCallBackUrl, string teaCommerceCommunicationUrl, IDictionary<string, string> settings )
{
order.MustNotBeNull( "order" );
settings.MustNotBeNull( "settings" );
settings.MustContainKey( "merchantId", "settings" );
PaymentHtmlForm htmlForm = new PaymentHtmlForm();
string[] settingsToExclude = new[] { "accepturl", "cancelurl", "instantcapture", "testMode" };
htmlForm.InputFields = settings.Where( i => !settingsToExclude.Contains( i.Key ) ).ToDictionary( i => i.Key, i => i.Value );
//orderNumber
htmlForm.InputFields[ "orderNumber" ] = order.CartNumber;
//currencyCode
Currency currency = CurrencyService.Instance.Get( order.StoreId, order.CurrencyId );
if ( !Iso4217CurrencyCodes.ContainsKey( currency.IsoCode ) ) {
throw new Exception( "You must specify an ISO 4217 currency code for the " + currency.Name + " currency" );
}
htmlForm.InputFields[ "currencyCode" ] = currency.IsoCode;
//amount
htmlForm.InputFields[ "amount" ] = ( order.TotalPrice.Value.WithVat * 100M ).ToString( "0", CultureInfo.InvariantCulture );
//redirectUrl
htmlForm.InputFields[ "redirectUrl" ] = teaCommerceCallBackUrl;
//redirectOnError
htmlForm.InputFields[ "redirectOnError" ] = "false";
//paymentMethodList
if ( htmlForm.InputFields.ContainsKey( "paymentMethodList" ) && string.IsNullOrEmpty( htmlForm.InputFields[ "paymentMethodList" ] ) )
htmlForm.InputFields.Remove( "paymentMethodList" );
XDocument xmlResponse = XDocument.Parse( MakePostRequest( settings.ContainsKey( "testMode" ) && settings[ "testMode" ] == "1" ? "https://epayment-test.bbs.no/Netaxept/Register.aspx" : "https://epayment.bbs.no/Netaxept/Register.aspx", htmlForm.InputFields ), LoadOptions.PreserveWhitespace );
if ( xmlResponse.XPathSelectElement( "//RegisterResponse" ) != null ) {
//Save the Tea Commerce continue and cancel url so we have access to them in the "Callback"
order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceContinueUrl", teaCommerceContinueUrl ) { ServerSideOnly = true } );
order.Properties.AddOrUpdate( new CustomProperty( "teaCommerceCancelUrl", teaCommerceCancelUrl ) { ServerSideOnly = true } );
order.Save();
htmlForm.Action = ( settings.ContainsKey( "testMode" ) && settings[ "testMode" ] == "1" ? "https://epayment-test.bbs.no/Terminal/default.aspx" : "https://epayment.bbs.no/Terminal/default.aspx" ) + "?merchantId=" + settings[ "merchantId" ] + "&transactionId=" + xmlResponse.XPathSelectElement( "//TransactionId" ).Value;
} else {
throw new Exception( "Generate html failed - error message: " + xmlResponse.XPathSelectElement( "//Error/Message" ).Value );
}
return htmlForm;
}
示例14: Insert
public void Insert(string CustomerID,int? EmployeeID,DateTime? OrderDate,DateTime? RequiredDate,DateTime? ShippedDate,int? ShipVia,decimal? Freight,string ShipName,string ShipAddress,string ShipCity,string ShipRegion,string ShipPostalCode,string ShipCountry)
{
Order item = new Order();
item.CustomerID = CustomerID;
item.EmployeeID = EmployeeID;
item.OrderDate = OrderDate;
item.RequiredDate = RequiredDate;
item.ShippedDate = ShippedDate;
item.ShipVia = ShipVia;
item.Freight = Freight;
item.ShipName = ShipName;
item.ShipAddress = ShipAddress;
item.ShipCity = ShipCity;
item.ShipRegion = ShipRegion;
item.ShipPostalCode = ShipPostalCode;
item.ShipCountry = ShipCountry;
item.Save(UserName);
}
示例15: SavePickList
/// <summary>
/// Saves issue order details
/// </summary>
/// <param name="orderID"></param>
/// <param name="dvPickListMakeup"></param>
public void SavePickList(int orderID, DataView dvPickListMakeup, int userID)
{
//~ Check if This Order has a previous Printed Picklist with detail: Note a header only doesnt affect us! //
var pickList = new PickList();
pickList.LoadByOrderID(orderID);
if(pickList.RowCount>0)
{
var pldetail = new PickListDetail();
pldetail.LoadByPickListID(pickList.ID);
if (pldetail.RowCount > 0)
{
RemoveFakePartialCommitPickListDetails(orderID);
var pickL = new PickList();
pickL.LoadByOrderID(orderID);
if (pickL.RowCount > 0)
{
throw new Exception("Picklist has already been printed for this Order ");
// This error has been apprearing for the last one year so funny! I hope it won't come again! day: 10/21/2014 @yido //
}
}
}
// Create a pick list entry
Order ord = new Order();
ord.LoadByPrimaryKey(orderID);
PickList pl = new PickList();
PalletLocation plocation = new PalletLocation();
plocation.LoadByPrimaryKey(Convert.ToInt32(dvPickListMakeup[0]["PalletLocationID"]));
pl.AddNew();
pl.OrderID = orderID;
pl.PickType = "Pick";
pl.PickedBy = userID;
pl.IsConfirmed = false;
pl.IssuedDate = DateTimeHelper.ServerDateTime;
pl.SavedDate = DateTimeHelper.ServerDateTime;
pl.PickedDate = DateTimeHelper.ServerDateTime;
pl.IsWarehouseConfirmed = 0;
pl.WarehouseID = plocation.WarehouseID;
pl.Save();
PickListDetail pld = new PickListDetail();
ReceivePallet rp = new ReceivePallet();
ReceiveDoc rd = new ReceiveDoc();
PickFace pf = new PickFace();
foreach (DataRowView drv in dvPickListMakeup)
{
pld.AddNew();
pld.PickListID = pl.ID;
pld.OrderDetailID = Convert.ToInt32(drv["OrderDetailID"]);
pld.ItemID = Convert.ToInt32(drv["ItemID"]);
pld.BatchNumber = (drv["BatchNo"].ToString());
if (drv["ExpDate"] != DBNull.Value)
{
pld.ExpireDate = Convert.ToDateTime(drv["ExpDate"]);
}
pld.ManufacturerID = Convert.ToInt32(drv["ManufacturerID"]);
pld.BoxLevel = Convert.ToInt32(drv["BoxLevel"]);
pld.QtyPerPack = Convert.ToInt32(drv["QtyPerPack"]);
pld.Packs = Convert.ToDecimal(drv["Pack"]);
pld.PalletLocationID = Convert.ToInt32(drv["PalletLocationID"]);
pld.QuantityInBU = Convert.ToDecimal(drv["QtyInBU"]);
pld.ReceiveDocID = Convert.ToInt32(drv["ReceiveDocID"]);
pld.ReceivePalletID = Convert.ToInt32(drv["ReceivePalletID"]);
if (drv["CalculatedCost"] != DBNull.Value)
pld.Cost = Convert.ToDouble(drv["CalculatedCost"]);
if (drv["UnitPrice"] != DBNull.Value)
pld.UnitPrice = Convert.ToDouble(drv["UnitPrice"]);
int ReceivePalletID = Convert.ToInt32(drv["ReceivePalletID"]);
rp.LoadByPrimaryKey(ReceivePalletID);
pld.StoreID = Convert.ToInt32(drv["StoreID"]);
if (drv["DeliveryNote"] != null)
pld.DeliveryNote = Convert.ToBoolean(drv["DeliveryNote"]);
else
pld.DeliveryNote = false;
if (rp.IsColumnNull("ReservedStock"))
{
rp.ReservedStock = Convert.ToDecimal(pld.QuantityInBU);
}
else
{
rp.ReservedStock += Convert.ToDecimal(pld.QuantityInBU);
}
if (drv["UnitID"] != DBNull.Value)
{
pld.UnitID = Convert.ToInt32(drv["UnitID"]);
}
plocation.LoadByPrimaryKey(Convert.ToInt32(drv["PalletLocationID"]));
pld.PhysicalStoreID = plocation.PhysicalStoreID;
rp.Save();
//.........这里部分代码省略.........