Exemplo n.º 1
0
 public async Task<bool> CheckQrCodeInV696(string qrCodeID)
 {
     var qrCodeMain = await _repoQRCodeMain.FindAll(x => x.Is_Scanned == "N" && x.QRCode_ID.Trim() == qrCodeID.Trim())
         .FirstOrDefaultAsync();
     if (qrCodeMain == null)
     {
         return false;
     }
     else
     {
         var packingModel = await _repoPackingList.FindAll(x => x.Receive_No.Trim() == qrCodeMain.Receive_No.Trim())
             .FirstOrDefaultAsync();
         if (packingModel == null)
         {
             return false;
         }
         else
         {
             if (packingModel.Supplier_ID.Trim() == "V696")
             {
                 return true;
             }
             else
             {
                 return false;
             }
         }
     }
 }
Exemplo n.º 2
0
        public async Task <List <Transfer_Form_Print_Dto> > GetInfoTransferFormPrintDetail(List <Transfer_Form_Generate_Dto> generateTransferForm)
        {
            List <Transfer_Form_Print_Dto> listTransferFormPrint = new List <Transfer_Form_Print_Dto>();
            var transationMain = _transactionMainRepo.FindAll();
            var packingList    = _packingListRepository.FindAll();
            var qrCodeMain     = _qRCodeMainRepository.FindAll();

            var data = generateTransferForm.GroupJoin(
                transationMain,
                x => x.Transac_No,
                y => y.Transac_No,
                (x, y) => new { GenerateTransferForm = x, TransationMain = y })
                       .SelectMany(
                x => x.TransationMain.DefaultIfEmpty(),
                (x, y) => new { GenerateTransferForm = x.GenerateTransferForm, TransationMain = y })
                       .GroupJoin(
                qrCodeMain,
                x => new { QRCode_ID = x.TransationMain.QRCode_ID, QRCode_Version = x.TransationMain.QRCode_Version },
                y => new { QRCode_ID = y.QRCode_ID, QRCode_Version = y.QRCode_Version },
                (x, y) => new { GenerateTransferFormTransactionMain = x, QrCodeMain = y })
                       .SelectMany(
                x => x.QrCodeMain.DefaultIfEmpty(),
                (x, y) => new { GenerateTransferFormTransactionMain = x.GenerateTransferFormTransactionMain, QrCodeMain = y })
                       .GroupJoin(
                packingList,
                x => x.QrCodeMain.Receive_No,
                y => y.Receive_No,
                (x, y) => new { GenerateTransferFormTransactionMainQrCodeMain = x, PackingList = y })
                       .SelectMany(
                x => x.PackingList.DefaultIfEmpty(),
                (x, y) => new Transfer_Form_Print_Dto
            {
                Rack_Location    = x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.TransationMain.Rack_Location,
                Collect_Trans_No = x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.GenerateTransferForm.Collect_Trans_No,
                MO_No            = x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.TransationMain.MO_No,
                MO_Seq           = x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.TransationMain.MO_Seq,
                Material_ID      = x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.TransationMain.Material_ID,
                Material_Name    = x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.TransationMain.Material_Name,
                T3_Supplier      = y.T3_Supplier,
                T3_Supplier_Name = y.T3_Supplier_Name,
                Supplier_ID      = y.Supplier_ID,
                Supplier_Name    = y.Supplier_Name,
                Article          = y.Article,
                Subcon_ID        = y.Subcon_ID,
                Subcon_Name      = y.Subcon_Name,
                Model_Name       = y.Model_Name,
                Model_No         = y.Model_No,
                Custmoer_Part    = x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.GenerateTransferForm.Custmoer_Part,
                Custmoer_Name    = x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.GenerateTransferForm.Custmoer_Name,
                Line_ASY         = _cacheRepository.GetLineASY(y.MO_No, y.MO_Seq, y.Material_ID, y.Purchase_No),
                Line_STF         = _materialViewRepository.GetLineSTF(y.MO_No, y.MO_Seq, y.Material_ID, y.Purchase_No),
                TransferFormQty  = GetTransferFormPrintQty(x.GenerateTransferFormTransactionMainQrCodeMain.GenerateTransferFormTransactionMain.GenerateTransferForm.Collect_Trans_No)
            }).ToList();

            return(await Task.FromResult(data));
        }
Exemplo n.º 3
0
        public async Task <PagedList <QRCodeMainViewModel> > Search(PaginationParams param, FilterQrCodeParam filterParam)
        {
            var pred_Packing_List = PredicateBuilder.New <WMSB_Packing_List>(true);

            if (filterParam.From_Date != null && filterParam.To_Date != null)
            {
                pred_Packing_List.And(x => x.Receive_Date >= Convert.ToDateTime(filterParam.From_Date) &&
                                      x.Receive_Date <= Convert.ToDateTime(filterParam.To_Date + " 23:59:59.997"));
            }
            if (!String.IsNullOrEmpty(filterParam.MO_No))
            {
                pred_Packing_List.And(x => x.MO_No.Trim() == filterParam.MO_No.Trim());
            }
            var listPackingList = _repoPacking.FindAll(pred_Packing_List);
            var listQrCodeMain  = _repoQrcode.FindAll(x => x.Is_Scanned.Trim() == "N");
            var listQrCodeModel = (from x in listQrCodeMain
                                   join y in listPackingList
                                   on x.Receive_No.Trim() equals y.Receive_No.Trim()
                                   select new QRCodeMainViewModel()
            {
                QRCode_ID = x.QRCode_ID,
                MO_No = y.MO_No,
                QRCode_Version = x.QRCode_Version,
                Receive_No = x.Receive_No,
                Receive_Date = y.Receive_Date,
                Supplier_ID = y.Supplier_ID,
                Supplier_Name = y.Supplier_Name,
                T3_Supplier = y.T3_Supplier,
                T3_Supplier_Name = y.T3_Supplier_Name,
                Subcon_ID = y.Subcon_ID,
                Subcon_Name = y.Subcon_Name,
                Model_Name = y.Model_Name,
                Model_No = y.Model_No,
                Article = y.Article,
                MO_Seq = y.MO_Seq,
                Material_ID = y.Material_ID,
                Material_Name = y.Material_Name
            }).Distinct().OrderByDescending(x => x.Receive_Date);

            return(await PagedList <QRCodeMainViewModel> .CreateAsync(listQrCodeModel, param.PageNumber, param.PageSize, false));
        }
Exemplo n.º 4
0
        public async Task <List <QRCodeMainViewModel> > GetListQrCodeMainView(List <QrCodeIDVersion> data)
        {
            var listQrCode     = data.Select(x => x.QRCode_ID).ToList();
            var listBatch      = data.Select(x => x.MO_Seq).ToList();
            var packingList    = _repoPackingList.FindAll();
            var listMono       = data.Select(x => x.MO_No.Trim()).ToList();
            var listQrCodeMain = _repoQrcode
                                 .FindAll(x => listQrCode.Contains(x.QRCode_ID));
            var viewMaterialPurchase = _repoMaterialView.FindAll(x => listBatch.Contains(x.MO_Seq) &&
                                                                 listMono.Contains(x.Plan_No.Trim()));
            var listQrCodeModel = await(from x in listQrCodeMain join y in packingList
                                        on x.Receive_No.Trim() equals y.Receive_No.Trim()
                                        join z in viewMaterialPurchase on
                                        new { Purchase_No = y.Purchase_No.Trim(), PlanNo = y.MO_No.Trim() } equals new
                                        { Purchase_No = z.Purchase_No.Trim(), PlanNo = z.Plan_No.Trim() }
                                        select new QRCodeMainViewModel()
            {
                QRCode_ID        = x.QRCode_ID,
                MO_No            = y.MO_No,
                Receive_No       = x.Receive_No,
                Receive_Date     = y.Receive_Date,
                Supplier_ID      = y.Supplier_ID,
                Supplier_Name    = y.Supplier_Name,
                T3_Supplier      = y.T3_Supplier,
                T3_Supplier_Name = y.T3_Supplier_Name,
                Subcon_ID        = y.Subcon_ID,
                Subcon_Name      = y.Subcon_Name,
                Model_Name       = y.Model_Name,
                Model_No         = y.Model_No,
                Article          = y.Article,
                MO_Seq           = z.MO_Seq,
                Material_ID      = y.Material_ID,
                Material_Name    = y.Material_Name,
                Stockfiting_Date = z.Stockfiting_Date,
                Assembly_Date    = z.Assembly_Date,
                CRD           = z.CRD,
                Line_ASY      = z.Line_ASY,
                Custmoer_Part = z.Custmoer_Part,
                Custmoer_Name = z.Custmoer_Name
            }).ToListAsync();

            return(listQrCodeModel);
        }
Exemplo n.º 5
0
        public async Task <bool> SaveListOutput(List <OutputParam> outputParam, string updateBy)
        {
            DateTime timeNow = DateTime.Now;
            string   outputSheetNo;

            do
            {
                string num = CodeUtility.RandomNumber(3);
                outputSheetNo = "OB" + DateTime.Now.ToString("yyyyMMdd") + num;// OB + 20200421 + 001
            } while (await _repoTransactionMain.CheckTranSheetNo(outputSheetNo));

            foreach (var itemt in outputParam)
            {
                // Tìm ra TransactionMain theo id
                var transactionMain = _repoTransactionMain.FindSingle(x => x.ID == itemt.output.Id);
                transactionMain.Can_Move = "N"; // update transaction main cũ: Can_Move thành N
                _repoTransactionMain.Update(transactionMain);

                // thêm transaction main type O
                WMSB_Transaction_Main modelTypeO = new WMSB_Transaction_Main();
                modelTypeO.Transac_Type = "O";
                modelTypeO.Can_Move     = "N";
                // modelTypeO.Is_Transfer_Form = "N";
                modelTypeO.Transac_No       = itemt.output.TransacNo;
                modelTypeO.Transac_Sheet_No = outputSheetNo;
                modelTypeO.Transacted_Qty   = itemt.output.TransOutQty;
                modelTypeO.Pickup_No        = itemt.output.PickupNo;
                modelTypeO.Transac_Time     = timeNow;
                modelTypeO.Updated_Time     = timeNow;
                modelTypeO.Updated_By       = updateBy;
                modelTypeO.Missing_No       = transactionMain.Missing_No;
                modelTypeO.Material_ID      = transactionMain.Material_ID;
                modelTypeO.Material_Name    = transactionMain.Material_Name;
                modelTypeO.Purchase_No      = transactionMain.Purchase_No;
                modelTypeO.Rack_Location    = null;// type O: racklocation rỗng
                modelTypeO.Purchase_Qty     = transactionMain.Purchase_Qty;
                modelTypeO.QRCode_Version   = transactionMain.QRCode_Version;
                modelTypeO.QRCode_ID        = transactionMain.QRCode_ID;
                modelTypeO.MO_No            = transactionMain.MO_No;
                modelTypeO.MO_Seq           = transactionMain.MO_Seq;
                _repoTransactionMain.Add(modelTypeO);

                // Thêm transaction detail mới theo type = o, dựa vào transaction detail của transaction main cũ
                foreach (var item in itemt.transactionDetail)
                {
                    item.ID           = 0;// ID trong db là tự tăng: dựa vào transaction detail cũ nên thêm mới gán id bằng 0, không cần phải new hết thuộc tính của đổi tượng ra
                    item.Transac_No   = itemt.output.TransacNo;
                    item.Updated_By   = updateBy;
                    item.Updated_Time = timeNow;
                    var itemModel = _mapper.Map <WMSB_Transaction_Detail>(item);
                    _repoTransactionDetail.Add(itemModel);
                }

                // Nếu output ra chưa hết thì thêm transaction main type R, và transaction detail, thêm qrcode mới và update version lên
                if (itemt.output.RemainingQty > 0)
                {
                    //  thêm type R
                    var tmpQrcodeVersion             = transactionMain.QRCode_Version + 1;
                    WMSB_Transaction_Main modelTypeR = new WMSB_Transaction_Main();
                    modelTypeR.Transac_Type     = "R";
                    modelTypeR.Transac_No       = "R" + transactionMain.Transac_No;
                    modelTypeR.Transac_Sheet_No = "R" + transactionMain.Transac_Sheet_No;
                    modelTypeR.Transacted_Qty   = itemt.output.TransOutQty;
                    modelTypeR.Updated_By       = updateBy;
                    modelTypeR.Updated_Time     = timeNow;
                    modelTypeR.Missing_No       = transactionMain.Missing_No;
                    modelTypeR.Material_ID      = transactionMain.Material_ID;
                    modelTypeR.Material_Name    = transactionMain.Material_Name;
                    modelTypeR.Purchase_No      = transactionMain.Purchase_No;
                    modelTypeR.Rack_Location    = transactionMain.Rack_Location;
                    modelTypeR.Purchase_Qty     = transactionMain.Purchase_Qty;
                    modelTypeR.QRCode_Version   = tmpQrcodeVersion;
                    modelTypeR.QRCode_ID        = transactionMain.QRCode_ID;
                    modelTypeR.MO_No            = transactionMain.MO_No;
                    modelTypeR.MO_Seq           = transactionMain.MO_Seq;
                    modelTypeR.Can_Move         = "Y";
                    // modelTypeR.Is_Transfer_Form = "N";
                    modelTypeR.Transac_Time = timeNow;
                    _repoTransactionMain.Add(modelTypeR);

                    // thêm transaction main cũng phải thêm transaction detail
                    foreach (var itemTypeR in itemt.transactionDetail)
                    {
                        itemTypeR.ID           = 0;// ID trong db là tự tăng: dựa vào transaction detail cũ nên thêm mới gán id bằng 0, không cần phải new hết thuộc tính của đổi tượng ra
                        itemTypeR.Transac_No   = modelTypeR.Transac_No;
                        itemTypeR.Updated_By   = updateBy;
                        itemTypeR.Updated_Time = timeNow;
                        itemTypeR.Qty          = itemTypeR.Instock_Qty;
                        itemTypeR.Trans_Qty    = itemTypeR.Instock_Qty;
                        var itemModel = _mapper.Map <WMSB_Transaction_Detail>(itemTypeR);
                        _repoTransactionDetail.Add(itemModel);
                    }

                    // thêm qrcode mới, nếu output ra chưa hết thì thêm qrcode main mới dựa vào cái cũ và update version lên
                    var qrCodeMain = await _repoQRCodeMain.FindAll(x => x.QRCode_ID.Trim() == itemt.output.QrCodeId.Trim()).OrderByDescending(x => x.QRCode_Version).FirstOrDefaultAsync();

                    WMSB_QRCode_Main modelQrCodeMain = new WMSB_QRCode_Main();
                    modelQrCodeMain.QRCode_ID      = qrCodeMain.QRCode_ID;
                    modelQrCodeMain.QRCode_Type    = qrCodeMain.QRCode_Type;
                    modelQrCodeMain.Receive_No     = qrCodeMain.Receive_No;
                    modelQrCodeMain.Valid_Status   = "Y";
                    modelQrCodeMain.Is_Scanned     = "Y";
                    modelQrCodeMain.Invalid_Date   = qrCodeMain.Invalid_Date;
                    modelQrCodeMain.QRCode_Version = qrCodeMain.QRCode_Version + 1;
                    modelQrCodeMain.Updated_Time   = timeNow;
                    modelQrCodeMain.Updated_By     = updateBy;
                    _repoQRCodeMain.Add(modelQrCodeMain);

                    // Update cho QRCode cũ, Valid_Status =N, Invalid_Date = Ngày mà tạo ra version mới
                    qrCodeMain.Valid_Status = "N";
                    qrCodeMain.Invalid_Date = timeNow;
                    _repoQRCodeMain.Update(qrCodeMain);

                    // thêm qrcodedetail của qrcode mới: thêm qrcode main cũng phải thêm qrcode detail
                    var qrCodeDetails = await _repoQRCodeDetail.FindAll(x => x.QRCode_ID.Trim() == qrCodeMain.QRCode_ID.Trim() && x.QRCode_Version == qrCodeMain.QRCode_Version).ToListAsync();

                    foreach (var itemQrCodeDetail in qrCodeDetails)
                    {
                        itemQrCodeDetail.QID            = 0;
                        itemQrCodeDetail.Updated_By     = updateBy;
                        itemQrCodeDetail.Updated_Time   = timeNow;
                        itemQrCodeDetail.QRCode_Version = modelQrCodeMain.QRCode_Version;
                        itemQrCodeDetail.Qty            = itemt.transactionDetail.Where(x => x.Tool_Size == itemQrCodeDetail.Tool_Size && x.Order_Size == itemQrCodeDetail.Order_Size && x.Model_Size == itemQrCodeDetail.Model_Size).FirstOrDefault().Instock_Qty;
                        _repoQRCodeDetail.Add(itemQrCodeDetail);
                    }
                }
                // Nếu QRCode đã out hết số lượng, cần update cho nó không còn hiệu lực
                // ( Ở bảng WMSB_QRCode_Main: UPDATE trường Valid_Status =’N”, Invalid_Date là ngày Output hết số lượng,
                // đồng thời cũng update trường Update_Time & Update_By)
                else
                {
                    var qrCodeMain = await _repoQRCodeMain.FindAll(x => x.QRCode_ID.Trim() == itemt.output.QrCodeId.Trim()).OrderByDescending(x => x.QRCode_Version).FirstOrDefaultAsync();

                    qrCodeMain.Valid_Status = "N";
                    qrCodeMain.Invalid_Date = timeNow;
                    qrCodeMain.Updated_Time = timeNow;
                    qrCodeMain.Updated_By   = updateBy;
                    _repoQRCodeMain.Update(qrCodeMain);
                }
            }

            // lưu Db
            return(await _repoTransactionMain.SaveAll());
        }
Exemplo n.º 6
0
        public async Task <bool> SaveListOutput(List <OutputParam> outputParam)
        {
            DateTime timeNow = DateTime.Now;

            foreach (var itemt in outputParam)
            {
                Random ran = new Random();
                int    num = ran.Next(100, 999);

                // Tìm ra TransactionMain theo id
                var transactionMain = _repoTransactionMain.FindSingle(x => x.ID == itemt.output.Id);
                if (transactionMain.Transac_Type != "R")
                {
                    transactionMain.Can_Move = "N"; // nếu type != R update transaction main cũ: Can_Move thành N
                    _repoTransactionMain.Update(transactionMain);
                }
                if (transactionMain.Transac_Type == "R" && itemt.output.RemainingQty == 0)
                {
                    transactionMain.Can_Move = "N"; // nếu type == R và output ra hết update : Can_Move thành N
                    _repoTransactionMain.Update(transactionMain);
                }

                // thêm transaction main type O
                WMSB_Transaction_Main modelTypeO = new WMSB_Transaction_Main();
                modelTypeO.Transac_Type     = "O";
                modelTypeO.Can_Move         = "N";
                modelTypeO.Transac_No       = itemt.output.TransacNo;
                modelTypeO.Transac_Sheet_No = "OB" + DateTime.Now.ToString("yyyyMMdd") + num.ToString();
                modelTypeO.Transacted_Qty   = itemt.output.TransOutQty;
                modelTypeO.Pickup_No        = itemt.output.PickupNo;
                modelTypeO.Transac_Time     = timeNow;
                modelTypeO.Updated_Time     = timeNow;
                modelTypeO.Updated_By       = "Emma";
                modelTypeO.Missing_No       = transactionMain.Missing_No;
                modelTypeO.Material_ID      = transactionMain.Material_ID;
                modelTypeO.Material_Name    = transactionMain.Material_Name;
                modelTypeO.Purchase_No      = transactionMain.Purchase_No;
                modelTypeO.Rack_Location    = null;// type O: racklocation rỗng
                modelTypeO.Purchase_Qty     = transactionMain.Purchase_Qty;
                modelTypeO.QRCode_Version   = transactionMain.QRCode_Version;
                modelTypeO.QRCode_ID        = transactionMain.QRCode_ID;
                modelTypeO.MO_No            = transactionMain.MO_No;
                modelTypeO.MO_Seq           = transactionMain.MO_Seq;
                _repoTransactionMain.Add(modelTypeO);

                // Thêm transaction detail mới theo type = o, dựa vào transaction detail của transaction main cũ
                foreach (var item in itemt.transactionDetail)
                {
                    item.ID           = 0;// ID trong db là tự tăng: dựa vào transaction detail cũ nên thêm mới gán id bằng 0, không cần phải new hết thuộc tính của đổi tượng ra
                    item.Transac_No   = itemt.output.TransacNo;
                    item.Updated_By   = "Emma";
                    item.Updated_Time = timeNow;
                    var itemModel = _mapper.Map <WMSB_Transaction_Detail>(item);
                    _repoTransactionDetail.Add(itemModel);
                }

                // Nếu output ra chưa hết thì thêm transaction main type R, và transaction detail, thêm qrcode mới và update version lên
                if (itemt.output.RemainingQty > 0)
                {
                    //  thêm type R
                    // nếu type là R: thì update lại
                    if (transactionMain.Transac_Type.Trim() == "R")
                    {
                        var tmpQrcodeVersion = transactionMain.QRCode_Version + 1;
                        transactionMain.Updated_Time   = timeNow;
                        transactionMain.Updated_By     = "Emma";
                        transactionMain.Transacted_Qty = itemt.output.TransOutQty;
                        transactionMain.QRCode_Version = tmpQrcodeVersion;
                        _repoTransactionMain.Update(transactionMain);

                        // update transaction main thì cũng phải update transaction detail
                        var transactionDetail = await _repoTransactionDetail.FindAll(x => x.Transac_No.Trim() == transactionMain.Transac_No.Trim()).ToListAsync();

                        foreach (var item in transactionDetail)
                        {
                            item.Trans_Qty    = 0;// nếu transaction main là Type R là thì transaction detail của nó gán Trans_Qty = 0
                            item.Qty          = itemt.transactionDetail.Where(x => x.Tool_Size == item.Tool_Size && x.Order_Size == item.Order_Size && x.Model_Size == item.Model_Size).FirstOrDefault().Qty;
                            item.Instock_Qty  = itemt.transactionDetail.Where(x => x.Tool_Size == item.Tool_Size && x.Order_Size == item.Order_Size && x.Model_Size == item.Model_Size).FirstOrDefault().Instock_Qty;
                            item.Updated_By   = "Emma";
                            item.Updated_Time = timeNow;
                            _repoTransactionDetail.Update(item);
                        }
                    }
                    // ngược lại thì thêm mới type R
                    else
                    {
                        var tmpQrcodeVersion             = transactionMain.QRCode_Version + 1;
                        WMSB_Transaction_Main modelTypeR = new WMSB_Transaction_Main();
                        modelTypeR.Transac_Type     = "R";
                        modelTypeR.Transac_No       = "R" + transactionMain.Transac_No;
                        modelTypeR.Transac_Sheet_No = "R" + transactionMain.Transac_Sheet_No;
                        modelTypeR.Transacted_Qty   = itemt.output.TransOutQty;
                        modelTypeR.Updated_By       = "Emma";
                        modelTypeR.Updated_Time     = timeNow;
                        modelTypeR.Missing_No       = transactionMain.Missing_No;
                        modelTypeR.Material_ID      = transactionMain.Material_ID;
                        modelTypeR.Material_Name    = transactionMain.Material_Name;
                        modelTypeR.Purchase_No      = transactionMain.Purchase_No;
                        modelTypeR.Rack_Location    = transactionMain.Rack_Location;
                        modelTypeR.Purchase_Qty     = transactionMain.Purchase_Qty;
                        modelTypeR.QRCode_Version   = tmpQrcodeVersion;
                        modelTypeR.QRCode_ID        = transactionMain.QRCode_ID;
                        modelTypeR.MO_No            = transactionMain.MO_No;
                        modelTypeR.MO_Seq           = transactionMain.MO_Seq;
                        modelTypeR.Can_Move         = "Y";
                        modelTypeR.Transac_Time     = transactionMain.Transac_Time;
                        _repoTransactionMain.Add(modelTypeR);

                        // thêm transaction main cũng phải thêm transaction detail
                        foreach (var itemTypeR in itemt.transactionDetail)
                        {
                            itemTypeR.ID           = 0;// ID trong db là tự tăng: dựa vào transaction detail cũ nên thêm mới gán id bằng 0, không cần phải new hết thuộc tính của đổi tượng ra
                            itemTypeR.Transac_No   = modelTypeR.Transac_No;
                            itemTypeR.Updated_By   = "Emma";
                            itemTypeR.Updated_Time = timeNow;
                            itemTypeR.Trans_Qty    = 0;// nếu transaction main là Type R là thì transaction detail của nó gán Trans_Qty = 0
                            var itemModel = _mapper.Map <WMSB_Transaction_Detail>(itemTypeR);
                            _repoTransactionDetail.Add(itemModel);
                        }
                    }

                    // thêm qrcode mới, nếu output ra chưa hết thì thêm qrcode main mới dựa vào cái cũ và update version lên
                    var qrCodeMain = await _repoQRCodeMain.FindAll(x => x.QRCode_ID.Trim() == itemt.output.QrCodeId.Trim()).OrderByDescending(x => x.QRCode_Version).FirstOrDefaultAsync();

                    WMSB_QRCode_Main modelQrCodeMain = new WMSB_QRCode_Main();
                    modelQrCodeMain.QRCode_ID      = qrCodeMain.QRCode_ID;
                    modelQrCodeMain.QRCode_Type    = qrCodeMain.QRCode_Type;
                    modelQrCodeMain.Receive_No     = qrCodeMain.Receive_No;
                    modelQrCodeMain.Valid_Status   = "Y";
                    modelQrCodeMain.Is_Scanned     = "Y";
                    modelQrCodeMain.Invalid_Date   = qrCodeMain.Invalid_Date;
                    modelQrCodeMain.QRCode_Version = qrCodeMain.QRCode_Version + 1;
                    modelQrCodeMain.Updated_Time   = timeNow;
                    modelQrCodeMain.Updated_By     = "Emma";
                    _repoQRCodeMain.Add(modelQrCodeMain);

                    // Update cho QRCode cũ, Valid_Status =N, Invalid_Date = Ngày mà tạo ra version mới
                    qrCodeMain.Valid_Status = "N";
                    qrCodeMain.Invalid_Date = timeNow;
                    _repoQRCodeMain.Update(qrCodeMain);

                    // thêm qrcodedetail của qrcode mới: thêm qrcode main cũng phải thêm qrcode detail
                    var qrCodeDetails = await _repoQRCodeDetail.FindAll(x => x.QRCode_ID.Trim() == qrCodeMain.QRCode_ID.Trim() && x.QRCode_Version == qrCodeMain.QRCode_Version).ToListAsync();

                    foreach (var itemQrCodeDetail in qrCodeDetails)
                    {
                        itemQrCodeDetail.QID            = 0;
                        itemQrCodeDetail.Updated_By     = "Emma";
                        itemQrCodeDetail.Updated_Time   = timeNow;
                        itemQrCodeDetail.QRCode_Version = modelQrCodeMain.QRCode_Version;
                        itemQrCodeDetail.Qty            = itemt.transactionDetail.Where(x => x.Tool_Size == itemQrCodeDetail.Tool_Size && x.Order_Size == itemQrCodeDetail.Order_Size && x.Model_Size == itemQrCodeDetail.Model_Size).FirstOrDefault().Instock_Qty;
                        _repoQRCodeDetail.Add(itemQrCodeDetail);
                    }
                }
            }

            // lưu Db
            return(await _repoTransactionMain.SaveAll());
        }
Exemplo n.º 7
0
 public async Task<int> GetQrCodeVersionLastest(string qrCodeId)
 {
     var model = await _repoQrcode.FindAll(x => x.QRCode_ID.Trim() == qrCodeId.Trim()).OrderByDescending(x => x.QRCode_Version).FirstOrDefaultAsync();
     return model.QRCode_Version;
 }