|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Data.Entity.Migrations;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using CK.SCP.Models;
|
|
|
|
using CK.SCP.Models.AppBoxEntity;
|
|
|
|
using CK.SCP.Models.ScpEntity;
|
|
|
|
using CK.SCP.Utils;
|
|
|
|
using System.Data.Entity.Core;
|
|
|
|
using CK.SCP.Models.Enums;
|
|
|
|
|
|
|
|
namespace CK.SCP.Controller
|
|
|
|
{
|
|
|
|
public class SCP_TS_BARCODE_CONTROLLER
|
|
|
|
{
|
|
|
|
public static void Get_TS_BARCODE_List(TS_BARCODE p_entity, Action<ResultObject<IQueryable<TS_BARCODE>>> p_action)
|
|
|
|
{
|
|
|
|
ResultObject<IQueryable<TS_BARCODE>> _ret = new ResultObject<IQueryable<TS_BARCODE>>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
IQueryable<TS_BARCODE> q = db.TS_BARCODE;
|
|
|
|
if (p_entity.UIDList != null && p_entity.UIDList.Count>0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p_entity.UIDList.Contains(p.UID));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.BarCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BarCode.Contains(p_entity.BarCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.FullBarCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.FullBarCode.Contains(p_entity.FullBarCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendPartCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendPartCode.Contains(p_entity.VendPartCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Batch))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Batch.Contains(p_entity.Batch));
|
|
|
|
}
|
|
|
|
if (p_entity.ManageType != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.ManageType == p_entity.ManageType);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.SerialNum))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.SerialNum.Contains(p_entity.SerialNum));
|
|
|
|
}
|
|
|
|
if (p_entity.Qty != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Qty == p_entity.Qty);
|
|
|
|
}
|
|
|
|
if (p_entity.BarCodeType != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BarCodeType == p_entity.BarCodeType);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.BillNum))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BillNum.Contains(p_entity.BillNum));
|
|
|
|
}
|
|
|
|
if (p_entity.PoBillLine != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PoBillLine == p_entity.PoBillLine);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendId))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendId.Contains(p_entity.VendId));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendBatch))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendBatch.Contains(p_entity.VendBatch));
|
|
|
|
}
|
|
|
|
if (p_entity.PackQty != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PackQty == p_entity.PackQty);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.CreateOper))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.CreateOper.Contains(p_entity.CreateOper));
|
|
|
|
}
|
|
|
|
if (p_entity.State != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.State == p_entity.State);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Remark))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Remark.Contains(p_entity.Remark));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PoUnit))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PoUnit.Contains(p_entity.PoUnit));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.LocUnit))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.LocUnit.Contains(p_entity.LocUnit));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartName))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PartName.Contains(p_entity.PartName));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Extend16))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Extend16==p_entity.Extend16);
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = q;
|
|
|
|
p_action(_ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_List", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_List", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_List", ex.ToString());
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_List", e.Message);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public static void Get_V_TS_BARCODE_List(V_TS_BARCODE p_entity, Action<ResultObject<IQueryable<V_TS_BARCODE>>> p_action)
|
|
|
|
{
|
|
|
|
ResultObject<IQueryable<V_TS_BARCODE>> _ret = new ResultObject<IQueryable<V_TS_BARCODE>>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
IQueryable<V_TS_BARCODE> q = db.V_TS_BARCODE;
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.BarCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BarCode.Contains(p_entity.BarCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Batch))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Batch.Contains(p_entity.Batch));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.BillNum))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BillNum.Contains(p_entity.BillNum));
|
|
|
|
}
|
|
|
|
if (p_entity.PoBillLine != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PoBillLine == p_entity.PoBillLine);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendBatch))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendBatch.Contains(p_entity.VendBatch));
|
|
|
|
}
|
|
|
|
if (p_entity.PackQty != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PackQty == p_entity.PackQty);
|
|
|
|
}
|
|
|
|
if (p_entity.UserInAddress != null && p_entity.UserInAddress.Count > 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p_entity.UserInAddress.Contains(p.Site));
|
|
|
|
}
|
|
|
|
if (p_entity.UserInVendIds != null && p_entity.UserInVendIds.Count > 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p_entity.UserInVendIds.Contains(p.VendId));
|
|
|
|
}
|
|
|
|
q = q.Where(p => p.IsScanned == p_entity.IsScanned);
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = q;
|
|
|
|
p_action(_ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_V_TS_BARCODE_List", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_V_TS_BARCODE_List", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_V_TS_BARCODE_List", ex.ToString());
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_V_TS_BARCODE_List", e.Message);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
public static void Get_TS_BARCODE_CUSTOM_List(TS_BARCODE_CUSTOM p_entity, Action<ResultObject<IQueryable<TS_BARCODE_CUSTOM>>> p_action)
|
|
|
|
{
|
|
|
|
ResultObject<IQueryable<TS_BARCODE_CUSTOM>> _ret = new ResultObject<IQueryable<TS_BARCODE_CUSTOM>>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
IQueryable<TS_BARCODE_CUSTOM> q = db.TS_BARCODE_CUSTOM;
|
|
|
|
if (p_entity.UIDList != null && p_entity.UIDList.Count > 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p_entity.UIDList.Contains(p.UID));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.BarCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BarCode.Contains(p_entity.BarCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.FullBarCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.FullBarCode.Contains(p_entity.FullBarCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendPartCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendPartCode.Contains(p_entity.VendPartCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Batch))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Batch.Contains(p_entity.Batch));
|
|
|
|
}
|
|
|
|
if (p_entity.ManageType != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.ManageType == p_entity.ManageType);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.SerialNum))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.SerialNum.Contains(p_entity.SerialNum));
|
|
|
|
}
|
|
|
|
if (p_entity.Qty != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Qty == p_entity.Qty);
|
|
|
|
}
|
|
|
|
if (p_entity.BarCodeType != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BarCodeType == p_entity.BarCodeType);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.BillNum))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BillNum.Contains(p_entity.BillNum));
|
|
|
|
}
|
|
|
|
if (p_entity.PoBillLine != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PoBillLine == p_entity.PoBillLine);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendId))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendId.Contains(p_entity.VendId));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendBatch))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendBatch.Contains(p_entity.VendBatch));
|
|
|
|
}
|
|
|
|
if (p_entity.PackQty != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PackQty == p_entity.PackQty);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.CreateOper))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.CreateOper.Contains(p_entity.CreateOper));
|
|
|
|
}
|
|
|
|
if (p_entity.State != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.State == p_entity.State);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Remark))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Remark.Contains(p_entity.Remark));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PoUnit))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PoUnit.Contains(p_entity.PoUnit));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.LocUnit))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.LocUnit.Contains(p_entity.LocUnit));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartName))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PartName.Contains(p_entity.PartName));
|
|
|
|
}
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = q;
|
|
|
|
p_action(_ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_CUSTOM_List", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_CUSTOM_List", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_CUSTOM_List", ex.ToString());
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_CUSTOM_List", e.Message);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public ResultObject<bool> Save_TS_BARCODE(List<TS_BARCODE> p_entitys)
|
|
|
|
{
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
foreach (var itm in p_entitys)
|
|
|
|
{
|
|
|
|
db.TS_BARCODE.AddOrUpdate(itm);
|
|
|
|
}
|
|
|
|
if (db.SaveChanges() != -1)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Save_TS_BARCODE", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Save_TS_BARCODE", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Save_TS_BARCODE", ex.ToString());
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Save_TS_BARCODE", e.Message);
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
return _ret;
|
|
|
|
}
|
|
|
|
public static void Get_TS_BARCODE_Small_List(TS_BARCODE_SMALL p_entity, Action<ResultObject<IQueryable<TS_BARCODE_SMALL>>> p_action)
|
|
|
|
{
|
|
|
|
ResultObject<IQueryable<TS_BARCODE_SMALL>> _ret = new ResultObject<IQueryable<TS_BARCODE_SMALL>>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
IQueryable<TS_BARCODE_SMALL> q = db.TS_BARCODE_SMALL;
|
|
|
|
if (p_entity.UIDList != null && p_entity.UIDList.Count > 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p_entity.UIDList.Contains(p.UID));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.BarCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BarCode.Contains(p_entity.BarCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.FullBarCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.FullBarCode.Contains(p_entity.FullBarCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendPartCode))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendPartCode.Contains(p_entity.VendPartCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Batch))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Batch.Contains(p_entity.Batch));
|
|
|
|
}
|
|
|
|
if (p_entity.ManageType != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.ManageType == p_entity.ManageType);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.SerialNum))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.SerialNum.Contains(p_entity.SerialNum));
|
|
|
|
}
|
|
|
|
if (p_entity.Qty != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Qty == p_entity.Qty);
|
|
|
|
}
|
|
|
|
if (p_entity.BarCodeType != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BarCodeType == p_entity.BarCodeType);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.BillNum))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.BillNum.Contains(p_entity.BillNum));
|
|
|
|
}
|
|
|
|
if (p_entity.PoBillLine != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PoBillLine == p_entity.PoBillLine);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendId))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendId.Contains(p_entity.VendId));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.VendBatch))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.VendBatch.Contains(p_entity.VendBatch));
|
|
|
|
}
|
|
|
|
if (p_entity.SmallPackQty != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.SmallPackQty == p_entity.SmallPackQty);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.CreateOper))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.CreateOper.Contains(p_entity.CreateOper));
|
|
|
|
}
|
|
|
|
if (p_entity.State != 0)
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.State == p_entity.State);
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.Remark))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.Remark.Contains(p_entity.Remark));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PoUnit))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PoUnit.Contains(p_entity.PoUnit));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.LocUnit))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.LocUnit.Contains(p_entity.LocUnit));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(p_entity.PartName))
|
|
|
|
{
|
|
|
|
q = q.Where(p => p.PartName.Contains(p_entity.PartName));
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = q;
|
|
|
|
p_action(_ret);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_Small_List", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_Small_List", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_Small_List", ex.ToString());
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Get_TS_BARCODE_Small_List", e.Message);
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public ResultObject<bool> Del_TS_BARCODE(List<TS_BARCODE> p_entitys)
|
|
|
|
{
|
|
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
|
|
{
|
|
|
|
foreach (var itm in p_entitys)
|
|
|
|
{
|
|
|
|
db.TS_BARCODE.Remove(itm);
|
|
|
|
}
|
|
|
|
if (db.SaveChanges() != -1)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Succeed;
|
|
|
|
_ret.Result = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)//捕获实体验证异常
|
|
|
|
{
|
|
|
|
var sb = new StringBuilder();
|
|
|
|
|
|
|
|
foreach (var error in dbEx.EntityValidationErrors.ToList())
|
|
|
|
{
|
|
|
|
|
|
|
|
error.ValidationErrors.ToList().ForEach(i =>
|
|
|
|
{
|
|
|
|
sb.AppendFormat("表:{0},字段:{1},信息:{2}\r\n", error.Entry.Entity.GetType().Name, i.PropertyName, i.ErrorMessage);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(dbEx);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Del_TS_BARCODE", sb.ToString());
|
|
|
|
throw new ScpException(ResultCode.DbEntityValidationException, sb.ToString(), "字段验证失败" + sb.ToString());
|
|
|
|
}
|
|
|
|
catch (OptimisticConcurrencyException ex)//并发冲突异常
|
|
|
|
{
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Del_TS_BARCODE", ex.ToString());
|
|
|
|
throw new ScpException(ResultCode.Exception, "9999", ex.ToString());
|
|
|
|
}
|
|
|
|
catch (ScpException ex)
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(ex);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Del_TS_BARCODE", ex.ToString());
|
|
|
|
|
|
|
|
if (ex.InnerException != null && ex.InnerException.GetType() == typeof(UpdateException))
|
|
|
|
{
|
|
|
|
var inner = (UpdateException)ex.InnerException;
|
|
|
|
|
|
|
|
|
|
|
|
throw new ScpException(ResultCode.Exception, "0000", ex.ToString());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (ex.InnerException != null) throw ex.InnerException;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
_ret.State = ReturnStatus.Failed;
|
|
|
|
_ret.Result = false;
|
|
|
|
_ret.ErrorList.Add(e);
|
|
|
|
LogHelper.Writlog(LogHelper.LogType.Error, typeof(SCP_TS_BARCODE_CONTROLLER), "Del_TS_BARCODE", e.Message); throw e;
|
|
|
|
}
|
|
|
|
return _ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|