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.
68 lines
2.2 KiB
68 lines
2.2 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using CK.SCP.Models;
|
|
using CK.SCP.Models.ScpEntity;
|
|
using CK.SCP.Utils;
|
|
|
|
namespace CK.SCP.Controller
|
|
{
|
|
public class SCP_TA_PART_CONTROLLER
|
|
{
|
|
public static List<TA_PART> Getlist()
|
|
{
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
{
|
|
return db.TA_PART.ToList();
|
|
}
|
|
}
|
|
public static List<TA_PART> GetlistByPartCode(TA_PART model)
|
|
{
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
{
|
|
return db.TA_PART.Where(p=>p.PartCode==model.PartCode).ToList();
|
|
}
|
|
}
|
|
public static ResultObject<bool> Save_TA_PART(List<TA_PART> p_entitys)
|
|
{
|
|
ResultObject<bool> _ret = new ResultObject<bool>();
|
|
try
|
|
{
|
|
using (ScpEntities db = EntitiesFactory.CreateScpInstance())
|
|
{
|
|
foreach (var itm in p_entitys)
|
|
{
|
|
var _entity=db.TA_PART.Where(p => p.PartCode == itm.PartCode && p.Site == p.Site).FirstOrDefault();
|
|
if (_entity != null)
|
|
{
|
|
_entity.Qlevel = itm.Qlevel;
|
|
_entity.Ischeck=itm.Ischeck;
|
|
_entity.ReceivePort = itm.ReceivePort;
|
|
}
|
|
}
|
|
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(TA_PART), "Save_TA_PART", e.Message);
|
|
_ret.Result = false;
|
|
_ret.ErrorList.Add(e);
|
|
throw e;
|
|
}
|
|
return _ret;
|
|
}
|
|
}
|
|
}
|
|
|