public bool UpdateSFTStatusIntoWH(DataTable dtERPPQC)
        {
            try
            {
                if (dtERPPQC.Rows.Count == 0)
                {
                    return(false);
                }
                ConvertDataTable convertDataTable = new ConvertDataTable();
                int[]            OutSequence      = new int[dtERPPQC.Rows.Count];
                DataTable        dtWSRUN          = convertDataTable.GetDataTableSFT_WS_RUNPendingWH(dtERPPQC);
                if (dtWSRUN.Rows.Count == 0)
                {
                    MessageBox.Show("data convert WS_RUN_PENDING WareHouse is fail", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
                Database.SFT.SFT_WS_RUN sFT_WS_RUN = new Database.SFT.SFT_WS_RUN();
                var InsertWsRun = sFT_WS_RUN.InsertData(dtWSRUN, out OutSequence);

                Database.SFT.SFT_LOT sFT_LOT = new Database.SFT.SFT_LOT();
                var InsertorUpdateLot        = sFT_LOT.InsertOrUpdateIntoWH(dtERPPQC);
                Database.SFT.SFT_OP_REALRUN sFT_OP_REALRUN = new Database.SFT.SFT_OP_REALRUN();

                var insertorUpdateREALRUN = sFT_OP_REALRUN.UpdateOrInsert(dtERPPQC, OutSequence);
                if (InsertWsRun && InsertorUpdateLot && insertorUpdateREALRUN)
                {
                    return(true);
                }
                else
                {
                    MessageBox.Show("Insert data for pending warehouse fail", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return(false);
                }
            }

            catch (Exception EX)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateSFTStatusIntoWH(DataTable dtERPPQC)", EX.Message);
            }
            return(false);
        }
        public bool UpdateDataDBForFinishedGoodsNotConfirm(DataTable dtERPPQC, string Location, out string ERPDoc, out string SFTDoc)
        {
            try
            {
                ERPDoc = "";
                SFTDoc = "";

                ERPDataUpdate eRPDataUpdate = new ERPDataUpdate();
                string        TB002         = eRPDataUpdate.getTB002(Class.valiballecommon.GetStorage().DocNo);
                SFTDataUpdate sFTDataUpdate = new SFTDataUpdate();
                string        TransNo       = sFTDataUpdate.getTransnoOfSFT(Class.valiballecommon.GetStorage().DocNo);
                Database.SFT.SFT_TRANSORDER_LINE sFT_TRANSORDER_LINE = new Database.SFT.SFT_TRANSORDER_LINE();
                ConvertDataTable convertDataTable  = new ConvertDataTable();
                DataTable        dtTRANSORDER_LINE = convertDataTable.ERPPQCtoSFTTRANSORDERLINE(dtERPPQC, TransNo, TB002, Location);
                DataTable        dtTRANSORDER      = convertDataTable.GetDataSFTTRANSORDER(dtERPPQC, dtTRANSORDER_LINE);
                DataTable        dtWSRUN           = convertDataTable.GetDataTableSFT_WS_RUN(dtERPPQC, dtTRANSORDER_LINE);
                ConvertDataERP   convertDataERP    = new ConvertDataERP();
                DataTable        dtSFCTC           = convertDataERP.GetDataTableSFCTC(dtERPPQC, TB002, "N");            ////
                DataTable        dtSFCTB           = convertDataERP.GetDataTableSFCTB(dtSFCTC, dtERPPQC, TransNo, "N"); ///

                if (dtTRANSORDER_LINE.Rows.Count > 0 && dtTRANSORDER.Rows.Count > 0 && dtWSRUN.Rows.Count > 0 &&
                    dtSFCTC.Rows.Count > 0 && dtSFCTB.Rows.Count > 0)
                {
                    var Result = sFT_TRANSORDER_LINE.InsertData(dtTRANSORDER_LINE);
                    if (Result == false)
                    {
                        MessageBox.Show("Insert TransOrder_Line fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }

                    Database.SFT.SFT_TRANSORDER sFT_TRANSORDER = new Database.SFT.SFT_TRANSORDER();
                    var resultTransOrder = sFT_TRANSORDER.InsertData(dtTRANSORDER);
                    if (resultTransOrder == false)
                    {
                        MessageBox.Show("Insert TransOrder fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }

                    int[] sequence = new int[dtERPPQC.Rows.Count];
                    Database.SFT.SFT_WS_RUN sFT_WS_RUN = new Database.SFT.SFT_WS_RUN();
                    var resultWs_run = sFT_WS_RUN.InsertData(dtWSRUN, out sequence);
                    if (resultWs_run == false)
                    {
                        MessageBox.Show("Insert SFT_WS_RUN fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                    Database.SFT.MODETAIL mODETAIL = new Database.SFT.MODETAIL();
                    var resultUpdate = mODETAIL.UpdateMODETAIL(dtTRANSORDER_LINE);                    //MOC027 ko biet la gi ?
                    if (resultUpdate == false)
                    {
                        MessageBox.Show("update Modetail fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                    Database.SFT.SFT_LOT sFT_LOT = new Database.SFT.SFT_LOT();
                    var InsertOrUpdate           = sFT_LOT.InsertUpdateLot(dtTRANSORDER_LINE);
                    if (InsertOrUpdate == false)
                    {
                        MessageBox.Show("Insert Lot fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }

                    Database.SFC.SFCTC sFCTC = new Database.SFC.SFCTC();            ///

                    var InsertSFCTC = sFCTC.InsertData(dtSFCTC);                    /////
                    if (InsertSFCTC == false)
                    {
                        MessageBox.Show("Insert SFCTC fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }

                    Database.SFC.SFCTB sFCTB = new Database.SFC.SFCTB();                    /////
                    var InsertSFCTB          = sFCTB.InsertData(dtSFCTB);
                    if (InsertSFCTB == false)
                    {
                        MessageBox.Show("Insert SFCTB fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                    Database.SFC.SFCTA sFCTA = new Database.SFC.SFCTA();                    /////
                    var UpdateSFCTA          = sFCTA.UpdateSFCTAForFinishedGoodsNotConfirm(dtERPPQC);
                    if (UpdateSFCTA == false)
                    {
                        MessageBox.Show("Insert SFCTA fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }

                    Database.ERPSOFT.ERPOutPQCQR eRPOutPQCQR = new Database.ERPSOFT.ERPOutPQCQR();                    ////function kho
                    var updateOutPQC = eRPOutPQCQR.UpdateImportWarehouse(dtERPPQC, Class.valiballecommon.GetStorage().DocNo + "-" + TB002);
                    if (updateOutPQC == false)
                    {
                        MessageBox.Show("Insert import status fail ", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return(false);
                    }
                }
                ERPDoc = TB002;
                SFTDoc = TransNo;
            }
            catch (Exception ex)
            {
                SystemLog.Output(SystemLog.MSG_TYPE.Err, "UpdateData2DBForFinishedGoods(FinishedGoodsItems fgItems)", ex.Message);
                ERPDoc = "";
                SFTDoc = "";
                return(false);
            }
            return(true);
        }