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.

195 lines
7.2 KiB

1 year ago
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_BK
{
public static void Get_TED_BK_DET_List(TED_BK_DET p_entity, Action<ResultObject<IQueryable<TED_BK_DET>>> p_action)
{
ResultObject<IQueryable<TED_BK_DET>> _ret = new ResultObject<IQueryable<TED_BK_DET>>();
try
{
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
{
IQueryable<TED_BK_DET> q = db.TED_BK_DET;
if (!string.IsNullOrEmpty(p_entity.BackFlushBillNum))
{
q = q.Where(p => p.BackFlushBillNum.Contains(p_entity.BackFlushBillNum));
}
if (!string.IsNullOrEmpty(p_entity.PartCode))
{
q = q.Where(p => p.PartCode.Contains(p_entity.PartCode));
}
if (p_entity.Operation != 0)
{
q = q.Where(p => p.Operation == p_entity.Operation);
}
if (!string.IsNullOrEmpty(p_entity.Line))
{
q = q.Where(p => p.Line.Contains(p_entity.Line));
}
if (!string.IsNullOrEmpty(p_entity.Lot))
{
q = q.Where(p => p.Lot.Contains(p_entity.Lot));
}
if (p_entity.Quantity != 0)
{
q = q.Where(p => p.Quantity == p_entity.Quantity);
}
if (!string.IsNullOrEmpty(p_entity.Location))
{
q = q.Where(p => p.Location.Contains(p_entity.Location));
}
if (!string.IsNullOrEmpty(p_entity.Um))
{
q = q.Where(p => p.Um.Contains(p_entity.Um));
}
if (!string.IsNullOrEmpty(p_entity.BKType))
{
q = q.Where(p => p.BKType.Contains(p_entity.BKType));
}
if (!string.IsNullOrEmpty(p_entity.Remarks))
{
q = q.Where(p => p.Remarks.Contains(p_entity.Remarks));
}
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 (!string.IsNullOrEmpty(p_entity.Site))
{
q = q.Where(p => p.Site.Contains(p_entity.Site));
}
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(TED_BK_DET), "Get_TED_BK_DET_List", e.Message);
throw e;
}
}
public static ResultObject<bool> Save_TED_BK_DET(List<TED_BK_DET> p_entitys)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
{
foreach (var itm in p_entitys)
{
db.TED_BK_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(TED_BK_DET), "Save_TED_BK_DET", e.Message);
_ret.Result = false;
_ret.ErrorList.Add(e);
throw e;
}
return _ret;
}
public ResultObject<bool> Del_TED_BK_DET(List<TED_BK_DET> p_entitys)
{
ResultObject<bool> _ret = new ResultObject<bool>();
try
{
using (var db = EntitiesFactory.CreateExchangeCenterInstance())
{
foreach (var itm in p_entitys)
{
db.TED_BK_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(TED_BK_DET), "Del_TED_BK_DET", e.Message); throw e;
}
return _ret;
}
}
}