📄 orderadd.cs
字号:
namespace PowerEasy.WebSite.Admin.Shop
{
using PowerEasy.AccessManage;
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Controls;
using PowerEasy.Crm;
using PowerEasy.Enumerations;
using PowerEasy.ExtendedControls;
using PowerEasy.Model.Crm;
using PowerEasy.Model.Shop;
using PowerEasy.Model.UserManage;
using PowerEasy.ModelControls;
using PowerEasy.Shop;
using PowerEasy.UserManage;
using PowerEasy.Web.UI;
using PowerEasy.WebSite.Controls;
using PowerEasy.WebSite.Controls.Shop;
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
public class OrderAdd : AdminPage
{
protected AddressPicker AddressPick;
protected ExtendedButton BtnAdd;
protected Button BtnCancel;
protected CheckBox ChkNeedInvoice;
protected DropDownList DropDeliverType;
protected DropDownList DropPaymentType;
protected HiddenField HdnAdminName;
protected Label LblDeliverTypeIntro;
protected Label LblPaymentTypeIntro;
protected decimal m_Total;
protected RadioButtonList RadlOutOfStockProject;
protected SelectAgent SelectAgent1;
protected CrmSelectControl SelectFunctionary;
protected ScriptManager SmgeRegion;
protected ExtendedSiteMapPath SmpNavigator;
protected TextBox TxtContacterName;
protected TextBox TxtEmail;
protected TextBox TxtInvoiceContent;
protected TextBox TxtMemo;
protected TextBox TxtMobile;
protected TextBox TxtPhone;
protected TextBox TxtRemark;
protected TextBox TxtUserName;
protected TextBox TxtZipCode;
protected System.Web.UI.UpdatePanel UpnlDeliverType;
protected System.Web.UI.UpdatePanel UpnlPaymentType;
protected System.Web.UI.UpdatePanel UpnlZipCode;
protected PowerEasy.Controls.RequiredFieldValidator ValfEmail;
protected PowerEasy.Controls.RequiredFieldValidator ValrContacterName;
protected PowerEasy.Controls.RequiredFieldValidator ValrZipCode;
protected CustomValidator ValxPhone;
protected EmailValidator VmailEmail;
protected MobileValidator VmblMobile;
protected TelephoneValidator VtelPhone;
protected ZipCodeValidator VzipZipCode;
private void AddressPick_AddressChanged(object sender, EventArgs e)
{
this.TxtZipCode.Text = this.AddressPick.ZipCode;
}
protected void BtnAdd_Click(object sender, EventArgs e)
{
if (this.Page.IsValid)
{
OrderInfo orderInfo = this.GetOrderInfo();
OrderFlowInfo orderFlowInfo = new OrderFlowInfo();
orderFlowInfo.Country = this.AddressPick.Country;
orderFlowInfo.Province = this.AddressPick.Province;
orderFlowInfo.City = this.AddressPick.City;
orderFlowInfo.Area = this.AddressPick.Area;
orderFlowInfo.Address = this.AddressPick.Address;
if (Order.Add(orderInfo, orderFlowInfo, true))
{
AdminPage.WriteSuccessMsg("添加订单成功!", "OrderModify.aspx?OrderID=" + orderInfo.OrderId);
}
else
{
AdminPage.WriteErrMsg("<li>添加订单失败!</li>");
}
}
}
protected void BtnCancel_Click(object sender, EventArgs e)
{
BasePage.ResponseRedirect("OrderList.aspx");
}
protected void DropDeliverType_SelectedIndexChanged(object sender, EventArgs e)
{
DeliverTypeInfo deliverTypeById = new DeliverTypeInfo();
deliverTypeById = DeliverType.GetDeliverTypeById(DataConverter.CLng(this.DropDeliverType.SelectedValue));
if (deliverTypeById != null)
{
this.LblDeliverTypeIntro.Text = deliverTypeById.Intro;
}
}
protected void DropPaymentType_SelectedIndexChanged(object sender, EventArgs e)
{
PaymentTypeInfo paymentTypeById = PaymentType.GetPaymentTypeById(DataConverter.CLng(this.DropPaymentType.SelectedValue));
this.LblPaymentTypeIntro.Text = paymentTypeById.Intro;
}
private OrderInfo GetOrderInfo()
{
OrderInfo info = new OrderInfo();
info.OrderId = Order.GetMaxId() + 1;
info.OrderNum = Order.GetOrderNum();
info.UserName = this.TxtUserName.Text;
UserInfo usersByUserName = Users.GetUsersByUserName(info.UserName);
if (!usersByUserName.IsNull)
{
info.ClientId = usersByUserName.ClientId;
}
info.ContacterName = this.TxtContacterName.Text;
StringBuilder builder = new StringBuilder();
if (this.AddressPick.Country != "中华人民共和国")
{
builder.Append(this.AddressPick.Country);
}
builder.Append(this.AddressPick.Province);
builder.Append(this.AddressPick.City);
builder.Append(this.AddressPick.Area);
builder.Append(this.AddressPick.Address);
info.Address = builder.ToString();
info.DeliverType = DataConverter.CLng(this.DropDeliverType.SelectedValue);
info.Email = this.TxtEmail.Text;
info.InvoiceContent = this.TxtInvoiceContent.Text;
info.NeedInvoice = this.ChkNeedInvoice.Checked;
info.Mobile = this.TxtMobile.Text;
info.Phone = this.TxtPhone.Text;
info.Remark = this.TxtRemark.Text;
info.PaymentType = DataConverter.CLng(this.DropPaymentType.SelectedValue);
info.AdminName = this.HdnAdminName.Value;
info.ZipCode = this.TxtZipCode.Text;
info.AgentName = this.SelectAgent1.AgentName;
info.Invoiced = false;
info.BeginDate = DateTime.Now;
info.ChargeDeliver = 0M;
info.Memo = this.TxtMemo.Text;
if (!string.IsNullOrEmpty(this.SelectFunctionary.Text))
{
info.Functionary = this.SelectFunctionary.Text;
}
else
{
info.Functionary = PEContext.Current.Admin.AdminName;
}
info.OutOfStockProject = (OutOfStockProject) DataConverter.CLng(this.RadlOutOfStockProject.SelectedValue);
info.DeliverStatus = DeliverStatus.Preparative;
info.EnableDownload = false;
info.InputTime = DateTime.Now;
info.MoneyGoods = 0M;
info.MoneyReceipt = 0M;
info.MoneyTotal = 0M;
info.Status = OrderStatus.WaitForConfirm;
info.PresentExp = 0;
info.PresentMoney = 0M;
info.PresentPoint = 0;
return info;
}
private void InitializePage()
{
IList<DeliverTypeInfo> enableDeliverTypeList = new List<DeliverTypeInfo>();
enableDeliverTypeList = DeliverType.GetEnableDeliverTypeList();
this.DropDeliverType.DataSource = enableDeliverTypeList;
this.DropDeliverType.DataBind();
int typeId = 0;
string intro = "";
foreach (DeliverTypeInfo info in enableDeliverTypeList)
{
if (info.IsDefault)
{
typeId = info.TypeId;
intro = info.Intro;
break;
}
}
this.DropDeliverType.SelectedValue = typeId.ToString();
this.LblDeliverTypeIntro.Text = intro;
IList<PaymentTypeInfo> paymentTypeListByEnabled = PaymentType.GetPaymentTypeListByEnabled();
int num2 = 0;
foreach (PaymentTypeInfo info2 in paymentTypeListByEnabled)
{
if (info2.IsDefault)
{
num2 = info2.TypeId;
this.LblPaymentTypeIntro.Text = info2.Intro;
break;
}
}
this.DropPaymentType.DataSource = paymentTypeListByEnabled;
this.DropPaymentType.DataBind();
BasePage.SetSelectedIndexByValue(this.DropPaymentType, num2.ToString());
}
protected void Page_Load(object sender, EventArgs e)
{
this.AddressPick.AddressChanged += new EventHandler(this.AddressPick_AddressChanged);
string str = base.Request.Params.Get("__EVENTTARGET");
string str2 = base.Request.Params.Get("__EVENTARGUMENT");
if (str == "AddUserButton")
{
if (!string.IsNullOrEmpty(str2))
{
string[] strArray = str2.Split(new char[] { ',' });
this.TxtUserName.Text = strArray[0];
}
UserInfo usersByUserName = Users.GetUsersByUserName(this.TxtUserName.Text);
ContacterInfo contacterByUserName = Contacter.GetContacterByUserName(usersByUserName.UserName);
AddressInfo defaultAddressByUserName = Address.GetDefaultAddressByUserName(usersByUserName.UserName);
if (!defaultAddressByUserName.IsNull)
{
this.AddressPick.SelectRegion(defaultAddressByUserName.Country, defaultAddressByUserName.Province, defaultAddressByUserName.City, defaultAddressByUserName.Area);
this.AddressPick.Address = defaultAddressByUserName.Address;
this.TxtZipCode.Text = defaultAddressByUserName.ZipCode;
this.TxtPhone.Text = defaultAddressByUserName.HomePhone;
this.TxtMobile.Text = defaultAddressByUserName.Mobile;
this.TxtContacterName.Text = defaultAddressByUserName.ConsigneeName;
this.TxtEmail.Text = contacterByUserName.Email;
}
else if (contacterByUserName != null)
{
this.AddressPick.SelectRegion(contacterByUserName.Country, contacterByUserName.Province, contacterByUserName.City, "");
this.AddressPick.Address = contacterByUserName.Address;
this.TxtZipCode.Text = contacterByUserName.ZipCode;
this.TxtPhone.Text = contacterByUserName.HomePhone;
this.TxtMobile.Text = contacterByUserName.Mobile;
this.TxtContacterName.Text = contacterByUserName.TrueName;
this.TxtEmail.Text = contacterByUserName.Email;
}
}
if (!this.Page.IsPostBack)
{
if (RolePermissions.AccessCheck(OperateCode.AddFunctionary))
{
this.SelectFunctionary.ButtonEnabled = true;
}
else
{
this.SelectFunctionary.ButtonEnabled = false;
}
this.HdnAdminName.Value = PEContext.Current.Admin.AdminName;
this.InitializePage();
}
}
protected void ValxPhone_ServerValidate(object source, ServerValidateEventArgs args)
{
if (string.IsNullOrEmpty(this.TxtPhone.Text) && string.IsNullOrEmpty(this.TxtMobile.Text))
{
args.IsValid = false;
}
else
{
args.IsValid = true;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -