191 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			191 lines
		
	
	
		
			5.7 KiB
		
	
	
	
		
			C#
		
	
	
	
| /// <summary>
 | ||
| ///WCF service
 | ||
| ///FOR TABLE t_erp_purch_d
 | ||
| ///By wm  
 | ||
| ///on 08/04/2023
 | ||
| /// </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 和配置文件中的类名 。
 | ||
|     public class T_ERP_PURCH_D :baseSvc, IErp_purch_d 
 | ||
|     {
 | ||
|         #region options
 | ||
|       /*: basicService, 
 | ||
|         private static  lErp_purch_d  _lErp_purch_d ;
 | ||
|          lErp_purch_d  lErp_purch_dObj
 | ||
|         {
 | ||
|             get
 | ||
|             {
 | ||
|                 if ( _lErp_purch_d  == null ||   _lErp_purch_d.operId != getOperId())
 | ||
|                 {
 | ||
|                      _lErp_purch_d= new  lErp_purch_d(getOperId());
 | ||
|                 }
 | ||
|                 return  _lErp_purch_d;
 | ||
|             }
 | ||
|         }
 | ||
|        */
 | ||
|        #endregion 
 | ||
|        
 | ||
|          public WcfErp_purch_d getObj(int Id)
 | ||
|         {
 | ||
|             log.Debug("getObj called --->" + Id);
 | ||
|             WcfErp_purch_d  wcfObj = new WcfErp_purch_d ();
 | ||
|             Erp_purch_d dbObj = new Erp_purch_d(Id);
 | ||
|              log.Debug("return json :" + Util.getJson( wcfObj.getWcfObject(dbObj)));
 | ||
|             return wcfObj.getWcfObject(dbObj);
 | ||
|         }
 | ||
| 
 | ||
|         public  Result add(WcfErp_purch_d obj)
 | ||
|         {
 | ||
|             log.Debug("add called --->" + Util.getJson(obj));
 | ||
|             int id = 0; 
 | ||
|             try
 | ||
|             {
 | ||
|                 id = obj.getDbObject().Add();
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 log.Error(ex);
 | ||
|                 return new Result(enumDbResult.失败, ex.Message);
 | ||
|             }
 | ||
|             Result  rt = id > 0 ? new Result(id, enumDbResult.成功) : new Result(enumDbResult.失败);
 | ||
|             log.Debug(Util.getJson(rt));
 | ||
|             return rt;
 | ||
|            
 | ||
|         }
 | ||
|  
 | ||
|       
 | ||
|         public Result update(WcfErp_purch_d obj)
 | ||
|         {
 | ||
|              log.Debug("update called --->" + Util.getJson(obj));
 | ||
|             int cnt = 0; 
 | ||
|             try
 | ||
|             {
 | ||
| 
 | ||
|                 cnt = obj.getDbObject().Update();
 | ||
| 
 | ||
|             }
 | ||
|             catch (Exception ex)
 | ||
|             {
 | ||
|                 log.Error(ex);
 | ||
|              return new Result(enumDbResult.失败, ex.Message);
 | ||
| 
 | ||
|             }
 | ||
|               Result rt  = cnt > 0 ? new Result(cnt, enumDbResult.成功) : new Result(enumDbResult.失败);
 | ||
| 
 | ||
|             log.Debug(Util.getJson(rt));
 | ||
| 
 | ||
|             return rt;
 | ||
|         } 
 | ||
|        #region options
 | ||
|        /*
 | ||
| 
 | ||
|         public enumDbResult delete(WcfErp_purch_d obj)
 | ||
|         {
 | ||
|             int cnt = 0;
 | ||
|             try { 
 | ||
|             
 | ||
|                 cnt = obj.getDbObject().Delete();
 | ||
| 
 | ||
|             }catch(Exception er)
 | ||
|             {
 | ||
|                 return new Result(enumDbResult.失败, er.Message);
 | ||
|             } 
 | ||
| 
 | ||
|             return new Result(cnt,  enumDbResult.成功);
 | ||
|         }
 | ||
|      
 | ||
|         public List<Result> updateList(List<WcfErp_purch_d> objs)
 | ||
|         {
 | ||
|              
 | ||
|             List<Result> results = new List<Result>();
 | ||
|            // using (TransactionScope scope = new TransactionScope())
 | ||
|             {
 | ||
|                 foreach (WcfErp_purch_d obj in objs)
 | ||
|                 {
 | ||
|                     Result rs = new Result(obj.id, obj.getDbObject().Update());
 | ||
|                     results.Add(rs);
 | ||
| 
 | ||
|                 }
 | ||
|               //  scope.Complete();
 | ||
|             }
 | ||
|             return results;
 | ||
|         }
 | ||
| 
 | ||
|         public List<Result> addList(List<WcfErp_purch_d> objs)
 | ||
|         {
 | ||
| 
 | ||
|             List<Result> results = new List<Result>();
 | ||
|            // using (TransactionScope scope = new TransactionScope())
 | ||
|             {
 | ||
|                 foreach (WcfErp_purch_d obj in objs)
 | ||
|                 {
 | ||
|                     Result rs = new Result( obj.getDbObject().Add(),1);
 | ||
|                     results.Add(rs);
 | ||
| 
 | ||
|                 }
 | ||
|               //  scope.Complete();
 | ||
|             }
 | ||
|             return results;
 | ||
|         }
 | ||
| 
 | ||
|         public List<Result> deleteList(List<WcfErp_purch_d> objs)
 | ||
|         {
 | ||
| 
 | ||
|             List<Result> results = new List<Result>();
 | ||
|            // using (TransactionScope scope = new TransactionScope())
 | ||
|             {
 | ||
|                 foreach (WcfErp_purch_d obj in objs)
 | ||
|                 {
 | ||
|                     Result rs = new Result(obj.id, obj.getDbObject().Delete());
 | ||
|                     results.Add(rs);
 | ||
| 
 | ||
|                 }
 | ||
|               //  scope.Complete();
 | ||
|             }
 | ||
|             return results;
 | ||
|         }*/
 | ||
|   #endregion 
 | ||
|      
 | ||
| 
 | ||
|         
 | ||
|         public WcfErp_purch_dList query(string condition, int pageno)
 | ||
|         {
 | ||
|             log.Debug("query called --->" + condition +", pageno " +pageno);
 | ||
|              condition = filterRisk(condition);
 | ||
|             WcfErp_purch_dList objLst = new WcfErp_purch_dList();
 | ||
|             List<WcfErp_purch_d> lst = new List<WcfErp_purch_d>();
 | ||
|               Erp_purch_d dbObj = new   Erp_purch_d();
 | ||
|             dbObj.rownumStart =(Convert.ToInt16(  pageno)-1)*  WmsConstants.PAGER_SIZE;
 | ||
|             dbObj.rownumEnd = dbObj.rownumStart + DeiNiu.Utils.WmsConstants.PAGER_SIZE;
 | ||
|             DataSet ds = dbObj.Query(condition);                     
 | ||
|             if (ds.Tables.Count >1)
 | ||
|             {
 | ||
|               DataTable dt = ds.Tables[0];    
 | ||
|                 foreach(DataRow dr in dt.Rows)
 | ||
|                 { 
 | ||
|                     lst.Add(new WcfErp_purch_d(dr));
 | ||
|                 }
 | ||
|                 objLst.rows = Convert.ToInt32(ds.Tables[1].Rows[0][0].ToString());
 | ||
|             }
 | ||
|             objLst.list =lst; 
 | ||
|             objLst.page = Convert.ToInt16(pageno);
 | ||
|             objLst.pageSize = WmsConstants.PAGER_SIZE;
 | ||
|             
 | ||
|             objLst.pageCnt = objLst.rows / WmsConstants.PAGER_SIZE;
 | ||
|             log.Debug(Util.getJson(objLst));
 | ||
|             return objLst;
 | ||
|         }
 | ||
| 
 | ||
|     }
 | ||
|  }
 |