180 lines
7.0 KiB
C#
180 lines
7.0 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
|
|||
|
namespace BLL
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 焊材回收表
|
|||
|
/// </summary>
|
|||
|
public static class RecycleMatService
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// 根据主键获取焊材回收
|
|||
|
/// </summary>
|
|||
|
/// <param name="recycleMatId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Model.Weld_RecycleMat GetRecycleMatById(string recycleMatId)
|
|||
|
{
|
|||
|
return Funs.DB.Weld_RecycleMat.FirstOrDefault(e => e.RecycleMatId == recycleMatId);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据材料领用ID获取焊材回收信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="usingMatId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Model.Weld_RecycleMat GetRecycleMatByUsingMatId(string usingMatId)
|
|||
|
{
|
|||
|
return Funs.DB.Weld_RecycleMat.FirstOrDefault(e => e.UsingMatId == usingMatId);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 添加焊材回收
|
|||
|
/// </summary>
|
|||
|
/// <param name="recycleMat"></param>
|
|||
|
public static void AddRecycleMat(Model.Weld_RecycleMat recycleMat)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Weld_RecycleMat newRecycleMat = new Model.Weld_RecycleMat();
|
|||
|
newRecycleMat.RecycleMatId = recycleMat.RecycleMatId;
|
|||
|
newRecycleMat.ProjectId = recycleMat.ProjectId;
|
|||
|
newRecycleMat.UsePosition = recycleMat.UsePosition;
|
|||
|
newRecycleMat.WeldId = recycleMat.WeldId;
|
|||
|
newRecycleMat.UsingPlanId = recycleMat.UsingPlanId;
|
|||
|
newRecycleMat.RecycleAmount = recycleMat.RecycleAmount;
|
|||
|
newRecycleMat.ReturnMatTop = recycleMat.ReturnMatTop;
|
|||
|
newRecycleMat.RecycleMan = recycleMat.RecycleMan;
|
|||
|
newRecycleMat.RecycleDate = recycleMat.RecycleDate;
|
|||
|
newRecycleMat.StockMan = recycleMat.StockMan;
|
|||
|
newRecycleMat.Warrantybook = recycleMat.Warrantybook;
|
|||
|
newRecycleMat.UsingMatId = recycleMat.UsingMatId;
|
|||
|
newRecycleMat.Number = recycleMat.Number;
|
|||
|
newRecycleMat.IsStoreManConfirm = recycleMat.IsStoreManConfirm;
|
|||
|
newRecycleMat.IsWelderConfirm = recycleMat.IsWelderConfirm;
|
|||
|
db.Weld_RecycleMat.InsertOnSubmit(newRecycleMat);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 修改焊材回收
|
|||
|
/// </summary>
|
|||
|
/// <param name="recycleMat"></param>
|
|||
|
public static void UpdateRecycleMat(Model.Weld_RecycleMat recycleMat)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Weld_RecycleMat newRecycleMat = db.Weld_RecycleMat.FirstOrDefault(e => e.RecycleMatId == recycleMat.RecycleMatId);
|
|||
|
if (newRecycleMat != null)
|
|||
|
{
|
|||
|
newRecycleMat.ProjectId = recycleMat.ProjectId;
|
|||
|
newRecycleMat.UsePosition = recycleMat.UsePosition;
|
|||
|
newRecycleMat.WeldId = recycleMat.WeldId;
|
|||
|
newRecycleMat.UsingPlanId = recycleMat.UsingPlanId;
|
|||
|
newRecycleMat.RecycleAmount = recycleMat.RecycleAmount;
|
|||
|
newRecycleMat.ReturnMatTop = recycleMat.ReturnMatTop;
|
|||
|
newRecycleMat.RecycleMan = recycleMat.RecycleMan;
|
|||
|
newRecycleMat.RecycleDate = recycleMat.RecycleDate;
|
|||
|
newRecycleMat.StockMan = recycleMat.StockMan;
|
|||
|
newRecycleMat.Warrantybook = recycleMat.Warrantybook;
|
|||
|
newRecycleMat.Number = recycleMat.Number;
|
|||
|
newRecycleMat.UsingMatId = recycleMat.UsingMatId;
|
|||
|
newRecycleMat.IsStoreManConfirm = recycleMat.IsStoreManConfirm;
|
|||
|
newRecycleMat.IsWelderConfirm = recycleMat.IsWelderConfirm;
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据主键删除焊材回收
|
|||
|
/// </summary>
|
|||
|
/// <param name="recycleMatId"></param>
|
|||
|
public static void DeleteRecycleMatById(string recycleMatId)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Weld_RecycleMat recycleMat = db.Weld_RecycleMat.FirstOrDefault(e => e.RecycleMatId == recycleMatId);
|
|||
|
if (recycleMat != null)
|
|||
|
{
|
|||
|
db.Weld_RecycleMat.DeleteOnSubmit(recycleMat);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据项目ID、退回人、计划ID删除焊材回收
|
|||
|
/// </summary>
|
|||
|
/// <param name="projectId"></param>
|
|||
|
/// <param name="welderId"></param>
|
|||
|
/// <param name="usingPlanId"></param>
|
|||
|
public static void DeleteRecycleMat(string projectId, string welderId, string usingPlanId)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Weld_RecycleMat recycleMat = db.Weld_RecycleMat.FirstOrDefault(e => e.ProjectId == projectId && e.RecycleMan == welderId && e.UsingPlanId == usingPlanId);
|
|||
|
if (recycleMat != null)
|
|||
|
{
|
|||
|
db.Weld_RecycleMat.DeleteOnSubmit(recycleMat);
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 根据焊材Id获取回收信息
|
|||
|
/// </summary>
|
|||
|
/// <param name="weldId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static Model.Weld_RecycleMat GetRecycleMatByWeldId(string weldId)
|
|||
|
{
|
|||
|
return Funs.DB.Weld_RecycleMat.FirstOrDefault(e => e.WeldId == weldId);
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 焊工确认
|
|||
|
/// </summary>
|
|||
|
/// <param name="usingMatId"></param>
|
|||
|
/// <param name="isConfirm"></param>
|
|||
|
public static void WelderConfirm(string recycleMatId, bool isConfirm)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Weld_RecycleMat newRecycleMat = db.Weld_RecycleMat.FirstOrDefault(e => e.RecycleMatId == recycleMatId);
|
|||
|
if (newRecycleMat != null)
|
|||
|
{
|
|||
|
newRecycleMat.IsWelderConfirm = isConfirm;
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 保管员确认
|
|||
|
/// </summary>
|
|||
|
/// <param name="usingMatId"></param>
|
|||
|
/// <param name="isConfirm"></param>
|
|||
|
public static void StoreManConfirm(string recycleMatId, bool isConfirm)
|
|||
|
{
|
|||
|
Model.SGGLDB db = Funs.DB;
|
|||
|
Model.Weld_RecycleMat newRecycleMat = db.Weld_RecycleMat.FirstOrDefault(e => e.RecycleMatId == recycleMatId);
|
|||
|
if (newRecycleMat != null)
|
|||
|
{
|
|||
|
newRecycleMat.IsStoreManConfirm = isConfirm;
|
|||
|
db.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 退还焊材的和
|
|||
|
/// </summary>
|
|||
|
/// <param name="usingPlanId"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static decimal GetRecycleMatSum(string usingPlanId)
|
|||
|
{
|
|||
|
decimal recycleMatSum = 0;
|
|||
|
var recycleList = from x in Funs.DB.Weld_RecycleMat where x.UsingPlanId == usingPlanId select x;
|
|||
|
if (recycleList.Count() > 0)
|
|||
|
{
|
|||
|
recycleMatSum = recycleList.Sum(e => e.RecycleAmount.HasValue ? e.RecycleAmount.Value : 0);
|
|||
|
}
|
|||
|
return recycleMatSum;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|