Пример #1
0
        public async Task<bool> IntegrationInputSubmit(List<IntegrationInputModel> data, string user)
        {
            data = data.Where(x => !string.IsNullOrEmpty(x.Rack_Location)).ToList();
            foreach (var item in data)
            {
                // Update Table WMSB_QRCode_Main
                var qrCodeModels = await _repoQRCodeMain.FindAll(x => x.QRCode_ID.Trim() == item.QRCode_ID.Trim() &&
                                                    x.Is_Scanned.Trim() == "N" &&
                                                    x.Receive_No.Trim() == item.Receive_No.Trim()).FirstOrDefaultAsync();
                if (qrCodeModels != null)
                {
                    qrCodeModels.Is_Scanned = "Y";
                }


                //---------------------------- Check TransactionMain-------------------------------//
                var transationMainCheck = await _repoTransactionMain.FindAll(x => x.QRCode_ID.Trim() == item.QRCode_ID.Trim() &&
                                                x.MO_No.Trim() == item.MO_No.Trim() &&
                                                x.Purchase_No.Trim() == item.Purchase_No.Trim() &&
                                                x.Material_ID.Trim() == item.Material_ID.Trim()).FirstOrDefaultAsync();
                if (transationMainCheck == null)
                {
                    string Transac_Sheet_No, Transac_No;
                    do
                    {
                        string num = CodeUtility.RandomNumber(3);
                        Transac_Sheet_No = "IB" + DateTime.Now.ToString("yyyyMMdd") + num;
                    } while (await _repoTransactionMain.CheckTranSheetNo(Transac_Sheet_No));
                    do
                    {
                        string num1 = CodeUtility.RandomNumber(3);
                        Transac_No = "IB" + item.MO_No.Trim() + num1;
                    } while (await _repoTransactionMain.CheckTransacNo(Transac_No));

                    // Tạo New Model để Add vào Table WMSB_Transaction_Main
                    var transactionMainModel = new WMSB_Transaction_Main();
                    transactionMainModel.Transac_Type = "I";
                    transactionMainModel.Transac_No = Transac_No;
                    transactionMainModel.Transac_Sheet_No = Transac_Sheet_No;
                    transactionMainModel.Can_Move = "Y";
                    transactionMainModel.Transac_Time = DateTime.Now;
                    transactionMainModel.QRCode_ID = item.QRCode_ID;
                    transactionMainModel.QRCode_Version = item.QRCode_Version;
                    transactionMainModel.MO_No = item.MO_No.Trim();
                    transactionMainModel.Purchase_No = item.Purchase_No.Trim();
                    transactionMainModel.MO_Seq = item.MO_Seq;
                    transactionMainModel.Material_ID = item.Material_ID.Trim();
                    transactionMainModel.Material_Name = item.Material_Name.Trim();
                    transactionMainModel.Purchase_Qty = item.Receive_Qty;
                    transactionMainModel.Transacted_Qty = item.Receive_Qty;
                    transactionMainModel.Rack_Location = item.Rack_Location;
                    transactionMainModel.Is_Transfer_Form = "N";
                    transactionMainModel.Updated_Time = DateTime.Now;
                    transactionMainModel.Updated_By = user;
                    _repoTransactionMain.Add(transactionMainModel);

                    // Add vào table WMSB_Transaction_Detail             
                    foreach (var item1 in item.PackingListDetailItem)
                    {
                        var transactionDetailModel = new WMSB_Transaction_Detail();
                        transactionDetailModel.Transac_No = Transac_No.Trim();
                        transactionDetailModel.Tool_Size = item1.Tool_Size;
                        transactionDetailModel.Order_Size = item1.Order_Size;
                        transactionDetailModel.Model_Size = item1.Model_Size;
                        transactionDetailModel.Spec_Size = item1.Spec_Size;
                        transactionDetailModel.Qty = item1.Received_Qty;
                        transactionDetailModel.Trans_Qty = item1.Received_Qty;
                        transactionDetailModel.Instock_Qty = item1.Received_Qty;
                        transactionDetailModel.Untransac_Qty = 0;
                        transactionDetailModel.Updated_Time = DateTime.Now;
                        transactionDetailModel.Updated_By = user;
                        _repoTransactionDetail.Add(transactionDetailModel);
                    }
                }
            }
            return await _repoTransactionDetail.SaveAll();
        }
Пример #2
0
 public async Task <bool> CheckTransacNoDuplicate(string transacNo)
 {
     return(await _repoTransactionMain.CheckTransacNo(transacNo));
 }