protected void btnSubmit_Click(object sender, EventArgs e) { using (var conn = new SqlConnection(DataAccess.ConnectString)) { conn.Open(); var trans = conn.BeginTransaction(); try { if (string.IsNullOrEmpty(ddlPlayerDetail.SelectedValue)) { throw new Exception("请选择印字印号信息"); } var m = _repo.Single<Member>(Mid); if (!string.IsNullOrEmpty(tbMemberWeChat.Text.Trim())) { m.WeChat = tbMemberWeChat.Text.Trim(); _repo.Update(m); } else { throw new Exception("请输入会员微信号"); } //New Order var o = new Order(); int newId; if (OrderID > 0) { o = _repo.Single<Order>(OrderID); } o.Mobile = tbOrderMobile.Text.Trim(); o.Address = tbOrderAddress.Text.Trim(); o.Payment = string.Empty; o.Postage = 0; o.UpdateTime = DateTime.Now; o.Description = tbOrderDescription.Text.Trim(); o.OrderType = OrderBaseType.Printing; if (OrderID > 0) { _repo.Update(o, trans); // used by setting OrderItem foreign key newId = OrderID; } else { o.MemberID = m.ID; o.MemberName = m.Name; o.Price = 0; o.Sale = null; o.Deposit = null; o.Status = OrderStatusType.Draft; o.Rate = 0; o.CreateTime = DateTime.Now; o.IsActive = true; o.Remark = string.Empty; //Get the Order ID after Insert new one object key; _repo.Insert(o, out key, trans); newId = Convert.ToInt32(key); } //Remove Order Item of this Order if (OrderID > 0 && o.ID.Equals(OrderID)) { _repo.Query<OrderItem>(x => x.OrderID == OrderID).Delete(trans); } // New Order Item for Player Number & Name if (!string.IsNullOrEmpty(ddlPlayerDetail.SelectedValue)) { var pNumber = Product.Cache.Load(ProductType.PlayerNumber).Find(p => p.IsActive); var pName = Product.Cache.Load(ProductType.PlayerName).Find(p => p.IsActive); if (pNumber == null || pName == null) throw new Exception("无印号信息,请联系管理员"); var oiFont = new OrdrItmArsenalFont(); var oiNumber = new OrdrItmPlayerNumber(); var oiName = new OrdrItmPlayerName(); oiFont.OrderID = newId; oiFont.Size = string.Empty; oiFont.Quantity = 1; oiFont.Sale = null; oiFont.Remark = string.Empty; oiNumber.OrderID = newId; oiNumber.Quantity = 1; oiName.OrderID = newId; oiName.Quantity = 1; if (ddlPlayerDetail.SelectedValue.Equals("custom", StringComparison.OrdinalIgnoreCase)) { // Custom Printing if (string.IsNullOrEmpty(tbPlayerNumber.Text.Trim()) || string.IsNullOrEmpty(tbPlayerName.Text.Trim())) { throw new Exception("请填写自定义印字印号"); } // New Order Item for Arsenal Font if (rblFontSelected.SelectedValue.Equals("ArsenalFont", StringComparison.OrdinalIgnoreCase)) { var pFont = Product.Cache.Load(ProductType.ArsenalFont).Find(p => p.IsActive); if (pFont == null) throw new Exception("无特殊字体信息,请联系管理员"); // 设置个性化印字印号价格 oiFont.Sale = _priceArsenalFont; oiFont.Place(m, trans); oiNumber.PrintingNumber = tbPlayerNumber.Text.Trim(); oiNumber.Sale = 0f; oiNumber.Remark = "custom"; oiNumber.Place(m, trans); oiName.PrintingName = tbPlayerName.Text.Trim().ToUpper(); oiName.Sale = 0f; oiName.Remark = "custom"; oiName.Place(m, trans); } else { oiNumber.PrintingNumber = tbPlayerNumber.Text.Trim(); // 设置个性化印字印号价格 oiNumber.Sale = _pricePremierLeague / 2; oiNumber.Remark = "custom"; oiNumber.Place(m, trans); oiName.PrintingName = tbPlayerName.Text.Trim().ToUpper(); // 设置个性化印字印号价格 oiName.Sale = _pricePremierLeague / 2; oiName.Remark = "custom"; oiName.Place(m, trans); } } else { // Arsenal Player Printing var player = Arsenal_Player.Cache.Load(new Guid(ddlPlayerDetail.SelectedValue)); if (player == null) throw new Exception("无球员信息,请联系管理员"); var printingName = GetArsenalPlayerPrintingName(player).ToUpper(); // New Order Item for Arsenal Font if (rblFontSelected.SelectedValue.Equals("ArsenalFont", StringComparison.OrdinalIgnoreCase)) { var pFont = Product.Cache.Load(ProductType.ArsenalFont).Find(p => p.IsActive); if (pFont == null) throw new Exception("无特殊字体信息,请联系管理员"); // 设置个性化印字印号价格 oiFont.Sale = _priceArsenalFont; oiFont.Place(m, trans); oiNumber.PrintingNumber = player.SquadNumber.ToString(); oiNumber.Sale = 0f; oiNumber.ArsenalPlayerGuid = player.ID; oiNumber.Place(m, trans); oiName.PrintingName = printingName; oiName.Sale = 0f; oiName.ArsenalPlayerGuid = player.ID; oiName.Place(m, trans); } else { oiNumber.PrintingNumber = player.SquadNumber.ToString(); // 设置个性化印字印号价格 oiNumber.Sale = _pricePremierLeague / 2; oiNumber.ArsenalPlayerGuid = player.ID; oiNumber.Place(m, trans); oiName.PrintingName = printingName; // 设置个性化印字印号价格 oiName.Sale = _pricePremierLeague / 2; oiName.ArsenalPlayerGuid = player.ID; oiName.Place(m, trans); } } } //// New Order Item for Premiership Patch //if (Convert.ToInt32(rblPremierPatch.SelectedValue) > 0) //{ // var pPremierPatch = Product.Cache.Load(ProductType.PremiershipPatch).Find(p => p.IsActive); // if (pPremierPatch == null) // throw new Exception("无英超袖标信息,请联系管理员"); // var oiPremierPatch = new OrdrItmPremiershipPatch // { // OrderID = newId, // Size = string.Empty, // Quantity = Convert.ToInt32(rblPremierPatch.SelectedValue), // Sale = null, // Remark = string.Empty // }; // oiPremierPatch.Place(m, trans); //} //// New Order Item for Championship Patch //if (Convert.ToInt32(rblChampionPatch.SelectedValue) > 0) //{ // var pChampionPatch = Product.Cache.Load(ProductType.ChampionshipPatch).Find(p => p.IsActive); // if (pChampionPatch == null) // throw new Exception("无欧冠袖标信息,请联系管理员"); // var oiChampionShipPatch = new OrdrItmChampionshipPatch // { // OrderID = newId, // Size = string.Empty, // Quantity = Convert.ToInt32(rblChampionPatch.SelectedValue), // Sale = null, // Remark = string.Empty // }; // oiChampionShipPatch.Place(m, trans); //} trans.Commit(); ClientScript.RegisterClientScriptBlock(typeof(string), "succeed", string.Format("alert('订单({0})保存成功');window.location.href = 'ServerOrderView.ashx?OrderID={0}'", newId), true); } catch (Exception ex) { trans.Rollback(); ClientScript.RegisterClientScriptBlock(typeof(string), "failed", $"alert('{ex.Message}')", true); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { using (var conn = new SqlConnection(DataAccess.ConnectString)) { conn.Open(); var trans = conn.BeginTransaction(); try { if (string.IsNullOrEmpty(ddlReplicaKit.SelectedValue)) { throw new Exception("请选择需要订购的球衣"); } var m = _repo.Single<Member>(Mid); if (!string.IsNullOrEmpty(tbMemberWeChat.Text.Trim())) { m.WeChat = tbMemberWeChat.Text.Trim(); _repo.Update(m); } else { throw new Exception("请输入会员微信号"); } //New Order var o = new Order(); int newId; if (OrderID > 0) { o = _repo.Single<Order>(OrderID); } o.Mobile = tbOrderMobile.Text.Trim(); o.Address = tbOrderAddress.Text.Trim(); //if (rblOrderPayment.SelectedValue.Equals("Bank", StringComparison.OrdinalIgnoreCase)) //{ // o.Payment = "{" + rblOrderPayment.SelectedValue + "|" + tbBankName.Text.Trim() + "|" + // tbBankAccount.Text.Trim() + "}"; //} //else //{ // o.Payment = "{" + rblOrderPayment.SelectedValue + "|" + tbAlipay.Text.Trim() + "}"; //} o.Payment = string.Empty; o.Postage = Convert.ToSingle(rblOrderPostage.SelectedValue); o.UpdateTime = DateTime.Now; o.Description = tbOrderDescription.Text.Trim(); o.OrderType = OrderBaseType.ReplicaKit; if (OrderID > 0) { _repo.Update(o, trans); // used by setting OrderItem foreign key newId = OrderID; } else { o.MemberID = m.ID; o.MemberName = m.Name; o.Price = 0; o.Sale = null; o.Deposit = null; o.Status = OrderStatusType.Draft; o.Rate = 0; o.CreateTime = DateTime.Now; o.IsActive = true; o.Remark = string.Empty; //Get the Order ID after Insert new one object key; _repo.Insert(o, out key, trans); newId = Convert.ToInt32(key); } //Remove Order Item of this Order if (OrderID > 0 && o.ID.Equals(OrderID)) { _repo.Query<OrderItem>(x => x.OrderID == OrderID).Delete(trans); } //New Order Item for ReplicaKit var pReplicaKit = Product.Cache.Load(new Guid(ddlReplicaKit.SelectedValue)); var oi = new OrdrItmReplicaKit(); if (pReplicaKit == null) throw new Exception("无相关纪念品或缺货,请联系管理员"); // HARD CORD for HongKong Home Kit //bool isHongKongKit = pReplicaKit.Code.Equals("M74756HK", StringComparison.OrdinalIgnoreCase); //float salePrinting = 61f; oi.OrderID = newId; oi.Size = tbOrderItemSize.Text.Trim().ToUpper(); oi.Quantity = 1; oi.Sale = null; oi.Remark = string.Empty; oi.Place(m, pReplicaKit, trans); // New Order Item for Home Player Number & Name if (!string.IsNullOrEmpty(ddlPlayerDetail.SelectedValue)) { var pNumber = Product.Cache.Load(ProductType.PlayerNumber).Find(p => p.IsActive); var pName = Product.Cache.Load(ProductType.PlayerName).Find(p => p.IsActive); if (pNumber == null || pName == null) throw new Exception("无印号信息,请联系管理员"); var oiFont = new OrdrItmArsenalFont(); var oiNumber = new OrdrItmPlayerNumber(); var oiName = new OrdrItmPlayerName(); oiFont.OrderID = newId; oiFont.Size = string.Empty; oiFont.Quantity = 1; oiFont.Sale = null; oiFont.Remark = string.Empty; oiNumber.OrderID = newId; oiNumber.Quantity = 1; oiName.OrderID = newId; oiName.Quantity = 1; if (ddlPlayerDetail.SelectedValue.Equals("custom")) { // Custom Printing if (string.IsNullOrEmpty(tbPlayerNumber.Text.Trim()) || string.IsNullOrEmpty(tbPlayerName.Text.Trim())) throw new Exception("请填写自定义印字印号"); // New Order Item for Arsenal Font if (cbArsenalFont.Checked) { var pFont = Product.Cache.Load(ProductType.ArsenalFont).Find(p => p.IsActive); if (pFont == null) throw new Exception("无特殊字体信息,请联系管理员"); oiFont.Place(m, trans); oiNumber.Size = tbPlayerNumber.Text.Trim(); oiNumber.Sale = 0f; oiNumber.Remark = "custom"; oiNumber.Place(m, trans); oiName.Size = tbPlayerName.Text.Trim(); oiName.Sale = 0f; oiName.Remark = "custom"; oiName.Place(m, trans); } else { oiNumber.Size = tbPlayerNumber.Text.Trim(); //if (isHongKongKit) //{ oiNumber.Sale = salePrinting; } //else //{ oiNumber.Sale = null; } oiNumber.Sale = null; oiNumber.Remark = "custom"; oiNumber.Place(m, trans); oiName.Size = tbPlayerName.Text.Trim(); //if (isHongKongKit) //{ oiName.Sale = salePrinting; } //else //{ oiName.Sale = null; } oiName.Sale = null; oiName.Remark = "custom"; oiName.Place(m, trans); } } else { // Arsenal Player Printing var player = Arsenal_Player.Cache.Load(new Guid(ddlPlayerDetail.SelectedValue)); if (player == null) throw new Exception("无球员信息,请联系管理员"); var printingName = GetArsenalPlayerPrintingName(player); // New Order Item for Arsenal Font if (cbArsenalFont.Checked) { var pFont = Product.Cache.Load(ProductType.ArsenalFont).Find(p => p.IsActive); if (pFont == null) throw new Exception("无特殊字体信息,请联系管理员"); oiFont.Place(m, trans); oiNumber.Size = player.SquadNumber.ToString(); oiNumber.Sale = 0f; oiNumber.Remark = player.ID.ToString(); oiNumber.Place(m, trans); oiName.Size = printingName; oiName.Sale = 0f; oiName.Remark = player.ID.ToString(); oiName.Place(m, trans); } else { oiNumber.Size = player.SquadNumber.ToString(); //if (isHongKongKit) //{ oiNumber.Sale = salePrinting; } //else //{ oiNumber.Sale = null; } oiNumber.Sale = null; oiNumber.Remark = player.ID.ToString(); oiNumber.Place(m, trans); oiName.Size = printingName; //if (isHongKongKit) //{ oiName.Sale = salePrinting; } //else //{ oiName.Sale = null; } oiName.Sale = null; oiName.Remark = player.ID.ToString(); oiName.Place(m, trans); } } } // HARD CODE FOR HongKong Home Kit //if (!isHongKongKit) //{ // New Order Item for Premiership Patch if (Convert.ToInt32(rblPremierPatch.SelectedValue) > 0) { var pPremierPatch = Product.Cache.Load(ProductType.PremiershipPatch).Find(p => p.IsActive); if (pPremierPatch == null) throw new Exception("无英超袖标信息,请联系管理员"); var oiPremierPatch = new OrdrItmPremiershipPatch { OrderID = newId, Size = string.Empty, Quantity = Convert.ToInt32(rblPremierPatch.SelectedValue), Sale = null, Remark = string.Empty }; oiPremierPatch.Place(m, trans); } // New Order Item for Championship Patch if (Convert.ToInt32(rblChampionPatch.SelectedValue) > 0) { var pChampionPatch = Product.Cache.Load(ProductType.ChampionshipPatch).Find(p => p.IsActive); if (pChampionPatch == null) throw new Exception("无欧冠袖标信息,请联系管理员"); var oiChampionShipPatch = new OrdrItmChampionshipPatch { OrderID = newId, Size = string.Empty, Quantity = Convert.ToInt32(rblChampionPatch.SelectedValue), Sale = null, Remark = string.Empty }; oiChampionShipPatch.Place(m, trans); } //} trans.Commit(); ClientScript.RegisterClientScriptBlock(typeof(string), "succeed", string.Format("alert('订单({0})保存成功');window.location.href = 'ServerOrderView.ashx?OrderID={0}'", newId), true); } catch (Exception ex) { trans.Rollback(); ClientScript.RegisterClientScriptBlock(typeof(string), "failed", $"alert('{ex.Message}')", true); } //conn.Close(); } }