📄 po06.aspx.cs
字号:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
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.Xml.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using VinciBusinessLogic.BusinessLogic;
using WebService;
public partial class PO06 : BasePage
{
#region 各变量声明
//声明一个常量
double douDiscount = 1.0;
//声明DataTable变量
DataTable dtPrd;
//声明全局总金额变量
private static decimal deRstTotal = 0;
//创建订单时间
private DateTime _dtNow;
public DateTime dtNow
{
get { return _dtNow; }
set { _dtNow = value; }
}
//客户注册组织ID
private int _regionID;
public int RegionID
{
get { return _regionID; }
set { _regionID = value; }
}
//商品添加次数标记
private static int _prdcount =0;
//声明VinciService
private VinciService vicService = new VinciService();
//声明数据引用层类
private VinciBusinessLogic.BusinessLogic.OrdersBL BlOrders = new OrdersBL();
private VinciBusinessLogic.BusinessLogic.CustomersBL BlCustomers = new CustomersBL();
private string _ticket;
private int _operatorID;
#endregion
#region 页面加载事件
protected void Page_Load(object sender, EventArgs e)
{
Master.UserData = UserData;
_ticket = Ticket;
_operatorID = UserData.EmployeeID;
if (Session["ProductList"] == null)
{
//返回一张自定义的DataTable
dtPrd=RetPrdDataTable();
Session["ProductList"] = dtPrd;
}
else
{
dtPrd = (DataTable)Session["ProductList"];
}
if (!IsPostBack)
{
this.PlNewOrder.Visible = true;
this.PlConfirmInfo.Visible = false;
//显示商品类别
BindCatagoris();
BindProduct(Convert.ToInt32(drpPrdCategory.SelectedItem.Value));
}
}
#endregion
#region 添加商品事件
protected void btnAdd_Click(object sender, EventArgs e)
{
if (this.txtCount.Text != "")
{
if (IsInteger(this.txtCount.Text) == false)
{
Response.Write("<script>alert('sorry,数量格式输入错误!')</script>");
return;
}
else
{
//第一次添加产品时
if (_prdcount == 0)
{
_prdcount++;
double _UniPrice = BlOrders.GetPrdPrice(Convert.ToInt32(drpPrdName.SelectedItem.Value));
int _Count = Convert.ToInt32(this.txtCount.Text);
decimal _PriceTotal = RetprdTotal(_UniPrice, _Count, douDiscount);
Session["ProductList"] = RetAddPrddt(dtPrd,
Convert.ToInt32(this.drpPrdName.SelectedItem.Value.ToString()),
this.drpPrdCategory.SelectedItem.Text,
this.drpPrdName.SelectedItem.Text,
Convert.ToString(_UniPrice),
_Count,
douDiscount,
Convert.ToDouble(_PriceTotal)
);
deRstTotal += Convert.ToDecimal(_PriceTotal);
this.lbRstRetotal.Text = "总金额:" + deRstTotal.ToString();
showPrd();
}
else
{
if (_isPrdID(dtPrd, Convert.ToInt32(this.drpPrdName.SelectedItem.Value)) == true)
{
Response.Write("<script>alert('sorry,不能重复添加该商品!')</script>");
return;
}
double _UniPrice = BlOrders.GetPrdPrice(Convert.ToInt32(drpPrdName.SelectedItem.Value));
int _Count = Convert.ToInt32(this.txtCount.Text);
//计算单条商品价格总计
decimal _PriceTotal = RetprdTotal(_UniPrice, _Count, douDiscount);
//调用BlOrders.RetAddPrddt()方法;加入选购商品记录,存储在Session中
Session["ProductList"] =RetAddPrddt(dtPrd,
Convert.ToInt32(this.drpPrdName.SelectedItem.Value.ToString()),
this.drpPrdCategory.SelectedItem.Text,
this.drpPrdName.SelectedItem.Text,
Convert.ToString(_UniPrice),
_Count,
douDiscount,
Convert.ToDouble(_PriceTotal)
);
//总金额
deRstTotal += Convert.ToDecimal(_PriceTotal);
this.lbRstRetotal.Text = "总金额:" + deRstTotal.ToString();
showPrd();
}
}
}
else
{
Response.Write("<script>alert('sorry,商品数量不能为空!')</script>");
}
}
#endregion
#region 新建订单照会事件
protected void btnOK_Click(object sender, EventArgs e)
{
if (this.NewOrder1.RequireDate != "")
{
if (IsDateformat(this.NewOrder1.RequireDate) == false)
{
Response.Write("<script>alert('Sorry,日期格式错误!请重新输入')</script>");
return;
}
else if (((DataTable)Session["ProductList"]).Rows.Count == 0 || Session["ProductList"]==null)
{
Response.Write("<script>alert('Sorry,您还没选购商品!')</script>");
return;
}
else
{
this.txtName.Text = this.NewOrder1.strCustomerName;
this.txtNote.Text = this.NewOrder1.OderNote;
this.txtDate.Text = this.NewOrder1.RequireDate;
this.lbReTatoal2.Text = "总金额:" + deRstTotal.ToString();
//给出来订单客户的RegionID
this._regionID = BlCustomers.getRgnIDbyCutID(Convert.ToInt32(NewOrder1.CustomerID));
//显示选购的商品
DataTable dt = (DataTable)Session["ProductList"];
this.RptConfirm.DataSource = dt;
this.RptConfirm.DataBind();
this.PlNewOrder.Visible = false;
this.PlConfirmInfo.Visible = true;
}
}
else {Response.Write("<script>alert('Sorry,订单期限不能为空')</script>"); }
}
#endregion
#region 新建商品订单取消事件
protected void btnCancel_Click(object sender, EventArgs e)
{
dtPrd = (DataTable)Session["ProductList"];
dtPrd.Clear();
deRstTotal = 0;
this.lbRstRetotal.Text = "";
showPrd();
this.PlNewOrder.Visible = true ;
this.PlConfirmInfo.Visible = false;
}
#endregion
#region 查询类别商品事件
protected void drpPrdCategory_SelectedIndexChanged(object sender, EventArgs e)
{
BindProduct(Convert.ToInt32(drpPrdCategory.SelectedItem.Value));
}
#endregion
#region 再次确认订单提交数据库事件
protected void btnConfirm_Click(object sender, EventArgs e)
{
int _OrgID = vicService.getOrgIDbyRgnID(this.RegionID, _operatorID, _ticket,out error_Message);
if (_OrgID< 0)
{
Response.Write("<script>alert('Sorry,您没有权限!')</script>");
return;
}
else if (BlOrders.AddOrders(Convert.ToInt32(NewOrder1.CustomerID),
Convert.ToInt32(this._operatorID),
Convert.ToDateTime(DateTime.Now),
Convert.ToDateTime(NewOrder1.RequireDate),
this.NewOrder1.OderNote,
Convert.ToInt32(_operatorID),
_OrgID
) == true)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -