Ejemplo n.º 1
0
        private void NewSelectMenuItem(DAL.MenuItem menuItem, int quantity = 1, DAL.OrderDetail orderDetail = null)
        {
            SelectMenuItemControl selectMenuItem = new SelectMenuItemControl(menuItem, quantity, orderDetail);

            selectMenuItem.Width       = this.flowLayoutPanelRight.Width - 24;
            selectMenuItem.Height      = (int)((double)selectMenuItem.Width / 3.6);
            selectMenuItem.OnDecrease += new SelectMenuItemControl.OnDecreaseHandle(this.SelectMenuItemControl_OnDecrease);
            selectMenuItem.OnRemove   += new SelectMenuItemControl.OnRemoveHandle(this.SelectMenuItemControl_OnRemove);
            this.flowLayoutPanelRight.Controls.Add(selectMenuItem);
        }
 partial void DeleteOrderDetail(OrderDetail instance);
 partial void UpdateOrderDetail(OrderDetail instance);
 partial void InsertOrderDetail(OrderDetail instance);
		private void detach_OrderDetails(OrderDetail entity)
		{
			this.SendPropertyChanging();
			entity.BaseAttribute = null;
		}
		private void detach_OrderDetails(OrderDetail entity)
		{
			this.SendPropertyChanging();
			entity.Product = null;
		}
		private void attach_OrderDetails(OrderDetail entity)
		{
			this.SendPropertyChanging();
			entity.Order = this;
		}
		private void detach_OrderDetails(OrderDetail entity)
		{
			this.SendPropertyChanging();
			entity.MeasurementUnit = null;
		}
 private void dgwOrderDetails_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 {
     DataGridView dgv = (DataGridView)sender;
     if (orderDetails == null)
     {
         orderDetails = new BindingList<OrderDetail>();
     }
     if (orderDetails.Count < dgwOrderDetails.RowCount - 1)
     {
         OrderDetail orderDetail = new OrderDetail();
         orderDetails.Add(orderDetail);
     }
     if (dgv.CurrentCell.Value != null)
     {
         switch (e.ColumnIndex)
         {
             case ProductAttrCell:
                 {
                     ProductAttributeService productAttrService = new ProductAttributeService();
                     ProductAttribute pa = productAttrService.GetProductAttribute((int)dgv.CurrentCell.Value);
                     if (pa != null)
                     {
                         orderDetails[e.RowIndex].ProductId = pa.ProductId;
                         orderDetails[e.RowIndex].AttributeId = pa.AttributeId;
                     }
                 } break;
             case PriceCell:
                 {
                     double price = 0;
                     try
                     {
                         price = (double)dgv.CurrentCell.Value;
                         if (price < 0)
                             price = 0;
                     }
                     catch { price = 0; }
                     orderDetails[e.RowIndex].Price = price;
                     dgv.CurrentCell.ToolTipText = Global.formatVNDCurrencyText(price.ToString());
                 } break;
             case CommissionCell:
                 {
                     double commission = 0;
                     try
                     {
                         commission = (double)dgv.CurrentCell.Value;
                         if (commission < 0)
                             commission = 0;
                     }
                     catch { commission = 0; }
                     orderDetails[e.RowIndex].Commission = commission;
                     dgv.CurrentCell.ToolTipText = Global.formatVNDCurrencyText(commission.ToString());
                 } break;
             case TotalCell:
                 {
                     dgv.CurrentCell.ToolTipText = Global.formatVNDCurrencyText(orderDetails[e.RowIndex].Cost.ToString());
                 } break;
             case NoteCell:
                 {
                     orderDetails[e.RowIndex].Note = (string)dgv.CurrentCell.Value;
                 } break;
             default:
                 break;
         }
     }
     calculateNumberUnit(dgv, e.RowIndex, e.ColumnIndex);
     calculateTotal();
     orderDetails[e.RowIndex].Cost = (int)dgwOrderDetails.Rows[e.RowIndex].Cells[NumberUnitCell].Value
         * (double)dgwOrderDetails.Rows[e.RowIndex].Cells[PriceCell].Value;
     dgwOrderDetails.Rows[e.RowIndex].Cells[TotalCell].ToolTipText = Global.formatVNDCurrencyText(orderDetails[e.RowIndex].Cost.ToString());
 }
Ejemplo n.º 10
0
 public void RemoveFood(Order order, DAL.OrderDetail orderDetail)
 {
     Connection.DBContext.OrderDetails.Remove(orderDetail);
     Connection.DBContext.SaveChanges();
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the OrderDetails EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrderDetails(OrderDetail orderDetail)
 {
     base.AddObject("OrderDetails", orderDetail);
 }
 /// <summary>
 /// Create a new OrderDetail object.
 /// </summary>
 /// <param name="orderId">Initial value of the OrderId property.</param>
 /// <param name="productId">Initial value of the ProductId property.</param>
 /// <param name="numberUnit">Initial value of the NumberUnit property.</param>
 /// <param name="price">Initial value of the Price property.</param>
 /// <param name="cost">Initial value of the Cost property.</param>
 /// <param name="tax">Initial value of the Tax property.</param>
 /// <param name="note">Initial value of the Note property.</param>
 public static OrderDetail CreateOrderDetail(global::System.Int32 orderId, global::System.Int32 productId, global::System.Int32 numberUnit, global::System.Double price, global::System.Double cost, global::System.Double tax, global::System.String note)
 {
     OrderDetail orderDetail = new OrderDetail();
     orderDetail.OrderId = orderId;
     orderDetail.ProductId = productId;
     orderDetail.NumberUnit = numberUnit;
     orderDetail.Price = price;
     orderDetail.Cost = cost;
     orderDetail.Tax = tax;
     orderDetail.Note = note;
     return orderDetail;
 }