CNCEC_SUBQHSE_WUHUAN/SGGL/BLL/TestRun/DriverGoods/GoodsBuyItemService.cs

69 lines
2.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
/// <summary>
/// 请购单明细
/// </summary>
public static class GoodsBuyItemService
{
public static Model.SGGLDB db = Funs.DB;
/// <summary>
/// 根据主键获取请购单明细
/// </summary>
/// <param name="GoodsBuyItemId"></param>
/// <returns></returns>
public static Model.DriverGoods_GoodsBuyItem GetGoodsBuyItemById(string GoodsBuyItemId)
{
return Funs.DB.DriverGoods_GoodsBuyItem.FirstOrDefault(e => e.GoodsBuyItemId == GoodsBuyItemId);
}
/// <summary>
/// 根据周报Id获取请购单明细
/// </summary>
/// <param name="GoodsBuyId"></param>
/// <returns></returns>
public static List<Model.DriverGoods_GoodsBuyItem> GetGoodsBuyItemByGoodsBuyId(string GoodsBuyId)
{
return (from x in Funs.DB.DriverGoods_GoodsBuyItem where x.GoodsBuyId == GoodsBuyId select x).ToList();
}
/// <summary>
/// 添加请购单明细
/// </summary>
/// <param name="GoodsBuyItem"></param>
public static void AddGoodsBuyItem(Model.DriverGoods_GoodsBuyItem GoodsBuyItem)
{
Model.SGGLDB db = Funs.DB;
Model.DriverGoods_GoodsBuyItem newGoodsBuyItem = new Model.DriverGoods_GoodsBuyItem();
newGoodsBuyItem.GoodsBuyItemId = GoodsBuyItem.GoodsBuyItemId;
newGoodsBuyItem.GoodsBuyId = GoodsBuyItem.GoodsBuyId;
newGoodsBuyItem.GoodsModelId = GoodsBuyItem.GoodsModelId;
newGoodsBuyItem.Quantity = GoodsBuyItem.Quantity;
newGoodsBuyItem.Num = GoodsBuyItem.Num;
newGoodsBuyItem.RequiredTime = GoodsBuyItem.RequiredTime;
db.DriverGoods_GoodsBuyItem.InsertOnSubmit(newGoodsBuyItem);
db.SubmitChanges();
}
/// <summary>
/// 根据周报Id删除所有相关明细信息
/// </summary>
/// <param name="GoodsBuyId"></param>
public static void DeleteGoodsBuyItemByGoodsBuyId(string GoodsBuyId)
{
Model.SGGLDB db = Funs.DB;
var q = (from x in db.DriverGoods_GoodsBuyItem where x.GoodsBuyId == GoodsBuyId select x).ToList();
if (q.Count() > 0)
{
db.DriverGoods_GoodsBuyItem.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
}
}