📄 getorders.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Text;
using YXShop.Common;
using System.Collections.Generic;
using YXShop.Model;
namespace YXShop.Web.Membercenter.Orders
{
public partial class getOrders : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
YXShop.Model.Orders order = new YXShop.Model.Orders();
YXShop.Model.OrderInvoice oi = new YXShop.Model.OrderInvoice();
OrderNumber onum = new OrderNumber();
YXShop.BLL.Orders bllOrder = new YXShop.BLL.Orders();
YXShop.BLL.OrderInvoice bllInv = new YXShop.BLL.OrderInvoice();
YXShop.Model.YXShop_Linkman lk = new YXShop.Model.YXShop_Linkman();
#region 联系人信息
#region MyRegion
lk.cConnectName = string.IsNullOrEmpty(Request.Params["userName"]) ? "" : Request.Params["userName"];
//= Request.Params["addr"];
lk.addr = string.IsNullOrEmpty(Request.Params["userAddr"]) ? "" : Request.Params["userAddr"];
lk.zip = string.IsNullOrEmpty(Request.Params["userZip"]) ? "" : Request.Params["userZip"];
lk.cConnectPhone = string.IsNullOrEmpty(Request.Params["userPhone"]) ? "" : Request.Params["userPhone"];
lk.cMobile = string.IsNullOrEmpty(Request.Params["userMobile"]) ? "" : Request.Params["userMobile"];
lk.cConnectFax = string.IsNullOrEmpty(Request.Params["userFax"]) ? "" : Request.Params["userFax"];
lk.cEmail = string.IsNullOrEmpty(Request.Params["userEmail"]) ? "" : Request.Params["userEmail"];
#endregion
#endregion
//支付方式online,bank
string payMethod = Request.Params["pay"];
#region MyRegion
//发票信息
//发票类型
//个人
string pComp = string.Empty;
string inc = string.Empty;
//纳税人识别号
string incN = string.Empty;
string incAddr = string.Empty;
string incPhone = string.Empty;
string incBank = string.Empty;
string incBankNum = string.Empty;
// 普通或者增值税
string invType = Request.Params["invType"];
//抬头类型,个人或者企业
string invT = Request.Params["invT"];
if (string.IsNullOrEmpty(invType))
{
order.Invoice = 0;
}
else
{
oi.InvoicePerAndCom = 2;
if (invType == "普通发票") //普通发票
{
order.Invoice = 1;
oi.InvoiceType = 9;
oi.InvoiceRise = "个人";
oi.InvoicePerAndCom = 1;
//个人或者企业
//企业
if (invT == "c")
{
oi.InvoiceRise = "企业";
//企业名称
pComp = string.IsNullOrEmpty(Request.Params["comp"]) ? "" : Request.Params["comp"];
oi.CompanyName = pComp;
}
}
else
{//增值发票
oi.InvoiceType = 4;
order.Invoice = 2;
oi.InvoiceRise = "企业";
inc = Request.Params["inc"];
oi.CompanyName = inc;
incN = Request.Params["incN"];
incAddr = Request.Params["incAddr"];
incPhone = Request.Params["incPhone"];
incBank = Request.Params["incBank"];
incBankNum = Request.Params["incBankNum"];
}
}
#endregion
//发票内容:详细
//送货方式ID
string deilv = Request.Params["Deil"];
if (string.IsNullOrEmpty(deilv) || string.IsNullOrEmpty(payMethod))
{
//送货方式
return;
}
#region 訂單子表
int orderItem = 0;
ProfileCommon Profile = new ProfileCommon();
ICollection<CartItemInfo> cart = Profile.ShoppingCart.CartItems;
YXShop.BLL.LineItem bll = new YXShop.BLL.LineItem();
YXShop.Model.LineItem model = null;
int reInt = 1;
decimal mPrice = 0;
decimal tPrice = 0;
if (cart.Count <= 0)
{
//购物车中没有数据
return;
}
foreach (CartItemInfo cItem in cart)
{
//插入多条数据(未采用事务)
if (reInt != 1)
break;
model = new YXShop.Model.LineItem();
model.MarketPrice = cItem.MarckerPricr;//商场价
model.OrderId = onum.OrderID;
model.ProductID = cItem.ProductId;
model.ProductName = cItem.ProductName;
model.ProIntegral = cItem.Integral;
model.Quantity = cItem.Quantity;
model.UnitPrice = cItem.Price;//市场价
mPrice += cItem.MarckerPricr * cItem.Quantity;//價格1
tPrice += cItem.Price * cItem.Price;//價格2
reInt = bll.Create(model);
}
model = new YXShop.Model.LineItem();
model.OrderId = onum.OrderID;
if (reInt != 1)
{
//如果插入訂單子項表中出錯的話,就刪除之前插入的訂單
bll.Delect(model);
}
else
{
orderItem = 1;
}
#endregion
#region 定单信息
//定单信息
order.OrderId = onum.OrderID;
order.UserId = "2";//
order.ShopDate = DateTime.Now;//
order.OrderDate = DateTime.Now;//
order.ConsigneeRealName = "hearain";//
order.ConsigneeName = WebUtility.replaceStr(lk.cConnectName);//
order.ConsigneePhone = WebUtility.replaceStr(lk.cMobile);
order.ConsigneeProvince = WebUtility.replaceStr(Request.Params["addr"]);//
order.ConsigneeAddress = WebUtility.replaceStr(lk.addr);//
order.ConsigneeZip = WebUtility.replaceStr(lk.zip);//
order.ConsigneeTel = WebUtility.replaceStr(lk.cConnectPhone);//
order.ConsigneeFax = WebUtility.replaceStr(lk.cConnectFax);//
order.ConsigneeEmail = WebUtility.replaceStr(lk.cEmail);
order.WhetherCouAndinte = Request.Params["Parvalue"] != null ? " 1" : "0";//
order.ParvalueAndInte = 0;
order.Payment = WebUtility.replaceStr(payMethod);
order.PaymentType = order.Payment.ToLower().Equals("online") ? 0 : 1;
//
order.Courier = WebUtility.replaceStr(deilv);//
order.TotalPrice = tPrice;//
order.FactPrice = mPrice;
///order.Invoice = (int)invType;
//判断参数是不是全面
if (string.IsNullOrEmpty(order.OrderId) || string.IsNullOrEmpty(order.ConsigneeProvince) || string.IsNullOrEmpty(order.ConsigneeAddress) || string.IsNullOrEmpty(order.ConsigneeZip) || string.IsNullOrEmpty(order.ConsigneeTel) || string.IsNullOrEmpty(order.ConsigneeFax) || string.IsNullOrEmpty(order.Payment) || string.IsNullOrEmpty(order.Courier))
{
//訂單信息不全参数不全
return;
}
#endregion
#region 发票信息
//oi.InvoiceType = invType;
oi.OrderId = order.OrderId;
//oi.InvoiceRise = WebUtility.replaceStr(invT);
//oi.CompanyName = "";
oi.TaxpayerNumber = WebUtility.replaceStr(incN);
oi.RegionAddress = WebUtility.replaceStr(incAddr);
oi.RegionTel = WebUtility.replaceStr(incPhone);
oi.AccountBack = WebUtility.replaceStr(incBank);
oi.BackNumber = WebUtility.replaceStr(incBankNum);
#endregion
#region 执行数据操作
bool bl = false;
if (orderItem == 1)
{
//創建訂單
int reI = bllOrder.Create(order);
if (reI > 0)
{
//判斷是否創建發票信息
if (order.Invoice != 0)
{
//創建發票信息
int rint = bllInv.Create(oi);
if (rint <= 0)
{
//如果發票信息插入失敗,刪除對應的訂單信息,子訂單信息
bll.Delect(model);
bllOrder.Delect(onum.OrderID);
}
else
{
bl = true;
}
}
}
}
#endregion
#region 返回定单信息显示
if (bl)
{
//dinggoushangping.Text = order.TotalPrice.ToString();
//this.zongjine = order.FactPrice.ToString();
}
else
{
Response.Redirect("../../Default.aspx");
}
#endregion
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -