ldj/WcfServiceErp/T_ERP_SALE.svc.cs

187 lines
5.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/// <summary>
///WCF service
///FOR TABLE t_erp_sale
///By wm
///on 05/09/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_SALE :baseSvc, IErp_sale , IOrder
{
#region options
/*: basicService,
private static lErp_sale _lErp_sale ;
lErp_sale lErp_saleObj
{
get
{
if ( _lErp_sale == null || _lErp_sale.operId != getOperId())
{
_lErp_sale= new lErp_sale(getOperId());
}
return _lErp_sale;
}
}
*/
#endregion
ErpSale IErp_sale.getObj(int id)
{
ErpSale obj = new ErpSale(new Erp_sale(id));
obj.ErpSaleDetails = getLst(obj.sale_order);
return obj;
}
public ErpSale getOrder(string orderNo)
{
ErpSale obj = new ErpSale(new Erp_sale(orderNo));
obj.ErpSaleDetails = getLst(orderNo);
return obj;
}
List<WcfErp_sale_d> getLst(string orderNo)
{
List<WcfErp_sale_d> lstwcf = new List<WcfErp_sale_d>();
List<Erp_sale_d> lst = new Erp_sale_d().getList(orderNo);
foreach (Erp_sale_d d in lst)
{
lstwcf.Add(new WcfErp_sale_d().getWcfObject(d));
}
return lstwcf;
}
public WcfErp_saleList query(string condition, int pageno)
{
condition = filterRisk(condition);
WcfErp_saleList objLst = new WcfErp_saleList();
List<WcfErp_sale> lst = new List<WcfErp_sale>();
Erp_sale dbObj = new Erp_sale();
dbObj.rownumStart = (Convert.ToInt16(pageno) - 1) * WmsConstants.PAGER_SIZE;
dbObj.rownumEnd = dbObj.rownumStart + DeiNiu.Utils.WmsConstants.PAGER_SIZE;
try
{
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_sale(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;
}
catch (Exception er)
{
objLst.error = er.Message;
}
return objLst;
}
Result IErp_sale.add(ErpSale obj)
{
log.Debug("add called --->" + obj.sale_order);
int id;
using (TransactionScope scope = new TransactionScope())
{
try
{
if (obj == null || obj.ErpSaleDetails == null)
{
throw new ArgumentNullException("非法的参数格式;订单明细不能为空");
}
foreach (WcfErp_sale_d d in obj.ErpSaleDetails)
{
if (d.count <= 0)
{
throw new ArgumentNullException("出库数量不能小于等于0");
}
d.getDbObject().Add();
}
obj.wms_state = 0;
id =obj.getDbObject().Add();
scope.Complete();
return new Result(id ,enumDbResult.);
}
catch (ConstraintException ex) {
return new Result( enumDbResult.);
}
catch (Exception er)
{
return new Result(enumDbResult.,er.Message);
}
}
}
public Result complete(string orderNo)
{
return new Result(enumDbResult.);
}
public Result cancel(string orderNo)
{
WmsOutRequest wor = new WmsOutRequest(orderNo);
if( wor.state <(int) enumOutStockRequestStatus.)
{
//cancel pickorder,picktasks,erp_sale order
}
return new Result(enumDbResult.);
}
public List<WcfErp_sale_d> getOutStockDetail(string pickOrder)
{
List<WcfErp_sale_d> lstwcf = new List<WcfErp_sale_d>();
List<Erp_sale_d> lst = new Erp_sale_d().getPickList(pickOrder);
foreach (Erp_sale_d d in lst)
{
lstwcf.Add(new WcfErp_sale_d().getWcfObject(d));
}
return lstwcf;
}
}
}