点击结账.
程序员文章站
2022-07-13 23:10:09
...
.Xaml中:给上一个按钮
.Cs中
结账命令
public RelayCommand ButtonClickCommand { get; set; }
/// 3.3 普通结账
///
/// 当前窗口
private void ButtonClick(Window window)
{
if (MessageBox.Show(“是否结账?”, “系统提示”, MessageBoxButton.OKCancel, MessageBoxImage.Question) == MessageBoxResult.OK)
{
using (TransactionScope scope = new TransactionScope())
{
//(1)修改订单信息
B_Order pW_Order = (from tbOrder in myModels.B_Order
where tbOrder.orderID == OrderID
select tbOrder).SingleOrDefault();
pW_Order.cutOffTime = DateTime.Now;//修改结账时间
myModels.Entry(pW_Order).State = System.Data.Entity.EntityState.Modified;
//(2)修改餐桌(修改状态)
S_DiningTable sYS_DiningTable = (from tbDining in myModels.S_DiningTable
where tbDining.orderID == OrderID
select tbDining).SingleOrDefault();
sYS_DiningTable.orderID = null;
sYS_DiningTable.status = "已付款";
sYS_DiningTable.totalMoney = 0;
myModels.Entry(sYS_DiningTable).State = System.Data.Entity.EntityState.Modified;
//(3)修改账号表(修改总金额,和可用余额)
S_Account account = (from tbaccount in myModels.S_Account
select tbaccount).SingleOrDefault();
decimal? TotalMoney_ = account.TotalMoney;
decimal? Avail_ = account.Avail;
account.TotalMoney = TotalMoney_ + Convert.ToDecimal(txtMoney);
account.Avail = Avail_ + Convert.ToDecimal(txtMoney);
myModels.Entry(account).State = System.Data.Entity.EntityState.Modified;
//(4)添加账户明细表(新增一条进账记录)
S_AmountOfDetail amountOfDetail = new S_AmountOfDetail();
amountOfDetail.money = Convert.ToDecimal(txtMoney);
amountOfDetail.reason = "餐饮消费";
amountOfDetail.time = DateTime.Now;
amountOfDetail.remark = "餐饮收入" + Convert.ToDecimal(txtMoney) + "元," + "该金额由餐饮收入";
amountOfDetail.capitalPosition = "收入";
myModels.S_AmountOfDetail.Add(amountOfDetail);
//(5)修改就餐记录
B_EatInRecord eatInRecord = (from tbeatInRecord in myModels.B_EatInRecord
where tbeatInRecord.orderID == OrderID
select tbeatInRecord).SingleOrDefault();
eatInRecord.totalMoney=Convert.ToDecimal(txtMoney);
eatInRecord.status = "已付款";
eatInRecord.endTime = DateTime.Now;
myModels.Entry(eatInRecord).State = System.Data.Entity.EntityState.Modified;
myModels.SaveChanges();
//提交事务
scope.Complete();
//返回成功信息
MessageBox.Show("结算成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information);
window.Close();
}
}
}
推荐阅读
-
PHP查询提交给自身展示结果并分页为何点击下一页显示全部内容
-
基于Vue.js的二级选项卡(v-for的循环嵌套)(点击横向的选项tab,在纵向显示tab的子选项tabchild,在右边显示子选项卡对应的内容)
-
CSS3和SVG炫酷鼠标点击按钮效果_html/css_WEB-ITnose
-
图片自动缩小 点击放大_图象特效
-
JS实现点击按钮后框架内载入不同网页的方法_javascript技巧
-
关于在ECside列表页面点击标题查看明细后不能回到原来所在页的问题
-
怎么提高网站浏览量?网站点击量大大增加方法介绍
-
phpexcel导出 如何实现点击导出后 弹出打开保存对话框 选择保存路径 保存
-
点击其他隐藏div
-
JQuery实现点击div以外的位置隐藏该div窗口_jquery