public doClearQtyAllLot ClearQtyInAllLot(doClearQtyAllLot doClear)
        {
            doClearQtyAllLot doClearReturn = new doClearQtyAllLot {
                blnResult = false
            };

            try
            {
                List <tbt_AccountInstalled> lst = this.ClearQtyInAllLot(doClear.OfficeCode, doClear.LocationCode, doClear.InstrumentCode);
                doClearReturn.blnResult = true;

                return(doClearReturn);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public bool UpdateAccountTransferSecondhandInstrumentIVS190(doGroupSecondhandInstrument doGroupSecondhand)
        {
            try
            {
                //1.    Get first-in first-out data for transfer oldest instrument
                List <doFIFOInstrument> FifoInstrument = GetFIFOInstrument(doGroupSecondhand.SourceOfficeCode, doGroupSecondhand.SourceLocationCode, doGroupSecondhand.Instrumentcode);

                //2.	Prepare Data for transfer
                if (doGroupSecondhand.TransferType == false)
                {
                    doGroupSecondhand.TransferQty = doGroupSecondhand.TransferQty * -1;
                }

                //3.	Set Clear QTY in all of lot No. in tbt_accountInstalled
                doClearQtyAllLot doClearQty = new doClearQtyAllLot();
                doClearQty.OfficeCode     = doGroupSecondhand.SourceOfficeCode;
                doClearQty.LocationCode   = doGroupSecondhand.SourceLocationCode;
                doClearQty.InstrumentCode = doGroupSecondhand.Instrumentcode;

                doClearQtyAllLot doClearResult = ClearQtyInAllLot(doClearQty);

                if (doClearResult.blnResult == false)
                {
                    throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0148, new string[] { TableName.C_TBL_NAME_INV_ACC_INSTALLED });
                }

                //4.	Update qty to lastest of lot No. in tbt_accountInstalled
                //4.1	Calculate Instrument Qty of lastest lot No
                int TTQty         = 0;
                int SumInstrument = 0;

                foreach (doFIFOInstrument i in FifoInstrument)
                {
                    if (i.InstrumentQty != null)
                    {
                        SumInstrument += i.InstrumentQty.Value;
                    }
                }

                TTQty = SumInstrument - doGroupSecondhand.TransferQty.Value;

                //4.3	Update Qty data to lastest of lot No.
                if (FifoInstrument.Count > 0)
                {
                    List <tbt_AccountInstalled> doTbt_InventoryAccountInstalled = GetTbt_AccountInstalled(doGroupSecondhand.SourceOfficeCode, doGroupSecondhand.SourceLocationCode, doGroupSecondhand.Instrumentcode, FifoInstrument[FifoInstrument.Count - 1].LotNo);

                    if (doTbt_InventoryAccountInstalled.Count > 0)
                    {
                        doTbt_InventoryAccountInstalled[0].InstrumentQty = TTQty;
                        doTbt_InventoryAccountInstalled[0].UpdateBy      = CommonUtil.dsTransData.dtUserData.EmpNo;
                        doTbt_InventoryAccountInstalled[0].UpdateDate    = CommonUtil.dsTransData.dtOperationData.ProcessDateTime;

                        List <tbt_AccountInstalled> dotbt_InvAccUpdate = new List <tbt_AccountInstalled>();
                        dotbt_InvAccUpdate.Add(doTbt_InventoryAccountInstalled[0]);

                        List <tbt_AccountInstalled> lstResult = UpdateTbt_AccountInstalled(dotbt_InvAccUpdate);
                        if (lstResult.Count <= 0)
                        {
                            throw ApplicationErrorException.ThrowErrorException(MessageUtil.MODULE_COMMON, MessageUtil.MessageList.MSG0148, new string[] { TableName.C_TBL_NAME_INV_ACC_INSTALLED });
                        }
                    }
                }

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }