73 lines
2.6 KiB
C#
73 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace BLL
|
|
{
|
|
public class ExpenseDetailService
|
|
{
|
|
|
|
public static List<Model.CostGoods_ExpenseDetail> GetExpenseDetailsByExpenseId(string expenseId)
|
|
{
|
|
return (from x in Funs.DB.CostGoods_ExpenseDetail where x.ExpenseId == expenseId select x).ToList();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 增加费用明细信息
|
|
/// </summary>
|
|
/// <param name="pauseNotice">费用明细实体</param>
|
|
public static void AddCostDetail(string expenseId )
|
|
{
|
|
DeleteCostDetailByExpenseId(expenseId);
|
|
Model.SGGLDB db = Funs.DB;
|
|
var getItems = from x in db.Base_CostTypeItem
|
|
join y in db.Base_CostType on x.CostTypeId equals y.CostTypeId
|
|
select new
|
|
{
|
|
SupCostTypeId = y.CostTypeId,
|
|
SupCostTypeName = y.CostTypeName,
|
|
SupSortIndex = y.CostTypeCode,
|
|
CostType = x.CostTypeId,
|
|
CostTypeName=x.CostTypeItemName,
|
|
SortIndex=x.SortIndex,
|
|
CostMoney=0,
|
|
};
|
|
foreach (var item in getItems)
|
|
{
|
|
Model.CostGoods_ExpenseDetail newExpenseDetail = new Model.CostGoods_ExpenseDetail
|
|
{
|
|
ExpenseDetailId = SQLHelper.GetNewID(),
|
|
ExpenseId = expenseId,
|
|
SupCostTypeId=item.SupCostTypeId,
|
|
SupCostTypeName=item.SupCostTypeName,
|
|
SupSortIndex=item.SupSortIndex,
|
|
|
|
CostType = item.CostType,
|
|
CostTypeName = item.CostTypeName,
|
|
SortIndex=item.SortIndex,
|
|
CostMoney = item.CostMoney,
|
|
};
|
|
db.CostGoods_ExpenseDetail.InsertOnSubmit(newExpenseDetail);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 根据费用编号删除对应的费用明细信息
|
|
/// </summary>
|
|
/// <param name="expenseId">编号</param>
|
|
public static void DeleteCostDetailByExpenseId(string expenseId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var q = from x in db.CostGoods_ExpenseDetail where x.ExpenseId == expenseId select x;
|
|
if (q.Count() > 0)
|
|
{
|
|
db.CostGoods_ExpenseDetail.DeleteAllOnSubmit(q);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|