125 lines
5.0 KiB
C#
125 lines
5.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BLL
|
|
{
|
|
public class CostControlService
|
|
{
|
|
/// <summary>
|
|
/// 根据费控项Id获取费控项信息
|
|
/// </summary>
|
|
/// <param name="unitProjectId">费控项Id</param>
|
|
/// <returns></returns>
|
|
public static Model.WBS_CostControl GetCostControlByCostControlId(string costControlId)
|
|
{
|
|
return Funs.DB.WBS_CostControl.FirstOrDefault(e => e.CostControlId.ToString() == costControlId);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据费控项编号集合获取费控项信息
|
|
/// </summary>
|
|
/// <param name="costControlCodes">费控项编号集合</param>
|
|
/// <returns></returns>
|
|
public static List<Model.WBS_CostControl> GetCostControlsByCostControlCodes(List<string> costControlCodes, string wbsSetId)
|
|
{
|
|
return (from x in Funs.DB.WBS_CostControl where costControlCodes.Contains(x.CostControlCode) && x.WbsSetId == wbsSetId select x).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据费控项编号集合获取费控项信息
|
|
/// </summary>
|
|
/// <param name="costControlCodes">费控项编号集合</param>
|
|
/// <returns></returns>
|
|
public static List<Model.WBS_CostControl> GetCostControlsByWbsSetId(string wbsSetId)
|
|
{
|
|
return (from x in Funs.DB.WBS_CostControl where x.WbsSetId == wbsSetId select x).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据费控项编号集合获取勾选的费控项信息
|
|
/// </summary>
|
|
/// <param name="costControlCodes">费控项编号集合</param>
|
|
/// <returns></returns>
|
|
public static List<Model.WBS_CostControl> GetSelectedCostControlsByWbsSetId(string wbsSetId)
|
|
{
|
|
return (from x in Funs.DB.WBS_CostControl where x.WbsSetId == wbsSetId && x.IsSelected == true orderby x.CostControlCode, x.CostControlName select x).ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加费控项
|
|
/// </summary>
|
|
/// <param name="user">费控项</param>
|
|
public static void AddCostControl(Model.WBS_CostControl costControl)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.WBS_CostControl newUP = new Model.WBS_CostControl();
|
|
newUP.CostControlId = SQLHelper.GetNewID();
|
|
newUP.ProjectId = costControl.ProjectId;
|
|
newUP.WbsSetId = costControl.WbsSetId;
|
|
newUP.CostControlCode = costControl.CostControlCode;
|
|
newUP.CostControlName = costControl.CostControlName;
|
|
newUP.Unit = costControl.Unit;
|
|
newUP.IsSelected = costControl.IsSelected;
|
|
newUP.TotalNum = costControl.TotalNum;
|
|
newUP.RealPrice = costControl.RealPrice;
|
|
|
|
db.WBS_CostControl.InsertOnSubmit(newUP);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 修改费控项信息
|
|
/// </summary>
|
|
/// <param name="user">费控项信息</param>
|
|
public static void UpdateCostControl(Model.WBS_CostControl costControl)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.WBS_CostControl newUP = db.WBS_CostControl.First(e => e.CostControlId == costControl.CostControlId);
|
|
|
|
newUP.CostControlCode = costControl.CostControlCode;
|
|
newUP.CostControlName = costControl.CostControlName;
|
|
newUP.Unit = costControl.Unit;
|
|
newUP.TotalNum = costControl.TotalNum;
|
|
newUP.IsSelected = costControl.IsSelected;
|
|
newUP.RealPrice = costControl.RealPrice;
|
|
newUP.PlanPrice = costControl.PlanPrice;
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据Id删除费控项信息
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
public static void DeleteCostControl(string costControlId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
Model.WBS_CostControl CnP = db.WBS_CostControl.First(e => e.CostControlId.ToString() == costControlId);
|
|
db.WBS_CostControl.DeleteOnSubmit(CnP);
|
|
db.SubmitChanges();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 根据Id删除费控项信息
|
|
/// </summary>
|
|
/// <param name="userId"></param>
|
|
public static void DeleteCostControlByWbsSetId(string wbsSetId)
|
|
{
|
|
Model.SGGLDB db = Funs.DB;
|
|
var costControls = from x in db.WBS_CostControl where x.WbsSetId == wbsSetId select x;
|
|
if (costControls.Count() > 0)
|
|
{
|
|
foreach (var costControl in costControls)
|
|
{
|
|
BLL.CostControlDetailHistoryService.DeleteCostControlDetailHistoryByCostControlId(costControl.CostControlId);
|
|
BLL.CostControlDetailService.DeleteCostControlDetailByCostControlId(costControl.CostControlId);
|
|
}
|
|
db.WBS_CostControl.DeleteAllOnSubmit(costControls);
|
|
db.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
}
|