📄 po06.aspx.cs
字号:
{
DataTable dt = (DataTable)Session["ProductList"];
if (BlOrders.AddorderDetails(dt) == true)
{
Response.Write("<script>alert('新建订单成功!')</script>");
//清空购物表
dtPrd = (DataTable)Session["ProductList"];
dtPrd.Clear();
showPrd();
this.PlNewOrder.Visible = true;
this.PlConfirmInfo.Visible = false;
deRstTotal = 0;
this.lbReTatoal2.Text = "";
this.lbRstRetotal.Text = "";
}
else
{
dtPrd = (DataTable)Session["ProductList"];
dtPrd.Clear();
showPrd();
this.PlNewOrder.Visible = true;
this.PlConfirmInfo.Visible = false;
deRstTotal = 0;
this.lbReTatoal2.Text = "";
this.lbRstRetotal.Text = "";
Response.Write("<script>alert('sorry,新建订单失败!')</script>");
//清空购物表
}
}
else
{
Response.Write("<script>alert('sorry,新建订单失败!')</script>");
//清空购物表
dtPrd = (DataTable)Session["ProductList"];
dtPrd.Clear();
showPrd();
this.PlNewOrder.Visible = true;
this.PlConfirmInfo.Visible = false;
deRstTotal = 0;
this.lbReTatoal2.Text = "";
this.lbRstRetotal.Text = "";
}
}
#endregion、
#region 再次取消事件
protected void btncel_Click(object sender, EventArgs e)
{
this.PlNewOrder.Visible = true;
this.PlConfirmInfo.Visible = false;
deRstTotal = 0;
this.lbRstRetotal.Text = "";
this.lbReTatoal2.Text = "";
dtPrd = (DataTable)Session["ProductList"];
dtPrd.Clear();
showPrd();
}
#endregion
#region 动态删除商品记录事件
protected void lkbtnDelet_Click(object sender, CommandEventArgs e)
{
try
{
this.lbRstRetotal.Text = "";
int _index = Convert.ToInt32(e.CommandName);
//Response.Write("<script>alert('" + _index + "')</script>");
dtPrd = (DataTable)Session["ProductList"];
//int _prdIndex =Convert.ToInt32( dtPrd.Rows[_index]["商品编号"].ToString());
decimal dTotal = Convert.ToDecimal(dtPrd.Rows[_index]["金额合计"]);
deRstTotal -= dTotal;
dtPrd.Rows[_index].Delete();
this.lbRstRetotal.Text = "总金额:" + deRstTotal.ToString();
Session["ProductList"] = dtPrd;
showPrd();
}
catch
{
Response.Write("<script>alert(' 删除出错! ')</script>");
}
}
#endregion
#region 显示选购的商品列表
public void showPrd()
{
//商品表行索引标记
int _count = 0;
DataTable dt = (DataTable)Session["ProductList"];
foreach (DataRow dr in dt.Rows)
{
dr["商品ID"] = _count;
_count++;
}
this.RepList.DataSource = dt;
this.RepList.DataBind();
}
#endregion
#region 显示数据库中Products产品名字段方法
public void BindProduct(int _CategoryID)
{
this.drpPrdName.DataSource=BlOrders.RetProductbyCategoryID(_CategoryID);
this.drpPrdName.DataValueField = "ProductID";
this.drpPrdName.DataTextField = "ProductName";
this.drpPrdName.DataBind();
}
#endregion
#region 显示数据库中Categories表类别字段方法
public void BindCatagoris()
{
this.drpPrdCategory.DataSource = BlOrders.RetCatagoris();
this.drpPrdCategory.DataValueField = "CategoryID";
this.drpPrdCategory.DataTextField = "CategoryName";
this.drpPrdCategory.DataBind();
}
#endregion
#region 创建选购商品表,返回一个DataTable
public DataTable RetPrdDataTable()
{
DataTable prdTb = new DataTable();
prdTb.Columns.Add(new DataColumn("商品编号", typeof(int)));
prdTb.Columns.Add(new DataColumn("商品ID", typeof(int)));
prdTb.Columns.Add(new DataColumn("商品类型", typeof(string)));
prdTb.Columns.Add(new DataColumn("商品名称", typeof(string)));
prdTb.Columns.Add(new DataColumn("商品单价", typeof(decimal)));
prdTb.Columns.Add(new DataColumn("商品数量", typeof(int)));
prdTb.Columns.Add(new DataColumn("商品折扣", typeof(float)));
prdTb.Columns.Add(new DataColumn("金额合计", typeof(decimal)));
prdTb.Columns.Add(new DataColumn("金额总计", typeof(decimal)));
return prdTb;
}
#endregion
#region 添加商品记录
public DataTable RetAddPrddt(DataTable dtPrd, int _productID, string _strCategordName, string _strProdName,
string _strUnitPrice, int _ProdCount, double _douDiscount, double _douPriceTotal)
{
DataRow dr = dtPrd.NewRow();
dr["商品编号"] = _productID;
dr["商品ID"] = dtPrd.Rows.Count.ToString();
dr["商品类型"] = _strCategordName;
dr["商品名称"] = _strProdName;
dr["商品单价"] = _strUnitPrice;
dr["商品数量"] = _ProdCount;
dr["商品折扣"] = _douDiscount;
dr["金额合计"] = _douPriceTotal;
dtPrd.Rows.Add(dr);
return dtPrd;
}
#endregion
#region 验证函数方法 是否输入为整数
public bool IsInteger(string _reg)
{
bool _isCount = false;
Regex reg = new Regex(@"^[0-9]*[1-9][0-9]*$");
if (reg.IsMatch(_reg))
{
_isCount = true;
return _isCount;
}
return _isCount;
}
#endregion
#region 验证函数方法,日期格式输入是否正确
public bool IsDateformat(string _strdate)
{
bool _isDate = false;
string strreg = @"((^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(10|12|0?[13578])([-\/\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(11|0?[469])([-\/\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(0?2)([-\/\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([3579][26]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][13579][26])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][13579][26])([-\/\._])(0?2)([-\/\._])(29)$))";
if (Regex.IsMatch(_strdate, strreg))
{
_isDate = true;
return _isDate;
}
return _isDate;
}
#endregion
#region 查询商品选购表中产品添加是否添加重复,返回一个bool值
public bool _isPrdID(DataTable dtPrd, int _sedid)
{
bool _ispid = false;
foreach (DataRow dr in dtPrd.Rows)
{
if (_sedid == Convert.ToInt32(dr["商品编号"].ToString()))
{
_ispid = true;
return _ispid;
}
}
return _ispid;
}
#endregion
#region 计算商品价格方法
public decimal RetprdTotal(double _price, int _count, double _disCount)
{
decimal Total = 0;
Total = Convert.ToDecimal(_price * Convert.ToDouble(_count) * _disCount);
return Total;
}
#endregion
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -