You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Mesnac.Action.ChemicalWeighing.FreeDb;
|
|
|
|
namespace Mesnac.Action.ChemicalWeighing.AutoControl.DB
|
|
{
|
|
public class DeviceMaterrialService
|
|
{
|
|
|
|
|
|
public static void Save(List<DeviceMaterrial> materrials)
|
|
{
|
|
var deviceMaterrial = materrials.First();
|
|
|
|
FreeSqlUnit.Instance.Delete<DeviceMaterrial>()
|
|
.Where(x => x.Type == deviceMaterrial.Type && x.DeviceId == deviceMaterrial.DeviceId)
|
|
.ExecuteDeleted();
|
|
|
|
foreach (var materrial in materrials)
|
|
{
|
|
materrial.Code = StockMaterrialDbHelp.GetCodeById(materrial.MaterrialId);
|
|
}
|
|
|
|
FreeSqlUnit.Instance.Insert(materrials).ExecuteAffrows();
|
|
}
|
|
|
|
|
|
public static List<DeviceMaterrial> GetByTypeId(int type, int deviceId)
|
|
{
|
|
return FreeSqlUnit.Instance.Select<DeviceMaterrial>()
|
|
.Where(x => x.Type == type && x.DeviceId == deviceId)
|
|
.ToList();
|
|
}
|
|
|
|
|
|
|
|
}
|
|
} |