public void Add(ViewModel.Order.AddForm form) { var orderDate = DateTime.Now; var deliveryDate = DateTime.Now; var details = new List <OrderDetailRecord>(); DateTime.TryParse(form.OrderDate, out orderDate); DateTime.TryParse(form.DeliveryDate, out deliveryDate); var model = new OrderRecord { OrderNo = form.OrderNo, Supplier = form.Supplier, LinkPerson = form.LinkPerson, Phone = form.Phone, Tel = form.Tel, Fax = form.Fax, OrderDate = orderDate, DeliveryDate = deliveryDate, Finished = 0, CreateTime = DateTime.Now, ModifyTime = DateTime.Now, Address = form.Address, Remark = form.Remark, Contract = form.Contract }; foreach (var det in form.Details) { details.Add(new OrderDetailRecord { SortIndex = det.SortIndex, Name = det.Name, Size = det.Size, Unit = det.Unit, Total = det.Total, Output = det.Output, Remark = det.Remark }); } try { int id = _thisDAL.Add(model); foreach (var det in details) { det.Order_Id = id; _orderDetailDal.Add(det); } } catch (Exception e) { _thisDAL.AbortTransaction(); throw e; } }
public void Add(OrderDetails entity) { _OrderDetailDAL.Add(entity); }
public bool Add(OrderDetail entity) { return(_orderDetailDal.Add(entity) > 0); }