/// <summary>
        /// Create tab panel for Version window's Tab
        /// </summary>
        /// <param name="tab"></param>
        public void CreateVerTabPanel(MTab tab)
        {
            int AD_TabPanel_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT AD_TabPanel_ID FROM AD_TabPanel WHERE Classname = '" + className + "' AND AD_Tab_ID = " + tab.GetAD_Tab_ID(), null, null));

            if (AD_TabPanel_ID <= 0)
            {
                MTabPanel tbPnl = new MTabPanel(GetCtx(), 0, Get_TrxName());
                tbPnl.SetAD_Client_ID(tab.GetAD_Client_ID());
                tbPnl.SetAD_Org_ID(tab.GetAD_Org_ID());
                tbPnl.SetAD_Tab_ID(tab.GetAD_Tab_ID());
                tbPnl.SetAD_Window_ID(tab.GetAD_Window_ID());
                tbPnl.SetClassname(className);
                tbPnl.SetName(tab.GetName() + " " + Msg.GetMsg(GetCtx(), "VersionHistory"));
                tbPnl.SetIsDefault(true);
                tbPnl.SetSeqNo(Util.GetValueOfInt(DB.ExecuteScalar("SELECT (NVL(MAX(SeqNo), 0) + 10) FROM AD_TabPanel WHERE AD_Tab_ID = " + tab.GetAD_Tab_ID(), null, null)));
                if (!tbPnl.Save())
                {
                    log.SaveError("MasterVerField", "Tab Panel data not created");
                }
            }
        }
        /// <summary>
        /// process logic (to create master version window and Tab)
        /// </summary>
        /// <returns></returns>
        protected override string DoIt()
        {
            if (_AD_Tab_ID <= 0)
            {
                _AD_Tab_ID = GetRecord_ID();
            }

            if (_AD_Tab_ID <= 0)
            {
                return(Msg.GetMsg(GetCtx(), "TabNotFound"));
            }

            int Ver_AD_Window_ID = 0;
            int Ver_AD_Tab_ID    = 0;

            // Created object of MTab with Tab ID (either selected from parameter or from Record ID)
            MTab tab = new MTab(GetCtx(), _AD_Tab_ID, Get_TrxName());

            if (!(Util.GetValueOfString(DB.ExecuteScalar("SELECT IsMaintainVersions FROM AD_Table WHERE AD_Table_ID = " + tab.GetAD_Table_ID(), null, Get_TrxName())) == "Y"))
            {
                // Checked whether there are any columns with the table which is marked as "Maintain Versions"
                // if no such column found then return message
                if (Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_Column_ID) FROM AD_Column WHERE AD_Table_ID = " + tab.GetAD_Table_ID() + " AND IsMaintainVersions = 'Y'", null, Get_TrxName())) <= 0)
                {
                    return(Msg.GetMsg(GetCtx(), "NoVerColFound"));
                }
            }

            // Always called this function so that in case if new column is added
            // to table this function creates new columns to table
            CreateMasterVersionTable(0, tab.GetAD_Table_ID());
            int Ver_AD_Table_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT AD_Table_ID FROM AD_Table WHERE TableName = ((SELECT TableName FROM AD_Table WHERE AD_Table_ID = " + tab.GetAD_Table_ID() + ") || '_Ver')"));

            if (Ver_AD_Table_ID <= 0)
            {
                return(Msg.GetMsg(GetCtx(), "VerTableNotFound"));
            }

            // Get Display Name of Window linked with the tab
            string displayName = Util.GetValueOfString(DB.ExecuteScalar("SELECT Name FROM AD_Window WHERE AD_Window_ID = " + tab.GetAD_Window_ID(), null, Get_TrxName())) + " Version";

            Ver_AD_Window_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT AD_Window_ID FROM AD_Window WHERE Name = '" + displayName + "_" + tab.GetName() + "'", null, Get_TrxName()));
            // Check if Version window do not exist, then create new version window
            if (Ver_AD_Window_ID <= 0)
            {
                Ver_AD_Window_ID = CreateVerWindow(displayName, tab.GetName());
                // if window not created then return message
                if (Ver_AD_Window_ID <= 0)
                {
                    return(Msg.GetMsg(GetCtx(), "VersionWinNotCreated"));
                }
                else
                {
                    // Update Version Window ID on Version Table
                    DB.ExecuteQuery("UPDATE AD_Table SET AD_Window_ID = " + Ver_AD_Window_ID + " WHERE  AD_Table_ID = " + Ver_AD_Table_ID, null, Get_Trx());
                }
            }

            // check access for Version window
            int countAcc = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(AD_Role_ID) FROM AD_Window_Access WHERE AD_Window_ID = " + Ver_AD_Window_ID + " AND IsReadWrite = 'Y'", null, Get_Trx()));

            if (countAcc <= 0)
            {
                // Provide access to Version window, for the roles which parent (Master window) has
                countAcc = Util.GetValueOfInt(DB.ExecuteQuery(@"UPDATE AD_Window_Access SET IsReadWrite = 'Y' WHERE AD_Window_ID = " + Ver_AD_Window_ID + @" 
                            AND AD_Role_ID IN (SELECT AD_Role_ID FROM AD_Window_Access WHERE AD_Window_ID = " + tab.GetAD_Window_ID() + @"  AND IsReadWrite = 'Y')", null, Get_Trx()));
            }

            // check for version tab
            Ver_AD_Tab_ID = Util.GetValueOfInt(DB.ExecuteScalar("SELECT AD_Tab_ID FROM AD_Tab WHERE AD_Window_ID = " + Ver_AD_Window_ID, null, Get_TrxName()));
            // if version tab do not exist, then create new version tab
            if (Ver_AD_Tab_ID <= 0)
            {
                Ver_AD_Tab_ID = CreateVerTab(tab, Ver_AD_Window_ID, Ver_AD_Table_ID);
            }
            else
            {
                MTab verTab = new MTab(GetCtx(), Ver_AD_Tab_ID, Get_TrxName());
                CreateVerTabPanel(verTab);
            }

            // if version tab not found then return message
            if (Ver_AD_Tab_ID <= 0)
            {
                return(Msg.GetMsg(GetCtx(), "VersionTabNotCreated"));
            }

            // Create fields against version Tab
            string retMsg = CreateVerFields(tab, Ver_AD_Tab_ID, Ver_AD_Table_ID);

            if (retMsg != "")
            {
                return(retMsg);
            }

            return(Msg.GetMsg(GetCtx(), "VersionWindowCreated"));
        }