/// <summary> /// Load món ăn /// </summary> /// <param name="inventoryItem"></param> /// <returns></returns> private UctChooseFood CreateUctChooseFoodByOrderDetail(DictionaryDataSet.OrderDetailRow orderDetail) { var uct = new UctChooseFood(orderDetail); uct.Click += ChooseFood_Click; uct.CalculateAmount += new EventHandler(CalculateAmount); if (!IsSendKitchen && uct.IsSendKitchen) { IsSendKitchen = true; } return(uct); }
/// <summary> /// Tính lại tổng tiền /// </summary> public void CalculateAmount(object sender, EventArgs e) { decimal amount = 0; foreach (var item in fpnlChooseFood.Controls) { if (item.GetType() == typeof(UctChooseFood)) { UctChooseFood uct = (UctChooseFood)item; amount += uct.UnitPrice * uct.Quantity; } } TotalAmount = amount; }
/// <summary> /// Thêm mới món ăn /// </summary> /// <param name="inventoryItem"></param> /// <returns></returns> private UctChooseFood CreateUctChooseFood(DictionaryDataSet.InventoryItemRow inventoryItem) { DictionaryDataSet.OrderRow master = (DictionaryDataSet.OrderRow)dsDictionary.Order.FindByOrderID(OrderID); var row = dsDictionary.OrderDetail.FirstOrDefault((t) => t.RowState != DataRowState.Deleted && t.InventoryItemID == inventoryItem.InventoryItemID && t.OrderDetailStatus == (int)EnumOrderDetailStatus.Ordering); if (row != null) { row.Quantity += 1; return(null); } else { DictionaryDataSet.OrderDetailRow orderDetail = (DictionaryDataSet.OrderDetailRow)_oBL.InitNewRowDetail(dsDictionary.OrderDetail, master, inventoryItem.InventoryItemID); var uct = new UctChooseFood(orderDetail); uct.Click += ChooseFood_Click; uct.CalculateAmount += new EventHandler(CalculateAmount); return(uct); } }
private void btnSendKitchen_Click(object sender, EventArgs e) { try { int countSendKitchen = 0; var oBLSendKitchen = new BLSendKitchen(); foreach (var item in fpnlChooseFood.Controls) { if (item.GetType() == typeof(UctChooseFood)) { UctChooseFood uct = (UctChooseFood)item; if (!uct.IsSendKitchen) { countSendKitchen++; // Insert To SendKitchen var sendKitchenRow = oBLSendKitchen.InitNewRow(dsDictionary.SendKitchen, uct.OrderDetailRow.OrderDetailID); oBLSendKitchen.InsertUpdate(sendKitchenRow); // Update detail uct.OrderDetailRow.OrderDetailStatus = (int)EnumOrderDetailStatus.Served; uct.IsSendKitchen = true; } } } if (SaveData() > 0) { FormActionMode = ActionMode.Edit; DsDictionary.AcceptChanges(); } if (countSendKitchen == 0) { MessageBoxCommon.ShowExclamation("Không có món nào mới để gửi bếp."); } else { IsSendKitchen = true; } } catch (Exception ex) { MessageBoxCommon.ShowException(ex); } }
private void ChooseFood_Click(object sender, EventArgs e) { try { UctChooseFood control = (UctChooseFood)sender; if (control != null) { if (control.IsRemove && !control.IsSendKitchen) { fpnlChooseFood.Controls.Remove(control); control.OrderDetailRow.Delete(); //DsDictionary.OrderDetail.RemoveOrderDetailRow(control.OrderDetailRow); TotalAmount -= control.UnitPrice * control.Quantity; } } } catch (Exception ex) { MessageBoxCommon.ShowException(ex); } }