wpf购物车模块
// 添加到购物车
private void Button_Click(object sender, RoutedEventArgs e)
{
DataRowView curItem = (DataRowView)((ListBoxItem)MenuitemView.ContainerFromElement((Button)sender)).Content;
int a = 0;
DataRow row = curItem.Row;
DataRow[] rows = null;
rows = OrderTable.Select("menuname='" + row["menuname"].ToString().Trim() + "'");
if (rows.Count() != 0)
{
DataRow dRow = rows[0];
dRow.BeginEdit();//开始编辑
dRow["number"] = Convert.ToInt16(rows[0]["number"]) + 1;
dRow.EndEdit();//编辑结束
OrderTable.AcceptChanges();
Totalprice += Convert.ToDecimal(dRow["price"]);
a += 1;
}
if (a == 0)
{
DataRow OrderRow = OrderTable.NewRow();