点击开台.

//鼠标按下判断开台
private void GridMouseDown()
{
string statu = dataTable.Rows[0][“Status”].ToString();//获取餐桌状态
int people = Convert.ToInt32(dataTable.Rows[0][“People”].ToString());//餐桌容纳人数
int tabletypeID = Convert.ToInt32(dataTable.Rows[0][“TableTypeID”].ToString());//桌子ID
if (dataTable.Rows[0][“orderID”].ToString() != “”)//判断是否下单
{
OrderID = Convert.ToInt32(dataTable.Rows[0][“OrderID”].ToString());//获取订单ID
}
if(statu == “空桌”)
{
KaiTaiKaiTai orderKT = new KaiTaiKaiTai();
var orderKTViewModel = (orderKT.DataContext as OrderKtViewModel);
orderKTViewModel.TableTypeID = TableTypeID;
orderKTViewModel.People = people;
//弹出窗口
orderKT.ShowDialog();
if (DiningTable != null)
{
DiningTable();
}
}
}
进去之后就是一个页面选择菜品样式

然后查询出菜品样式
private void SelectAtion(WrapPanel wp)
{
//获取WrapPanel
WP = wp;
if (wp != null)
{
WP.Children.Clear();
}
if(Cuisine == null)
{
var Grop = (from tbop in myModel.R_DishesCategory
select new InFormationVo
{
DishesID = tbop.DishesID,
DishName = tbop.DishName,
DishPrice1 = tbop.DishPrice1,
pictures = tbop.pictures,
}).ToList();
//临时保存
dataTable = ListToDataTable.ListToDataTablen(Grop);

        }
        else
        {
            var Grops = (from tbop in myModel.R_DishesCategory
                             //大类
                         join tbType in myModel.D_DishesBelongsType
                         on tbop.BelongID equals tbType.BelongID
                         where tbType.BelongLargeClass == Cuisine
                         select new InFormationVo
                         {
                             DishesID = tbop.DishesID,
                             DishName = tbop.DishName,
                             DishPrice1 = tbop.DishPrice1,
                             pictures = tbop.pictures,
                         }).ToList();
            dataTable = ListToDataTable.ListToDataTablen(Grops);
        }
        if (dataTable != null)
        {
            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                //实例化控件
                KaiTaiDianCai DianCai = new KaiTaiDianCai();
                int dishesID = Convert.ToInt32(dataTable.Rows[i]["DishesID"].ToString());
                var orderMealViewModel = (DianCai.DataContext as OrderMealViewModel);
                orderMealViewModel.DishesID = dishesID;
                orderMealViewModel.ChangeTextEvent += new OrderMealViewModel.ChangeTextHandler(ShowMessage);
                WP.Children.Add(DianCai);
            }
            txt_people = "1";
            txt_Remark = "+整单备注";
        }
    }

最后就点击下单
private void MakeOrder(Window window)
{
using (TransactionScope scope = new TransactionScope())
{
//判断页面数据不为空
if(dgOrderDetails.Count >0 && !string.IsNullOrEmpty(txt_people.ToString()))
{
B_Order order = new B_Order();
order.People = Convert.ToInt32(txt_people).ToString();//用餐人数
order.orderTime = DateTime.Now;//下单时间
order.money = Convert.ToDecimal(txt_ZJE);//账单金额
if(txt_Remark != “+整单备注”)
{
order.remark = txt_Remark;//备注
}
else
{
order.remark = null;
}

            order.Amount = Convert.ToInt32(txt_amount);//菜数
            myModel.B_Order.Add(order);
            myModel.SaveChanges();
            //新增订单明细表
            for (int i = 0; i < dgOrderDetails.Count; i++)
            {
                InFormationVo InForm = dgOrderDetails[i] as InFormationVo;
                int DishesID = InForm.DishesID;//菜名ID
                int? Quantity = InForm.Amount;//点菜数量
                //订单明细表
                B_DishesOrder dishesOrder = new B_DishesOrder();
                dishesOrder.OrderID = order.OrderID;//订单ID
                dishesOrder.DishesID = DishesID;//菜ID
                dishesOrder.Quantity = Quantity;//数量
                myModel.B_DishesOrder.Add(dishesOrder);
            }
            //修改餐桌表
            R_TableType tableType = (from tbType in myModel.R_TableType
                                     where tbType.TableTypeID == TableTypeID
                                     select tbType).SingleOrDefault();
            tableType.OrderID = order.OrderID;//获取订单ID
            tableType.TotalMoney= Convert.ToDecimal(txt_ZJE);
            tableType.Status = "待付款";
            myModel.Entry(tableType).State = System.Data.Entity.EntityState.Modified;
            //新增餐桌消费记录表
            B_OrderRecording Recording = new B_OrderRecording();
            Recording.People = Convert.ToInt32(txt_people).ToString();//人数
            Recording.Status = "待付款";
            Recording.TotalMoney = Convert.ToDecimal(txt_ZJE);//总金额
            Recording.OrderID = order.OrderID;
            Recording.StarTime = DateTime.Now;
            myModel.B_OrderRecording.Add(Recording);

            myModel.SaveChanges();//保存
            scope.Complete();//事务提交
            MessageBox.Show("下单成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
                window.Close();
            }
            else
            {
                MessageBox.Show("请选择菜品!", "提示", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值