feat(clgl): 新增入库材料条形码打印
生成入库单时同步生成入库材料条形码明细,并在入库单管理中支持整单和单条条形码打印。
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class TwInputdetailBarCodeService
|
||||
{
|
||||
public static int Count
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public static IEnumerable GetListData(Tw_InputDetailBarCodeOutput table, Grid grid1)
|
||||
{
|
||||
List<Tw_InputDetailBarCodeOutput> list = GetListData(table);
|
||||
Count = list.Count;
|
||||
if (Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return list.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize);
|
||||
}
|
||||
|
||||
public static List<Tw_InputDetailBarCodeOutput> GetListData(Tw_InputDetailBarCodeOutput table)
|
||||
{
|
||||
var q = from x in Funs.DB.Tw_InputDetailBarCode
|
||||
join master in Funs.DB.Tw_InputMaster on x.InputMasterId equals master.Id into masters
|
||||
from master in masters.DefaultIfEmpty()
|
||||
join mat in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals mat.MaterialCode into mats
|
||||
from mat in mats.DefaultIfEmpty()
|
||||
where
|
||||
(string.IsNullOrEmpty(table.Id) || x.Id.Contains(table.Id)) &&
|
||||
(string.IsNullOrEmpty(table.InputDetailId) || x.InputDetailId.Contains(table.InputDetailId)) &&
|
||||
(string.IsNullOrEmpty(table.InputMasterId) || x.InputMasterId.Contains(table.InputMasterId)) &&
|
||||
(string.IsNullOrEmpty(table.MaterialCode) || x.MaterialCode.Contains(table.MaterialCode))
|
||||
orderby master.CusBillCode, x.MaterialCode, x.Id
|
||||
select new Tw_InputDetailBarCodeOutput
|
||||
{
|
||||
Id = x.Id,
|
||||
InputDetailId = x.InputDetailId,
|
||||
InputMasterId = x.InputMasterId,
|
||||
CusBillCode = master.CusBillCode,
|
||||
MaterialCode = x.MaterialCode,
|
||||
MaterialName = mat.MaterialName,
|
||||
MaterialDef = mat.MaterialDef,
|
||||
BarCode = x.BarCode
|
||||
};
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
public static void AddByInputDetail(Tw_InputMaster inputMaster, Tw_InputDetail inputDetail)
|
||||
{
|
||||
if (inputMaster == null || inputDetail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (IsExist(inputDetail.Id))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string id = SQLHelper.GetNewID();
|
||||
Tw_InputDetailBarCode table = new Tw_InputDetailBarCode
|
||||
{
|
||||
Id = id,
|
||||
InputDetailId = inputDetail.Id,
|
||||
InputMasterId = inputMaster.Id,
|
||||
MaterialCode = inputDetail.MaterialCode,
|
||||
BarCode = BuildBarCode(inputMaster, inputDetail, id)
|
||||
};
|
||||
Funs.DB.Tw_InputDetailBarCode.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
public static void DeleteByInputMasterId(string inputMasterId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputMasterId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var list = Funs.DB.Tw_InputDetailBarCode.Where(x => x.InputMasterId == inputMasterId).ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
Funs.DB.Tw_InputDetailBarCode.DeleteAllOnSubmit(list);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteByInputDetailId(string inputDetailId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(inputDetailId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var list = Funs.DB.Tw_InputDetailBarCode.Where(x => x.InputDetailId == inputDetailId).ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
Funs.DB.Tw_InputDetailBarCode.DeleteAllOnSubmit(list);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
private static bool IsExist(string inputDetailId)
|
||||
{
|
||||
return Funs.DB.Tw_InputDetailBarCode.Any(x => x.InputDetailId == inputDetailId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 入库材料条形码生成规则,后续调整条形码内容只需修改此方法。
|
||||
/// </summary>
|
||||
public static string BuildBarCode(Tw_InputMaster inputMaster, Tw_InputDetail inputDetail, string barCodeDetailId)
|
||||
{
|
||||
return "IB" + barCodeDetailId.Replace("-", string.Empty).ToUpperInvariant();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user