You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

377 lines
16 KiB

using CK.SCP.Models;
using CK.SCP.Models.ExchangeCenterTables;
using CK.SCP.Utils;
using System;
using System.Collections.Generic;
using System.Data.Entity.Migrations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CK.SCP.Controller
{
public class UN_EC_CONTROLLER_PART_DET
{
public static void Get_TES_PART_DET_List(TES_PART_DET p_entity, Action<ResultObject<IQueryable<TES_PART_DET>>> p_action)
{
ResultObject<IQueryable<TES_PART_DET>> _ret = new ResultObject<IQueryable<TES_PART_DET>>();
try
{
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
{
IQueryable<TES_PART_DET> q = db.TES_PART_DET;
if (!string.IsNullOrEmpty(p_entity.PartCode))
{
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
}
if (!string.IsNullOrEmpty(p_entity.Site))
{
q = q.Where(p => p.Site.Contains(p_entity.Site));
}
if (!string.IsNullOrEmpty(p_entity.AbcClass))
{
q = q.Where(p => p.AbcClass.Contains(p_entity.AbcClass));
}
if (!string.IsNullOrEmpty(p_entity.LotControl))
{
q = q.Where(p => p.LotControl.Contains(p_entity.LotControl));
}
if (!string.IsNullOrEmpty(p_entity.Location))
{
q = q.Where(p => p.Location.Contains(p_entity.Location));
}
if (!string.IsNullOrEmpty(p_entity.LocationType))
{
q = q.Where(p => p.LocationType.Contains(p_entity.LocationType));
}
if (p_entity.AutoMaticLotNumbers != false)
{
q = q.Where(p => p.AutoMaticLotNumbers == p_entity.AutoMaticLotNumbers);
}
if (p_entity.AverageInterval != 0)
{
q = q.Where(p => p.AverageInterval == p_entity.AverageInterval);
}
if (p_entity.CycleCountInterval != 0)
{
q = q.Where(p => p.CycleCountInterval == p_entity.CycleCountInterval);
}
if (p_entity.ShelfLife != 0)
{
q = q.Where(p => p.ShelfLife == p_entity.ShelfLife);
}
if (p_entity.KeyPart != false)
{
q = q.Where(p => p.KeyPart == p_entity.KeyPart);
}
if (!string.IsNullOrEmpty(p_entity.PoReceiptStatus))
{
q = q.Where(p => p.PoReceiptStatus.Contains(p_entity.PoReceiptStatus));
}
if (p_entity.RctPoActive != false)
{
q = q.Where(p => p.RctPoActive == p_entity.RctPoActive);
}
if (!string.IsNullOrEmpty(p_entity.WoReceiptStatus))
{
q = q.Where(p => p.WoReceiptStatus.Contains(p_entity.WoReceiptStatus));
}
if (p_entity.RctWoActive != false)
{
q = q.Where(p => p.RctWoActive == p_entity.RctWoActive);
}
if (!string.IsNullOrEmpty(p_entity.MemoOrderType))
{
q = q.Where(p => p.MemoOrderType.Contains(p_entity.MemoOrderType));
}
if (p_entity.MasterSchedule != false)
{
q = q.Where(p => p.MasterSchedule == p_entity.MasterSchedule);
}
if (p_entity.PlanOrders != false)
{
q = q.Where(p => p.PlanOrders == p_entity.PlanOrders);
}
if (p_entity.TimeFence != 0)
{
q = q.Where(p => p.TimeFence == p_entity.TimeFence);
}
if (!string.IsNullOrEmpty(p_entity.OrderPolicy))
{
q = q.Where(p => p.OrderPolicy.Contains(p_entity.OrderPolicy));
}
if (p_entity.OrderQuantity != 0)
{
q = q.Where(p => p.OrderQuantity == p_entity.OrderQuantity);
}
if (p_entity.OrderPeriod != 0)
{
q = q.Where(p => p.OrderPeriod == p_entity.OrderPeriod);
}
if (p_entity.SafetyStock != 0)
{
q = q.Where(p => p.SafetyStock == p_entity.SafetyStock);
}
if (p_entity.SafetyTime != 0)
{
q = q.Where(p => p.SafetyTime == p_entity.SafetyTime);
}
if (p_entity.ReorderPoint != 0)
{
q = q.Where(p => p.ReorderPoint == p_entity.ReorderPoint);
}
if (!string.IsNullOrEmpty(p_entity.PlanningRev))
{
q = q.Where(p => p.PlanningRev.Contains(p_entity.PlanningRev));
}
if (p_entity.IssuePolicy != false)
{
q = q.Where(p => p.IssuePolicy == p_entity.IssuePolicy);
}
if (!string.IsNullOrEmpty(p_entity.BuyerPlanner))
{
q = q.Where(p => p.BuyerPlanner.Contains(p_entity.BuyerPlanner));
}
if (!string.IsNullOrEmpty(p_entity.Supplier))
{
q = q.Where(p => p.Supplier.Contains(p_entity.Supplier));
}
if (!string.IsNullOrEmpty(p_entity.PoSite))
{
q = q.Where(p => p.PoSite.Contains(p_entity.PoSite));
}
if (!string.IsNullOrEmpty(p_entity.PurMfg))
{
q = q.Where(p => p.PurMfg.Contains(p_entity.PurMfg));
}
if (!string.IsNullOrEmpty(p_entity.ConfigurationType))
{
q = q.Where(p => p.ConfigurationType.Contains(p_entity.ConfigurationType));
}
if (!string.IsNullOrEmpty(p_entity.InspectionLocation))
{
q = q.Where(p => p.InspectionLocation.Contains(p_entity.InspectionLocation));
}
if (p_entity.InspectionRequired != false)
{
q = q.Where(p => p.InspectionRequired == p_entity.InspectionRequired);
}
if (p_entity.InspectionLeadTime != 0)
{
q = q.Where(p => p.InspectionLeadTime == p_entity.InspectionLeadTime);
}
if (p_entity.CumulativeLeadTime != 0)
{
q = q.Where(p => p.CumulativeLeadTime == p_entity.CumulativeLeadTime);
}
if (p_entity.ManufacturingLedaTime != 0)
{
q = q.Where(p => p.ManufacturingLedaTime == p_entity.ManufacturingLedaTime);
}
if (p_entity.PurchaseLeadTime != 0)
{
q = q.Where(p => p.PurchaseLeadTime == p_entity.PurchaseLeadTime);
}
if (!string.IsNullOrEmpty(p_entity.AtpEnforcementLevel))
{
q = q.Where(p => p.AtpEnforcementLevel.Contains(p_entity.AtpEnforcementLevel));
}
if (p_entity.FamilyATP != false)
{
q = q.Where(p => p.FamilyATP == p_entity.FamilyATP);
}
if (p_entity.AtpHorizon != 0)
{
q = q.Where(p => p.AtpHorizon == p_entity.AtpHorizon);
}
if (!string.IsNullOrEmpty(p_entity.RunSeq1))
{
q = q.Where(p => p.RunSeq1.Contains(p_entity.RunSeq1));
}
if (!string.IsNullOrEmpty(p_entity.RunSeq2))
{
q = q.Where(p => p.RunSeq2.Contains(p_entity.RunSeq2));
}
if (p_entity.Phantom != false)
{
q = q.Where(p => p.Phantom == p_entity.Phantom);
}
if (p_entity.MinimumOrder != 0)
{
q = q.Where(p => p.MinimumOrder == p_entity.MinimumOrder);
}
if (p_entity.MaximumOrder != 0)
{
q = q.Where(p => p.MaximumOrder == p_entity.MaximumOrder);
}
if (p_entity.OrderMultiple != 0)
{
q = q.Where(p => p.OrderMultiple == p_entity.OrderMultiple);
}
if (p_entity.OperationBasedYield != false)
{
q = q.Where(p => p.OperationBasedYield == p_entity.OperationBasedYield);
}
if (p_entity.YieldPercent != 0)
{
q = q.Where(p => p.YieldPercent == p_entity.YieldPercent);
}
if (!string.IsNullOrEmpty(p_entity.RunTime))
{
q = q.Where(p => p.RunTime.Contains(p_entity.RunTime));
}
if (p_entity.SetupTime != 0)
{
q = q.Where(p => p.SetupTime == p_entity.SetupTime);
}
if (!string.IsNullOrEmpty(p_entity.EmtType))
{
q = q.Where(p => p.EmtType.Contains(p_entity.EmtType));
}
if (p_entity.AutomaticEmtProcessing != false)
{
q = q.Where(p => p.AutomaticEmtProcessing == p_entity.AutomaticEmtProcessing);
}
if (!string.IsNullOrEmpty(p_entity.NetWorkCode))
{
q = q.Where(p => p.NetWorkCode.Contains(p_entity.NetWorkCode));
}
if (!string.IsNullOrEmpty(p_entity.RoutingCode))
{
q = q.Where(p => p.RoutingCode.Contains(p_entity.RoutingCode));
}
if (!string.IsNullOrEmpty(p_entity.BomFormulaCode))
{
q = q.Where(p => p.BomFormulaCode.Contains(p_entity.BomFormulaCode));
}
if (!string.IsNullOrEmpty(p_entity.ReplenishmentMethod))
{
q = q.Where(p => p.ReplenishmentMethod.Contains(p_entity.ReplenishmentMethod));
}
if (p_entity.UID != 0)
{
q = q.Where(p => p.UID == p_entity.UID);
}
if (!string.IsNullOrEmpty(p_entity.CreateUser))
{
q = q.Where(p => p.CreateUser.Contains(p_entity.CreateUser));
}
if (!string.IsNullOrEmpty(p_entity.Remark))
{
q = q.Where(p => p.Remark.Contains(p_entity.Remark));
}
if (!string.IsNullOrEmpty(p_entity.CommandType))
{
q = q.Where(p => p.CommandType.Contains(p_entity.CommandType));
}
if (!string.IsNullOrEmpty(p_entity.Domain))
{
q = q.Where(p => p.Domain.Contains(p_entity.Domain));
}
if (p_entity.GUID != Guid.Empty)
{
q = q.Where(p => p.GUID == p_entity.GUID);
}
if (p_entity.TaskID != Guid.Empty)
{
q = q.Where(p => p.TaskID == p_entity.TaskID);
}
if (p_entity.DataID != Guid.Empty)
{
q = q.Where(p => p.DataID == p_entity.DataID);
}
if (p_entity.CreateTime != DateTime.MinValue)
{
q = q.Where(p => p.CreateTime.Year == p_entity.CreateTime.Year && p.CreateTime.Day == p_entity.CreateTime.Day && p.CreateTime.Month == p_entity.CreateTime.Month);
}
_ret.State = ReturnStatus.Succeed;
_ret.Result = q;
p_action(_ret);
}
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
_ret.ErrorList.Add(e);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TES_PART_DET), "Get_TES_PART_DET_List", e.Message);
throw e;
}
}
public static ResultObject<bool> Save_TES_PART_DET(List<TES_PART_DET> p_entitys)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
{
foreach (var itm in p_entitys)
{
db.TES_PART_DET.AddOrUpdate(itm);
}
if (db.SaveChanges() != -1)
{
_ret.State = ReturnStatus.Succeed;
_ret.Result = true;
}
else
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
}
}
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TES_PART_DET), "Save_TES_PART_DET", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
}
return _ret;
}
public ResultObject<bool> Del_TES_PART_DET(List<TES_PART_DET> p_entitys)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
{
foreach (var itm in p_entitys)
{
db.TES_PART_DET.Remove(itm);
}
if (db.SaveChanges() != -1)
{
_ret.State = ReturnStatus.Succeed;
_ret.Result = true;
}
else
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
}
}
}
catch (Exception e)
{
_ret.State = ReturnStatus.Failed;
_ret.Result = false;
_ret.ErrorList.Add(e);
LogHelper.Writlog(LogHelper.LogType.Error, typeof(TES_PART_DET), "Del_TES_PART_DET", e.Message); throw e;
}
return _ret;
}
}
}