Esempio n. 1
0
        public void DrawOpeningPage()
        {
            try
            {
                int iColNo = 0;
                int iSectionId = 0;
                string sId = m_sPassedId;
                float iVert = 0f;
                float iPwrIdRowVertInner = 0f;
                float iSectionHdrRowHeight = 40f;
                float iTotalHeight = 0f;
                float iHeightToAdd = 0f;
                bool bHideComplete = true;
                bool bHideSectionComplete = true;
                bool bFullyCommitted = false;
                bool bRFUPwrIdCommitted = false;
                UIView[] arrItems4 = new UIView[8];
                UIView[] arrItems5 = new UIView[8];

                //Get some static data for dropdowns only once so we don't reprocess unecessarily
                clsTabletDB.ITPInventory ITPInventory = new clsTabletDB.ITPInventory();
                string[] sBatteryMakes = ITPInventory.GetBatteryMakes();
                m_sBatteryMakes = sBatteryMakes;

                UIScrollView layout = new UIScrollView();
                layout.Frame = new RectangleF(0f,35f,1000f,620f);
                layout.Tag = 2;
                clsTabletDB.ITPDocumentSection ITPSection = new clsTabletDB.ITPDocumentSection();
                //******************************************************************************************//
                //                      SECTION 10 (BATTERIES)                                              //
                //******************************************************************************************//
                //Get all the PwrId's for this project from ITPSection10
                DataSet arrITPSection10PwrIds = ITPSection.GetLocalITPSection10PwrIds(sId, 6);

                if (arrITPSection10PwrIds.Tables.Count > 0)
                {
                    int ii = 0;
                    m_iSections++; //Add an extra one for the batteries section
                    m_iBatterySectionCounter = ii;
                    int iPwrIdRows = arrITPSection10PwrIds.Tables[0].Rows.Count;
                    m_iPwrdIdRows = iPwrIdRows;

                    //Add in the section title and buttons for each section header
                    UIView Section10Row = new UIView();
                    float iSection10RowVertTop = iVert;
                    Section10Row.Frame = new RectangleF(0f,iSection10RowVertTop,1000f,iSectionHdrRowHeight);
                    iSectionId = iSectionTagId * (ii+1);
                    Section10Row.Tag = iSectionId;
                    layout.AddSubview(Section10Row);

                    UILabel hfSection10 = new UILabel();
                    hfSection10.Text = "10";
                    hfSection10.Tag = iSectionDBIdTagId * (ii+1);
                    hfSection10.Hidden = true;
                    Section10Row.AddSubview(hfSection10);

                    iUtils.CreateFormGridItem Section10 = new iUtils.CreateFormGridItem();
                    UIView Section10Vw = new UIView();
                    Section10.SetDimensions(0f,0f, 400f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f);
                    Section10.SetLabelText("BATTERIES");
                    Section10.SetBorderWidth(0.0f);
                    Section10.SetFontName("Verdana-Bold");
                    Section10.SetTextColour("White");
                    Section10.SetFontSize(12f);
                    Section10.SetCellColour("DarkSlateGrey");
                    Section10.SetTag(iSectionDescTagId * (ii+1));
                    Section10Vw = Section10.GetLabelCell();
                    arrItems4[0] = Section10Vw;

                    if(BatteryFullyCommitted())
                    {
                        bFullyCommitted = true;
                        bHideComplete = false;
                    }
                    else
                    {
                        bFullyCommitted = false;
                        if(BatteryFullyComplete())
                        {
                            bHideComplete = false;
                        }
                        else
                        {
                            bHideComplete = true;
                        }
                    }

                    iUtils.CreateFormGridItem SectionCompleteLabel = new iUtils.CreateFormGridItem();
                    UIView SectionCompleteLabelVw = new UIView();
                    SectionCompleteLabel.SetDimensions(400f,0f, 150f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f);
                    if(bFullyCommitted)
                    {
                        SectionCompleteLabel.SetLabelText("COMMITTED");
                    }
                    else
                    {
                        SectionCompleteLabel.SetLabelText("COMPLETED");
                    }
                    SectionCompleteLabel.SetBorderWidth(0.0f);
                    SectionCompleteLabel.SetFontName("Verdana-Bold");
                    SectionCompleteLabel.SetTextColour("Bright Yellow");
                    SectionCompleteLabel.SetFontSize(14f);
                    SectionCompleteLabel.SetCellColour("DarkSlateGrey");
                    SectionCompleteLabel.SetTag(iSectionCompleteLabelTagId * (ii+1));
                    SectionCompleteLabel.SetHidden(bHideComplete);
                    SectionCompleteLabelVw = SectionCompleteLabel.GetLabelCell();
                    arrItems4[1] = SectionCompleteLabelVw;

                    iUtils.CreateFormGridItem btnSave10 = new iUtils.CreateFormGridItem();
                    UIView btnSave10Vw = new UIView();
                    btnSave10.SetDimensions(550f,0f, 150f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                    btnSave10.SetLabelText("Save Section");
                    btnSave10.SetBorderWidth(0.0f);
                    btnSave10.SetFontName("Verdana");
                    btnSave10.SetFontSize(12f);
                    btnSave10.SetHidden(true);
                    btnSave10.SetTag(iSaveSectionBtnTagId * (ii+1));
                    btnSave10.SetCellColour("DarkSlateGrey");
                    btnSave10Vw = btnSave10.GetButtonCell();

                    UIButton btnSave10Button = new UIButton();
                    btnSave10Button = btnSave10.GetButton();
                    btnSave10Button.TouchUpInside += (sender,e) => {SaveThisSection(sender, e);};

                    arrItems4[2] = btnSave10Vw;

                    iUtils.CreateFormGridItem btnExpand10 = new iUtils.CreateFormGridItem();
                    UIView btnExpand10Vw = new UIView();
                    btnExpand10.SetDimensions(700f,0f, 50f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                    btnExpand10.SetLabelText("+");
                    btnExpand10.SetBorderWidth(0.0f);
                    btnExpand10.SetFontName("Verdana");
                    btnExpand10.SetFontSize(12f);
                    btnExpand10.SetTag(iExpandSectionBtnTagId * (ii+1));
                    btnExpand10.SetCellColour("DarkSlateGrey");
                    btnExpand10Vw = btnExpand10.GetButtonCell();

                    UIButton btnExpand10Button = new UIButton();
                    btnExpand10Button = btnExpand10.GetButton();
                    btnExpand10Button.Enabled = false;
                    btnExpand10Button.TouchUpInside += (sender,e) => {ExpandSection(sender, e);};

                    arrItems4[3] = btnExpand10Vw;

                    iUtils.CreateFormGridItem btnContract10 = new iUtils.CreateFormGridItem();
                    UIView btnContract10Vw = new UIView();
                    btnContract10.SetDimensions(750f,0f, 50f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                    btnContract10.SetLabelText("-");
                    btnContract10.SetBorderWidth(0.0f);
                    btnContract10.SetFontName("Verdana");
                    btnContract10.SetFontSize(12f);
                    btnContract10.SetTag(iContractSectionBtnTagId * (ii+1));
                    btnContract10.SetCellColour("DarkSlateGrey");
                    btnContract10Vw = btnContract10.GetButtonCell();

                    UIButton btnContract10Button = new UIButton();
                    btnContract10Button = btnContract10.GetButton();
                    btnContract10Button.TouchUpInside += (sender,e) => {ContractSection(sender, e);};

                    arrItems4[4] = btnContract10Vw;

                    UILabel hfSectionHeight = new UILabel();
                    hfSectionHeight.Tag = iSectionHeightTagId * (ii+1);
                    hfSectionHeight.Hidden = true;
                    hfSectionHeight.Text = "0";
                    arrItems4[5] = hfSectionHeight;

                    UILabel hfSectionRows = new UILabel();
                    hfSectionRows.Tag = iSectionRowsTagId * (ii+1);
                    hfSectionRows.Hidden = true;
                    hfSectionRows.Text = iPwrIdRows.ToString();
                    arrItems4[6] = hfSectionRows;

                    UILabel hfSectionStatus = new UILabel();
                    hfSectionStatus.Tag = iSectionStatusTagId * (ii+1);
                    hfSectionStatus.Hidden = true;
                    hfSectionStatus.Text = "0";
                    arrItems4[7] = hfSectionStatus;

                    Section10Row.AddSubviews(arrItems4);

                    iVert += iSectionHdrRowHeight;

                    //Now add a new view to this view to hold another view containing all the pwrid info for this section 10
                    UIView PwrIdTableRow = new UIView();
                    PwrIdTableRow.Frame = new RectangleF(0f,iVert,1000f,iSectionHdrRowHeight);
                    iSectionId = iContainerSectionTagId * (ii+1);
                    PwrIdTableRow.Tag = iSectionId;
                    layout.AddSubview(PwrIdTableRow);
                    float iPwrIdRowVert = 0.0f;
                    float iSectionPwrIdHeight = 0.0f;
                    float iPwrIdRowVertTop = iVert;
                    float iPwrIdRowInnerTop = 0.0f;
                    float iPwrIdRowInnerTop2 = 0.0f;

                    for (var j = 0; j < iPwrIdRows; j++)
                    {
                        iPwrIdRowInnerTop2 = 0.0f;
                        UIView vwPwrInternalRowId = new UIView();
                        vwPwrInternalRowId.Frame = new RectangleF(0f,iPwrIdRowVert,1000f,200f); //This will be resized later on
                        vwPwrInternalRowId.Tag = (iPwrIdSectionTagId + (j+1)) * (ii+1);

                        UILabel hfRow10Status = new UILabel();
                        hfRow10Status.Text = "0";
                        hfRow10Status.Tag = (ihfRow10StatusTagId + (j+1)) * (ii+1);
                        hfRow10Status.Hidden = true;
                        arrItems5[0] = hfRow10Status;

                        //Put in the PwrId Label
                        iUtils.CreateFormGridItem rowPwrIdLabel = new iUtils.CreateFormGridItem();
                        UIView rowPwrIdLabelVw = new UIView();
                        iColNo = arrITPSection10PwrIds.Tables[0].Columns["PwrId"].Ordinal;
                        string sPwrId = arrITPSection10PwrIds.Tables[0].Rows[j].ItemArray[iColNo].ToString();
                        rowPwrIdLabel.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                        rowPwrIdLabel.SetDimensions(0f,iPwrIdRowVert, 200f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                        rowPwrIdLabel.SetLabelText(sPwrId);
                        rowPwrIdLabel.SetBorderWidth(0.0f);
                        rowPwrIdLabel.SetFontName("Verdana-Bold");
                        rowPwrIdLabel.SetFontSize(18f);
                        rowPwrIdLabel.SetTag((iPwrIdRowLabelTagId + (j+1)) * (ii+1));

                        if (j % 2 == 0)
                        {
                            rowPwrIdLabel.SetCellColour("Pale Yellow");
                        }
                        else
                        {
                            rowPwrIdLabel.SetCellColour("Pale Orange");
                        }

                        rowPwrIdLabelVw = rowPwrIdLabel.GetLabelCell();
                        iHeightToAdd = iSectionHdrRowHeight;
                        arrItems5[1] = rowPwrIdLabelVw;

                        bRFUPwrIdCommitted = RFUPwrIdCommitted(sPwrId);

                        iUtils.CreateFormGridItem btnNewBatteryString = new iUtils.CreateFormGridItem();
                        UIView btnNewBatteryStringVw = new UIView();
                        btnNewBatteryString.SetDimensions(200f,iPwrIdRowVert, 200f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                        btnNewBatteryString.SetLabelText("New Battery Block/String");
                        btnNewBatteryString.SetBorderWidth(0.0f);
                        btnNewBatteryString.SetFontName("Verdana");
                        btnNewBatteryString.SetFontSize(12f);
                        btnNewBatteryString.SetTag((iPwrIdNewBtnTagId + (j+1)) * (ii+1));
                        if (j % 2 == 0)
                        {
                            btnNewBatteryString.SetCellColour("Pale Yellow");
                        }
                        else
                        {
                            btnNewBatteryString.SetCellColour("Pale Orange");
                        }
                        btnNewBatteryStringVw = btnNewBatteryString.GetButtonCell();

                        UIButton btnNewBatteryStringButton = new UIButton();
                        btnNewBatteryStringButton = btnNewBatteryString.GetButton();
                        btnNewBatteryStringButton.TouchUpInside += (sender,e) => {AddNewBatteryString(sender, e);};
                        if(bRFUPwrIdCommitted)
                        {
                            btnNewBatteryStringButton.Enabled = false;
                        }
                        arrItems5[2] = btnNewBatteryStringVw;

                        if(BatteryPwrIdComplete(sPwrId))
                        {
                            bHideSectionComplete = false;
                        }
                        else
                        {
                            bHideSectionComplete = true;
                        }
                        iUtils.CreateFormGridItem PwrIdCompleteLabel = new iUtils.CreateFormGridItem();
                        UIView PwrIdCompleteLabelVw = new UIView();
                        PwrIdCompleteLabel.SetDimensions(400f,0f, 150f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f);
                        if(bRFUPwrIdCommitted)
                        {
                            PwrIdCompleteLabel.SetLabelText("COMMITTED");
                            bHideSectionComplete = false;
                        }
                        else
                        {
                            PwrIdCompleteLabel.SetLabelText("COMPLETED");
                        }

                        PwrIdCompleteLabel.SetBorderWidth(0.0f);
                        PwrIdCompleteLabel.SetFontName("Verdana-Bold");
                        PwrIdCompleteLabel.SetTextColour("Royal Blue");
                        PwrIdCompleteLabel.SetFontSize(14f);
                        if (j % 2 == 0)
                        {
                            PwrIdCompleteLabel.SetCellColour("Pale Yellow");
                        }
                        else
                        {
                            PwrIdCompleteLabel.SetCellColour("Pale Orange");
                        }
                        PwrIdCompleteLabel.SetTag((iPwrIdSectionCompleteLabelTagId + (j+1)) * (ii+1));
                        PwrIdCompleteLabel.SetHidden(bHideSectionComplete);
                        PwrIdCompleteLabelVw = PwrIdCompleteLabel.GetLabelCell();
                        arrItems5[3] = PwrIdCompleteLabelVw;

                        iUtils.CreateFormGridItem rowPwrIdBlank = new iUtils.CreateFormGridItem();
                        UIView rowPwrIdBlankVw = new UIView();
                        rowPwrIdBlank.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                        rowPwrIdBlank.SetDimensions(550f,iPwrIdRowVert, 350f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                        rowPwrIdBlank.SetLabelText("");
                        rowPwrIdBlank.SetBorderWidth(0.0f);
                        rowPwrIdBlank.SetFontName("Verdana");
                        rowPwrIdBlank.SetFontSize(12f);
                        rowPwrIdBlank.SetTag((iPwrIdRowLabelTagId + (j+1)) * (ii+1));

                        if (j % 2 == 0)
                        {
                            rowPwrIdBlank.SetCellColour("Pale Yellow");
                        }
                        else
                        {
                            rowPwrIdBlank.SetCellColour("Pale Orange");
                        }

                        rowPwrIdBlankVw = rowPwrIdBlank.GetLabelCell();
                        arrItems5[4] = rowPwrIdBlankVw;

                        iUtils.CreateFormGridItem btnExpandPwrId = new iUtils.CreateFormGridItem();
                        UIView btnExpandPwrIdVw = new UIView();
                        btnExpandPwrId.SetDimensions(900f,0f, 50f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                        btnExpandPwrId.SetLabelText("+");
                        btnExpandPwrId.SetBorderWidth(0.0f);
                        btnExpandPwrId.SetFontName("Verdana");
                        btnExpandPwrId.SetFontSize(12f);
                        btnExpandPwrId.SetTag((iPwrIdExpandTagId + (j+1)) * (ii+1));
                        if (j % 2 == 0)
                        {
                            btnExpandPwrId.SetCellColour("Pale Yellow");
                        }
                        else
                        {
                            btnExpandPwrId.SetCellColour("Pale Orange");
                        }
                        btnExpandPwrIdVw = btnExpandPwrId.GetButtonCell();

                        UIButton btnExpandPwrIdButton = new UIButton();
                        btnExpandPwrIdButton = btnExpandPwrId.GetButton();
                        btnExpandPwrIdButton.Enabled = false;
                        btnExpandPwrIdButton.TouchUpInside += (sender,e) => {ExpandPwrId(sender, e, 1);};

                        arrItems5[5] = btnExpandPwrIdVw;

                        iUtils.CreateFormGridItem btnContractPwrId = new iUtils.CreateFormGridItem();
                        UIView btnContractPwrIdVw = new UIView();
                        btnContractPwrId.SetDimensions(950f,0f, 50f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                        btnContractPwrId.SetLabelText("-");
                        btnContractPwrId.SetBorderWidth(0.0f);
                        btnContractPwrId.SetFontName("Verdana");
                        btnContractPwrId.SetFontSize(12f);
                        btnContractPwrId.SetTag((iPwrIdContractTagId + (j+1)) * (ii+1));
                        if (j % 2 == 0)
                        {
                            btnContractPwrId.SetCellColour("Pale Yellow");
                        }
                        else
                        {
                            btnContractPwrId.SetCellColour("Pale Orange");
                        }
                        btnContractPwrIdVw = btnContractPwrId.GetButtonCell();

                        UIButton btnContractPwrIdButton = new UIButton();
                        btnContractPwrIdButton = btnContractPwrId.GetButton();
                        btnContractPwrIdButton.TouchUpInside += (sender,e) => {ContractPwrId(sender, e, 1);};

                        arrItems5[6] = btnContractPwrIdVw;

                        UILabel hfPwrIdSectionHeight = new UILabel();
                        hfPwrIdSectionHeight.Tag = (iPwrIdHeightTagId + (j+1)) * (ii+1);
                        hfPwrIdSectionHeight.Hidden = true;
                        hfPwrIdSectionHeight.Text = "0";
                        arrItems5[7] = hfPwrIdSectionHeight;

                        iHeightToAdd = iSectionHdrRowHeight;

                        //Now add the row details into the view
                        vwPwrInternalRowId.AddSubviews(arrItems5);

                        iSectionPwrIdHeight += iHeightToAdd;
                        iPwrIdRowVert += iHeightToAdd;
                        iVert += iHeightToAdd;
                        iPwrIdRowInnerTop2 += iHeightToAdd;

                        iPwrIdRowVertInner = 0f;
                        UIView vwPwrInternalRowIdInnner = new UIView();
                        vwPwrInternalRowIdInnner.Tag = (iPwrIdSectionInnerTagId + (j+1)) * (ii+1);
                        vwPwrInternalRowIdInnner.Frame = new RectangleF(0f,iPwrIdRowVertInner,1000f,200f); //This will be resized later on

                        UIView PwrIdHdr = BuildBatteryHeader(j, ref iHeightToAdd);
                        PwrIdHdr.Frame = new RectangleF(0f, iPwrIdRowVertInner, 1000f, iHeightToAdd);
                        vwPwrInternalRowIdInnner.AddSubview(PwrIdHdr);
                        vwPwrInternalRowId.AddSubview(vwPwrInternalRowIdInnner);

                        iSectionPwrIdHeight += iHeightToAdd;
                        iPwrIdRowVert += iHeightToAdd;
                        iPwrIdRowVertInner += iHeightToAdd;
                        iVert += iHeightToAdd;

                        //Now for each PwrId get the details for each string
                        DataSet arrITPSection10PwrIdStrings = ITPSection.GetLocalITPSection10PwrIdStringDetails(sId, sPwrId);

                        if (arrITPSection10PwrIdStrings.Tables.Count > 0)
                        {
                            int iPwrIdStringRows = arrITPSection10PwrIdStrings.Tables[0].Rows.Count;
                            //Add the rows to a hidden field so we know how many rows are in each PwrId battery block
                            UILabel hfPwrIdStringRows = new UILabel();
                            hfPwrIdStringRows.Text = iPwrIdStringRows.ToString();
                            hfPwrIdStringRows.Tag = (ihfPwrIdStringRowsTagId + (j+1)) * (ii+1);
                            hfPwrIdStringRows.Hidden = true;
                            vwPwrInternalRowIdInnner.AddSubview(hfPwrIdStringRows);

                            for (var k = 0; k < iPwrIdStringRows; k++)
                            {
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["AutoId"].Ordinal;
                                int iAutoId = Convert.ToInt32(arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo]);
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["BankNo"].Ordinal;
                                string sBankNo = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                string sBankPlane = sPwrId.Substring(sPwrId.Length - 2, 1);
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["Make"].Ordinal;
                                string sMake = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["Model"].Ordinal;
                                string sModel = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["SPN"].Ordinal;
                                string sSPN = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["DOM"].Ordinal;
                                string sDOM = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["FuseOrCB"].Ordinal;
                                string sFuseOrCB = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["RatingAmps"].Ordinal;
                                string sRatingAmps = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["Floor"].Ordinal;
                                string sFloor = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["Suite"].Ordinal;
                                string sSuite = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["Rack"].Ordinal;
                                string sRack = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["SubRack"].Ordinal;
                                string sSubRack = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["Equipment_Condition"].Ordinal;
                                string sEquipType = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["SerialBatch"].Ordinal;
                                string sSerialNo = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["tblMaximoPSA_ID"].Ordinal;
                                string sMaximoPSAId = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["tblMaximoTransfer_Eqnum"].Ordinal;
                                string sMaximoTransferId = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                if(sMaximoPSAId == "" || sMaximoPSAId == "0")
                                {
                                    sMaximoPSAId = "-1";
                                }
                                if(sMaximoTransferId == "" || sMaximoTransferId == "0")
                                {
                                    sMaximoTransferId = "-1";
                                }
                                int iMaximoPSAId = Convert.ToInt32(sMaximoPSAId);
                                int iMaximoTransferId = Convert.ToInt32(sMaximoTransferId);
                                int iMaximoAssetId = -1;

                                if(iMaximoPSAId > 0)
                                {
                                    iMaximoAssetId = iMaximoPSAId;
                                }
                                else if(iMaximoTransferId > 0)
                                {
                                    iMaximoAssetId = iMaximoTransferId;
                                }
                                else
                                {
                                    iMaximoAssetId = -1;
                                }
                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["LinkTest"].Ordinal;
                                string sLinkTest = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                int iLinkTest = 0;
                                if(sLinkTest == "" || sLinkTest == "0")
                                {
                                    iLinkTest = 0;
                                }
                                else
                                {
                                    iLinkTest = Convert.ToInt32(sLinkTest);
                                }

                                iColNo = arrITPSection10PwrIdStrings.Tables[0].Columns["BatteryTest"].Ordinal;
                                string sBatteryTest = arrITPSection10PwrIdStrings.Tables[0].Rows[k].ItemArray[iColNo].ToString();
                                int iBatteryTest = 0;
                                if(sBatteryTest == "" || sBatteryTest == "0")
                                {
                                    iBatteryTest = 0;
                                }
                                else
                                {
                                    iBatteryTest = Convert.ToInt32(sBatteryTest);
                                }

                                //Add in the row
                                UIView BatteryStringRow = BuildBatteryStringRowDetails(ii, j, k, sPwrId, iAutoId,
                                                                                       iMaximoAssetId, sBankNo,
                                                                                       sBankPlane, sMake, sModel, sSPN, sDOM,
                                                                                       sFuseOrCB, sRatingAmps, sFloor,
                                                                                       sSuite, sRack, sSubRack, sEquipType,
                                                                                       sSerialNo, iLinkTest, iBatteryTest,
                                                                                       false, bRFUPwrIdCommitted,ref iHeightToAdd);
                                BatteryStringRow.Frame = new RectangleF(0f, iPwrIdRowVertInner, 1000f, iHeightToAdd);
                                BatteryStringRow.Tag = iStringFullRowTagId * (j + 1) + (k + 1);
                                vwPwrInternalRowIdInnner.AddSubview(BatteryStringRow);

                                m_iBatteryRowHeight = iHeightToAdd;
                                iSectionPwrIdHeight += iHeightToAdd;
                                iPwrIdRowVert += iHeightToAdd;
                                iPwrIdRowVertInner += iHeightToAdd;
                                iVert += iHeightToAdd;

                            }

                            hfPwrIdSectionHeight.Text = iPwrIdRowVertInner.ToString();
                            vwPwrInternalRowIdInnner.Frame = new RectangleF(0f, iPwrIdRowInnerTop2, 1000f, iPwrIdRowVertInner);
                            vwPwrInternalRowId.Frame = new RectangleF(0f, iPwrIdRowInnerTop, 1000f, iPwrIdRowVert);
                            PwrIdTableRow.AddSubview(vwPwrInternalRowId);
                            iPwrIdRowInnerTop += iPwrIdRowVert;
                            //iPwrIdRowInnerTop2 += iPwrIdRowVertInner;
                            iPwrIdRowVert = 0f;
                        }

                    }
                    //Now resize the UIView that is effectively the container for the battery info for this section
                    //And also store this height in a hidden field for use in the contract and expand functions
                    PwrIdTableRow.Frame = new RectangleF(0f,iPwrIdRowVertTop,1000f,iSectionPwrIdHeight);
                    hfSectionHeight.Text = iSectionPwrIdHeight.ToString();
                }

                iTotalHeight = iVert + 280f;
                SizeF layoutSize = new SizeF(1000f, iTotalHeight);
                layout.ContentSize = layoutSize;

                UILabel hfScrollContentHeight = new UILabel();
                hfScrollContentHeight.Text = iTotalHeight.ToString();
                hfScrollContentHeight.Tag = 3;
                hfScrollContentHeight.Hidden = true;
                layout.AddSubview(hfScrollContentHeight);
                View.AddSubview(layout);

                //Contract all the power conversion PwrIds
                for(int iiii=0;iiii< m_iPwrdIdRows; iiii++)
                {
                    UILabel lblPwrId = (UILabel)View.ViewWithTag ((iPwrIdRowLabelTagId + (iiii+1)) * (m_iBatterySectionCounter+1));
                    string sPwrId = lblPwrId.Text;
                    bRFUPwrIdCommitted = RFUPwrIdCommitted(sPwrId);
                    if(bRFUPwrIdCommitted)
                    {
                        UIButton btnContract = (UIButton)View.ViewWithTag ((iPwrIdContractTagId + (iiii+1)) * (m_iBatterySectionCounter+1));
                        ContractPwrId(btnContract, null, 1);
                    }
                }

            }
            catch (Exception except)
            {
                string sTest = except.Message.ToString();
                iUtils.AlertBox alert = new iUtils.AlertBox ();
                alert.CreateErrorAlertDialog (sTest);
            }
        }