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 { /// /// Key Quantity /// public class KeyQuantityService { /// /// 根据主键获取Key Quantity /// /// /// 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; } /// /// 添加Key Quantity /// /// 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(); } /// /// 修改key Quantity /// /// 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(); } } /// /// 根据主键删除Key Quantity /// /// 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(); } } } }