public JsonResult Create(OrderPackRecordType obj) { try { NSession.SaveOrUpdate(obj); NSession.Flush(); } catch (Exception ee) { return Json(new { IsSuccess = false, ErrorMsg = "出错了" }); } return Json(new { IsSuccess = true }); }
public void SaveRecord(OrderType order, string p) { IList<OrderProductType> orderproduct = NSession.CreateQuery("from OrderProductType where OId='" + order.Id + "'").List<OrderProductType>(); double PackCoefficient = 0; string sku = ""; if (orderproduct.Count == 0) { PackCoefficient = 3; } foreach (OrderProductType item in orderproduct) { IList<ProductType> product = NSession.CreateQuery("from ProductType where SKU='" + item.SKU + "'").List<ProductType>(); if (product.Count != 0) { if (product[0].PackCoefficient > PackCoefficient) { PackCoefficient = product[0].PackCoefficient; sku = product[0].SKU; } } else { PackCoefficient = 1; } } var orderPackRecord = new OrderPackRecordType { OId = order.Id, OrderNo = order.OrderNo, PackBy = p, PackOn = DateTime.Now, ScanBy = CurrentUser.Realname, PackCoefficient = PackCoefficient, SKU = sku }; NSession.Save(orderPackRecord); NSession.Flush(); }