123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.TeachingMaterial;
- using EMIS.ViewModel.TeachingMaterial;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.DataLogic.Repositories;
- using System.Linq.Expressions;
- using Bowin.Common.Linq;
- using EMIS.DataLogic.Common.ProcurementPlan;
- using EMIS.CommonLogic.SystemServices;
- using System.Text.RegularExpressions;
- namespace EMIS.CommonLogic.TeachingMaterial
- {
- public class StockInServices : BaseServices, IStockInServices
- {
- public StockInDAL StockInDAL { get; set; }
- public PurchasingStatisticsDAL PurchasingStatisticsDAL { get; set; }
- public Lazy<ITeachersOrderServices> TeachersOrderServices { get; set; }
- public Lazy<IParameterServices> ParameterServices { get; set; }
- public Lazy<ISerialNumberServices> SerialNumberServices { get; set; }
- #region --0.0 定义--
- public TeachersOrderRepository TeachersOrderRepository { get; set; }
- public StockInRepository StockInRepository { get; set; }
- public StockInDetailRepository StockInDetailRepository { get; set; }
- public SchoolyearRepository SchoolyearRepository { get; set; }
- public UserRepository UserRepository { get; set; }
- public TeachingMaterialPoolRepository TeachingMaterialPoolRepository { get; set; }
- public CoursematerialRepository CoursematerialRepository { get; set; }
- public PublishRepository PublishRepository { get; set; }
- public CollegeRepository CollegeRepository { get; set; }
- public DictionaryItemRepository DictionaryItemRepository { get; set; }
- public TeachingMateriaInventoryRepository TeachingMateriaInventoryRepository { get; set; }
-
- #endregion
- #region 1.0 查询入库信息
- public Bowin.Common.Linq.Entity.IGridResultSet<StockInView> GetStockInViewGrid(ViewModel.ConfiguretView configuretView,
- Guid? schoolyearID, Guid? supplierID, DateTime? stockInDJTimeStart, DateTime? stockInDJTimeEnd, int? isLate, IList<int?> stockInTypeIDList,
- int pageIndex, int pageSize)
- {
- if (stockInDJTimeStart == null)
- {
- stockInDJTimeStart = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd"));
- }
- var query = StockInDAL.GetStockInGridView(x => stockInTypeIDList.Contains(x.StockInType));
- if (isLate.HasValue&& isLate >= 0)
- {
- query = query.Where(x => x.RecordStatus == isLate);
- }
- if (schoolyearID.HasValue)
- query = query.Where(x => x.SchoolyearID == schoolyearID);
- if (supplierID.HasValue)
- query = query.Where(x => x.SupplierID == supplierID);
- if (stockInDJTimeStart.HasValue)
- query = query.Where(x => x.StockInDJTime >= stockInDJTimeStart);
- if (stockInDJTimeEnd.HasValue)
- {
- DateTime newStockOutTimeEnd = stockInDJTimeEnd.Value.AddDays(1);//取起止日期一天、
- query = query.Where(x => x.StockInDJTime <= newStockOutTimeEnd);
- }
- // query = GetQueryByDataRangeByCollege(query);//区分院系数据
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.StockInDJTime).ToGridResultSet<StockInView>(pageIndex, pageSize);
- return query.OrderBy(x => x.SchoolyearName).OrderBy(x => x.StockInDocumentNo).OrderByDescending(x => x.StockInDJTime).ToGridResultSet<StockInView>(pageIndex, pageSize);
- }
- #endregion
- #region 2.0 查询教材信息
- public IGridResultSet<TeachingMaterialPoolView> GetStockInByTeachingMaterialPoolViewGrid(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? teachingMaterialPoolID, Guid? teachingMaterialCodeID, decimal? discount, int pageIndex, int pageSize)
- {
- var endStatusID = TeachersOrderServices.Value.GetCorrectEndStatus();
- Expression<Func<ET_TeachersOrder, bool>> teacherOrderExp = (x => x.ApprovalStatus == endStatusID);
- Expression<Func<ET_StudentsOrder, bool>> studentOrderExp = (x => true);
- if (schoolyearID.HasValue)
- {
- teacherOrderExp = teacherOrderExp.And(x => x.SchoolyearID == schoolyearID);
- studentOrderExp = studentOrderExp.And(x => x.EM_SpecialtyPlan.SchoolyearID == schoolyearID);
- }
- if (teachingMaterialPoolID.HasValue)
- {
- teacherOrderExp = teacherOrderExp.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- studentOrderExp = studentOrderExp.And(x => x.TeachingMaterialPoolID == teachingMaterialPoolID);
- }
- if (teachingMaterialCodeID.HasValue)
- {
- teacherOrderExp = teacherOrderExp.And(x => x.TeachingMaterialPoolID == teachingMaterialCodeID);
- studentOrderExp = studentOrderExp.And(x => x.TeachingMaterialPoolID == teachingMaterialCodeID);
- }
- var query = StockInDAL.GetTeachingMaterial(x => x.IsLate == false, 1);
- if (discount.HasValue)
- {
- query = StockInDAL.GetTeachingMaterial(x => x.IsLate == false, discount);//获取不过期数据
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<TeachingMaterialPoolView>(pageIndex, pageSize);
- return query.OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToGridResultSet<TeachingMaterialPoolView>(pageIndex, pageSize);
- }
- #endregion
- #region 3.0 保存
- public void Save(StockInView stockInView, IList<TeachingMaterialPoolView> tmList, Guid? userId, string type)
- {
- if (this.StockInRepository.GetList(x => x.StockInDocumentNo == stockInView.StockInDocumentNo
- && x.StockInID != stockInView.StockInID).Count() > 0)
- {
- throw new Exception("入库单号已经存在,请重新输入!");
- }
- int RecordStatusType = (int)CF_GeneralPurpose.IsNo;
- if (type == "Submit")//如果是Save 那么状态默认为0、 如果是Submit 那么状态默认1
- {
- RecordStatusType = (int)CF_GeneralPurpose.IsYes;
- }
- ET_StockIn stockInEntity = StockInRepository.GetSingle(x => x.StockInID == stockInView.StockInID);
- if (stockInEntity != null)
- {
- stockInEntity.Desc = stockInView.Desc;
- stockInEntity.SchoolyearID = stockInView.SchoolyearID;
- stockInEntity.StockInTime = (DateTime)stockInView.StockInDJTime;
- stockInEntity.StockInDocumentNo = stockInView.StockInDocumentNo;
- stockInEntity.SupplierID = (Guid)stockInView.SupplierID;
- stockInEntity.StockInNumber = stockInView.StockInNumber;
- stockInEntity.RecordStatus = RecordStatusType;
- StockInRepository.UnitOfWork.Update(stockInEntity);
- // StockInRepository.UnitOfWork.Commit();
- //删除明细数据、重新插入
- StockInDetailRepository.UnitOfWork.Delete<ET_StockInDetail>(x => x.StockInID == stockInView.StockInID);
- List<ET_StockInDetail> stockInDetailList = new List<ET_StockInDetail>();
- foreach (var item in tmList)
- {
- ET_StockInDetail stockInDetail = new ET_StockInDetail()
- {
- CreateTime = DateTime.Now,
- CreateUserID = userId,
- Desc = stockInView.Desc,
- Discount = item.Discount,
- LibraryID = null,//stockInView.LibraryID,,
- ModifyTime = DateTime.Now,
- ModifyUserID = userId,
- DiscountPrice = item.Discount * item.Price,//折合价
- Quantity = item.OrderQty,
- RecordStatus = RecordStatusType,
- StockInDetailID = Guid.NewGuid(),
- StockInID = stockInView.StockInID,
- TeachingMaterialPoolID = item.TeachingMaterialPoolID
- };
- UnitOfWork.Add(stockInDetail);
- }
- }
- else
- {
- ET_StockIn stockIn = new ET_StockIn()
- {
- StockInID = Guid.NewGuid(),
- Desc = stockInView.Desc,
- StockInType = stockInView.StockInType,
- CreateTime = DateTime.Now,
- CreateUserID = userId,
- SchoolyearID = stockInView.SchoolyearID,
- ModifyTime = DateTime.Now,
- ModifyUserID = userId,
- HandlerUserID = userId,
- OrdersNo = stockInView.OrdersNo,
- RecordStatus = RecordStatusType,
- StockInSumMoney = stockInView.StockInSumMoney,
- StockInTime = (DateTime)stockInView.StockInDJTime,
- StockInNumber = stockInView.StockInNumber,
- StockInDocumentNo = stockInView.StockInDocumentNo,
- SupplierID = (Guid)stockInView.SupplierID
- };
- UnitOfWork.Add(stockIn);
- List<ET_StockInDetail> stockInDetailList = new List<ET_StockInDetail>();
- foreach (var item in tmList)
- {
- ET_StockInDetail stockInDetail = new ET_StockInDetail()
- {
- CreateTime = DateTime.Now,
- CreateUserID = userId,
- Desc = stockInView.Desc,
- Discount = item.Discount,
- LibraryID = null,//stockInView.LibraryID,
- ModifyTime = DateTime.Now,
- ModifyUserID = userId,
- DiscountPrice = item.Discount * item.Price,//折合价
- Quantity = item.OrderQty,
- RecordStatus = RecordStatusType,
- StockInDetailID = Guid.NewGuid(),
- StockInID = stockIn.StockInID,
- TeachingMaterialPoolID = item.TeachingMaterialPoolID
- };
- UnitOfWork.Add(stockInDetail);
- }
- }
- UnitOfWork.Commit();
- }
- #endregion
- #region 4.0 Excel 查询
- public IList<StockInView> GetStockInViewList(ViewModel.ConfiguretView configuretView, Guid? schoolyearID, Guid? supplierID, DateTime? stockInDJTimeStart, DateTime? stockInDJTimeEnd, int? isLate, IList<int?> stockInTypeIDList)
- {
- DateTime newStockOutTimeEnd = stockInDJTimeEnd.Value.AddDays(1);//取起止日期一天、
- var query = StockInDAL.GetStockInGridView(x => stockInTypeIDList.Contains(x.StockInType));
- if (isLate.HasValue && isLate > 0)
- {
- query = query.Where(x => x.RecordStatus == isLate);
- }
- if (schoolyearID.HasValue)
- query = query.Where(x => x.SchoolyearID == schoolyearID);
- if (supplierID.HasValue)
- query = query.Where(x => x.SupplierID == supplierID);
- if (stockInDJTimeStart.HasValue)
- query = query.Where(x => x.StockInDJTime >= stockInDJTimeStart);
- if (stockInDJTimeEnd.HasValue)
- query = query.Where(x => x.StockInDJTime <= newStockOutTimeEnd);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderBy(x => x.StockInDJTime).ToList();
- return query.OrderBy(x => x.StockInDJTime).ToList();
- }
- #endregion
- #region 5.0 删除
- /// <summary>
- /// 删除入库信息
- /// </summary>
- /// <param name="stockInIDs"></param>
- public void Delete(List<Guid> stockInIDs)
- {
- try
- {
- var stockInList = StockInRepository.GetList(x => stockInIDs.Contains(x.StockInID)).ToList();
- foreach (var stockIn in stockInList)
- {
- if (stockIn.RecordStatus == (int)SYS_STATUS.USABLE)
- {
- throw new Exception("选择的信息已入库,无法删除。");
- }
- }
- if (stockInIDs.Count > 0)
- {
- //删除入库数据、及该单号下挂钩的明细数据
- StockInDetailRepository.UnitOfWork.Delete<ET_StockInDetail>(x => stockInIDs.Contains(x.StockInID));
- StockInRepository.UnitOfWork.Delete<ET_StockIn>(x => stockInIDs.Contains(x.StockInID));
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- #region 6.0 获取编辑信息
- /// <summary>
- /// 获取编辑数据
- /// </summary>
- /// <param name="stockInID"></param>
- /// <returns></returns>
- public StockInView GetSingleStockIn(Guid stockInID)
- {
- return StockInDAL.GetSingleStockIn(stockInID);
- }
- #endregion
- #region 7.0 获取要入库的教材信息
- public IList<TeachingMaterialPoolView> GetStockInByTMViewList(Guid stockInID)
- {
- return StockInDAL.GetTeachingMaterialView(stockInID).OrderBy(x => x.TeachingMaterialCode.Length).ThenBy(x => x.TeachingMaterialCode).ToList();
- }
- #endregion
- #region 8.0 废弃的提交
- public void Submit(List<Guid> stockInIDs, Guid userId)
- {
- try
- {
- if (stockInIDs.Count > 0)
- {
- var stockInList = StockInRepository.GetList(x => stockInIDs.Contains(x.StockInID), (x => x.ET_StockInDetail)).ToList();
- foreach (var stockInEnity in stockInList)
- {
- if (stockInEnity.RecordStatus == (int)CF_GeneralPurpose.IsYes)
- {
- throw new Exception("选择的信息已提交,无法重复提交。");
- }
- }
- foreach (var stockInEnity in stockInList)
- {
- stockInEnity.RecordStatus = (int)CF_GeneralPurpose.IsYes;
- StockInRepository.UnitOfWork.Update(stockInEnity);
- StockInRepository.UnitOfWork.Commit();
- IList<ET_StockInDetail> stockInDetailList = stockInEnity.ET_StockInDetail.ToList();
- BalanceInventory(stockInDetailList, userId);//提交平衡库存
- }
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- #endregion
- #region 9.0 检验入库单据编号是否存在
- /// <summary>
- /// 检验入库单据编号是否存在
- /// </summary>
- /// <param name="stockInDocumentNo"></param>
- /// <returns></returns>
- public bool IsExistStockInDocumentNo(string stockInDocumentNo)
- {
- return StockInDAL.IsExistStockInDocumentNo(stockInDocumentNo);
- }
- #endregion
- #region 11.0 平衡教材库存数量(适用与出库、入库)
- public void BalanceInventory(IList<ET_StockInDetail> stockInDetailList, Guid userId)
- {
- //1.0 提取当前库存量、
- foreach (var stockInDetail in stockInDetailList)
- {
- ET_TeachingMateriaInventory teachingMateriaInventoryEntity = TeachingMateriaInventoryRepository.GetSingle(x => x.TeachingMaterialPoolID == stockInDetail.TeachingMaterialPoolID && x.Discount == stockInDetail.DiscountPrice);
- if (teachingMateriaInventoryEntity != null)
- {
- //2.0 当前库存量+入库数量 当前库存量-出库数量
- teachingMateriaInventoryEntity.PresentInventory = teachingMateriaInventoryEntity.PresentInventory + stockInDetail.Quantity;
- teachingMateriaInventoryEntity.ModifyTime = DateTime.Now;
- TeachingMateriaInventoryRepository.UnitOfWork.Update(teachingMateriaInventoryEntity);//更新库存数量
- }
- else
- {
- ET_TeachingMateriaInventory teachingMateriaInventoryEnt = new ET_TeachingMateriaInventory
- {
- PresentInventory = stockInDetail.Quantity,
- TeachingMateriaInventoryID = Guid.NewGuid(),
- CreateTime = DateTime.Now,
- CreateUserID = userId,
- Discount = stockInDetail.Discount,
- DiscountPrice = stockInDetail.DiscountPrice,
- ModifyTime = DateTime.Now,
- ModifyUserID = userId,
- TeachingMaterialPoolID = (Guid)stockInDetail.TeachingMaterialPoolID
- };
- TeachingMateriaInventoryRepository.UnitOfWork.Add(teachingMateriaInventoryEnt);
- }
- }
- UnitOfWork.Commit();
- }
- #endregion
- #region 12.0 自动生成入库信息
- public void AutoNewStockIn(Guid? schoolyearID, Guid? userId)
- {
- var endStatusID = TeachersOrderServices.Value.GetCorrectEndStatus();
- Expression<Func<ET_TeachersOrder, bool>> exporder = (x => x.ApprovalStatus == endStatusID);
- Expression<Func<ET_StudentsOrder, bool>> stuExporder = (x => true);
- Expression<Func<CF_TeachingMaterialPool, bool>> poolexp = (x => true);
- if (schoolyearID.HasValue)
- {
- exporder = exporder.And(x => x.SchoolyearID == schoolyearID);
- stuExporder = stuExporder.And(x => x.EM_SpecialtyPlan.SchoolyearID == schoolyearID);
- }
- var Purchasingquery = PurchasingStatisticsDAL.GetPurchasingStatisticsGridView(exporder, stuExporder);
- List<PurchasingStatisticsView> purchasingList = Purchasingquery.ToList();//获取一个学期下所有采购信息
-
- var StockInquery = StockInDAL.GetStockInGridView(x => true);
- if (schoolyearID.HasValue)
- {
- StockInquery = StockInquery.Where(x => x.SchoolyearID == schoolyearID);
- }
- List<StockInView> stockInList = StockInquery.ToList();
- List<Guid> TeachingMaterialPoolIDList = new List<Guid>();
- List<Guid> stockinIDList = stockInList.Select(x => x.StockInID).ToList();
- var teachingMaterialPoolViewList = StockInDAL.GetDetailByIDList(stockinIDList).ToList();
- List<PurchasingStatisticsView> purchasingList1 = new List<PurchasingStatisticsView>();
- List<PurchasingStatisticsView> a = new List<PurchasingStatisticsView>();
- foreach (PurchasingStatisticsView purchasing in purchasingList)
- {
- //判断这个学期下是否已经有入库信息,有的就排除。
- if (stockInList != null)
- {
- foreach (StockInView stockIn in stockInList)
- {
- var teachingMaterialPoolView = teachingMaterialPoolViewList.Where(x => x.StockInID == stockIn.StockInID);
- foreach (var view in teachingMaterialPoolView)
- {
- if (view.TeachingMaterialPoolID == purchasing.TeachingMaterialPoolID)
- {
- TeachingMaterialPoolIDList.Add(purchasing.TeachingMaterialPoolID);//获取已有入库信息的教材ID
- }
- };
- };
- }
- };
- List<Guid> id = TeachingMaterialPoolIDList.Distinct().ToList<Guid>();
- List<TeachingMaterialPoolView> tmList = new List<TeachingMaterialPoolView>();
- var supplier = StockInDAL.SupplierDiscountSetRepository.GetList(x => x.IsDefault == true).FirstOrDefault();
- var query = StockInDAL.GetTeachersOrderByTeachingMaterial(x => x.IsLate == false, exporder, stuExporder);
- purchasingList1 = Purchasingquery.Where(x => id.All(y => y!=x.TeachingMaterialPoolID)).ToList();
- tmList = StockInDAL.GetTeachersOrderByTeachingMaterial(poolexp, exporder, stuExporder).Where(x => id.All(y => y != x.TeachingMaterialPoolID)).ToList();
- //foreach (var MateriaPoolID in id)
- //{
- // //purchasingList = null;
- // //PurchasingStatisticsView view = Purchasingquery.Where(x => x.TeachingMaterialPoolID != MateriaPoolID).FirstOrDefault();
- // //purchasingList1.Add(view);//排除掉已有的入库信息
- // poolexp = poolexp.And(x => x.TeachingMaterialPoolID == MateriaPoolID);
- // TeachingMaterialPoolView pool = StockInDAL.GetTeachersOrderByTeachingMaterial(poolexp, exporder, stuExporder).FirstOrDefault();//根据教材总库ID获取教材信息
- // tmList.Add(pool);
- //};
- string datestr = DateTime.Now.ToString("yyyyMMdd");
- var stockInNumber = this.GetStockInNo(CF_StockInType.PurchasingStockIn);
- var numStr = stockInNumber.Remove(0, stockInNumber.Length - 4);
- var num = int.Parse(numStr);
- var noStr = stockInNumber.Remove(stockInNumber.Length - 4);
- int count = 0;
- foreach (PurchasingStatisticsView pur in purchasingList1)
- {
- string stockInNumberstr = noStr + num.ToString("0000");
-
- ET_StockIn NewstockIn = new ET_StockIn()
- {
- StockInID = Guid.NewGuid(),
- Desc = "",//
- StockInType = (int)CF_StockInType.PurchasingStockIn,
- CreateTime = DateTime.Now,
- CreateUserID = userId,
- SchoolyearID = schoolyearID,
- ModifyTime = DateTime.Now,
- ModifyUserID = userId,
- HandlerUserID = userId,
- OrdersNo = null,//
- RecordStatus = 0,
- StockInSumMoney = Math.Round((decimal)(pur.Price * supplier.Discount * pur.CountNumber), 2),//
- StockInTime = DateTime.Now,//
- StockInNumber = datestr + num.ToString("0000"),//入库编号
- StockInDocumentNo = stockInNumberstr,//入库单据号
- SupplierID = supplier == null ? null : supplier.PublishID,
- };
- num += 1;
- count += 1;
- UnitOfWork.Add(NewstockIn);
- foreach (var item in tmList.Where(x => x.TeachingMaterialPoolID == pur.TeachingMaterialPoolID))
- {
- List<ET_StockInDetail> stockInDetailList = new List<ET_StockInDetail>();
- ET_StockInDetail stockInDetail = new ET_StockInDetail()
- {
- CreateTime = DateTime.Now,
- CreateUserID = userId,
- Desc = "",//
- Discount = supplier == null ? 1 : supplier.Discount,
- LibraryID = null,//stockInView.LibraryID,
- ModifyTime = DateTime.Now,
- ModifyUserID = userId,
- DiscountPrice = (supplier == null ? 1 : supplier.Discount) * pur.Price,//折合价
- Quantity = pur.CountNumber,
- RecordStatus = 0,
- StockInDetailID = Guid.NewGuid(),
- StockInID = NewstockIn.StockInID,
- TeachingMaterialPoolID = item.TeachingMaterialPoolID
- };
- UnitOfWork.Add(stockInDetail);
- };
- };
- string prefix = "";
- DateTime nowTime = DateTime.Now;
- prefix = ParameterServices.Value.GetParameterValue(CF_ParameterType.PurchaseStockInPrifix);
- var matchFormatterList = Regex.Matches(prefix, @"\{[\S]*\}");
- for (int i = 0; i < matchFormatterList.Count; i++)
- {
- var formatter = matchFormatterList[i].Value.TrimStart('{').TrimEnd('}');
- var dateString = nowTime.ToString(formatter);
- prefix = prefix.Replace(matchFormatterList[i].Value, dateString);
- }
- UnitOfWork.Commit();
- SerialNumberServices.Value.SkipSN(prefix, count - 1);
- }
- #endregion
- public string GetStockInNo(CF_StockInType stockInType)
- {
- string prefix = "";
- DateTime nowTime = DateTime.Now;
- switch (stockInType)
- {
- case CF_StockInType.PurchasingStockIn:
- prefix = ParameterServices.Value.GetParameterValue(CF_ParameterType.PurchaseStockInPrifix);
- break;
- case CF_StockInType.Return:
- prefix = ParameterServices.Value.GetParameterValue(CF_ParameterType.ReturnStockInPrifix);
- break;
- }
- var matchFormatterList = Regex.Matches(prefix, @"\{[\S]*\}");
- for (int i = 0; i < matchFormatterList.Count; i++)
- {
- var formatter = matchFormatterList[i].Value.TrimStart('{').TrimEnd('}');
- var dateString = nowTime.ToString(formatter);
- prefix = prefix.Replace(matchFormatterList[i].Value, dateString);
- }
- string stockOutNo = SerialNumberServices.Value.SetSN(prefix, 4);
- return stockOutNo;
- }
- }
- }
|