ZHJA_HJGL/HJGL_ZH/BLL/WeldMat/Recycle/RecycleMatTopService.cs

152 lines
6.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
public static class RecycleMatTopService
{
/// <summary>
/// 根据主键获取焊条头回收信息
/// </summary>
/// <param name="recycleMatId"></param>
/// <returns></returns>
public static Model.Weld_RecycleMatTop GetRecycleMatTopById(string recycleMatTopId)
{
return Funs.DB.Weld_RecycleMatTop.FirstOrDefault(e => e.RecycleMatTopId == recycleMatTopId);
}
/// <summary>
/// 根据材料领用ID获取焊条头回收信息
/// </summary>
/// <param name="usingMatId"></param>
/// <returns></returns>
public static Model.Weld_RecycleMatTop GetRecycleMatTopByUsingMatId(string usingMatId)
{
return Funs.DB.Weld_RecycleMatTop.FirstOrDefault(e => e.UsingMatId == usingMatId);
}
/// <summary>
/// 添加焊条头回收
/// </summary>
/// <param name="recycleMatTop"></param>
public static void AddRecycleMatTop(Model.Weld_RecycleMatTop recycleMatTop)
{
Model.SGGLDB db = Funs.DB;
Model.Weld_RecycleMatTop newRecycleMatTop = new Model.Weld_RecycleMatTop();
newRecycleMatTop.RecycleMatTopId = recycleMatTop.RecycleMatTopId;
newRecycleMatTop.ProjectId = recycleMatTop.ProjectId;
newRecycleMatTop.UsePosition = recycleMatTop.UsePosition;
newRecycleMatTop.WeldId = recycleMatTop.WeldId;
newRecycleMatTop.UsingPlanId = recycleMatTop.UsingPlanId;
newRecycleMatTop.RecycleAmount = recycleMatTop.RecycleAmount;
newRecycleMatTop.RecycleMan = recycleMatTop.RecycleMan;
newRecycleMatTop.RecycleDate = recycleMatTop.RecycleDate;
newRecycleMatTop.StockMan = recycleMatTop.StockMan;
newRecycleMatTop.Moneys = recycleMatTop.Moneys;
newRecycleMatTop.UsingMatId = recycleMatTop.UsingMatId;
db.Weld_RecycleMatTop.InsertOnSubmit(newRecycleMatTop);
db.SubmitChanges();
}
/// <summary>
/// 修改焊条头回收
/// </summary>
/// <param name="recycleMatTop"></param>
public static void UpdateRecycleMatTop(Model.Weld_RecycleMatTop recycleMatTop)
{
Model.SGGLDB db = Funs.DB;
Model.Weld_RecycleMatTop newRecycleMatTop = db.Weld_RecycleMatTop.FirstOrDefault(e => e.RecycleMatTopId == recycleMatTop.RecycleMatTopId);
if (newRecycleMatTop != null)
{
newRecycleMatTop.ProjectId = recycleMatTop.ProjectId;
newRecycleMatTop.UsePosition = recycleMatTop.UsePosition;
newRecycleMatTop.WeldId = recycleMatTop.WeldId;
newRecycleMatTop.UsingPlanId = recycleMatTop.UsingPlanId;
newRecycleMatTop.RecycleAmount = recycleMatTop.RecycleAmount;
newRecycleMatTop.RecycleMan = recycleMatTop.RecycleMan;
newRecycleMatTop.RecycleDate = recycleMatTop.RecycleDate;
newRecycleMatTop.StockMan = recycleMatTop.StockMan;
newRecycleMatTop.Moneys = recycleMatTop.Moneys;
db.SubmitChanges();
}
}
/// <summary>
/// 根据主键删除焊材回收
/// </summary>
/// <param name="recycleMatId"></param>
public static void DeleteRecycleMatTopById(string recycleMatTopId)
{
Model.SGGLDB db = Funs.DB;
Model.Weld_RecycleMatTop recycleMatTop = db.Weld_RecycleMatTop.FirstOrDefault(e => e.RecycleMatTopId == recycleMatTopId);
if (recycleMatTop != null)
{
db.Weld_RecycleMatTop.DeleteOnSubmit(recycleMatTop);
db.SubmitChanges();
}
}
/// <summary>
/// 焊工确认
/// </summary>
/// <param name="usingMatId"></param>
/// <param name="isConfirm"></param>
public static void WelderConfirm(string recycleMatTopId, bool isConfirm)
{
Model.SGGLDB db = Funs.DB;
Model.Weld_RecycleMatTop newRecycleMatTop = db.Weld_RecycleMatTop.FirstOrDefault(e => e.RecycleMatTopId == recycleMatTopId);
if (newRecycleMatTop != null)
{
newRecycleMatTop.IsWelderConfirm = isConfirm;
db.SubmitChanges();
}
}
/// <summary>
/// 保管员确认
/// </summary>
/// <param name="usingMatId"></param>
/// <param name="isConfirm"></param>
public static void StoreManConfirm(string recycleMatTopId, bool isConfirm)
{
Model.SGGLDB db = Funs.DB;
Model.Weld_RecycleMatTop newRecycleMatTop = db.Weld_RecycleMatTop.FirstOrDefault(e => e.RecycleMatTopId == recycleMatTopId);
if (newRecycleMatTop != null)
{
newRecycleMatTop.IsStoreManConfirm = isConfirm;
db.SubmitChanges();
}
}
/// <summary>
/// 退还焊条头的和
/// </summary>
/// <param name="usingPlanId"></param>
/// <returns></returns>
public static int GetRecycleMatTopSum(string usingPlanId)
{
int recycleMatTopSum = 0;
var recycleList = from x in Funs.DB.Weld_RecycleMatTop where x.UsingPlanId == usingPlanId select x;
if (recycleList.Count() > 0)
{
recycleMatTopSum = recycleList.Sum(e => e.RecycleAmount.HasValue ? e.RecycleAmount.Value : 0);
}
return recycleMatTopSum;
}
/// <summary>
/// 根据保管员获取退还焊条头数量
/// </summary>
/// <param name="StockMan"></param>
/// <returns></returns>
public static int GetRecycleMatTopByStockMan(string StockMan)
{
return (from x in Funs.DB.Weld_RecycleMatTop where x.StockMan == StockMan select x).Count();
}
}
}