| | |
| | | return UpdateData(db, mesSalesOrder, mesSalesOrderDatas) ? 1 : 0; |
| | | case "2": |
| | | case "4": |
| | | case "5": |
| | | return SaveOrUpdateData(db, mesSalesOrder, mesSalesOrderDatas, erpSalesOrderDto.Type) |
| | | ? 1 |
| | | : 0; |
| | |
| | | return result.All(b => b); |
| | | } |
| | | |
| | | //自动映射字段 |
| | | public static void MapProperties<T>(T target, object source) |
| | | { |
| | | var targetProps = typeof(T).GetProperties(); |
| | | var sourceProps = source.GetType().GetProperties(); |
| | | |
| | | foreach (var targetProp in targetProps) |
| | | { |
| | | var sourceProp = sourceProps.FirstOrDefault(p => p.Name == targetProp.Name && p.PropertyType == targetProp.PropertyType); |
| | | if (sourceProp != null) |
| | | { |
| | | var value = sourceProp.GetValue(source); |
| | | targetProp.SetValue(target, value); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private SalesOrder ConvertErpToSalesOrder( |
| | | ErpSalesOrder erpDto1) |
| | | { |
| | |
| | | return null; // 如果转换失败,返回null |
| | | } |
| | | var erpDto = erpDto1.OrderDto; |
| | | var salesOrder = new SalesOrder |
| | | var salesOrder = new SalesOrder(); |
| | | MapProperties(salesOrder, erpDto); |
| | | /*var salesOrder = new SalesOrder |
| | | { |
| | | Id = erpDto.Id, |
| | | Erpid = erpDto.Erpid, |
| | |
| | | //long.Parse() |
| | | //Convert.ToDecimal() |
| | | //Convert.ToDouble() |
| | | }; |
| | | };*/ |
| | | |
| | | var single = base.GetSingle(it => it.Erpid == erpDto.Erpid); |
| | | if (single != null) salesOrder.Id = single.Id; |
| | |
| | | |
| | | foreach (var erpDto in erpDtoList.Items) |
| | | { |
| | | var salesOrderSub = new SalesOrderDetail |
| | | var salesOrderSub = new SalesOrderDetail(); |
| | | MapProperties(salesOrderSub, erpDto); |
| | | /*var salesOrderSub = new SalesOrderDetail |
| | | { |
| | | Id = erpDto.Id, |
| | | Erpid = erpDto.Erpid, |
| | |
| | | Fmapid = erpDto.Fmapid, |
| | | Fmapname = erpDto.Fmapname, |
| | | Fmapspec = erpDto.Fmapspec |
| | | }; |
| | | };*/ |
| | | |
| | | var single = _SalesOrderDetailManager.GetSingle(it => |
| | | it.Erpid == salesOrderSub.Erpid); |