public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length > CoreDataBlockHeader.TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                //dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
                //messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                int offset = 0;
                while (offset < messagebytes.Length)
                {
                    byte[] dbbytes = CommonDataHelper.SubBytes(messagebytes, offset, messagebytes.Length - offset);
                    dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(dbbytes);
                    if (dbhdr == null)
                    {
                        offset += CoreDataBlockHeader.TOTAL_WIDTH;
                        continue;
                    }
                    switch (dbhdr.DBH_DB_ID.Trim())
                    {
                        case "BY999000":
                            DB_BY999000 = (AcctEraseODATA_DB1)DB_BY999000.FromBytes(dbbytes);
                            if (dbhdr.DBH_DB_LENGTH > 0)
                            {
                                offset += (int)dbhdr.DBH_DB_LENGTH;                                
                            }
                            else
                            {
                                offset += AcctEraseODATA_DB1.TOTAL_WIDTH;
                            }
                            break;

                        case "BY999001":
                            AcctEraseODATA_DB2 db = new AcctEraseODATA_DB2();
                            db = (AcctEraseODATA_DB2)db.FromBytes(dbbytes);
                            DB_BY999001_List.Add(db);
                            if (dbhdr.DBH_DB_LENGTH > 0)
                            {
                                offset += (int)dbhdr.DBH_DB_LENGTH;
                            }
                            else
                            {
                                offset += AcctEraseODATA_DB2.TOTAL_WIDTH;
                            }
                            break;

                        default:
                            if (dbhdr.DBH_DB_LENGTH > 0)
                            {
                                offset += (int)dbhdr.DBH_DB_LENGTH;
                            }
                            else
                            {
                                offset += CoreDataBlockHeader.TOTAL_WIDTH;
                            }
                            break;
                    }
                }
            }
            return this;
        }
        public byte[] ToBytes()
        {
            //统一编码消息头 MH

            CoreMessageHeader msgHeader = new CoreMessageHeader();
            msgHeader.MH_MESSAGE_LENGTH = CoreMessageHeader.TOTAL_WIDTH + RQ_TOTAL_WIDTH;
            msgHeader.MH_LAST_FLAG = MessageHeaderLastFlag;
            byte[] buffer = new byte[msgHeader.MH_MESSAGE_LENGTH];
            Array.Copy(msgHeader.ToBytes(), buffer, CoreMessageHeader.TOTAL_WIDTH);

            byte[] rqtotal = new byte[RQ_TOTAL_WIDTH];
            CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
            dbhdr1.DBH_DB_LENGTH = CoreDataBlockHeader.TOTAL_WIDTH + RQHDR_MsgHandler.TOTAL_WIDTH;
            dbhdr1.DBH_DB_ID = "@RQHDR";
            Array.Copy(dbhdr1.ToBytes(), rqtotal, CoreDataBlockHeader.TOTAL_WIDTH);
            Array.Copy(RQhdrHandler.ToBytes(), 0, rqtotal, CoreDataBlockHeader.TOTAL_WIDTH, RQHDR_MsgHandler.TOTAL_WIDTH);

            if (GetRQDTLLen() > 0)
            {
                CoreDataBlockHeader dbhdr2 = new CoreDataBlockHeader();
                dbhdr2.DBH_DB_LENGTH = (UInt32)(CoreDataBlockHeader.TOTAL_WIDTH + GetRQDTLLen());
                dbhdr2.DBH_DB_ID = "@RQDTL";
                Array.Copy(dbhdr2.ToBytes(), 0, rqtotal, CoreDataBlockHeader.TOTAL_WIDTH + RQHDR_MsgHandler.TOTAL_WIDTH, CoreDataBlockHeader.TOTAL_WIDTH);
                rqtotal = RQDTL_ToBytes(rqtotal);
            }
            Array.Copy(rqtotal, 0, buffer, CoreMessageHeader.TOTAL_WIDTH, RQ_TOTAL_WIDTH);
            return buffer;
        }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= CoreDataBlockHeader.TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                //dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
                //messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                int offset = 0;
                while (offset < messagebytes.Length)
                {
                    
                    byte[] dbbytes = CommonDataHelper.SubBytes(messagebytes, offset, messagebytes.Length - offset);
                    dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(dbbytes);
                    if (dbhdr == null)
                    {
                        offset += CoreDataBlockHeader.TOTAL_WIDTH;
                        continue;
                    }
                    switch (dbhdr.DBH_DB_ID.Trim())
                    {
                        case "BGO30800":
                            DB_BGO30800 = (AcctRetrieveODATA_DB1)DB_BGO30800.FromBytes(dbbytes);
                            offset += AcctRetrieveODATA_DB1.TOTAL_WIDTH;
                            break;

                        case "BGO30802":
                            DB_BGO30802 = (AcctRetrieveODATA_DB3)DB_BGO30802.FromBytes(dbbytes);
                            offset += AcctRetrieveODATA_DB3.TOTAL_WIDTH;
                            break;

                        case "BGO30801":
                            AcctRetrieveODATA_DB2 db2 = new AcctRetrieveODATA_DB2();
                            db2 = (AcctRetrieveODATA_DB2)db2.FromBytes(dbbytes);
                            offset += AcctRetrieveODATA_DB2.TOTAL_WIDTH;
                            DB_BGO30801_List.Add(db2);
                            break;

                        case "BGO30803":
                            AcctRetrieveODATA_DB4 db4 = new AcctRetrieveODATA_DB4();
                            db4 = (AcctRetrieveODATA_DB4)db4.FromBytes(dbbytes);
                            offset += AcctRetrieveODATA_DB4.TOTAL_WIDTH;
                            DB_BGO30803_List.Add(db4);
                            break;
                        default:
                            offset += CoreDataBlockHeader.TOTAL_WIDTH;
                            break;

                    }
                }
            }
            return this;
            
        }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= CoreDataBlockHeader.TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                int offset = 0;
                while (offset < messagebytes.Length)
                {
                    byte[] dbbytes = CommonDataHelper.SubBytes(messagebytes, offset, messagebytes.Length - offset);
                    dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(dbbytes);
                    if (dbhdr == null)
                    {
                        offset += CoreDataBlockHeader.TOTAL_WIDTH;
                        continue;
                    }
                    switch (dbhdr.DBH_DB_ID.Trim())
                    {
                        case "BXO00008":
                            AcctRecordODATA_Item item = new AcctRecordODATA_Item();
                            item = (AcctRecordODATA_Item)item.FromBytes(dbbytes);
                            offset += AcctRecordODATA_Item.TOTAL_WIDTH;
                            _odataItemList.Add(item);
                            break;

                        case "BG203300":
                            AcctRecordODATA_PendingItem pending = new AcctRecordODATA_PendingItem();
                            pending = (AcctRecordODATA_PendingItem)pending.FromBytes(dbbytes);
                            offset += AcctRecordODATA_PendingItem.TOTAL_WIDTH;
                            _odataPendingList.Add(pending);
                            break;
                        case "BG203301":
                            _odateRepeatItem = new AcctRecordODATA_RepeatItem();
                            _odateRepeatItem = (AcctRecordODATA_RepeatItem)_odateRepeatItem.FromBytes(dbbytes);
                            offset += AcctRecordODATA_RepeatItem.TOTAL_WIDTH;
                            break;
                        default:
                            offset += (int)dbhdr.DBH_DB_LENGTH;
                            break;
                    }
                }
            }
            else
            {
                RespOdata = CommonDataHelper.GetValueFromBytes(ref messagebytes, (UInt16)messagebytes.Length).TrimEnd();
            }
            return this;
        }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length == TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
                dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(messagebytes);

                messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                CUS_CDE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 11).TrimEnd();
            }
            else
            {
                CUS_CDE = CommonDataHelper.GetValueFromBytes(ref messagebytes, (UInt16)messagebytes.Length).TrimEnd(); 
            }

            return this;
        }
        public new byte[] ToBytes()
        {

            if (IBDATACollection == null || IBDATACollection.Count == 0)
            {
                base.MessageHeaderLastFlag = true;
                return base.ToBytes();
            }
            else
            {
                base.MessageHeaderLastFlag = false;
                byte[] regularBytes = base.ToBytes();
                int index = 0;
                
                int ibdataLength = (from ibdata in IBDATACollection
                                   where ibdata != null && ibdata.TOTAL_WIDTH > 0
                                    select ibdata.TOTAL_WIDTH).Sum() + IBDATACollection.Count * (CoreDataBlockHeader.TOTAL_WIDTH + CoreMessageHeader.TOTAL_WIDTH);
                byte [] result = new byte[ibdataLength + regularBytes.Length];
                Array.Copy(regularBytes, result, regularBytes.Length);
                int offset = regularBytes.Length;
                foreach (var ibdata in IBDATACollection)
                {
                    CoreMessageHeader msgHeader = new CoreMessageHeader();
                    msgHeader.MH_MESSAGE_LENGTH = (uint)(CoreMessageHeader.TOTAL_WIDTH + CoreDataBlockHeader.TOTAL_WIDTH + ibdata.TOTAL_WIDTH);
                    msgHeader.MH_LAST_FLAG = (++index == IBDATACollection.Count) ? true : false;
                    Array.Copy(msgHeader.ToBytes(), 0, result, offset,  CoreMessageHeader.TOTAL_WIDTH);
                    offset += CoreMessageHeader.TOTAL_WIDTH;
                    
                    CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                    dbhdr.DBH_DB_LENGTH = (uint)(CoreDataBlockHeader.TOTAL_WIDTH + ibdata.TOTAL_WIDTH);
                    dbhdr.DBH_DB_ID = "@IBDATA";
                    Array.Copy(dbhdr.ToBytes(), 0, result, offset, CoreDataBlockHeader.TOTAL_WIDTH);
                    offset += CoreDataBlockHeader.TOTAL_WIDTH;
                    Array.Copy(ibdata.ToBytes(), 0, result, offset, ibdata.TOTAL_WIDTH);
                    offset += ibdata.TOTAL_WIDTH;
                }

                return result;                
            }
        }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= CoreDataBlockHeader.TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
         int offset = 0;
         while (offset < messagebytes.Length)
         {
             byte[] dbbytes = CommonDataHelper.SubBytes(messagebytes, offset, messagebytes.Length - offset);
             dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(dbbytes);
             if (dbhdr == null)
             {
                 offset += CoreDataBlockHeader.TOTAL_WIDTH;
                 continue;
             }
             SuperiorCurrentAcctODATAItem item = new SuperiorCurrentAcctODATAItem();
             item = (SuperiorCurrentAcctODATAItem)item.FromBytes(dbbytes);
             offset += SuperiorCurrentAcctODATAItem.TOTAL_WIDTH;
             CrntAcctList.Add(item);
         }
     }
     return this;
 }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= CoreDataBlockHeader.TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
         int offset = 0;
         while (offset < messagebytes.Length)
         {
             byte[] dbbytes = CommonDataHelper.SubBytes(messagebytes, offset, messagebytes.Length - offset);
             dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(dbbytes);
             if (dbhdr == null)
             {
                 offset += CoreDataBlockHeader.TOTAL_WIDTH;
                 continue;
             }
             DepositClearingFundODATAItem item = new DepositClearingFundODATAItem();
             item = (DepositClearingFundODATAItem)item.FromBytes(dbbytes);
             offset += DepositClearingFundODATAItem.TOTAL_WIDTH;
             BalanceInfoList.Add(item);
         }
     }
     return this;
 }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= CoreDataBlockHeader.TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
         int offset = 0;
         while (offset < messagebytes.Length)
         {
             byte[] dbbytes = CommonDataHelper.SubBytes(messagebytes, offset, messagebytes.Length - offset);
             dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(dbbytes);
             if (dbhdr == null)
             {
                 offset += CoreDataBlockHeader.TOTAL_WIDTH;
                 continue;
             }
             RetrieveAcctCrntBalanceODATA_Item item = new RetrieveAcctCrntBalanceODATA_Item();
             item = (RetrieveAcctCrntBalanceODATA_Item)item.FromBytes(dbbytes);
             offset += (RetrieveAcctCrntBalanceODATA_Item.TOTAL_WIDTH + CoreDataBlockHeader.TOTAL_WIDTH);
             BalanceList.Add(item);
         }
     }
     return this;
 }
        public void DetailFromBytes(byte[] messagebytes)
        {
            if (messagebytes == null || messagebytes.Length < CoreDataBlockHeader.TOTAL_WIDTH)
            {
                return;
            }
            int len = messagebytes.Length;
            int offset = 0;

            while (len > 0)
            {
                byte[] buffer = new byte[CoreDataBlockHeader.TOTAL_WIDTH];
                Array.Copy(messagebytes, offset, buffer, 0, CoreDataBlockHeader.TOTAL_WIDTH);
                CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
                dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(buffer);
               
                offset += CoreDataBlockHeader.TOTAL_WIDTH;
                len -= CoreDataBlockHeader.TOTAL_WIDTH;
                if (dbhdr1 == null)
                {
                    continue;
                }
                if (len > 0)
                {
                    switch (dbhdr1.DBH_DB_ID.Trim())
                    {
                        case "@RPHDR":
                            buffer = new byte[RPHDR_MsgHandler.TOTAL_WIDTH];
                            Array.Copy(messagebytes, offset, buffer, 0, RPHDR_MsgHandler.TOTAL_WIDTH);
                            RPhdrHandler = (RPHDR_MsgHandler)RPhdrHandler.FromBytes(buffer);
                            len -= RPHDR_MsgHandler.TOTAL_WIDTH;
                            offset += RPHDR_MsgHandler.TOTAL_WIDTH;
                            break;

                        case "@ODATA":
                            UInt16 odataLen = (UInt16)(dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH);
                            buffer = new byte[odataLen];
                            Array.Copy(messagebytes, offset, buffer, 0, odataLen);
                            ODATA_FromBytes(buffer);
                            len -= odataLen;
                            offset += odataLen;
                            break;
                        case "@OBDATA":
                            UInt32 obdataLen = dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                            buffer = new byte[obdataLen];
                            Array.Copy(messagebytes, offset, buffer, 0, obdataLen);
                            OBDATA_FromBytes(buffer);
                            len -= (Int32)obdataLen;
                            offset += (Int32)obdataLen;
                            break;

                        case "@OMSG":
                            UInt32 omsgLen = dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                            buffer = new byte[omsgLen];
                            Array.Copy(messagebytes, offset, buffer, 0, omsgLen);
                            OmsgHandler = (OMSG_MsgHandler)OmsgHandler.FromBytes(buffer);
                            len -= (int)omsgLen;
                            offset += (int)omsgLen;
                            break;

                        case "@SYSERR":
                            int syserrLen = (int)dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                            buffer = new byte[syserrLen];
                            //ms.Read(buffer, offset, (int)syserrLen);
                            Array.Copy(messagebytes, offset, buffer, 0, syserrLen);
                            SyserrHandler = (SYSERR_MsgHandler)SyserrHandler.FromBytes(buffer);
                            len -= (int)syserrLen;
                            offset += (int)syserrLen;
                            break;
                        default:
                            break;
                    }

                }
            }
        }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
         dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(messagebytes);
         messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
         OrgNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
         Currency = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
         Subject = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
         PerviousBalance = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
         DebitAmount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
         CreditAmount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
         CurrentBalance = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
         FloorAmount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
         OffsetBalance = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
     }
     return this;
 }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
         dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(messagebytes);
         messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
         AcctNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
         AcctProperty = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
         ResultFlag = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
         Balance = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
         BalanceDirection = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
     }
     return this;
 }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
         dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
         if (dbhdr.DBH_DB_ID.Trim() == "BGO30803")
         {
             messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
             Currency = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3);
             //string amount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17);
             //decimal quotaAmount;
             //if (Decimal.TryParse(amount, out quotaAmount))
             //{
             //    QuotaAmount = quotaAmount;
             //}
             QuotaAmount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17);
         }
         
     }
     
     return this;
 }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
                dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(messagebytes);
                messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                AccountNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                OrgnaztionNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                Currcency = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
                SubjectNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                SequenceNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 4).TrimEnd();
                AccountName = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                PreviousTradeDate = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                PreviousBalanceDirection = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                PreviousBalance = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                BalanceDirection = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                CurrentBalance = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                OverdraftLimitation = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                Rate = CommonDataHelper.GetValueFromBytes(ref messagebytes, 10).TrimEnd();
                OverdraftRate = CommonDataHelper.GetValueFromBytes(ref messagebytes, 10).TrimEnd();
                InterestCumulation = CommonDataHelper.GetValueFromBytes(ref messagebytes, 19).TrimEnd();
                OverdraftCumulation = CommonDataHelper.GetValueFromBytes(ref messagebytes, 19).TrimEnd();
                UsageRange = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                IsEliminate = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                IsExchangePay = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                SettlementType = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                IsSettlementWithAccount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                IncomeAccount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                PaymentAccount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                AccountStatus = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                AccountOrgan = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                HeadOrgan = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                CirculateExchangeLevel = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                AccountDate = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                AccountTeller = CommonDataHelper.GetValueFromBytes(ref messagebytes, 7).TrimEnd();
                
            }

            return this;
        }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
                if (dbhdr.DBH_DB_ID != null && dbhdr.DBH_DB_ID.Trim() == "BY999001")
                {
                    messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                    GL_SEQ = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                    ACC_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                    ACC_NAME = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                    DRCR_IND = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                    TX_AMT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                    //string amount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17);
                    //decimal tradeAmt;
                    //if (Decimal.TryParse(amount, out tradeAmt))
                    //{
                    //    TX_AMT = tradeAmt;
                    //}
                    TX_CCY = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
                }
            }

            return this;
        }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
                if (dbhdr.DBH_DB_ID.Trim() == "BGO30802")
                {
                    messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                    IsQuotaMoney = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                    String val = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2);
                    UInt16 count;
                    if (UInt16.TryParse(val, out count))
                    {
                        QuotaMoneyCount = count;
                    }
                }
            }

            return this;
        }
        public object FromBytes(byte[] messagebytes)
        {
            // MessageHeader
            byte[] buffer = new byte[CoreMessageHeader.TOTAL_WIDTH];
            if (messagebytes.Length >= buffer.Length)
            {
                Array.Copy(messagebytes, buffer, buffer.Length);
            }
            else
            {
                return null;
            }
            CoreMessageHeader msgHeader = new CoreMessageHeader();
            msgHeader.FromBytes(buffer);

            UInt32 mbLen = msgHeader.MH_MESSAGE_LENGTH - CoreMessageHeader.TOTAL_WIDTH;
            messagebytes = CommonDataHelper.SubBytes(messagebytes, (int)CoreMessageHeader.TOTAL_WIDTH, (int)mbLen);

            // MessageBody
            int len = messagebytes.Length;
            int offset = 0;

            while (len > 0)
            {
                buffer = new byte[CoreDataBlockHeader.TOTAL_WIDTH];
                Array.Copy(messagebytes, offset, buffer, 0, CoreDataBlockHeader.TOTAL_WIDTH);
                CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
                dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(buffer);
                len -= CoreDataBlockHeader.TOTAL_WIDTH;
                offset += CoreDataBlockHeader.TOTAL_WIDTH;
                if (len > 0)
                {
                    switch (dbhdr1.DBH_DB_ID.Trim())
                    {
                        case "@RPHDR":
                            buffer = new byte[RPHDR_MsgHandler.TOTAL_WIDTH];
                            Array.Copy(messagebytes, offset, buffer, 0, RPHDR_MsgHandler.TOTAL_WIDTH);
                            RPhdrHandler = (RPHDR_MsgHandler)RPhdrHandler.FromBytes(buffer);
                            len -= RPHDR_MsgHandler.TOTAL_WIDTH;
                            offset += RPHDR_MsgHandler.TOTAL_WIDTH;
                            break;

                        case "@ODATA":
                            //buffer = new byte[GetODATALen()];
                            UInt16 odataLen = (UInt16)(dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH);
                            buffer = new byte[odataLen];
                            Array.Copy(messagebytes, offset, buffer, 0, odataLen);
                            //Array.Copy(messagebytes, offset, buffer, 0, GetODATALen());
                            //OData = (RetrieveCstmODATA)OData.FromBytes(buffer);
                            ODATA_FromBytes(buffer);
                            len -= odataLen;
                            offset += odataLen;
                            //len -= GetODATALen();
                            //offset += GetODATALen();
                            break;
                        //case "@OBDATA":
                        //    UInt32 obdataLen = dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                        //    buffer = new byte[obdataLen];
                        //    Array.Copy(messagebytes, offset, buffer, 0, obdataLen);
                        //    OBDATA_FromBytes(buffer);
                        //    len -= (Int32)obdataLen;
                        //    offset += (Int32)obdataLen;
                        //    break;

                        case "@OMSG":
                            UInt32 omsgLen = dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                            buffer = new byte[omsgLen];
                            Array.Copy(messagebytes, offset, buffer, 0, omsgLen);
                            OmsgHandler = (OMSG_MsgHandler)OmsgHandler.FromBytes(buffer);
                            len -= (int)omsgLen;
                            offset += (int)omsgLen;
                            break;

                        case "@SYSERR":
                            int syserrLen = (int)dbhdr1.DBH_DB_LENGTH - CoreDataBlockHeader.TOTAL_WIDTH;
                            buffer = new byte[syserrLen];
                            //ms.Read(buffer, offset, (int)syserrLen);
                            Array.Copy(messagebytes, offset, buffer, 0, syserrLen);
                            SyserrHandler = (SYSERR_MsgHandler)SyserrHandler.FromBytes(buffer);
                            len -= (int)syserrLen;
                            offset += (int)syserrLen;
                            break;
                        default:
                            len--;
                            break;

                    }
                }
            }

            return this;
        }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
         dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
         if (dbhdr.DBH_DB_ID.Trim() == "BG203300")
         {
             messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
             FlowNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 18).TrimEnd();
             InnerSN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
             PendingSN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 14).TrimEnd();
             PendingAccount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
             PendingAmount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
         }
     }
     return this;
 }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
                dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(messagebytes);
                messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                CUS_CDE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 11).TrimEnd();
                CUS_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 23).TrimEnd();
                CUS_TYP = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                CUS_NAM = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                CUS_ONAM = CommonDataHelper.GetValueFromBytes(ref messagebytes, 30).TrimEnd();
                CUS_ENAM = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                NATION = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
                VIP_TYP = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                CUS_STS = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                ADD_SN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                ADDR = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                TEL_SN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                TEL_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                MBL_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                ZIP = CommonDataHelper.GetValueFromBytes(ref messagebytes, 10).TrimEnd();
                CMB_QYLX = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
                CRT_PDT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                CRT_OPR = CommonDataHelper.GetValueFromBytes(ref messagebytes, 7).TrimEnd();
                CRT_DTE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                UP_PDT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                UP_OPR = CommonDataHelper.GetValueFromBytes(ref messagebytes, 7).TrimEnd();
                UP_DTE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
            }

            return this;
        }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
                dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(messagebytes);
                messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                ACCOUNT_DATE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                NOTICE_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                NOTICE_TYPE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                BUSINESS_TYPE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                ACCOUNT_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 15).TrimEnd();
                CURRENCY = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
                CUSTOMER_TYPE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                CASH_PROPERTY = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                PRODUCT_TYPE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                PRODUCT_CODE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
                DEPOSIT_TYPE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                ACCOUNT_PROPERTY = CommonDataHelper.GetValueFromBytes(ref messagebytes, 4).TrimEnd();
                ACCOUNT_TYPE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                CURRENT_ACCOUNT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 22).TrimEnd();
                INTEREST_ACCOUNT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 22).TrimEnd();
                FIXED_NEW_ACCOUNT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 15).TrimEnd();
                VOUCHER_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                VOUCHER_NEW_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                AUTO_REDEPO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                DEPOSIT_TERM = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
                VALUE_DATE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                MATURITY_DATE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                AMOUNT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                RATE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 11).TrimEnd();
                INTEREST_BEARING_MANNER = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                INTEREST = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                CUSTOMER_CODE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 11).TrimEnd();
                BANK_FLAG = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                HANDLE_ORGNAZTION = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                APPROVE_ORGNAZTION = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                HANDLE_TELLER = CommonDataHelper.GetValueFromBytes(ref messagebytes, 7).TrimEnd();
                APPROVE_TELLER = CommonDataHelper.GetValueFromBytes(ref messagebytes, 7).TrimEnd();
                HANDLE_FLAG = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                TRADE_FLOW_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                CHILD_TRADE_FLOW_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                TELLER_FLOW_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 11).TrimEnd();
                RECORD_FLAG = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                BOOK_TYPE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                ACCOUNT_NAME = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                BALANCE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                SUM_AMOUNT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                RESERVE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 100).TrimEnd();
                ORIGNAL_ACCOUNT_NAME = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                ORIGNAL_ACCOUNT_ORG = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                CANCEL_ACCOUNT_ORG = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
            }

            return this;
        }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
                messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                CUS_CDE = CommonDataHelper.GetValueFromBytes(ref messagebytes, 11).TrimEnd();
                CUS_NAM = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                ADDR = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                ADSNPTSN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                TEL_SN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                TEL_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
            }

            return this;
        }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
         dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
         if (dbhdr.DBH_DB_ID.Trim() == "BXO00008")
         {
             messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
             ACCT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
             GL_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
             CCY = CommonDataHelper.GetValueFromBytes(ref messagebytes, 3).TrimEnd();
             CD_IND = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
             AMT = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
             GL_SEQ = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
         }
     }
     return this;
 }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                int totalLen = messagebytes.Length;
                int offset = 0;
                while (offset < totalLen)
                {
                    byte[] subMessage = CommonDataHelper.SubBytes(messagebytes, offset, totalLen - offset);
                    CoreDataBlockHeader dbhdr1 = new CoreDataBlockHeader();
                    dbhdr1 = (CoreDataBlockHeader)dbhdr1.FromBytes(subMessage);
                    offset += (int)dbhdr1.DBH_DB_LENGTH;
                    if (dbhdr1.DBH_DB_ID.Trim() == "BDO75112")
                    {
                        subMessage = CommonDataHelper.SubBytes(subMessage, CoreDataBlockHeader.TOTAL_WIDTH, subMessage.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                        AccountNO = CommonDataHelper.GetValueFromBytes(ref subMessage, 22).TrimEnd();
                        Currency = CommonDataHelper.GetValueFromBytes(ref subMessage, 3).TrimEnd();
                        ExchangeType = CommonDataHelper.GetValueFromBytes(ref subMessage, 1).TrimEnd();
                        CashFlag = CommonDataHelper.GetValueFromBytes(ref subMessage, 1).TrimEnd();
                        AccountStatus = CommonDataHelper.GetValueFromBytes(ref subMessage, 1).TrimEnd();
                        AcctStatusWord = CommonDataHelper.GetValueFromBytes(ref subMessage, 16).TrimEnd();
                        PartyFrozenFlag = CommonDataHelper.GetValueFromBytes(ref subMessage, 2).TrimEnd();
                        CurrentBalance = CommonDataHelper.GetValueFromBytes(ref subMessage, 17).TrimEnd();
                        AvailableBalance = CommonDataHelper.GetValueFromBytes(ref subMessage, 17).TrimEnd();
                        FrozenBalance = CommonDataHelper.GetValueFromBytes(ref subMessage, 17).TrimEnd();
                        EndPayBalance = CommonDataHelper.GetValueFromBytes(ref subMessage, 17).TrimEnd();
                        KeepingBalance = CommonDataHelper.GetValueFromBytes(ref subMessage, 17).TrimEnd();
                        AuthBalance = CommonDataHelper.GetValueFromBytes(ref subMessage, 17).TrimEnd();
                        OpenDate = CommonDataHelper.GetValueFromBytes(ref subMessage, 8).TrimEnd();
                        SettleDate = CommonDataHelper.GetValueFromBytes(ref subMessage, 8).TrimEnd();
                        CheckOrg = CommonDataHelper.GetValueFromBytes(ref subMessage, 6).TrimEnd();
                        BelongOrg = CommonDataHelper.GetValueFromBytes(ref subMessage, 6).TrimEnd();
                        ActingSubject = CommonDataHelper.GetValueFromBytes(ref subMessage, 8).TrimEnd();
                        LatestDepositDate = CommonDataHelper.GetValueFromBytes(ref subMessage, 8).TrimEnd();
                        CalcInterestFlag = CommonDataHelper.GetValueFromBytes(ref subMessage, 1).TrimEnd();
                    }
                    
                }
            }

            return this;
        }
 public object FromBytes(byte[] messagebytes)
 {
     if (messagebytes.Length >= TOTAL_WIDTH)
     {
         CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
         dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
         if (dbhdr.DBH_DB_ID.Trim() == "BG203301")
         {
             messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
             CoreSN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 11).TrimEnd();
         }
     }
     return this;
 }
        public object FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
                if (dbhdr.DBH_DB_ID.Trim() == "BGO30800")
                {
                    messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                    CoreTradeSN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 12).TrimEnd();
                    SrcSystemCode = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                    AcctSNFlag = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                    OutsideSN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 12).TrimEnd();
                    ErasedFlag = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                }
            }

            return this;
        }
        public object  FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
                if (dbhdr.DBH_DB_ID.Trim() == "BGO30801")
                {
                    messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                    CoreTradeSN = CommonDataHelper.GetValueFromBytes(ref messagebytes, 12).TrimEnd();
                    TradeAccount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                    AccountName = CommonDataHelper.GetValueFromBytes(ref messagebytes, 80).TrimEnd();
                    CashFalg = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                    LoanFlag = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                    //string value = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17);
                    //decimal amount;
                    //if (Decimal.TryParse(value, out amount))
                    //{
                    //    Amount = amount;
                    //}
                    Amount = CommonDataHelper.GetValueFromBytes(ref messagebytes, 17).TrimEnd();
                    VoucherNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 20).TrimEnd();
                    SrcSystemCode = CommonDataHelper.GetValueFromBytes(ref messagebytes, 2).TrimEnd();
                    PostingCashFlag = CommonDataHelper.GetValueFromBytes(ref messagebytes, 1).TrimEnd();
                }

            }

            return this;
        }
        public object  FromBytes(byte[] messagebytes)
        {
            if (messagebytes.Length >= TOTAL_WIDTH)
            {
                CoreDataBlockHeader dbhdr = new CoreDataBlockHeader();
                dbhdr = (CoreDataBlockHeader)dbhdr.FromBytes(messagebytes);
                if (dbhdr.DBH_DB_ID !=null && dbhdr.DBH_DB_ID.Trim() == "BY999000")
                {
                    messagebytes = CommonDataHelper.SubBytes(messagebytes, CoreDataBlockHeader.TOTAL_WIDTH, messagebytes.Length - CoreDataBlockHeader.TOTAL_WIDTH);
                    TIME = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                    JNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 12).TrimEnd();
                    Date = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                    TX_TIME = CommonDataHelper.GetValueFromBytes(ref messagebytes, 8).TrimEnd();
                    TEL_NO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 7).TrimEnd();
                    TX_ID = CommonDataHelper.GetValueFromBytes(ref messagebytes, 6).TrimEnd();
                    TX_JNO = CommonDataHelper.GetValueFromBytes(ref messagebytes, 12).TrimEnd();                    
                }
            }

            return this;
        }