| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | /// <summary> | 
					
						
							|  |  |  |  | ///WCF service | 
					
						
							|  |  |  |  | ///FOR TABLE t_erpGoods | 
					
						
							|  |  |  |  | ///By wm   | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  | ///on 08/04/2023 | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | /// </summary> | 
					
						
							|  |  |  |  |    | 
					
						
							|  |  |  |  | using System.Collections.Generic; | 
					
						
							|  |  |  |  | using System.Data; | 
					
						
							|  |  |  |  | using DeiNiu.wms.Data.Model.Wcf ; | 
					
						
							|  |  |  |  | using DeiNiu.wms.Data.Model; | 
					
						
							|  |  |  |  | using System.Transactions; | 
					
						
							|  |  |  |  | using DeiNiu.Utils; | 
					
						
							|  |  |  |  | using System; | 
					
						
							|  |  |  |  | using DeiNiu.Wcf.erp.wcfData; | 
					
						
							|  |  |  |  | namespace DeiNiu.Wcf | 
					
						
							|  |  |  |  | { | 
					
						
							|  |  |  |  |     // 注意: 使用“重构”菜单上的“重命名”命令,可以同时更改代码、svc 和配置文件中的类名 。 | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |     public class T_ERPGOODS :baseSvc, IErpGoods  | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |     { | 
					
						
							|  |  |  |  |         #region options | 
					
						
							|  |  |  |  |       /*: basicService,  | 
					
						
							|  |  |  |  |         private static  lErpGoods  _lErpGoods ; | 
					
						
							|  |  |  |  |          lErpGoods  lErpGoodsObj | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |             get | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 if ( _lErpGoods  == null ||   _lErpGoods.operId != getOperId()) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                      _lErpGoods= new  lErpGoods(getOperId()); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 return  _lErpGoods; | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  |        */ | 
					
						
							|  |  |  |  |        #endregion  | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |         | 
					
						
							|  |  |  |  |          public WcfErpGoods getObj(int Id) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |             log.Debug("查询物料 --->" + Id); | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             WcfErpGoods  wcfObj = new WcfErpGoods (); | 
					
						
							|  |  |  |  |             ErpGoods dbObj = new ErpGoods(Id); | 
					
						
							|  |  |  |  |              log.Debug("return json :" + Util.getJson( wcfObj.getWcfObject(dbObj))); | 
					
						
							|  |  |  |  |             return wcfObj.getWcfObject(dbObj); | 
					
						
							|  |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |         public  Result add(WcfErpGoods obj) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |             log.Debug("新增物料 --->" + Util.getJson(obj)); | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             int id = 0;  | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 ErpGoods erpgood = obj.getDbObject(); | 
					
						
							|  |  |  |  |                 erpgood.minOperateCount = erpgood.middleCount; | 
					
						
							|  |  |  |  |                 erpgood.bigCount = erpgood.middleCount; | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 id = erpgood.Add(); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             catch (Exception ex) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             { | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |                 log.Error(ex); | 
					
						
							|  |  |  |  |                 return new Result(enumDbResult.失败, ex.Message); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             Result  rt = id > 0 ? new Result(id, enumDbResult.成功) : new Result(enumDbResult.失败); | 
					
						
							|  |  |  |  |             log.Debug(Util.getJson(rt)); | 
					
						
							|  |  |  |  |             return rt; | 
					
						
							|  |  |  |  |             | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |   | 
					
						
							|  |  |  |  |        | 
					
						
							|  |  |  |  |         public Result update(WcfErpGoods obj) | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2025-01-23 22:53:20 +08:00
										 |  |  |  |              log.Debug("更新物料 --->" + Util.getJson(obj)); | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             int cnt = 0;  | 
					
						
							|  |  |  |  |             try | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |                 ErpGoods erpgood = obj.getDbObject(); | 
					
						
							|  |  |  |  |                 erpgood.minOperateCount = erpgood.middleCount; | 
					
						
							|  |  |  |  |                 erpgood.bigCount = erpgood.middleCount; | 
					
						
							|  |  |  |  |                 cnt = erpgood.Update(); | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             catch (Exception ex) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 log.Error(ex); | 
					
						
							|  |  |  |  |              return new Result(enumDbResult.失败, ex.Message); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |               Result rt  = cnt > 0 ? new Result(cnt, enumDbResult.成功) : new Result(enumDbResult.失败); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-06 19:36:47 +08:00
										 |  |  |  |             log.Debug("update result:" +Util.getJson(rt)); | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |             return rt; | 
					
						
							|  |  |  |  |         }  | 
					
						
							|  |  |  |  |        #region options | 
					
						
							|  |  |  |  |        /* | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |         public enumDbResult delete(WcfErpGoods obj) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             int cnt = 0; | 
					
						
							|  |  |  |  |             try {  | 
					
						
							|  |  |  |  |              | 
					
						
							|  |  |  |  |                 cnt = obj.getDbObject().Delete(); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             }catch(Exception er) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 return new Result(enumDbResult.失败, er.Message); | 
					
						
							|  |  |  |  |             }  | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             return new Result(cnt,  enumDbResult.成功); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         } | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |       | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |         public List<Result> updateList(List<WcfErpGoods> objs) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  |               | 
					
						
							|  |  |  |  |             List<Result> results = new List<Result>(); | 
					
						
							|  |  |  |  |            // using (TransactionScope scope = new TransactionScope()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (WcfErpGoods obj in objs) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Result rs = new Result(obj.id, obj.getDbObject().Update()); | 
					
						
							|  |  |  |  |                     results.Add(rs); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |               //  scope.Complete(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return results; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public List<Result> addList(List<WcfErpGoods> objs) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             List<Result> results = new List<Result>(); | 
					
						
							|  |  |  |  |            // using (TransactionScope scope = new TransactionScope()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (WcfErpGoods obj in objs) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Result rs = new Result( obj.getDbObject().Add(),1); | 
					
						
							|  |  |  |  |                     results.Add(rs); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |               //  scope.Complete(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return results; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |         public List<Result> deleteList(List<WcfErpGoods> objs) | 
					
						
							|  |  |  |  |         { | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |             List<Result> results = new List<Result>(); | 
					
						
							|  |  |  |  |            // using (TransactionScope scope = new TransactionScope()) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |                 foreach (WcfErpGoods obj in objs) | 
					
						
							|  |  |  |  |                 { | 
					
						
							|  |  |  |  |                     Result rs = new Result(obj.id, obj.getDbObject().Delete()); | 
					
						
							|  |  |  |  |                     results.Add(rs); | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |               //  scope.Complete(); | 
					
						
							|  |  |  |  |             } | 
					
						
							|  |  |  |  |             return results; | 
					
						
							|  |  |  |  |         }*/ | 
					
						
							|  |  |  |  |   #endregion  | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |       | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  | 
 | 
					
						
							|  |  |  |  |          | 
					
						
							|  |  |  |  |         public WcfErpGoodsList query(string condition, int pageno) | 
					
						
							|  |  |  |  |         { | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             log.Debug("query called --->" + condition +", pageno " +pageno); | 
					
						
							|  |  |  |  |              condition = filterRisk(condition); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             WcfErpGoodsList objLst = new WcfErpGoodsList(); | 
					
						
							|  |  |  |  |             List<WcfErpGoods> lst = new List<WcfErpGoods>(); | 
					
						
							|  |  |  |  |               ErpGoods dbObj = new   ErpGoods(); | 
					
						
							|  |  |  |  |             dbObj.rownumStart =(Convert.ToInt16(  pageno)-1)*  WmsConstants.PAGER_SIZE; | 
					
						
							|  |  |  |  |             dbObj.rownumEnd = dbObj.rownumStart + DeiNiu.Utils.WmsConstants.PAGER_SIZE; | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             DataSet ds = dbObj.Query(condition);                      | 
					
						
							|  |  |  |  |             if (ds.Tables.Count >1) | 
					
						
							|  |  |  |  |             { | 
					
						
							|  |  |  |  |               DataTable dt = ds.Tables[0];     | 
					
						
							|  |  |  |  |                 foreach(DataRow dr in dt.Rows) | 
					
						
							|  |  |  |  |                 {  | 
					
						
							|  |  |  |  |                     lst.Add(new WcfErpGoods(dr)); | 
					
						
							|  |  |  |  |                 } | 
					
						
							|  |  |  |  |                 objLst.rows = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString()); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             objLst.list =lst;  | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             objLst.page = Convert.ToInt16(pageno); | 
					
						
							|  |  |  |  |             objLst.pageSize = WmsConstants.PAGER_SIZE; | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |              | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             objLst.pageCnt = objLst.rows / WmsConstants.PAGER_SIZE; | 
					
						
							| 
									
										
										
										
											2023-09-04 22:41:19 +08:00
										 |  |  |  |             log.Debug(Util.getJson(objLst)); | 
					
						
							| 
									
										
										
										
											2023-05-23 16:13:17 +08:00
										 |  |  |  |             return objLst; | 
					
						
							|  |  |  |  |         } | 
					
						
							|  |  |  |  | 
 | 
					
						
							|  |  |  |  |     } | 
					
						
							|  |  |  |  |  } |