Exemplo n.º 1
0
        public Result <bool> AddToolPurchaseOrder(ToolPurchaseOrder order)
        {
            Result <bool> rlt = new Result <bool>();

            try
            {
                Db.ToolPurchaseOrders.Add(order);//TODO:测试明细会不会同步保存
                Db.SaveChanges();
            }
            catch (Exception ex)
            {
                LogUtil.WriteLog(ex);
                rlt.HasError = true;
                rlt.Msg      = ex.Message;
            }
            return(rlt);
        }
Exemplo n.º 2
0
        public Result <bool> EditToolPurchaseOrder(ToolPurchaseOrder ord)
        {
            Result <bool> rlt = new Result <bool>();

            try
            {
                var old = Db.Entry(ord);
                old.State = System.Data.Entity.EntityState.Modified;

                Db.ToolPurchaseOrderDtls.RemoveRange(Db.ToolPurchaseOrderDtls.Where(p => p.OrderId == ord.Id));
                Db.ToolPurchaseOrderDtls.AddRange(ord.OrderDtls);

                Db.SaveChanges();
            }
            catch (Exception ex)
            {
                LogUtil.WriteLog(ex);
                rlt.HasError = true;
                rlt.Msg      = ex.Message;
            }
            return(rlt);
        }