Basf_EProject/EProject/BLL/EditorManage/KeyQuantityService.cs

90 lines
3.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.UI.WebControls;
using System.Windows.Forms;
namespace BLL
{
/// <summary>
/// Key Quantity
/// </summary>
public class KeyQuantityService
{
/// <summary>
/// 根据主键获取Key Quantity
/// </summary>
/// <param name="keyQuantityId"></param>
/// <returns></returns>
public static Model.Editor_KeyQuantity GetKeyQuantityById(string keyQuantityId)
{
return Funs.DB.Editor_KeyQuantity.FirstOrDefault(e => e.KeyQuantityId == keyQuantityId);
}
public static decimal? GetSumPlanMHRsByKeyId(string eprojectId, string identifier, string descipline)
{
decimal? sum = 0;
sum = (from x in Funs.DB.Editor_KeyQuantity where x.EProjectId == eprojectId && x.Identifier == identifier && x.Descipline == descipline select x.PlanMHRs).Sum();
return sum;
}
/// <summary>
/// 添加Key Quantity
/// </summary>
/// <param name="keyQuantity"></param>
public static void AddKeyQuantity(Model.Editor_KeyQuantity keyQuantity)
{
Model.Editor_KeyQuantity newKeyQuantity = new Model.Editor_KeyQuantity();
newKeyQuantity.KeyQuantityId = keyQuantity.KeyQuantityId;
newKeyQuantity.EProjectId = keyQuantity.EProjectId;
newKeyQuantity.KeyId = keyQuantity.KeyId;
newKeyQuantity.InputQuantity = keyQuantity.InputQuantity;
newKeyQuantity.PlanMHRs = keyQuantity.PlanMHRs;
newKeyQuantity.Identifier = keyQuantity.Identifier;
newKeyQuantity.Descipline = keyQuantity.Descipline;
newKeyQuantity.QuantityDesctiption = keyQuantity.QuantityDesctiption;
newKeyQuantity.PlanMHRsUnit = keyQuantity.PlanMHRsUnit;
newKeyQuantity.Type = keyQuantity.Type;
Funs.DB.Editor_KeyQuantity.InsertOnSubmit(newKeyQuantity);
Funs.DB.SubmitChanges();
}
/// <summary>
/// 修改key Quantity
/// </summary>
/// <param name="keyQuantity"></param>
public static void UpdateKeyQuantity(Model.Editor_KeyQuantity keyQuantity)
{
Model.Editor_KeyQuantity newKeyQuantity = Funs.DB.Editor_KeyQuantity.FirstOrDefault(e => e.KeyQuantityId == keyQuantity.KeyQuantityId);
if (newKeyQuantity != null)
{
newKeyQuantity.KeyId = keyQuantity.KeyId;
newKeyQuantity.InputQuantity = keyQuantity.InputQuantity;
newKeyQuantity.PlanMHRs = keyQuantity.PlanMHRs;
newKeyQuantity.Identifier = keyQuantity.Identifier;
newKeyQuantity.Descipline = keyQuantity.Descipline;
newKeyQuantity.QuantityDesctiption = keyQuantity.QuantityDesctiption;
newKeyQuantity.PlanMHRsUnit = keyQuantity.PlanMHRsUnit;
newKeyQuantity.Type = keyQuantity.Type;
Funs.DB.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除Key Quantity
/// </summary>
/// <param name="keyQuantityId"></param>
public static void DeleteKeyQuantityById(string keyQuantityId)
{
Model.Editor_KeyQuantity keyQuantity = Funs.DB.Editor_KeyQuantity.FirstOrDefault(e => e.KeyQuantityId == keyQuantityId);
if (keyQuantity != null)
{
Funs.DB.Editor_KeyQuantity.DeleteOnSubmit(keyQuantity);
Funs.DB.SubmitChanges();
}
}
}
}