using System.Collections.Generic; using System.Linq; namespace BLL { /// /// 费用管理明细 /// public static class CostManageItemService { /// /// 根据主键删除费用管理明细 /// /// /// public static Model.CostGoods_CostManageItem GetCostManageItemById(string costManageItemId) { return Funs.DB.CostGoods_CostManageItem.FirstOrDefault(e => e.CostManageItemId == costManageItemId); } /// /// 根据费用管理主键获取所有相关明细信息 /// /// /// public static List GetCostManageItemByCostManageId(string costManageId) { return (from x in Funs.DB.CostGoods_CostManageItem where x.CostManageId == costManageId select x).ToList(); } /// /// 添加费用管理明细 /// /// public static void AddCostManageItem(Model.CostGoods_CostManageItem costManageItem) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { Model.CostGoods_CostManageItem newCostManageItem = new Model.CostGoods_CostManageItem { CostManageItemId = costManageItem.CostManageItemId, CostManageId = costManageItem.CostManageId, InvestCostProject = costManageItem.InvestCostProject, PriceMoney = costManageItem.PriceMoney, SupCostTypeId = costManageItem.SupCostTypeId, SupCostTypeName = costManageItem.SupCostTypeName, SupSortIndex = costManageItem.SupSortIndex, CostTypeId = costManageItem.CostTypeId, CostTypeName = costManageItem.CostTypeName, SortIndex = costManageItem.SortIndex, }; db.CostGoods_CostManageItem.InsertOnSubmit(newCostManageItem); db.SubmitChanges(); CostManageService.UpdateSumMoney(newCostManageItem.CostManageId); } } /// /// 修改费用管理明细 /// /// public static void UpdateCostManageItem(Model.CostGoods_CostManageItem costManageItem) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { Model.CostGoods_CostManageItem newCostManageItem = db.CostGoods_CostManageItem.FirstOrDefault(e => e.CostManageItemId == costManageItem.CostManageItemId); if (newCostManageItem != null) { newCostManageItem.InvestCostProject = costManageItem.InvestCostProject; newCostManageItem.PriceMoney = costManageItem.PriceMoney; newCostManageItem.SupCostTypeId = costManageItem.SupCostTypeId; newCostManageItem.SupCostTypeName = costManageItem.SupCostTypeName; newCostManageItem.SupSortIndex = costManageItem.SupSortIndex; newCostManageItem.CostTypeId = costManageItem.CostTypeId; newCostManageItem.CostTypeName = costManageItem.CostTypeName; newCostManageItem.SortIndex = costManageItem.SortIndex; db.SubmitChanges(); CostManageService.UpdateSumMoney(newCostManageItem.CostManageId); } } } /// /// 根据费用管理主键删除所有相关明细信息 /// /// public static void DeleteCostManageItemByCostManageId(string costManageId) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { var q = (from x in db.CostGoods_CostManageItem where x.CostManageId == costManageId select x).ToList(); if (q != null) { db.CostGoods_CostManageItem.DeleteAllOnSubmit(q); db.SubmitChanges(); } CostManageService.UpdateSumMoney(costManageId); } } /// /// 根据主键删除费用管理信息 /// /// public static void DeleteCostManageItemById(string costManageItemId) { using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) { Model.CostGoods_CostManageItem costManageItem = db.CostGoods_CostManageItem.FirstOrDefault(e => e.CostManageItemId == costManageItemId); if (costManageItem != null) { db.CostGoods_CostManageItem.DeleteOnSubmit(costManageItem); db.SubmitChanges(); CostManageService.UpdateSumMoney(costManageItem.CostManageId); } } } } }