生活随笔
收集整理的這篇文章主要介紹了
点击开台.
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
//鼠標按下判斷開臺
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_DishesBelongsTypeon tbop.BelongID equals tbType.BelongIDwhere tbType.BelongLargeClass == Cuisineselect 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;//菜名IDint? Quantity = InForm.Amount;//點菜數量//訂單明細表B_DishesOrder dishesOrder = new B_DishesOrder();dishesOrder.OrderID = order.OrderID;//訂單IDdishesOrder.DishesID = DishesID;//菜IDdishesOrder.Quantity = Quantity;//數量myModel.B_DishesOrder.Add(dishesOrder);}//修改餐桌表R_TableType tableType = (from tbType in myModel.R_TableTypewhere tbType.TableTypeID == TableTypeIDselect tbType).SingleOrDefault();tableType.OrderID = order.OrderID;//獲取訂單IDtableType.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);}}}
總結
以上是生活随笔為你收集整理的点击开台.的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。