Esempio n. 1
0
        public UIView BuildBatteryStringRowDetails(int iSectionCounterId, int iRowNo, int iStringRow, string sPwrId, 
                                                   int iAutoId, int iMaximoAssetId, string sBankNo,
                                                   string sBankPlane, string sMake, string sModel, string sSPN, string sDOM,
                                                   string sFuseOrCB, string sRatingAmps, string sFloor, string sSuite,
                                                   string sRack, string sSubRack, string sEquipType, string sSerialNo,
                                                   int iLinkTestStatus, int i20MinTest, 
                                                   bool bNewRow, bool bReadOnly, ref float iHeightToAdd)
        {
            DateClass dt = new DateClass();
            iHeightToAdd = 0.0f;
            UIView hdrRow = new UIView();
            float iHdrVert = 0.0f;
            float iRowHeight = 40f;
            UIView[] arrItems = new UIView[20];
            UIView[] arrItems2 = new UIView[16];
            UIView[] arrItems3 = new UIView[4];

            UILabel hfSectionCounter = new UILabel();
            hfSectionCounter.Text = iSectionCounterId.ToString();
            hfSectionCounter.Tag = iStringRowSectionCounterTagId * (iRowNo + 1) + (iStringRow + 1);
            hfSectionCounter.Hidden = true;
            arrItems [0] = hfSectionCounter;

            UILabel hfPwrId = new UILabel();
            hfPwrId.Text = sPwrId;
            hfPwrId.Tag = iStringRowPwrIdTagId * (iRowNo + 1) + (iStringRow + 1);
            hfPwrId.Hidden = true;
            arrItems [1] = hfPwrId;

            UILabel hfRowStatus = new UILabel();
            if (bNewRow)
            {
                hfRowStatus.Text = "2"; //2 means new
            }
            else
            {
                hfRowStatus.Text = "0";
            }

            hfRowStatus.Tag = iStringRowStatusTagId * (iRowNo + 1) + (iStringRow + 1);
            hfRowStatus.Hidden = true;
            arrItems [2] = hfRowStatus;

            UILabel hfAutoId = new UILabel();
            hfAutoId.Text = iAutoId.ToString();
            hfAutoId.Tag = iStringRowAutoIdTagId * (iRowNo + 1) + (iStringRow + 1);
            hfAutoId.Hidden = true;
            arrItems [3] = hfAutoId;

            UILabel hfMaximoAssetId = new UILabel();
            hfMaximoAssetId.Text = iMaximoAssetId.ToString();
            hfMaximoAssetId.Tag = iStringRowMaximoAssetIdTagId * (iRowNo + 1) + (iStringRow + 1);
            hfMaximoAssetId.Hidden = true;
            arrItems [4] = hfMaximoAssetId;

            iUtils.CreateFormGridItem lblBankNo = new iUtils.CreateFormGridItem();
            UIView lblBankNoVw = new UIView();
            lblBankNo.SetDimensions(0f, iHdrVert, 100f, iRowHeight, 2f, 2f, 2f, 2f);
            lblBankNo.SetLabelText(sBankNo);
            lblBankNo.SetBorderWidth(0.0f);
            lblBankNo.SetFontName("Verdana");
            lblBankNo.SetFontSize(12f);
            lblBankNo.SetTag(iBankNoTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblBankNoVw = lblBankNo.GetTextFieldCell();
            UITextField txtBankNoView = lblBankNo.GetTextFieldView();
            txtBankNoView.AutocorrectionType = UITextAutocorrectionType.No;
            txtBankNoView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtBankNoView.ReturnKeyType = UIReturnKeyType.Next;
            txtBankNoView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 1);};
            txtBankNoView.ShouldEndEditing += (sender) => {
                return ValidateBankNo(sender, 1, 0);};
            txtBankNoView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 1);};

            if(bReadOnly)
            {
                txtBankNoView.Enabled = false;
            }
            arrItems [5] = lblBankNoVw;

            UILabel hfCurrentBankNo = new UILabel();
            hfCurrentBankNo.Text = sBankNo;
            hfCurrentBankNo.Tag = iBankNoHiddenTagId * (iRowNo + 1) + (iStringRow + 1);
            hfCurrentBankNo.Hidden = true;
            arrItems [6] = hfCurrentBankNo;

            iUtils.CreateFormGridItem btnBankNoSearch = new iUtils.CreateFormGridItem();
            UIView btnBankNoSearchVw = new UIView();
            btnBankNoSearch.SetDimensions(100f, iHdrVert, 60f, iRowHeight, 8f, 4f, 8f, 4f);
            btnBankNoSearch.SetLabelText("...");
            btnBankNoSearch.SetBorderWidth(0.0f);
            btnBankNoSearch.SetFontName("Verdana");
            btnBankNoSearch.SetFontSize(12f);
            btnBankNoSearch.SetTag(iBankNoSearchTagId * (iRowNo + 1) + (iStringRow + 1));
            if (iRowNo % 2 == 0)
            {
                btnBankNoSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnBankNoSearch.SetCellColour("Pale Orange");
            }
            btnBankNoSearchVw = btnBankNoSearch.GetButtonCell();

            UIButton btnBankNoSearchButton = new UIButton();
            btnBankNoSearchButton = btnBankNoSearch.GetButton();
            btnBankNoSearchButton.TouchUpInside += (sender,e) => {
                OpenBankNoList(sender, e);};

            if(bReadOnly)
            {
                btnBankNoSearchButton.Enabled = false;
            }

            arrItems [7] = btnBankNoSearchVw;

            iUtils.CreateFormGridItem lblBankPlane = new iUtils.CreateFormGridItem();
            UIView lblBankPlaneVw = new UIView();
            lblBankPlane.SetDimensions(160f, iHdrVert, 40f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
            lblBankPlane.SetLabelText(sBankPlane);
            lblBankPlane.SetBorderWidth(0.0f);
            lblBankPlane.SetFontName("Verdana");
            lblBankPlane.SetFontSize(12f);
            lblBankPlane.SetTag(iBankPlaneTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblBankPlaneVw = lblBankPlane.GetLabelCell();
            arrItems [8] = lblBankPlaneVw;

            iUtils.CreateFormGridItem lblBankMake = new iUtils.CreateFormGridItem();
            UIView lblBankMakeVw = new UIView();
            lblBankMake.SetDimensions(199f, iHdrVert, 140f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
            lblBankMake.SetLabelText(sMake);
            lblBankMake.SetBorderWidth(0.0f);
            lblBankMake.SetFontName("Verdana");
            lblBankMake.SetFontSize(12f);
            lblBankMake.SetTag(iBankMakeTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblBankMakeVw = lblBankMake.GetLabelCell();
            arrItems [9] = lblBankMakeVw;

            iUtils.CreateFormGridItem btnMakeSearch = new iUtils.CreateFormGridItem();
            UIView btnMakeSearchVw = new UIView();
            btnMakeSearch.SetDimensions(339f, iHdrVert, 60f, iRowHeight, 8f, 4f, 8f, 4f);
            btnMakeSearch.SetLabelText("...");
            btnMakeSearch.SetBorderWidth(0.0f);
            btnMakeSearch.SetFontName("Verdana");
            btnMakeSearch.SetFontSize(12f);
            btnMakeSearch.SetTag(iBankMakeSearchTagId * (iRowNo + 1) + (iStringRow + 1));
            if (iRowNo % 2 == 0)
            {
                btnMakeSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnMakeSearch.SetCellColour("Pale Orange");
            }
            btnMakeSearchVw = btnMakeSearch.GetButtonCell();

            UIButton btnMakeSearchButton = new UIButton();
            btnMakeSearchButton = btnMakeSearch.GetButton();
            btnMakeSearchButton.TouchUpInside += (sender,e) => {
                OpenMakeList(sender, e);};

            if(bReadOnly)
            {
                btnMakeSearchButton.Enabled = false;
            }
            arrItems [10] = btnMakeSearchVw;

            iUtils.CreateFormGridItem lblBankModel = new iUtils.CreateFormGridItem();
            UIView lblBankModelVw = new UIView();
            lblBankModel.SetDimensions(398f, iHdrVert, 240f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
            lblBankModel.SetLabelText(sModel);
            lblBankModel.SetBorderWidth(0.0f);
            lblBankModel.SetFontName("Verdana");
            lblBankModel.SetFontSize(12f);
            lblBankModel.SetTag(iBankModelTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblBankModelVw = lblBankModel.GetLabelCell();
            arrItems [11] = lblBankModelVw;

            UILabel hfSPN = new UILabel();
            hfSPN.Text = sSPN;
            hfSPN.Tag = iSPNHiddenTagId * (iRowNo + 1) + (iStringRow + 1);
            hfSPN.Hidden = true;
            arrItems [12] = hfSPN;

            iUtils.CreateFormGridItem btnModelSearch = new iUtils.CreateFormGridItem();
            UIView btnModelSearchVw = new UIView();
            btnModelSearch.SetDimensions(638f, iHdrVert, 60f, iRowHeight, 8f, 4f, 8f, 4f);
            btnModelSearch.SetLabelText("...");
            btnModelSearch.SetBorderWidth(0.0f);
            btnModelSearch.SetFontName("Verdana");
            btnModelSearch.SetFontSize(12f);
            btnModelSearch.SetTag(iBankModelSearchTagId * (iRowNo + 1) + (iStringRow + 1));
            if (iRowNo % 2 == 0)
            {
                btnModelSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnModelSearch.SetCellColour("Pale Orange");
            }
            btnModelSearchVw = btnModelSearch.GetButtonCell();

            UIButton btnModelSearchButton = new UIButton();
            btnModelSearchButton = btnModelSearch.GetButton();
            btnModelSearchButton.TouchUpInside += (sender,e) => {
                OpenModelList(sender, e);};

            if(bReadOnly)
            {
                btnModelSearchButton.Enabled = false;
            }
            arrItems [13] = btnModelSearchVw;

            iUtils.CreateFormGridItem txtDOM = new iUtils.CreateFormGridItem();
            UIView txtDOMVw = new UIView();
            txtDOM.SetDimensions(697f, iHdrVert, 80f, iRowHeight, 2f, 2f, 2f, 2f);
            if (sDOM == "0")
            {
                sDOM = "01/01/1900";
            }
            string sDOMDisplay;
            if(sDOM == "")
            {
                sDOMDisplay = sDOM;
            }
            else
            {
                DateTime dtDOM = Convert.ToDateTime(sDOM);
                sDOMDisplay = dt.Get_Date_String(dtDOM, "dd/mm/yy");
            }
            txtDOM.SetLabelText(sDOMDisplay);
            txtDOM.SetBorderWidth(0.0f);
            txtDOM.SetFontName("Verdana");
            txtDOM.SetFontSize(12f);
            txtDOM.SetTag(iBankDOMTagId * (iRowNo + 1) + (iStringRow + 1));

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

            txtDOMVw = txtDOM.GetTextFieldCell();
            UITextField txtDOMTextView = txtDOM.GetTextFieldView();
            txtDOMTextView.AutocorrectionType = UITextAutocorrectionType.No;
            txtDOMTextView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtDOMTextView.ReturnKeyType = UIReturnKeyType.Next;
            txtDOMTextView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 2);};
            txtDOMTextView.ShouldEndEditing += (sender) => {
                return ValidateDOM(sender, 0);};
            txtDOMTextView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 2);};

            if(bReadOnly)
            {
                txtDOMTextView.Enabled = false;
            }
            arrItems[14] = txtDOMVw;

            UILabel hfCurrentDOM = new UILabel();
            hfCurrentDOM.Text = sDOMDisplay;
            hfCurrentDOM.Tag = iHiddenDOMTagId * (iRowNo + 1) + (iStringRow + 1);
            hfCurrentDOM.Hidden = true;
            arrItems[15] = hfCurrentDOM;

            iUtils.CreateFormGridItem lblBankFuseOrCB = new iUtils.CreateFormGridItem();
            UIView lblBankFuseOrCBVw = new UIView();
            lblBankFuseOrCB.SetDimensions(776f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
            lblBankFuseOrCB.SetLabelText(sFuseOrCB);
            lblBankFuseOrCB.SetBorderWidth(0.0f);
            lblBankFuseOrCB.SetFontName("Verdana");
            lblBankFuseOrCB.SetFontSize(12f);
            lblBankFuseOrCB.SetTag(iBankFuseOrCBTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblBankFuseOrCBVw = lblBankFuseOrCB.GetLabelCell();
            arrItems[16] = lblBankFuseOrCBVw;

            iUtils.CreateFormGridItem btnFuseOrCBSearch = new iUtils.CreateFormGridItem();
            UIView btnFuseOrCBSearchVw = new UIView();
            btnFuseOrCBSearch.SetDimensions(826f, iHdrVert, 50f, iRowHeight, 3f, 4f, 3f, 4f);
            btnFuseOrCBSearch.SetLabelText("...");
            btnFuseOrCBSearch.SetBorderWidth(0.0f);
            btnFuseOrCBSearch.SetFontName("Verdana");
            btnFuseOrCBSearch.SetFontSize(12f);
            btnFuseOrCBSearch.SetTag(iBankFuseOrCBSearchTagId * (iRowNo + 1) + (iStringRow + 1));
            if (iRowNo % 2 == 0)
            {
                btnFuseOrCBSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnFuseOrCBSearch.SetCellColour("Pale Orange");
            }
            btnFuseOrCBSearchVw = btnFuseOrCBSearch.GetButtonCell();

            UIButton btnFuseOrCBSearchButton = new UIButton();
            btnFuseOrCBSearchButton = btnFuseOrCBSearch.GetButton();
            btnFuseOrCBSearchButton.TouchUpInside += (sender,e) => {
                OpenFuseOrCBList(sender, e);};

            if(bReadOnly)
            {
                btnFuseOrCBSearchButton.Enabled = false;
            }
            arrItems[17] = btnFuseOrCBSearchVw;

            iUtils.CreateFormGridItem txtRating = new iUtils.CreateFormGridItem();
            UIView txtRatingVw = new UIView();
            txtRating.SetDimensions(876f, iHdrVert, 125f, iRowHeight, 2f, 2f, 2f, 2f);
            txtRating.SetLabelText(sRatingAmps);
            txtRating.SetBorderWidth(0.0f);
            txtRating.SetFontName("Verdana");
            txtRating.SetFontSize(12f);
            txtRating.SetTag(iBankRatingTagId * (iRowNo + 1) + (iStringRow + 1));

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

            txtRatingVw = txtRating.GetTextFieldCell();
            UITextField txtRatingTextView = txtRating.GetTextFieldView();
            txtRatingTextView.AutocorrectionType = UITextAutocorrectionType.No;
            txtRatingTextView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtRatingTextView.ReturnKeyType = UIReturnKeyType.Next;
            txtRatingTextView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 3);};
            txtRatingTextView.ShouldEndEditing += (sender) => {
                return ValidateRating(sender, 0);};
            txtRatingTextView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 3);};

            if(bReadOnly)
            {
                txtRatingTextView.Enabled = false;
            }
            arrItems[18] = txtRatingVw;

            UILabel hfCurrentRating = new UILabel();
            hfCurrentRating.Text = sRatingAmps;
            hfCurrentRating.Tag = iHiddenRatingTagId * (iRowNo + 1) + (iStringRow + 1);
            hfCurrentRating.Hidden = true;
            arrItems[19] = hfCurrentRating;

            hdrRow.AddSubviews(arrItems);

            iHeightToAdd += iRowHeight;
            iHdrVert += iRowHeight;

            //***************************************************************//
            //              2nd Row                                          //
            //***************************************************************//
            iUtils.CreateFormGridItem lblFloor = new iUtils.CreateFormGridItem();
            UIView lblFloorVw = new UIView();
            lblFloor.SetDimensions(0f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
            lblFloor.SetLabelText(sFloor);
            lblFloor.SetBorderWidth(0.0f);
            lblFloor.SetFontName("Verdana");
            lblFloor.SetFontSize(12f);
            lblFloor.SetTag(iFloorTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblFloorVw = lblFloor.GetTextFieldCell();
            UITextField txtFloorView = lblFloor.GetTextFieldView();
            txtFloorView.AutocorrectionType = UITextAutocorrectionType.No;
            txtFloorView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtFloorView.ReturnKeyType = UIReturnKeyType.Next;
            txtFloorView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 4);};
            txtFloorView.ShouldEndEditing += (sender) => {
                return ValidateFloor(sender, 0);};
            txtFloorView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 4);};

            if(bReadOnly)
            {
                txtFloorView.Enabled = false;
            }
            arrItems2 [0] = lblFloorVw;

            UILabel hfCurrentFloor = new UILabel();
            hfCurrentFloor.Text = sFloor;
            hfCurrentFloor.Tag = iFloorHiddenTagId * (iRowNo + 1) + (iStringRow + 1);
            hfCurrentFloor.Hidden = true;
            arrItems2 [1] = hfCurrentFloor;

            iUtils.CreateFormGridItem lblSuite = new iUtils.CreateFormGridItem();
            UIView lblSuiteVw = new UIView();
            lblSuite.SetDimensions(50f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
            lblSuite.SetLabelText(sSuite);
            lblSuite.SetBorderWidth(0.0f);
            lblSuite.SetFontName("Verdana");
            lblSuite.SetFontSize(12f);
            lblSuite.SetTag(iSuiteTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblSuiteVw = lblSuite.GetTextFieldCell();
            UITextField txtSuiteView = lblSuite.GetTextFieldView();
            txtSuiteView.AutocorrectionType = UITextAutocorrectionType.No;
            txtSuiteView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtSuiteView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 5);};
            txtSuiteView.ReturnKeyType = UIReturnKeyType.Next;
            txtSuiteView.ShouldEndEditing += (sender) => {
                return ValidateSuite(sender, 0);};
            txtSuiteView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 5);};

            if(bReadOnly)
            {
                txtSuiteView.Enabled = false;
            }
            arrItems2 [2] = lblSuiteVw;

            UILabel hfCurrentSuite = new UILabel();
            hfCurrentSuite.Text = sSuite;
            hfCurrentSuite.Tag = iSuiteHiddenTagId * (iRowNo + 1) + (iStringRow + 1);
            hfCurrentSuite.Hidden = true;
            arrItems2 [3] = hfCurrentSuite;

            iUtils.CreateFormGridItem lblRack = new iUtils.CreateFormGridItem();
            UIView lblRackVw = new UIView();
            lblRack.SetDimensions(100f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
            lblRack.SetLabelText(sRack);
            lblRack.SetBorderWidth(0.0f);
            lblRack.SetFontName("Verdana");
            lblRack.SetFontSize(12f);
            lblRack.SetTag(iRackTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblRackVw = lblRack.GetTextFieldCell();
            UITextField txtRackView = lblRack.GetTextFieldView();
            txtRackView.AutocorrectionType = UITextAutocorrectionType.No;
            txtRackView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtRackView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 6);};
            txtRackView.ReturnKeyType = UIReturnKeyType.Next;
            txtRackView.ShouldEndEditing += (sender) => {
                return ValidateRack(sender, 0);};
            txtRackView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 6);};

            if(bReadOnly)
            {
                txtRackView.Enabled = false;
            }
            arrItems2 [4] = lblRackVw;

            UILabel hfCurrentRack = new UILabel();
            hfCurrentRack.Text = sRack;
            hfCurrentRack.Tag = iRackHiddenTagId * (iRowNo + 1) + (iStringRow + 1);
            hfCurrentRack.Hidden = true;
            arrItems2 [5] = hfCurrentRack;

            iUtils.CreateFormGridItem lblSubRack = new iUtils.CreateFormGridItem();
            UIView lblSubRackVw = new UIView();
            lblSubRack.SetDimensions(150f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
            lblSubRack.SetLabelText(sSubRack);
            lblSubRack.SetBorderWidth(0.0f);
            lblSubRack.SetFontName("Verdana");
            lblSubRack.SetFontSize(12f);
            lblSubRack.SetTag(iSubRackTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblSubRackVw = lblSubRack.GetTextFieldCell();
            UITextField txtSubRackView = lblSubRack.GetTextFieldView();
            txtSubRackView.AutocorrectionType = UITextAutocorrectionType.No;
            txtSubRackView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtSubRackView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 7);};
            txtSubRackView.ReturnKeyType = UIReturnKeyType.Next;
            txtSubRackView.ShouldEndEditing += (sender) => {
                return ValidateSubRack(sender, 0);};
            txtSubRackView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 7);};

            if(bReadOnly)
            {
                txtSubRackView.Enabled = false;
            }
            arrItems2 [6] = lblSubRackVw;

            UILabel hfCurrentSubRack = new UILabel();
            hfCurrentSubRack.Text = sSubRack;
            hfCurrentSubRack.Tag = iSubRackHiddenTagId * (iRowNo + 1) + (iStringRow + 1);
            hfCurrentSubRack.Hidden = true;
            arrItems2 [7] = hfCurrentSubRack;

            iUtils.CreateFormGridItem radEquipType = new iUtils.CreateFormGridItem();
            UIView radEquipTypeVw = new UIView();
            radEquipType.SetDimensions(199f, iHdrVert, 200f, iRowHeight * 2, 8f, iRowHeight / 2f, 8f, iRowHeight / 2f);
            radEquipType.SetFontName("Verdana");
            radEquipType.SetFontSize(12f);
            radEquipType.SetTag(iEquipTypeTagId * (iRowNo + 1) + (iStringRow + 1));

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

            radEquipTypeVw = radEquipType.GetRadioButtonCell();

            UISegmentedControl radEquipTypeRadio = new UISegmentedControl();
            radEquipTypeRadio = radEquipType.GetRadioGroup();
            radEquipTypeRadio.ValueChanged += (sender,e) => {
                SetStringEquipTypeChanged(sender, e);};

            radEquipTypeRadio.InsertSegment("New", 0, false);
            radEquipTypeRadio.InsertSegment("Used", 1, false);

            if (sEquipType == "N")
            {
                radEquipTypeRadio.SelectedSegment = 0;
            }
            else
            {
                radEquipTypeRadio.SelectedSegment = 1;
            }

            if (bNewRow || iMaximoAssetId < 0)
            {
                radEquipTypeRadio.Enabled = true;
            }
            else
            {
                radEquipTypeRadio.Enabled = false;
            }

            if(bReadOnly)
            {
                radEquipTypeRadio.Enabled = false;
            }

            arrItems2 [8] = radEquipTypeVw;

            iUtils.CreateFormGridItem lblSerialNo = new iUtils.CreateFormGridItem();
            UIView lblSerialNoVw = new UIView();
            lblSerialNo.SetDimensions(398f, iHdrVert, 300f, iRowHeight * 2f, 2f, iRowHeight / 2f, 2f, iRowHeight / 2f);
            lblSerialNo.SetLabelText(sSerialNo);
            lblSerialNo.SetBorderWidth(0.0f);
            lblSerialNo.SetFontName("Verdana");
            lblSerialNo.SetFontSize(12f);
            lblSerialNo.SetTag(iSerialNoTagId * (iRowNo + 1) + (iStringRow + 1));

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

            lblSerialNoVw = lblSerialNo.GetTextFieldCell();
            UITextField txtSerialNoView = lblSerialNo.GetTextFieldView();
            txtSerialNoView.AutocorrectionType = UITextAutocorrectionType.No;
            txtSerialNoView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtSerialNoView.ReturnKeyType = UIReturnKeyType.Next;
            txtSerialNoView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 8);};
            txtSerialNoView.ShouldEndEditing += (sender) => {
                return ValidateSerialNo(sender, 0);};
            txtSerialNoView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 8);};

            if(bReadOnly)
            {
                txtSerialNoView.Enabled = false;
            }
            arrItems2 [9] = lblSerialNoVw;

            UILabel hfCurrentSerialNo = new UILabel();
            hfCurrentSerialNo.Text = sSerialNo;
            hfCurrentSerialNo.Tag = iHiddenSerialNoTagId * (iRowNo + 1) + (iStringRow + 1);
            hfCurrentSerialNo.Hidden = true;
            arrItems2 [10] = hfCurrentSerialNo;

            iUtils.CreateFormGridItem btnLinkTest = new iUtils.CreateFormGridItem();
            UIView btnLinkTestVw = new UIView();
            btnLinkTest.SetDimensions(697f, iHdrVert, 80f, iRowHeight * 2f, 8f, iRowHeight / 2f, 8f, iRowHeight / 2f);
            btnLinkTest.SetLabelText("Link Test");
            btnLinkTest.SetBorderWidth(0.0f);
            btnLinkTest.SetFontName("Verdana");
            btnLinkTest.SetFontSize(12f);
            btnLinkTest.SetTag(iLinkTestBtnTagId * (iRowNo + 1) + (iStringRow + 1));

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

            btnLinkTestVw = btnLinkTest.GetButtonCell();

            UIButton btnLinkTestButton = new UIButton();
            btnLinkTestButton = btnLinkTest.GetButton();
            btnLinkTestButton.TouchUpInside += (sender,e) => {
                OpenLinkTest(sender, e);};

            if(bReadOnly)
            {
                btnLinkTestButton.Enabled = false;
            }
            arrItems2 [11] = btnLinkTestVw;

            UILabel hfLinkTestStatus = new UILabel();
            hfLinkTestStatus.Text = iLinkTestStatus.ToString();
            hfLinkTestStatus.Tag = iLinkTestHiddenTagId * (iRowNo + 1) + (iStringRow + 1);
            hfLinkTestStatus.Hidden = true;
            arrItems2 [12] = hfLinkTestStatus;

            iUtils.CreateFormGridItem btn20MinTest = new iUtils.CreateFormGridItem();
            UIView btn20MinTestVw = new UIView();
            btn20MinTest.SetDimensions(776f, iHdrVert, 100f, iRowHeight * 2f, 8f, iRowHeight / 2f, 8f, iRowHeight / 2f);
            btn20MinTest.SetLabelText("20Min Test");
            btn20MinTest.SetBorderWidth(0.0f);
            btn20MinTest.SetFontName("Verdana");
            btn20MinTest.SetFontSize(12f);
            btn20MinTest.SetTag(i20MinTestBtnTagId * (iRowNo + 1) + (iStringRow + 1));

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

            btn20MinTestVw = btn20MinTest.GetButtonCell();

            UIButton btn20MinTestButton = new UIButton();
            btn20MinTestButton = btn20MinTest.GetButton();
            btn20MinTestButton.TouchUpInside += (sender,e) => {
                Open20MinTest(sender, e);};

            if(bReadOnly)
            {
                btn20MinTestButton.Enabled = false;
            }
            arrItems2 [13] = btn20MinTestVw;

            UILabel hf20MinTestStatus = new UILabel();
            hf20MinTestStatus.Text = i20MinTest.ToString();
            hf20MinTestStatus.Tag = i20MinTestHiddenTagId * (iRowNo + 1) + (iStringRow + 1);
            hf20MinTestStatus.Hidden = true;
            arrItems2 [14] = hf20MinTestStatus;

            iUtils.CreateFormGridItem btnDelete = new iUtils.CreateFormGridItem();
            UIView btnDeleteVw = new UIView();
            btnDelete.SetDimensions(875f, iHdrVert, 125f, iRowHeight * 2f, 8f, iRowHeight / 2f, 8f, iRowHeight / 2f);
            btnDelete.SetLabelText("Delete");
            btnDelete.SetBorderWidth(0.0f);
            btnDelete.SetFontName("Verdana");
            btnDelete.SetFontSize(12f);
            btnDelete.SetTag(iDeleteBatteryStringBtnTagId * (iRowNo + 1) + (iStringRow + 1));

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

            btnDeleteVw = btnDelete.GetButtonCell();

            UIButton btnDeleteButton = new UIButton();
            btnDeleteButton = btnDelete.GetButton();
            btnDeleteButton.TouchUpInside += (sender,e) => {
                DeleteBatteryString(sender, e);};

            if (iMaximoAssetId > 0)
            {
                btnDeleteButton.Enabled = false;
            }
            if(bReadOnly)
            {
                btnDeleteButton.Enabled = false;
            }
            arrItems2[15] = btnDeleteVw;

            hdrRow.AddSubviews(arrItems2);

            iHeightToAdd += iRowHeight;
            iHdrVert += iRowHeight;

            //***************************************************************//
            //              3rd Row                                          //
            //***************************************************************//

            iUtils.CreateFormGridItem btnFloorSearch = new iUtils.CreateFormGridItem();
            UIView btnFloorSearchVw = new UIView();
            btnFloorSearch.SetDimensions(0f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
            btnFloorSearch.SetLabelText("...");
            btnFloorSearch.SetBorderWidth(0.0f);
            btnFloorSearch.SetFontName("Verdana");
            btnFloorSearch.SetFontSize(12f);
            btnFloorSearch.SetTag(iFloorSearchTagId * (iRowNo+1) + (iStringRow+1));
            if (iRowNo % 2 == 0)
            {
                btnFloorSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnFloorSearch.SetCellColour("Pale Orange");
            }
            btnFloorSearchVw = btnFloorSearch.GetButtonCell();

            UIButton btnFloorSearchButton = new UIButton();
            btnFloorSearchButton = btnFloorSearch.GetButton();
            btnFloorSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 1);};

            if(bReadOnly)
            {
                btnFloorSearchButton.Enabled = false;
            }
            arrItems3[0] = btnFloorSearchVw;

            iUtils.CreateFormGridItem btnSuiteSearch = new iUtils.CreateFormGridItem();
            UIView btnSuiteSearchVw = new UIView();
            btnSuiteSearch.SetDimensions(50f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
            btnSuiteSearch.SetLabelText("...");
            btnSuiteSearch.SetBorderWidth(0.0f);
            btnSuiteSearch.SetFontName("Verdana");
            btnSuiteSearch.SetFontSize(12f);
            btnSuiteSearch.SetTag(iSuiteSearchTagId * (iRowNo+1) + (iStringRow+1));
            if (iRowNo % 2 == 0)
            {
                btnSuiteSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnSuiteSearch.SetCellColour("Pale Orange");
            }
            btnSuiteSearchVw = btnSuiteSearch.GetButtonCell();

            UIButton btnSuiteSearchButton = new UIButton();
            btnSuiteSearchButton = btnSuiteSearch.GetButton();
            btnSuiteSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 2);};

            if(bReadOnly)
            {
                btnSuiteSearchButton.Enabled = false;
            }
            arrItems3[1] = btnSuiteSearchVw;

            iUtils.CreateFormGridItem btnRackSearch = new iUtils.CreateFormGridItem();
            UIView btnRackSearchVw = new UIView();
            btnRackSearch.SetDimensions(100f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
            btnRackSearch.SetLabelText("...");
            btnRackSearch.SetBorderWidth(0.0f);
            btnRackSearch.SetFontName("Verdana");
            btnRackSearch.SetFontSize(12f);
            btnRackSearch.SetTag(iRackSearchTagId * (iRowNo+1) + (iStringRow+1));
            if (iRowNo % 2 == 0)
            {
                btnRackSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnRackSearch.SetCellColour("Pale Orange");
            }
            btnRackSearchVw = btnRackSearch.GetButtonCell();

            UIButton btnRackSearchButton = new UIButton();
            btnRackSearchButton = btnRackSearch.GetButton();
            btnRackSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 3);};

            if(bReadOnly)
            {
                btnRackSearchButton.Enabled = false;
            }
            arrItems3[2] = btnRackSearchVw;

            iUtils.CreateFormGridItem btnSubRackSearch = new iUtils.CreateFormGridItem();
            UIView btnSubRackSearchVw = new UIView();
            btnSubRackSearch.SetDimensions(150f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
            btnSubRackSearch.SetLabelText("...");
            btnSubRackSearch.SetBorderWidth(0.0f);
            btnSubRackSearch.SetFontName("Verdana");
            btnSubRackSearch.SetFontSize(12f);
            btnSubRackSearch.SetTag(iSubRackSearchTagId * (iRowNo+1) + (iStringRow+1));
            if (iRowNo % 2 == 0)
            {
                btnSubRackSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnSubRackSearch.SetCellColour("Pale Orange");
            }
            btnSubRackSearchVw = btnSubRackSearch.GetButtonCell();

            UIButton btnSubRackSearchButton = new UIButton();
            btnSubRackSearchButton = btnSubRackSearch.GetButton();
            btnSubRackSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 4);};

            if(bReadOnly)
            {
                btnSubRackSearchButton.Enabled = false;
            }
            arrItems3[3] = btnSubRackSearchVw;

            hdrRow.AddSubviews(arrItems3);

            iHeightToAdd += iRowHeight;
            iHdrVert += iRowHeight;

            //Now draw a 1 pixel horizontal line
            UIView vwHorizLine = new UIView();
            vwHorizLine.Frame = new RectangleF(0f,iHdrVert, 1000f, 1f);
            vwHorizLine.BackgroundColor = UIColor.FromRGBA(0,0,0,255);

            iHeightToAdd += 1f;
            iHdrVert += 1f;

            hdrRow.AddSubview(vwHorizLine);

            return hdrRow;
        }
Esempio n. 2
0
        public UIView BuildEquipmentItemRowDetails(int iSectionCounterId, int iPwrIdRowNo, int iEquipRowNo, string sPwrId, 
                                                   int iAutoId, int iMaximoAssetId, string sStringNo,
                                                   string sMake, string sModel, string sSPN, string sDOM,
                                                   string sFloor, string sSuite,string sRack, string sSubRack, 
                                                   string sPosition, string sEquipType, string sSerialNo,
                                                   int iEquipmentType, int iDuplicate, bool bNewRow, bool bReadOnly, ref float iHeightToAdd)
        {
            DateClass dt = new DateClass();
            iHeightToAdd = 0.0f;
            UIView hdrRow = new UIView();
            float iHdrVert = 0.0f;
            float iRowHeight = 40f;
            UIView[] arrItems = new UIView[8];
            UIView[] arrItems2 = new UIView[18];
            UIView[] arrItems3 = new UIView[6];
            UIView[] arrItems4 = new UIView[7];
            UIView vwBlank = new UIView();

            UILabel hfSectionCounter = new UILabel();
            hfSectionCounter.Text = iSectionCounterId.ToString();
            hfSectionCounter.Tag = iEquipmentRowSectionCounterTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfSectionCounter.Hidden = true;
            arrItems4[0] = hfSectionCounter;

            UILabel hfPwrId = new UILabel();
            hfPwrId.Text = sPwrId;
            hfPwrId.Tag = iEquipmentRowPwrIdTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfPwrId.Hidden = true;
            arrItems4[1] = hfPwrId;

            UILabel hfRowStatus = new UILabel();
            if (bNewRow)
            {
                hfRowStatus.Text = "2"; //2 means new
            }
            else
            {
                hfRowStatus.Text = "0";
            }

            hfRowStatus.Tag = iEquipmentRowStatusTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfRowStatus.Hidden = true;
            arrItems4[2] = hfRowStatus;

            UILabel hfAutoId = new UILabel();
            hfAutoId.Text = iAutoId.ToString();
            hfAutoId.Tag = iEquipmentRowAutoIdTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfAutoId.Hidden = true;
            arrItems4[3] = hfAutoId;

            UILabel hfMaximoAssetId = new UILabel();
            hfMaximoAssetId.Text = iMaximoAssetId.ToString();
            hfMaximoAssetId.Tag = iEquipmentRowMaximoAssetIdTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfMaximoAssetId.Hidden = true;
            arrItems4[4] = hfMaximoAssetId;

            UILabel hfEquipmentTypeId = new UILabel();
            hfEquipmentTypeId.Text = iEquipmentType.ToString();
            hfEquipmentTypeId.Tag = iEquipmentTypeTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfEquipmentTypeId.Hidden = true;
            arrItems4[5] = hfEquipmentTypeId;

            UILabel hfDuplicateId = new UILabel();
            hfDuplicateId.Text = iDuplicate.ToString();
            hfDuplicateId.Tag = iDuplicateTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfDuplicateId.Hidden = true;
            arrItems4[6] = hfDuplicateId;

            hdrRow.AddSubviews(arrItems4);

            //***************************************************************//
            //              1st Row                                          //
            //***************************************************************//
            iUtils.CreateFormGridItem lblFloor = new iUtils.CreateFormGridItem();
            UIView lblFloorVw = new UIView();
            lblFloor.SetDimensions(0f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
            lblFloor.SetLabelText(sFloor);
            lblFloor.SetBorderWidth(0.0f);
            lblFloor.SetFontName("Verdana");
            lblFloor.SetFontSize(12f);
            lblFloor.SetTag(iEquipmentFloorTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            lblFloorVw = lblFloor.GetTextFieldCell();
            UITextField txtFloorView = lblFloor.GetTextFieldView();
            txtFloorView.AutocorrectionType = UITextAutocorrectionType.No;
            txtFloorView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtFloorView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 1);};
            txtFloorView.ReturnKeyType = UIReturnKeyType.Next;
            txtFloorView.ShouldEndEditing += (sender) => {
                return ValidateFloor(sender, 0);};
            txtFloorView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 1);};

            if(bReadOnly)
            {
                txtFloorView.Enabled = false;
            }
            arrItems2 [0] = lblFloorVw;

            UILabel hfCurrentFloor = new UILabel();
            hfCurrentFloor.Text = sFloor;
            hfCurrentFloor.Tag = iEquipmentFloorHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfCurrentFloor.Hidden = true;
            arrItems2 [1] = hfCurrentFloor;

            iUtils.CreateFormGridItem lblSuite = new iUtils.CreateFormGridItem();
            UIView lblSuiteVw = new UIView();
            lblSuite.SetDimensions(50f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
            lblSuite.SetLabelText(sSuite);
            lblSuite.SetBorderWidth(0.0f);
            lblSuite.SetFontName("Verdana");
            lblSuite.SetFontSize(12f);
            lblSuite.SetTag(iEquipmentSuiteTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            lblSuiteVw = lblSuite.GetTextFieldCell();
            UITextField txtSuiteView = lblSuite.GetTextFieldView();
            txtSuiteView.AutocorrectionType = UITextAutocorrectionType.No;
            txtSuiteView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtSuiteView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 2);};
            txtSuiteView.ReturnKeyType = UIReturnKeyType.Next;
            txtSuiteView.ShouldEndEditing += (sender) => {
                return ValidateSuite(sender, 0);};
            txtSuiteView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 2);};

            if(bReadOnly)
            {
                txtSuiteView.Enabled = false;
            }
            arrItems2 [2] = lblSuiteVw;

            UILabel hfCurrentSuite = new UILabel();
            hfCurrentSuite.Text = sSuite;
            hfCurrentSuite.Tag = iEquipmentSuiteHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfCurrentSuite.Hidden = true;
            arrItems2 [3] = hfCurrentSuite;

            iUtils.CreateFormGridItem lblRack = new iUtils.CreateFormGridItem();
            UIView lblRackVw = new UIView();
            lblRack.SetDimensions(100f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
            lblRack.SetLabelText(sRack);
            lblRack.SetBorderWidth(0.0f);
            lblRack.SetFontName("Verdana");
            lblRack.SetFontSize(12f);
            lblRack.SetTag(iEquipmentRackTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            lblRackVw = lblRack.GetTextFieldCell();
            UITextField txtRackView = lblRack.GetTextFieldView();
            txtRackView.AutocorrectionType = UITextAutocorrectionType.No;
            txtRackView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtRackView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 3);};
            txtRackView.ReturnKeyType = UIReturnKeyType.Next;
            txtRackView.ShouldEndEditing += (sender) => {
                return ValidateRack(sender, 0);};
            txtRackView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 3);};

            if(bReadOnly)
            {
                txtRackView.Enabled = false;
            }
            arrItems2 [4] = lblRackVw;

            UILabel hfCurrentRack = new UILabel();
            hfCurrentRack.Text = sRack;
            hfCurrentRack.Tag = iEquipmentRackHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfCurrentRack.Hidden = true;
            arrItems2 [5] = hfCurrentRack;

            if(iEquipmentType > 3)
            {
                iUtils.CreateFormGridItem lblSubRack = new iUtils.CreateFormGridItem();
                UIView lblSubRackVw = new UIView();
                lblSubRack.SetDimensions(140f, iHdrVert, 60f, iRowHeight, 2f, 2f, 2f, 2f);
                lblSubRack.SetLabelText(sSubRack);
                lblSubRack.SetBorderWidth(0.0f);
                lblSubRack.SetFontName("Verdana");
                lblSubRack.SetFontSize(12f);
                lblSubRack.SetTag(iEquipmentSubRackTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

                lblSubRackVw = lblSubRack.GetTextFieldCell();
                UITextField txtSubRackView = lblSubRack.GetTextFieldView();
                txtSubRackView.AutocorrectionType = UITextAutocorrectionType.No;
                txtSubRackView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
                txtSubRackView.ShouldBeginEditing += (sender) => {
                    return SetGlobalEditItems(sender, 4);};
                txtSubRackView.ReturnKeyType = UIReturnKeyType.Next;
                txtSubRackView.ShouldEndEditing += (sender) => {
                    return ValidateSubRack(sender, 0);};
                txtSubRackView.ShouldReturn += (sender) => {
                    return MoveNextTextField(sender, 4);};

                if(bReadOnly)
                {
                    txtSubRackView.Enabled = false;
                }
                arrItems2 [6] = lblSubRackVw;

                UILabel hfCurrentSubRack = new UILabel();
                hfCurrentSubRack.Text = sSubRack;
                hfCurrentSubRack.Tag = iEquipmentSubRackHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
                hfCurrentSubRack.Hidden = true;
                arrItems2 [7] = hfCurrentSubRack;
            }
            else
            {
                iUtils.CreateFormGridItem lblSubRack = new iUtils.CreateFormGridItem();
                UIView lblSubRackVw = new UIView();
                lblSubRack.SetDimensions(140f, iHdrVert, 60f, iRowHeight, 2f, 2f, 2f, 2f);
                lblSubRack.SetBorderWidth(0.0f);

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

                lblSubRackVw = lblSubRack.GetLabelCell();
                arrItems2 [6] = lblSubRackVw;
                arrItems2 [7] = vwBlank;
            }

            if(iEquipmentType > 4)
            {
                iUtils.CreateFormGridItem lblPosition = new iUtils.CreateFormGridItem();
                UIView lblPositionVw = new UIView();
                lblPosition.SetDimensions(200f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
                lblPosition.SetLabelText(sPosition);
                lblPosition.SetBorderWidth(0.0f);
                lblPosition.SetFontName("Verdana");
                lblPosition.SetFontSize(12f);
                lblPosition.SetTag(iEquipmentPositionTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

                lblPositionVw = lblPosition.GetTextFieldCell();
                UITextField txtPositionView = lblPosition.GetTextFieldView();
                txtPositionView.AutocorrectionType = UITextAutocorrectionType.No;
                txtPositionView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
                txtPositionView.ShouldBeginEditing += (sender) => {
                    return SetGlobalEditItems(sender, 5);};
                txtPositionView.ReturnKeyType = UIReturnKeyType.Next;
                txtPositionView.ShouldEndEditing += (sender) => {
                    return ValidatePosition(sender, 0);};
                txtPositionView.ShouldReturn += (sender) => {
                    return MoveNextTextField(sender, 5);};

                if(bReadOnly)
                {
                    txtPositionView.Enabled = false;
                }
                arrItems2 [8] = lblPositionVw;

                UILabel hfCurrentPosition = new UILabel();
                hfCurrentPosition.Text = sPosition;
                hfCurrentPosition.Tag = iEquipmentPositionHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
                hfCurrentPosition.Hidden = true;
                arrItems2 [9] = hfCurrentPosition;
            }
            else
            {
                iUtils.CreateFormGridItem lblPosition = new iUtils.CreateFormGridItem();
                UIView lblPositionVw = new UIView();
                lblPosition.SetDimensions(200f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
                lblPosition.SetBorderWidth(0.0f);

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

                lblPositionVw = lblPosition.GetLabelCell();
                arrItems2 [8] = lblPositionVw;
                arrItems2 [9] = vwBlank;
            }

            if(iEquipmentType > 5)
            {
                iUtils.CreateFormGridItem lblString = new iUtils.CreateFormGridItem();
                UIView lblStringVw = new UIView();
                lblString.SetDimensions(250f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
                lblString.SetLabelText(sStringNo);
                lblString.SetBorderWidth(0.0f);
                lblString.SetFontName("Verdana");
                lblString.SetFontSize(12f);
                lblString.SetTag(iEquipmentStringTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

                lblStringVw = lblString.GetTextFieldCell();
                UITextField txtStringView = lblString.GetTextFieldView();
                txtStringView.AutocorrectionType = UITextAutocorrectionType.No;
                txtStringView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
                txtStringView.ReturnKeyType = UIReturnKeyType.Next;
                txtStringView.ShouldBeginEditing += (sender) => {
                    return SetGlobalEditItems(sender, 6);};
                txtStringView.ShouldEndEditing += (sender) => {
                    return ValidateBankNo(sender, 2, 0);};
                txtStringView.ShouldReturn += (sender) => {
                    return MoveNextTextField(sender, 6);};

                if(bReadOnly)
                {
                    txtStringView.Enabled = false;
                }
                arrItems2 [10] = lblStringVw;

                UILabel hfCurrentString = new UILabel();
                hfCurrentString.Text = sStringNo;
                hfCurrentString.Tag = iEquipmentStringHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
                hfCurrentString.Hidden = true;
                arrItems2 [11] = hfCurrentString;
            }
            else
            {
                iUtils.CreateFormGridItem lblString = new iUtils.CreateFormGridItem();
                UIView lblStringVw = new UIView();
                lblString.SetDimensions(250f, iHdrVert, 50f, iRowHeight, 2f, 2f, 2f, 2f);
                lblString.SetBorderWidth(0.0f);

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

                lblStringVw = lblString.GetLabelCell();
                arrItems2 [10] = lblStringVw;
                arrItems2 [11] = vwBlank;
            }

            iUtils.CreateFormGridItem radEquipType = new iUtils.CreateFormGridItem();
            UIView radEquipTypeVw = new UIView();
            radEquipType.SetDimensions(300f, iHdrVert, 200f, iRowHeight * 2, 8f, iRowHeight / 2f, 8f, iRowHeight / 2f);
            radEquipType.SetFontName("Verdana");
            radEquipType.SetFontSize(12f);
            radEquipType.SetTag(iEquipmentEquipTypeTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            radEquipTypeVw = radEquipType.GetRadioButtonCell();

            UISegmentedControl radEquipTypeRadio = new UISegmentedControl();
            radEquipTypeRadio = radEquipType.GetRadioGroup();
            radEquipTypeRadio.ValueChanged += (sender,e) => {
                SetStringEquipTypeChanged(sender, e);};

            radEquipTypeRadio.InsertSegment("New", 0, false);
            radEquipTypeRadio.InsertSegment("Used", 1, false);

            if (sEquipType == "N")
            {
                radEquipTypeRadio.SelectedSegment = 0;
            }
            else
            {
                radEquipTypeRadio.SelectedSegment = 1;
            }

            if (bNewRow || iDuplicate < 0)
            {
                radEquipTypeRadio.Enabled = true;
            }
            else
            {
                radEquipTypeRadio.Enabled = false;
            }

            if(bReadOnly)
            {
                radEquipTypeRadio.Enabled = false;
            }

            arrItems2 [12] = radEquipTypeVw;

            iUtils.CreateFormGridItem txtDOM = new iUtils.CreateFormGridItem();
            UIView txtDOMVw = new UIView();
            txtDOM.SetDimensions(500f, iHdrVert, 80f, iRowHeight * 2, 2f, iRowHeight / 2f, 2f, iRowHeight / 2f);
            if (sDOM == "0")
            {
                sDOM = "01/01/1900";
            }
            string sDOMDisplay;
            if(sDOM == "")
            {
                sDOMDisplay = sDOM;
            }
            else
            {
                DateTime dtDOM = Convert.ToDateTime(sDOM);
                sDOMDisplay = dt.Get_Date_String(dtDOM, "dd/mm/yy");
            }
            txtDOM.SetLabelText(sDOMDisplay);
            txtDOM.SetBorderWidth(0.0f);
            txtDOM.SetFontName("Verdana");
            txtDOM.SetFontSize(12f);
            txtDOM.SetTag(iEquipmentDOMTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            txtDOMVw = txtDOM.GetTextFieldCell();
            UITextField txtDOMTextView = txtDOM.GetTextFieldView();
            txtDOMTextView.AutocorrectionType = UITextAutocorrectionType.No;
            txtDOMTextView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtDOMTextView.ReturnKeyType = UIReturnKeyType.Next;
            txtDOMTextView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 7);};
            txtDOMTextView.ShouldEndEditing += (sender) => {
                return ValidateDOM(sender, 0);};
            txtDOMTextView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 7);};

            if(bReadOnly)
            {
                txtDOMTextView.Enabled = false;
            }
            arrItems2 [13] = txtDOMVw;

            UILabel hfCurrentDOM = new UILabel();
            hfCurrentDOM.Text = sDOMDisplay;
            hfCurrentDOM.Tag = iEquipmentDOMHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfCurrentDOM.Hidden = true;
            arrItems2 [14] = hfCurrentDOM;

            iUtils.CreateFormGridItem lblSerialNo = new iUtils.CreateFormGridItem();
            UIView lblSerialNoVw = new UIView();
            lblSerialNo.SetDimensions(580f, iHdrVert, 300f, iRowHeight * 2f, 2f, iRowHeight / 2f, 2f, iRowHeight / 2f);
            lblSerialNo.SetLabelText(sSerialNo);
            lblSerialNo.SetBorderWidth(0.0f);
            lblSerialNo.SetFontName("Verdana");
            lblSerialNo.SetFontSize(12f);
            lblSerialNo.SetTag(iEquipmentSerialNoTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            lblSerialNoVw = lblSerialNo.GetTextFieldCell();
            UITextField txtSerialNoView = lblSerialNo.GetTextFieldView();
            txtSerialNoView.AutocorrectionType = UITextAutocorrectionType.No;
            txtSerialNoView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtSerialNoView.ReturnKeyType = UIReturnKeyType.Next;
            txtSerialNoView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 8);};
            txtSerialNoView.ShouldEndEditing += (sender) => {
                return ValidateSerialNo(sender, 0);};
            txtSerialNoView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 8);};

            if(bReadOnly)
            {
                txtSerialNoView.Enabled = false;
            }
            arrItems2 [15] = lblSerialNoVw;

            UILabel hfCurrentSerialNo = new UILabel();
            hfCurrentSerialNo.Text = sSerialNo;
            hfCurrentSerialNo.Tag = iEquipmentSerialNoHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfCurrentSerialNo.Hidden = true;
            arrItems2 [16] = hfCurrentSerialNo;

            iUtils.CreateFormGridItem btnDelete = new iUtils.CreateFormGridItem();
            UIView btnDeleteVw = new UIView();
            btnDelete.SetDimensions(880f, iHdrVert, 120f, iRowHeight * 2f, 8f, iRowHeight / 2f, 8f, iRowHeight / 2f);
            btnDelete.SetLabelText("Delete");
            btnDelete.SetBorderWidth(0.0f);
            btnDelete.SetFontName("Verdana");
            btnDelete.SetFontSize(12f);
            btnDelete.SetTag(iEquipmentDeleteBtnTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            btnDeleteVw = btnDelete.GetButtonCell();

            UIButton btnDeleteButton = new UIButton();
            btnDeleteButton = btnDelete.GetButton();
            btnDeleteButton.TouchUpInside += (sender,e) => {
                DeleteEquipmentRow(sender, e);};

            if (iMaximoAssetId >= 0)
            {
                btnDeleteButton.Enabled = false;
            }

            if(bReadOnly)
            {
                btnDeleteButton.Enabled = false;
            }
            arrItems2[17] = btnDeleteVw;

            hdrRow.AddSubviews(arrItems2);

            iHeightToAdd += iRowHeight;
            iHdrVert += iRowHeight;

            //***************************************************************//
            //              2nd Row                                          //
            //***************************************************************//

            iUtils.CreateFormGridItem btnFloorSearch = new iUtils.CreateFormGridItem();
            UIView btnFloorSearchVw = new UIView();
            btnFloorSearch.SetDimensions(0f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
            btnFloorSearch.SetLabelText("...");
            btnFloorSearch.SetBorderWidth(0.0f);
            btnFloorSearch.SetFontName("Verdana");
            btnFloorSearch.SetFontSize(12f);
            btnFloorSearch.SetTag(iEquipmentFloorSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));
            if (iPwrIdRowNo % 2 == 0)
            {
                btnFloorSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnFloorSearch.SetCellColour("Pale Orange");
            }
            btnFloorSearchVw = btnFloorSearch.GetButtonCell();

            UIButton btnFloorSearchButton = new UIButton();
            btnFloorSearchButton = btnFloorSearch.GetButton();
            btnFloorSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 1);};

            if(bReadOnly)
            {
                btnFloorSearchButton.Enabled = false;
            }
            arrItems3[0] = btnFloorSearchVw;

            iUtils.CreateFormGridItem btnSuiteSearch = new iUtils.CreateFormGridItem();
            UIView btnSuiteSearchVw = new UIView();
            btnSuiteSearch.SetDimensions(50f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
            btnSuiteSearch.SetLabelText("...");
            btnSuiteSearch.SetBorderWidth(0.0f);
            btnSuiteSearch.SetFontName("Verdana");
            btnSuiteSearch.SetFontSize(12f);
            btnSuiteSearch.SetTag(iEquipmentSuiteSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));
            if (iPwrIdRowNo % 2 == 0)
            {
                btnSuiteSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnSuiteSearch.SetCellColour("Pale Orange");
            }
            btnSuiteSearchVw = btnSuiteSearch.GetButtonCell();

            UIButton btnSuiteSearchButton = new UIButton();
            btnSuiteSearchButton = btnSuiteSearch.GetButton();
            btnSuiteSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 2);};

            if(bReadOnly)
            {
                btnSuiteSearchButton.Enabled = false;
            }
            arrItems3[1] = btnSuiteSearchVw;

            iUtils.CreateFormGridItem btnRackSearch = new iUtils.CreateFormGridItem();
            UIView btnRackSearchVw = new UIView();
            btnRackSearch.SetDimensions(100f,iHdrVert, 40f, iRowHeight, 3f, 4f, 3f, 4f);
            btnRackSearch.SetLabelText("...");
            btnRackSearch.SetBorderWidth(0.0f);
            btnRackSearch.SetFontName("Verdana");
            btnRackSearch.SetFontSize(12f);
            btnRackSearch.SetTag(iEquipmentRackSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));
            if (iPwrIdRowNo % 2 == 0)
            {
                btnRackSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnRackSearch.SetCellColour("Pale Orange");
            }
            btnRackSearchVw = btnRackSearch.GetButtonCell();

            UIButton btnRackSearchButton = new UIButton();
            btnRackSearchButton = btnRackSearch.GetButton();
            btnRackSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 3);};

            if(bReadOnly)
            {
                btnRackSearchButton.Enabled = false;
            }
            arrItems3[2] = btnRackSearchVw;

            if(iEquipmentType > 3)
            {
                iUtils.CreateFormGridItem btnSubRackSearch = new iUtils.CreateFormGridItem();
                UIView btnSubRackSearchVw = new UIView();
                btnSubRackSearch.SetDimensions(140f,iHdrVert, 60f, iRowHeight, 13f, 4f, 13f, 4f);
                btnSubRackSearch.SetLabelText("...");
                btnSubRackSearch.SetBorderWidth(0.0f);
                btnSubRackSearch.SetFontName("Verdana");
                btnSubRackSearch.SetFontSize(12f);
                btnSubRackSearch.SetTag(iEquipmentSubRackSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));
                if (iPwrIdRowNo % 2 == 0)
                {
                    btnSubRackSearch.SetCellColour("Pale Yellow");
                }
                else
                {
                    btnSubRackSearch.SetCellColour("Pale Orange");
                }
                btnSubRackSearchVw = btnSubRackSearch.GetButtonCell();

                UIButton btnSubRackSearchButton = new UIButton();
                btnSubRackSearchButton = btnSubRackSearch.GetButton();
                btnSubRackSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 4);};

                if(bReadOnly)
                {
                    btnSubRackSearchButton.Enabled = false;
                }
                arrItems3[3] = btnSubRackSearchVw;
            }
            else
            {
                iUtils.CreateFormGridItem btnSubRackSearch = new iUtils.CreateFormGridItem();
                UIView btnSubRackSearchVw = new UIView();
                btnSubRackSearch.SetDimensions(140f,iHdrVert, 60f, iRowHeight, 13f, 4f, 13f, 4f);
                btnSubRackSearch.SetBorderWidth(0.0f);
                btnSubRackSearch.SetTag(iEquipmentSubRackSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));

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

                btnSubRackSearchVw = btnSubRackSearch.GetLabelCell();
                arrItems3[3] = btnSubRackSearchVw;
            }

            if(iEquipmentType > 4)
            {
                iUtils.CreateFormGridItem btnPositionSearch = new iUtils.CreateFormGridItem();
                UIView btnPositionSearchVw = new UIView();
                btnPositionSearch.SetDimensions(200f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
                btnPositionSearch.SetLabelText("...");
                btnPositionSearch.SetBorderWidth(0.0f);
                btnPositionSearch.SetFontName("Verdana");
                btnPositionSearch.SetFontSize(12f);
                btnPositionSearch.SetTag(iEquipmentPositionSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));
                if (iPwrIdRowNo % 2 == 0)
                {
                    btnPositionSearch.SetCellColour("Pale Yellow");
                }
                else
                {
                    btnPositionSearch.SetCellColour("Pale Orange");
                }
                btnPositionSearchVw = btnPositionSearch.GetButtonCell();

                UIButton btnPositionSearchButton = new UIButton();
                btnPositionSearchButton = btnPositionSearch.GetButton();
                btnPositionSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 5);};

                if(bReadOnly)
                {
                    btnPositionSearchButton.Enabled = false;
                }
                arrItems3[4] = btnPositionSearchVw;
            }
            else
            {
                iUtils.CreateFormGridItem btnPositionSearch = new iUtils.CreateFormGridItem();
                UIView btnPositionSearchVw = new UIView();
                btnPositionSearch.SetDimensions(200f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
                btnPositionSearch.SetBorderWidth(0.0f);
                btnPositionSearch.SetTag(iEquipmentSubRackSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));

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

                btnPositionSearchVw = btnPositionSearch.GetLabelCell();
                arrItems3[4] = btnPositionSearchVw;
            }

            if(iEquipmentType > 5)
            {
                iUtils.CreateFormGridItem btnStringSearch = new iUtils.CreateFormGridItem();
                UIView btnStringSearchVw = new UIView();
                btnStringSearch.SetDimensions(250f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
                btnStringSearch.SetLabelText("...");
                btnStringSearch.SetBorderWidth(0.0f);
                btnStringSearch.SetFontName("Verdana");
                btnStringSearch.SetFontSize(12f);
                btnStringSearch.SetTag(iEquipmentStringSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));
                if (iPwrIdRowNo % 2 == 0)
                {
                    btnStringSearch.SetCellColour("Pale Yellow");
                }
                else
                {
                    btnStringSearch.SetCellColour("Pale Orange");
                }
                btnStringSearchVw = btnStringSearch.GetButtonCell();

                UIButton btnStringSearchButton = new UIButton();
                btnStringSearchButton = btnStringSearch.GetButton();
                btnStringSearchButton.TouchUpInside += (sender,e) => {OpenSearchView(sender, e, 7);};

                if(bReadOnly)
                {
                    btnStringSearchButton.Enabled = false;
                }
                arrItems3[5] = btnStringSearchVw;
            }
            else
            {
                iUtils.CreateFormGridItem btnStringSearch = new iUtils.CreateFormGridItem();
                UIView btnStringSearchVw = new UIView();
                btnStringSearch.SetDimensions(250f,iHdrVert, 50f, iRowHeight, 8f, 4f, 8f, 4f);
                btnStringSearch.SetBorderWidth(0.0f);
                btnStringSearch.SetTag(iEquipmentSubRackSearchTagId * (iPwrIdRowNo+1) + (iEquipRowNo+1));

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

                btnStringSearchVw = btnStringSearch.GetLabelCell();
                arrItems3[5] = btnStringSearchVw;
            }

            hdrRow.AddSubviews(arrItems3);

            iHeightToAdd += iRowHeight;
            iHdrVert += iRowHeight;

            //***************************************************************//
            //              3rd Row                                          //
            //***************************************************************//

            iUtils.CreateFormGridItem lblBankMake = new iUtils.CreateFormGridItem();
            UIView lblBankMakeVw = new UIView();
            lblBankMake.SetDimensions(0f, iHdrVert, 340f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
            lblBankMake.SetLabelText(sMake);
            lblBankMake.SetBorderWidth(0.0f);
            lblBankMake.SetFontName("Verdana");
            lblBankMake.SetFontSize(12f);
            lblBankMake.SetTag(iEquipmentMakeTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            lblBankMakeVw = lblBankMake.GetLabelCell();
            arrItems[0] = lblBankMakeVw;

            iUtils.CreateFormGridItem btnMakeSearch = new iUtils.CreateFormGridItem();
            UIView btnMakeSearchVw = new UIView();
            btnMakeSearch.SetDimensions(340f, iHdrVert, 60f, iRowHeight, 8f, 4f, 8f, 4f);
            btnMakeSearch.SetLabelText("...");
            btnMakeSearch.SetBorderWidth(0.0f);
            btnMakeSearch.SetFontName("Verdana");
            btnMakeSearch.SetFontSize(12f);
            btnMakeSearch.SetTag(iEquipmentMakeSearchTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));
            if (iPwrIdRowNo % 2 == 0)
            {
                btnMakeSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnMakeSearch.SetCellColour("Pale Orange");
            }
            btnMakeSearchVw = btnMakeSearch.GetButtonCell();

            UIButton btnMakeSearchButton = new UIButton();
            btnMakeSearchButton = btnMakeSearch.GetButton();
            btnMakeSearchButton.TouchUpInside += (sender,e) => {
                OpenMakeList(sender, e);};

            if(bReadOnly)
            {
                btnMakeSearchButton.Enabled = false;
            }
            arrItems[1] = btnMakeSearchVw;

            iUtils.CreateFormGridItem lblBankModel = new iUtils.CreateFormGridItem();
            UIView lblBankModelVw = new UIView();
            lblBankModel.SetDimensions(400f, iHdrVert, 440f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
            lblBankModel.SetLabelText(sModel);
            lblBankModel.SetBorderWidth(0.0f);
            lblBankModel.SetFontName("Verdana");
            lblBankModel.SetFontSize(12f);
            lblBankModel.SetTag(iEquipmentModelTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            lblBankModelVw = lblBankModel.GetLabelCell();
            arrItems[2] = lblBankModelVw;

            UILabel hfSPN = new UILabel();
            hfSPN.Text = sSPN;
            hfSPN.Tag = iEquipmentSPNHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfSPN.Hidden = true;
            arrItems[3] = hfSPN;

            iUtils.CreateFormGridItem btnModelSearch = new iUtils.CreateFormGridItem();
            UIView btnModelSearchVw = new UIView();
            btnModelSearch.SetDimensions(840f, iHdrVert, 60f, iRowHeight, 8f, 4f, 8f, 4f);
            btnModelSearch.SetLabelText("...");
            btnModelSearch.SetBorderWidth(0.0f);
            btnModelSearch.SetFontName("Verdana");
            btnModelSearch.SetFontSize(12f);
            btnModelSearch.SetTag(iEquipmentModelSearchTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));
            if (iPwrIdRowNo % 2 == 0)
            {
                btnModelSearch.SetCellColour("Pale Yellow");
            }
            else
            {
                btnModelSearch.SetCellColour("Pale Orange");
            }
            btnModelSearchVw = btnModelSearch.GetButtonCell();

            UIButton btnModelSearchButton = new UIButton();
            btnModelSearchButton = btnModelSearch.GetButton();
            btnModelSearchButton.TouchUpInside += (sender,e) => {
                OpenModelList(sender, e);};

            if(bReadOnly)
            {
                btnModelSearchButton.Enabled = false;
            }
            arrItems[4] = btnModelSearchVw;

            bool bAssetTextHidden = true;
            string sMaximoAssetId = iMaximoAssetId.ToString();
            if (sEquipType == "U")
            {
                bAssetTextHidden = false;
                sMaximoAssetId = iMaximoAssetId.ToString().PadLeft(10,'0');
            }

            iUtils.CreateFormGridItem txtMaximoAssetId = new iUtils.CreateFormGridItem();
            UIView txtMaximoAssetIdVw = new UIView();
            txtMaximoAssetId.SetDimensions(900f,iHdrVert, 100f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
            txtMaximoAssetId.SetLabelText(sMaximoAssetId);
            txtMaximoAssetId.SetBorderWidth(0.0f);
            txtMaximoAssetId.SetFontName("Verdana");
            txtMaximoAssetId.SetFontSize(12f);
            txtMaximoAssetId.SetTextAlignment("right");
            txtMaximoAssetId.SetHidden(bAssetTextHidden);
            txtMaximoAssetId.SetTag(iEquipmentMaximoAssetTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            txtMaximoAssetIdVw = txtMaximoAssetId.GetTextFieldCell();
            txtMaximoAssetIdVw.Hidden = bAssetTextHidden;
            txtMaximoAssetIdVw.Tag = iEquipmentMaximoAssetTextViewTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);

            UITextField txtMaximoAssetIdView = txtMaximoAssetId.GetTextFieldView();
            txtMaximoAssetIdView.AutocorrectionType = UITextAutocorrectionType.No;
            txtMaximoAssetIdView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
            txtMaximoAssetIdView.ReturnKeyType = UIReturnKeyType.Next;
            txtMaximoAssetIdView.ShouldBeginEditing += (sender) => {
                return SetGlobalEditItems(sender, 9);};
            txtMaximoAssetIdView.ShouldEndEditing += (sender) => {
                return ValidateMaximoAssetId(sender, 0);};
            txtMaximoAssetIdView.ShouldReturn += (sender) => {
                return MoveNextTextField(sender, 9);};

            if(bReadOnly)
            {
                txtMaximoAssetIdView.Enabled = false;
            }

            iUtils.CreateFormGridItem lblMaximoAssetId = new iUtils.CreateFormGridItem();
            UIView lblMaximoAssetIdVw = new UIView();
            lblMaximoAssetId.SetDimensions(900f,iHdrVert, 100f, iRowHeight, 2f, 2f, 2f, 2f); //Set left to 1 less so border does not double up
            lblMaximoAssetId.SetLabelText(sMaximoAssetId);
            lblMaximoAssetId.SetBorderWidth(0.0f);
            lblMaximoAssetId.SetFontName("Verdana");
            lblMaximoAssetId.SetFontSize(12f);
            lblMaximoAssetId.SetTextAlignment("right");
            lblMaximoAssetId.SetHidden(!bAssetTextHidden);
            lblMaximoAssetId.SetTag(iEquipmentMaximoLblAssetTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1));

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

            lblMaximoAssetIdVw = lblMaximoAssetId.GetLabelCell();
            lblMaximoAssetIdVw.Hidden = !bAssetTextHidden;
            lblMaximoAssetIdVw.Tag = iEquipmentMaximoLblViewAssetTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);

            arrItems[5] = txtMaximoAssetIdVw;
            arrItems[6] = lblMaximoAssetIdVw;

            UILabel hfCurrentMaximoAssetId = new UILabel();
            hfCurrentMaximoAssetId.Text = sMaximoAssetId;
            hfCurrentMaximoAssetId.Tag = iEquipmentMaximoAssetHiddenTagId * (iPwrIdRowNo + 1) + (iEquipRowNo + 1);
            hfCurrentMaximoAssetId.Hidden = true;
            arrItems[7] = hfCurrentMaximoAssetId;

            hdrRow.AddSubviews(arrItems);

            iHeightToAdd += iRowHeight;
            iHdrVert += iRowHeight;

            //Now draw a 1 pixel horizontal line
            UIView vwHorizLine = new UIView();
            vwHorizLine.Frame = new RectangleF(0f,iHdrVert, 1000f, 1f);
            vwHorizLine.BackgroundColor = UIColor.FromRGBA(0,0,0,255);

            iHeightToAdd += 1f;
            iHdrVert += 1f;

            hdrRow.AddSubview(vwHorizLine);

            return hdrRow;
        }
Esempio n. 3
0
        public void DrawOpeningPage()
        {
            try
            {
                DateClass dt = new DateClass();
                int iColNo = 0;
                int iSectionId = 0;
                bool bYes;
                bool bNo;
                bool bNA;
                string sId = m_sPassedId;
                float iVert = 0f;
                float iSectionHdrRowHeight = 40f;
                float iQuestionHdrRowHeight = 20f;
                float iQuestionRowHeight = 30f;
                float iQuestionRowVert = 0f;
                float iTotalHeight = 0f;
                float iHeightToAdd = iQuestionRowHeight;
                float iHeightToAdd2 = iHeightToAdd;
                bool bDisableRow = false;
                bool bFullyCommitted = false;
                bool bHideComplete = true;
                bool[] bHideSections = new bool[1];
                UIView[] arrItems = new UIView[5];
                UIView[] arrItems2 = new UIView[6];
                UIView[] arrItems3 = new UIView[5];
                UIView[] arrItems4 = new UIView[6];
                UIView[] arrItems6 = new UIView[11];
                UIView[] arrItems7 = new UIView[7];
                UIView[] arrItems14 = new UIView[8];

                UIScrollView layout = new UIScrollView();
                layout.Frame = new RectangleF(0f,35f,1000f,620f);
                layout.Tag = 2;
                clsTabletDB.ITPDocumentSection ITPSection = new clsTabletDB.ITPDocumentSection();

                //Get all the sections and place a table layout for each one
                DataSet arrITPSections = ITPSection.GetLocalITPSections(sId);

                if (arrITPSections.Tables.Count > 0)
                {
                    int iRows = arrITPSections.Tables[0].Rows.Count;
                    m_iSections = iRows;
                    m_iQuestionSections = iRows;
                    Array.Resize<bool>(ref bHideSections, iRows);

                    for (int i = 0; i < iRows; i++)
                    {
                        bHideSections[i] = false;

                        //Add in a view for each section.
                        UIView SectionRow = new UIView();
                        iSectionId = iSectionTagId * (i+1);
                        SectionRow.Tag = iSectionId;
                        SectionRow.Frame = new RectangleF(0f,iVert,1000f,iSectionHdrRowHeight);

                        layout.AddSubview(SectionRow);

                        //Add in the section title and buttons for each section header
                        UILabel hfSection = new UILabel();
                        iColNo = arrITPSections.Tables[0].Columns["SectionId"].Ordinal;
                        hfSection.Text = arrITPSections.Tables[0].Rows[i].ItemArray[iColNo].ToString();
                        hfSection.Tag = iSectionDBIdTagId * (i+1);
                        hfSection.Hidden = true;
                        SectionRow.AddSubview(hfSection);

                        iUtils.CreateFormGridItem Section = new iUtils.CreateFormGridItem();
                        UIView SectionVw = new UIView();
                        iColNo = arrITPSections.Tables[0].Columns["Name"].Ordinal;
                        Section.SetDimensions(0f,0f, 300f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f);
                        Section.SetLabelText(arrITPSections.Tables[0].Rows[i].ItemArray[iColNo].ToString());
                        Section.SetBorderWidth(0.0f);
                        Section.SetFontName("Verdana-Bold");
                        Section.SetTextColour("White");
                        Section.SetFontSize(12f);
                        Section.SetCellColour("DarkSlateGrey");
                        Section.SetTag(iSectionDescTagId * (i+1));
                        SectionVw = Section.GetLabelCell();
                        arrItems[0] = SectionVw;

                        bool bAnyCommitted = ITPSection.ProjectSectionRFUAnyPwrIdCommitted(m_sPassedId);

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

                        iUtils.CreateFormGridItem SectionCompleteLabel = new iUtils.CreateFormGridItem();
                        UIView SectionCompleteLabelVw = new UIView();
                        SectionCompleteLabel.SetDimensions(300f,0f, 250f, 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 * (i+1));
                        SectionCompleteLabel.SetHidden(bHideComplete);
                        SectionCompleteLabelVw = SectionCompleteLabel.GetLabelCell();
                        arrItems[1] = SectionCompleteLabelVw;

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

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

                        arrItems[2] = btnSaveVw;

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

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

                        arrItems[3] = btnExpandVw;

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

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

                        arrItems[4] = btnContractVw;

                        SectionRow.AddSubviews(arrItems);

                        iVert += iSectionHdrRowHeight;

                        //Now add a new view to this view to hold another view containing all the questions for this section
                        UIView QuestionsTableRow = new UIView();
                        float iQuestionRowVertTop = iVert;
                        QuestionsTableRow.Frame = new RectangleF(0f,iQuestionRowVertTop,1000f,iQuestionHdrRowHeight);
                        iSectionId = iContainerSectionTagId * (i+1);
                        QuestionsTableRow.Tag = iSectionId;
                        layout.AddSubview(QuestionsTableRow);

                        //Get all the questions in this section and place a row for each one
                        iColNo = arrITPSections.Tables[0].Columns["SectionId"].Ordinal;
                        int iDBSectionId = Convert.ToInt32( arrITPSections.Tables[0].Rows[i].ItemArray[iColNo]);
                        iColNo = arrITPSections.Tables[0].Columns["QuestionType"].Ordinal;
                        int iQuestionTypes = Convert.ToInt32(arrITPSections.Tables[0].Rows[i].ItemArray[iColNo]);

                        DataSet arrITPSectionQuestions = ITPSection.GetLocalITPSectionQuestions(sId, iDBSectionId);

                        if (arrITPSectionQuestions.Tables.Count > 0)
                        {
                            int iQuestionRows = arrITPSectionQuestions.Tables[0].Rows.Count;

                            //Put in the header row
                            iUtils.CreateFormGridItem lblQuestionHdr = new iUtils.CreateFormGridItem();
                            UIView lblQuestionHdrVw = new UIView();
                            lblQuestionHdr.SetDimensions(0f,0f, 400f, iQuestionHdrRowHeight, 4f, 1f, 4f, 1f);
                            lblQuestionHdr.SetLabelText("Question");
                            lblQuestionHdr.SetBorderWidth(0.0f);
                            lblQuestionHdr.SetFontName("Verdana-Bold");
                            lblQuestionHdr.SetTextAlignment("Centre");
                            lblQuestionHdr.SetFontSize(12f);
                            lblQuestionHdr.SetCellColour("Pale Yellow");
                            lblQuestionHdr.SetTag(iQuestionHdrTagId * (i+1));
                            lblQuestionHdrVw = lblQuestionHdr.GetLabelCell();
                            arrItems2[0] = lblQuestionHdrVw;

                            iUtils.CreateFormGridItem lblAnswerHdr = new iUtils.CreateFormGridItem();
                            UIView lblAnswerHdrVw = new UIView();
                            lblAnswerHdr.SetDimensions(400f,0f, 200f, iQuestionHdrRowHeight, 4f, 1f, 4f, 1f);
                            lblAnswerHdr.SetLabelText("Answer");
                            lblAnswerHdr.SetBorderWidth(0.0f);
                            lblAnswerHdr.SetFontName("Verdana-Bold");
                            lblAnswerHdr.SetTextAlignment("Centre");
                            lblAnswerHdr.SetFontSize(12f);
                            lblAnswerHdr.SetCellColour("Pale Yellow");
                            lblAnswerHdr.SetTag(iAnswerHdrTagId * (i+1));
                            lblAnswerHdrVw = lblAnswerHdr.GetLabelCell();
                            arrItems2[1] = lblAnswerHdrVw;

                            iUtils.CreateFormGridItem lblCommentsHdr = new iUtils.CreateFormGridItem();
                            UIView lblCommentsHdrVw = new UIView();
                            lblCommentsHdr.SetDimensions(600f,0f, 200f, iQuestionHdrRowHeight, 4f, 1f, 4f, 1f);
                            lblCommentsHdr.SetLabelText("Comments");
                            lblCommentsHdr.SetBorderWidth(0.0f);
                            lblCommentsHdr.SetFontName("Verdana-Bold");
                            lblCommentsHdr.SetTextAlignment("Centre");
                            lblCommentsHdr.SetFontSize(12f);
                            lblCommentsHdr.SetCellColour("Pale Yellow");
                            lblCommentsHdr.SetTag(iCommentsHdrTagId * (i+1));
                            lblCommentsHdrVw = lblCommentsHdr.GetLabelCell();
                            arrItems2[2] = lblCommentsHdrVw;
                            layout.AddSubview(QuestionsTableRow);

                            float iSectionQuestionsHeight = iQuestionHdrRowHeight;
                            UILabel hfSectionHeight = new UILabel();
                            hfSectionHeight.Tag = iSectionHeightTagId * (i+1);
                            hfSectionHeight.Hidden = true;
                            arrItems2[3] = hfSectionHeight;

                            UILabel hfSectionRows = new UILabel();
                            hfSectionRows.Tag = iSectionRowsTagId * (i+1);
                            hfSectionRows.Hidden = true;
                            hfSectionRows.Text = iQuestionRows.ToString();
                            arrItems2[4] = hfSectionRows;

                            UILabel hfSectionStatus = new UILabel();
                            hfSectionStatus.Tag = iSectionStatusTagId * (i+1);
                            hfSectionStatus.Hidden = true;
                            hfSectionStatus.Text = "0";
                            arrItems2[5] = hfSectionStatus;

                            QuestionsTableRow.AddSubviews(arrItems2);

                            iVert += iQuestionHdrRowHeight;
                            iQuestionRowVert = iQuestionHdrRowHeight;
                            bool bSectionFullyCompleted = true;

                            for (int j = 0; j < iQuestionRows; j++)
                            {

                                UILabel hfRowStatus = new UILabel();
                                hfRowStatus.Text = "0";
                                hfRowStatus.Tag = (ihfRowStatusTagId + (j+1)) * (i+1);
                                hfRowStatus.Hidden = true;
                                arrItems3[0] = hfRowStatus;

                                iColNo = arrITPSectionQuestions.Tables[0].Columns["AutoId"].Ordinal;
                                string sAutoId = arrITPSectionQuestions.Tables[0].Rows[j].ItemArray[iColNo].ToString();
                                iColNo = arrITPSectionQuestions.Tables[0].Columns["Question"].Ordinal;
                                string sQuestion = arrITPSectionQuestions.Tables[0].Rows[j].ItemArray[iColNo].ToString();

                                UILabel hfAutoId = new UILabel();
                                hfAutoId.Text = sAutoId;
                                hfAutoId.Tag = (ihfAutoRowTagId + (j+1)) * (i+1);
                                hfAutoId.Hidden = true;
                                arrItems3[1] = hfAutoId;

                                //Put in the question
                                iUtils.CreateFormGridItem rowQuestion = new iUtils.CreateFormGridItem();
                                UIView rowQuestionVw = new UIView();
                                rowQuestion.SetLabelWrap(1); //This means the text will be wrapped in the label
                                rowQuestion.SetDimensions(0f,iQuestionRowVert, 400f, iQuestionRowHeight, 2f, 2.5f, 2f, 2.5f);
                                rowQuestion.SetLabelText(sQuestion);
                                rowQuestion.SetBorderWidth(0.0f);
                                rowQuestion.SetFontName("Verdana");
                                rowQuestion.SetFontSize(12f);
                                rowQuestion.SetTag((iQuestionRowTagId + (j+1)) * (i+1));

                                if (j % 2 == 0)
                                {
                                    rowQuestion.SetCellColour("Pale Blue");
                                }
                                else
                                {
                                    rowQuestion.SetCellColour("Sky Blue");
                                }

                                rowQuestionVw = rowQuestion.GetLabelCell();
                                iHeightToAdd = rowQuestion.GetCellHeight();

                                //Put in the answer
                                iColNo = arrITPSectionQuestions.Tables[0].Columns["Yes"].Ordinal;
                                bYes = Convert.ToBoolean(arrITPSectionQuestions.Tables[0].Rows[j].ItemArray[iColNo]);

                                iColNo = arrITPSectionQuestions.Tables[0].Columns["No"].Ordinal;
                                bNo = Convert.ToBoolean(arrITPSectionQuestions.Tables[0].Rows[j].ItemArray[iColNo]);

                                iColNo = arrITPSectionQuestions.Tables[0].Columns["NA"].Ordinal;
                                bNA = Convert.ToBoolean(arrITPSectionQuestions.Tables[0].Rows[j].ItemArray[iColNo]);

                                iUtils.CreateFormGridItem radGrp = new iUtils.CreateFormGridItem();
                                UIView radGrpVw = new UIView();
                                radGrp.SetDimensions(400f,iQuestionRowVert, 200f, iQuestionRowHeight, 2f, 2.5f, 2f, 2.5f);
                                radGrp.SetFontName("Verdana");
                                radGrp.SetFontSize(12f);
                                radGrp.SetTag((iAnswerGroupTagId + (j+1)) * (i+1));

                                if (j % 2 == 0)
                                {
                                    radGrp.SetCellColour("Pale Blue");
                                }
                                else
                                {
                                    radGrp.SetCellColour("Sky Blue");
                                }

                                radGrpVw = radGrp.GetRadioButtonCell();

                                UISegmentedControl radGrpRadio = new UISegmentedControl();
                                radGrpRadio = radGrp.GetRadioGroup();
                                radGrpRadio.TouchUpInside += (sender,e) => {SetRowRadioChanged(sender, e);};
                                radGrpRadio.ValueChanged += (sender,e) => {SetRowRadioChanged(sender, e);};

                                QuestionsBitMask mask = (QuestionsBitMask)iQuestionTypes;
                                int iPos = 0;
                                bool bQuestionSet = false;

                                if ((mask & QuestionsBitMask.Yes) == QuestionsBitMask.Yes)
                                {
                                    radGrpRadio.InsertSegment("Yes", iPos,false);
                                    if(bYes)
                                    {
                                        radGrpRadio.SelectedSegment = iPos;
                                        bQuestionSet= true;
                                    }
                                    iPos++;
                                }

                                if ((mask & QuestionsBitMask.No) == QuestionsBitMask.No)
                                {
                                    radGrpRadio.InsertSegment("No", iPos,false);
                                    if(bNo)
                                    {
                                        radGrpRadio.SelectedSegment = iPos;
                                        bQuestionSet= true;
                                    }
                                    iPos++;
                                }

                                if ((mask & QuestionsBitMask.NA) == QuestionsBitMask.NA)
                                {
                                    radGrpRadio.InsertSegment("N/A", iPos,false);
                                    if(bNA)
                                    {
                                        radGrpRadio.SelectedSegment = iPos;
                                        bQuestionSet= true;
                                    }
                                }

                                if(bQuestionSet)
                                {
                                    radGrpRadio.Enabled = false;
                                }
                                else
                                {
                                    bSectionFullyCompleted = false;
                                }

                                //Put in the comments
                                iUtils.CreateFormGridItem rowComments = new iUtils.CreateFormGridItem();
                                UIView rowCommentsVw = new UIView();
                                iColNo = arrITPSectionQuestions.Tables[0].Columns["Comments"].Ordinal;
                                rowComments.SetLabelWrap(1); //This means the text will be wrapped in the label
                                rowComments.SetDimensions(600f,iQuestionRowVert, 200f, iQuestionRowHeight, 2f, 2.5f, 2f, 2.5f);
                                rowComments.SetLabelText(arrITPSectionQuestions.Tables[0].Rows[j].ItemArray[iColNo].ToString());
                                rowComments.SetBorderWidth(0.0f);
                                rowComments.SetFontName("Verdana");
                                rowComments.SetFontSize(12f);
                                rowComments.SetTag((iCommentsTagId + (j+1)) * (i+1)); //

                                if (j % 2 == 0)
                                {
                                    rowComments.SetCellColour("Pale Blue");
                                }
                                else
                                {
                                    rowComments.SetCellColour("Sky Blue");
                                }

                                rowCommentsVw = rowComments.GetTextCell();
                                iHeightToAdd2 = rowComments.GetCellHeight();
                                UITextView rowCommentsTextVw = new UITextView();
                                rowCommentsTextVw = rowComments.GetTextView();
                                rowCommentsTextVw.ShouldBeginEditing += (sender) => {
                                    return SetGlobalEditItems(sender, 11);};
                                rowCommentsTextVw.Changed += (sender,e) => {SetRowEditTextChanged(sender, e);};

                                if(bQuestionSet)
                                {
                                    rowCommentsTextVw.Editable = false;
                                }

                                if(iHeightToAdd2 > iHeightToAdd)
                                {
                                    rowQuestion.SetDimensions(0f,iQuestionRowVert, 400f, iHeightToAdd2, 2f, 2.5f, 2f, 2.5f);
                                    rowQuestion.ResetCellViewDimensions(rowQuestionVw);
                                    radGrp.SetDimensions(400f,iQuestionRowVert, 200f, iHeightToAdd2, 2f, 2.5f, 2f, 2.5f);
                                    radGrp.ResetCellViewDimensions(radGrpVw);
                                }
                                else
                                {
                                    radGrp.SetDimensions(400f,iQuestionRowVert, 200f, iHeightToAdd, 2f, 2.5f, 2f, 2.5f);
                                    radGrp.ResetCellViewDimensions(radGrpVw);
                                    rowComments.SetDimensions(600f,iQuestionRowVert, 200f, iHeightToAdd, 2f, 2.5f, 2f, 2.5f);
                                    rowComments.ResetCellViewDimensions(rowCommentsVw);
                                    rowComments.ResetCellTextViewDimensions(rowCommentsTextVw);
                                }

                                arrItems3[2] = rowQuestionVw;
                                arrItems3[3] = radGrpVw;
                                arrItems3[4] = rowCommentsVw;

                                QuestionsTableRow.AddSubviews(arrItems3);

                                iSectionQuestionsHeight += iHeightToAdd;
                                iQuestionRowVert += iHeightToAdd;
                                iVert += iHeightToAdd;

                            }

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

                            if(bSectionFullyCompleted)
                            {
                                bHideSections[i] = true;
                            }
                        }
                    }

                }

                //******************************************************************************************//
                //                      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 = arrITPSections.Tables[0].Rows.Count;
                    m_iSections++; //Add an extra one for the batteries section
                    m_iBatterySectionCounter = ii;
                    int iPwrIdRows = arrITPSection10PwrIds.Tables[0].Rows.Count;

                    //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, 300f, 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(RFUFullyCommitted())
                    {
                        bFullyCommitted = true;
                        bHideComplete = false;
                    }
                    else
                    {
                        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(300f,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(450f,0f, 350f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                    btnSave10.SetLabelText("Open Battery Details Screen");
                    btnSave10.SetBorderWidth(0.0f);
                    btnSave10.SetFontName("Verdana");
                    btnSave10.SetFontSize(12f);
                    btnSave10.SetTag(iSaveSectionBtnTagId * (ii+1));
                    btnSave10.SetCellColour("DarkSlateGrey");
                    btnSave10Vw = btnSave10.GetButtonCell();

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

                    arrItems4[2] = btnSave10Vw;

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

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

                    UILabel hfSectionStatus = new UILabel();
                    hfSectionStatus.Tag = iSectionStatusTagId * (ii+1);
                    hfSectionStatus.Hidden = true;
                    hfSectionStatus.Text = "0";
                    arrItems4[5] = 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,0f);
                    iSectionId = iContainerSectionTagId * (ii+1);
                    PwrIdTableRow.Tag = iSectionId;
                    layout.AddSubview(PwrIdTableRow);
                }

                //******************************************************************************************//
                //                      SECTION 10 (EQUIPMENT)                                              //
                //******************************************************************************************//
                //Get all the PwrId's for this project from ITPSection10
                DataSet arrITPSectionEquipmentPwrIds = ITPSection.GetLocalITPSectionEquipmentPwrIds(sId);

                if (arrITPSectionEquipmentPwrIds.Tables.Count > 0)
                {
                    int iii = m_iSections;
                    m_iSections++; //Add an extra one for the equipment section
                    m_iEquipmentSectionCounter = iii;
                    int iPwrIdRows = arrITPSectionEquipmentPwrIds.Tables[0].Rows.Count;

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

                    UILabel hfSectionEquipment = new UILabel();
                    hfSectionEquipment.Text = "10";
                    hfSectionEquipment.Tag = iSectionDBIdTagId * (iii+1);
                    hfSectionEquipment.Hidden = true;
                    SectionEquipmentRow.AddSubview(hfSectionEquipment);

                    iUtils.CreateFormGridItem SectionEquipment = new iUtils.CreateFormGridItem();
                    UIView SectionEquipmentVw = new UIView();
                    SectionEquipment.SetDimensions(0f,0f, 300f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f);
                    SectionEquipment.SetLabelText("POWER CONVERSION EQUIPMENT");
                    SectionEquipment.SetBorderWidth(0.0f);
                    SectionEquipment.SetFontName("Verdana-Bold");
                    SectionEquipment.SetTextColour("White");
                    SectionEquipment.SetFontSize(12f);
                    SectionEquipment.SetCellColour("DarkSlateGrey");
                    SectionEquipment.SetTag(iSectionDescTagId * (iii+1));
                    SectionEquipmentVw = SectionEquipment.GetLabelCell();
                    arrItems4[0] = SectionEquipmentVw;

                    if(RFUFullyCommitted())
                    {
                        bFullyCommitted = true;
                        bHideComplete = false;
                    }
                    else
                    {
                        if(PowerConversionFullyCommitted())
                        {
                            bFullyCommitted = true;
                            bHideComplete = false;
                        }
                        else
                        {
                            bFullyCommitted = false;
                            if(PowerConversionFullyComplete())
                            {
                                bHideComplete = false;
                            }
                            else
                            {
                                bHideComplete = true;
                            }
                        }
                    }

                    iUtils.CreateFormGridItem SectionCompleteLabel = new iUtils.CreateFormGridItem();
                    UIView SectionCompleteLabelVw = new UIView();
                    SectionCompleteLabel.SetDimensions(300f,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 * (iii+1));
                    SectionCompleteLabel.SetHidden(bHideComplete);
                    SectionCompleteLabelVw = SectionCompleteLabel.GetLabelCell();
                    arrItems4[1] = SectionCompleteLabelVw;

                    iUtils.CreateFormGridItem btnSaveEquipment = new iUtils.CreateFormGridItem();
                    UIView btnSaveEquipmentVw = new UIView();
                    btnSaveEquipment.SetDimensions(450f,0f, 350f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                    btnSaveEquipment.SetLabelText("Open Power Conversion Equipment Screen");
                    btnSaveEquipment.SetBorderWidth(0.0f);
                    btnSaveEquipment.SetFontName("Verdana");
                    btnSaveEquipment.SetFontSize(12f);
                    btnSaveEquipment.SetTag(iSaveSectionBtnTagId * (iii+1));
                    btnSaveEquipment.SetCellColour("DarkSlateGrey");
                    btnSaveEquipmentVw = btnSaveEquipment.GetButtonCell();

                    UIButton btnSaveEquipmentButton = new UIButton();
                    btnSaveEquipmentButton = btnSaveEquipment.GetButton();
                    btnSaveEquipmentButton.TouchUpInside += (sender,e) => {OpenPowerConversion(sender, e);};

                    arrItems4[2] = btnSaveEquipmentVw;

                    UILabel hfSectionEquipmentHeight = new UILabel();
                    hfSectionEquipmentHeight.Tag = iSectionHeightTagId * (iii+1);
                    hfSectionEquipmentHeight.Hidden = true;
                    hfSectionEquipmentHeight.Text = "0";
                    arrItems4[3] = hfSectionEquipmentHeight;

                    UILabel hfSectionEquipmentRows = new UILabel();
                    hfSectionEquipmentRows.Tag = iSectionRowsTagId * (iii+1);
                    hfSectionEquipmentRows.Hidden = true;
                    hfSectionEquipmentRows.Text = iPwrIdRows.ToString();
                    arrItems4[4] = hfSectionEquipmentRows;

                    UILabel hfSectionEquipmentStatus = new UILabel();
                    hfSectionEquipmentStatus.Tag = iSectionStatusTagId * (iii+1);
                    hfSectionEquipmentStatus.Hidden = true;
                    hfSectionEquipmentStatus.Text = "0";
                    arrItems4[5] = hfSectionEquipmentStatus;

                    SectionEquipmentRow.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,0f);
                    iSectionId = iContainerSectionTagId * (iii+1);
                    PwrIdTableRow.Tag = iSectionId;
                    layout.AddSubview(PwrIdTableRow);
                }

                //******************************************************************************************//
                //                      SECTION RFU                                                         //
                //******************************************************************************************//
                //Get all the PwrId's for this project from ITPRFU
                DataSet arrITPRFUs = ITPSection.GetLocalITPRFUPwrIds(sId);

                if (arrITPRFUs.Tables.Count > 0)
                {
                    float iRFURowVert = 0.0f;
                    float iSectionRFUHeight = 0.0f;
                    float iRFURowVertTop = iVert;
                    float iRFURowInnerTop = 0.0f;

                    int ii = m_iSections;
                    m_iSections++; //Add an extra one for the RFU section
                    m_iRFUSectionCounter = ii; //Here ii and m_iSections are different by 1. If we add more sections after this it will be different later on
                    int iPwrIdRowsRFU = arrITPRFUs.Tables[0].Rows.Count;

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

                    UILabel hfSectionRFU = new UILabel();
                    hfSectionRFU.Text = "RFU";
                    hfSectionRFU.Tag = iSectionDBIdTagId * (ii+1);
                    hfSectionRFU.Hidden = true;
                    SectionRFURow.AddSubview(hfSectionRFU);

                    iUtils.CreateFormGridItem SectionRFU = new iUtils.CreateFormGridItem();
                    UIView SectionRFUVw = new UIView();
                    SectionRFU.SetDimensions(0f,0f, 300f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f);
                    SectionRFU.SetLabelText("READY FOR USE (RFU)");
                    SectionRFU.SetBorderWidth(0.0f);
                    SectionRFU.SetFontName("Verdana-Bold");
                    SectionRFU.SetTextColour("White");
                    SectionRFU.SetFontSize(12f);
                    SectionRFU.SetCellColour("DarkSlateGrey");
                    SectionRFU.SetTag(iSectionDescTagId * (ii+1));
                    SectionRFUVw = SectionRFU.GetLabelCell();
                    arrItems14[0] = SectionRFUVw;

                    if(RFUFullyCommitted())
                    {
                        bFullyCommitted = false;
                    }
                    else
                    {
                        bFullyCommitted = true;
                    }

                    iUtils.CreateFormGridItem SectionCompleteLabel = new iUtils.CreateFormGridItem();
                    UIView SectionCompleteLabelVw = new UIView();
                    SectionCompleteLabel.SetDimensions(300f,0f, 250f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f);
                    SectionCompleteLabel.SetLabelText("COMMITTED");
                    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(bFullyCommitted);
                    SectionCompleteLabelVw = SectionCompleteLabel.GetLabelCell();
                    arrItems14[1] = SectionCompleteLabelVw;

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

                    UIButton btnSaveRFUButton = new UIButton();
                    btnSaveRFUButton = btnSaveRFU.GetButton();
                    btnSaveRFUButton.TouchUpInside += (sender,e) => {SaveThisSection(sender, e);};
                    btnSaveRFUButton.Hidden = true;
                    arrItems14[2] = btnSaveRFUVw;

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

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

                    arrItems14[3] = btnExpandRFUVw;

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

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

                    arrItems14[4] = btnContractRFUVw;

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

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

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

                    SectionRFURow.AddSubviews(arrItems14);

                    iVert += iSectionHdrRowHeight;
                    iRFURowVertTop += iSectionHdrRowHeight;

                    //Now add a new view to this view to hold another view containing all the pwrid info for this RFU section
                    UIView RFUTableRow = new UIView();
                    RFUTableRow.Frame = new RectangleF(0f,iRFURowVertTop,1000f,iSectionHdrRowHeight);
                    iSectionId = iContainerSectionTagId * (ii+1);
                    RFUTableRow.Tag = iSectionId;
                    layout.AddSubview(RFUTableRow);

                    //Put in the header
                    UIView vwPwrHdrInternalRowId = new UIView();
                    vwPwrHdrInternalRowId.Frame = new RectangleF(0f,iRFURowVert,1000f,iSectionHdrRowHeight); //This will be resized later on

                    iUtils.CreateFormGridItem rowPwrIdHdrLbl = new iUtils.CreateFormGridItem();
                    UIView rowPwrIdHdrLblVw = new UIView();
                    rowPwrIdHdrLbl.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                    rowPwrIdHdrLbl.SetDimensions(0f,iRFURowVert, 100f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                    rowPwrIdHdrLbl.SetLabelText("Power Id");
                    rowPwrIdHdrLbl.SetTextAlignment("centre");
                    rowPwrIdHdrLbl.SetBorderWidth(0.0f);
                    rowPwrIdHdrLbl.SetFontName("Verdana-Bold");
                    rowPwrIdHdrLbl.SetFontSize(14f);
                    rowPwrIdHdrLbl.SetTag((iRFUPwrIdHdrLabelTagId) * (ii+1));
                    rowPwrIdHdrLbl.SetCellColour("Pale Yellow");

                    rowPwrIdHdrLblVw = rowPwrIdHdrLbl.GetLabelCell();
                    iHeightToAdd = iSectionHdrRowHeight;
                    arrItems7[0] = rowPwrIdHdrLblVw;

                    iUtils.CreateFormGridItem rowDesignLoadHdrLbl = new iUtils.CreateFormGridItem();
                    UIView rowDesignLoadHdrLblVw = new UIView();
                    rowDesignLoadHdrLbl.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                    rowDesignLoadHdrLbl.SetDimensions(100f,iRFURowVert, 100f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                    rowDesignLoadHdrLbl.SetLabelText("Design Load");
                    rowDesignLoadHdrLbl.SetTextAlignment("centre");
                    rowDesignLoadHdrLbl.SetBorderWidth(0.0f);
                    rowDesignLoadHdrLbl.SetFontName("Verdana-Bold");
                    rowDesignLoadHdrLbl.SetFontSize(14f);
                    rowDesignLoadHdrLbl.SetTag((iRFUDesignLoadHdrLabelTagId) * (ii+1));
                    rowDesignLoadHdrLbl.SetCellColour("Pale Yellow");
                    rowDesignLoadHdrLblVw = rowDesignLoadHdrLbl.GetLabelCell();
                    iHeightToAdd = iSectionHdrRowHeight;
                    arrItems7[1] = rowDesignLoadHdrLblVw;

                    iUtils.CreateFormGridItem rowCutoverLoadHdrLbl = new iUtils.CreateFormGridItem();
                    UIView rowCutoverLoadHdrLblVw = new UIView();
                    rowCutoverLoadHdrLbl.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                    rowCutoverLoadHdrLbl.SetDimensions(200f,iRFURowVert, 100f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                    rowCutoverLoadHdrLbl.SetLabelText("Cutover Load");
                    rowCutoverLoadHdrLbl.SetTextAlignment("centre");
                    rowCutoverLoadHdrLbl.SetBorderWidth(0.0f);
                    rowCutoverLoadHdrLbl.SetFontName("Verdana-Bold");
                    rowCutoverLoadHdrLbl.SetFontSize(14f);
                    rowCutoverLoadHdrLbl.SetTag((iRFUCutoverLoadHdrLabelTagId) * (ii+1));
                    rowCutoverLoadHdrLbl.SetCellColour("Pale Yellow");

                    rowCutoverLoadHdrLblVw = rowCutoverLoadHdrLbl.GetLabelCell();
                    iHeightToAdd = iSectionHdrRowHeight;
                    arrItems7[2] = rowCutoverLoadHdrLblVw;

                    iUtils.CreateFormGridItem rowCutoverDateHdrLbl = new iUtils.CreateFormGridItem();
                    UIView rowCutoverDateHdrLblVw = new UIView();
                    rowCutoverDateHdrLbl.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                    rowCutoverDateHdrLbl.SetDimensions(300f,iRFURowVert, 100f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                    rowCutoverDateHdrLbl.SetLabelText("Cutover Date");
                    rowCutoverDateHdrLbl.SetTextAlignment("centre");
                    rowCutoverDateHdrLbl.SetBorderWidth(0.0f);
                    rowCutoverDateHdrLbl.SetFontName("Verdana-Bold");
                    rowCutoverDateHdrLbl.SetFontSize(14f);
                    rowCutoverDateHdrLbl.SetTag((iRFUCutoverDateHdrLabelTagId) * (ii+1));
                    rowCutoverDateHdrLbl.SetCellColour("Pale Yellow");

                    rowCutoverDateHdrLblVw = rowCutoverDateHdrLbl.GetLabelCell();
                    iHeightToAdd = iSectionHdrRowHeight;
                    arrItems7[3] = rowCutoverDateHdrLblVw;

                    iUtils.CreateFormGridItem rowDecommissionedHdrLbl = new iUtils.CreateFormGridItem();
                    UIView rowDecommissionedHdrLblVw = new UIView();
                    rowDecommissionedHdrLbl.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                    rowDecommissionedHdrLbl.SetDimensions(400f,iRFURowVert, 150f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                    rowDecommissionedHdrLbl.SetLabelText("Decommissioned");
                    rowDecommissionedHdrLbl.SetTextAlignment("centre");
                    rowDecommissionedHdrLbl.SetBorderWidth(0.0f);
                    rowDecommissionedHdrLbl.SetFontName("Verdana-Bold");
                    rowDecommissionedHdrLbl.SetFontSize(14f);
                    rowDecommissionedHdrLbl.SetTag((iRFUDecommissionedHdrLabelTagId) * (ii+1));
                    rowDecommissionedHdrLbl.SetCellColour("Pale Yellow");

                    rowDecommissionedHdrLblVw = rowDecommissionedHdrLbl.GetLabelCell();
                    iHeightToAdd = iSectionHdrRowHeight;
                    arrItems7[4] = rowDecommissionedHdrLblVw;

                    iUtils.CreateFormGridItem rowCommissionedHdrLbl = new iUtils.CreateFormGridItem();
                    UIView rowCommissionedHdrLblVw = new UIView();
                    rowCommissionedHdrLbl.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                    rowCommissionedHdrLbl.SetDimensions(550f,iRFURowVert, 150f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                    rowCommissionedHdrLbl.SetLabelText("Commissioned");
                    rowCommissionedHdrLbl.SetTextAlignment("centre");
                    rowCommissionedHdrLbl.SetBorderWidth(0.0f);
                    rowCommissionedHdrLbl.SetFontName("Verdana-Bold");
                    rowCommissionedHdrLbl.SetFontSize(14f);
                    rowCommissionedHdrLbl.SetTag((iRFUCommissionedHdrLabelTagId) * (ii+1));
                    rowCommissionedHdrLbl.SetCellColour("Pale Yellow");

                    rowCommissionedHdrLblVw = rowCommissionedHdrLbl.GetLabelCell();
                    iHeightToAdd = iSectionHdrRowHeight;
                    arrItems7[5] = rowCommissionedHdrLblVw;

                    iUtils.CreateFormGridItem rowSaveRFUHdrLbl = new iUtils.CreateFormGridItem();
                    UIView rowSaveRFUHdrLblVw = new UIView();
                    rowSaveRFUHdrLbl.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                    rowSaveRFUHdrLbl.SetDimensions(700f,iRFURowVert, 130f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                    rowSaveRFUHdrLbl.SetLabelText("Commit RFU");
                    rowSaveRFUHdrLbl.SetTextAlignment("centre");
                    rowSaveRFUHdrLbl.SetBorderWidth(0.0f);
                    rowSaveRFUHdrLbl.SetFontName("Verdana-Bold");
                    rowSaveRFUHdrLbl.SetFontSize(14f);
                    rowSaveRFUHdrLbl.SetTag((iRFUSaveRFUHdrLabelTagId) * (ii+1));
                    rowSaveRFUHdrLbl.SetCellColour("Pale Yellow");

                    rowSaveRFUHdrLblVw = rowSaveRFUHdrLbl.GetLabelCell();
                    iHeightToAdd = iSectionHdrRowHeight;
                    arrItems7[6] = rowSaveRFUHdrLblVw;

                    //Now add the row details into the view
                    vwPwrHdrInternalRowId.AddSubviews(arrItems7);

                    iSectionRFUHeight += iHeightToAdd;
                    iRFURowVert += iHeightToAdd;
                    iVert += iHeightToAdd;

                    vwPwrHdrInternalRowId.Frame = new RectangleF(0f, iRFURowInnerTop, 1000f, iRFURowVert);
                    RFUTableRow.AddSubview(vwPwrHdrInternalRowId);
                    iRFURowInnerTop += iRFURowVert;
                    iRFURowVert = 0f;

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

                        iColNo = arrITPRFUs.Tables[0].Columns["PwrId"].Ordinal;
                        string sPwrId = arrITPRFUs.Tables[0].Rows[j].ItemArray[iColNo].ToString();
                        iColNo = arrITPRFUs.Tables[0].Columns["CutoverLoad"].Ordinal;
                        string sCutoverLoad = arrITPRFUs.Tables[0].Rows[j].ItemArray[iColNo].ToString();
                        iColNo = arrITPRFUs.Tables[0].Columns["CutoverDate"].Ordinal;
                        string sCutoverDate = arrITPRFUs.Tables[0].Rows[j].ItemArray[iColNo].ToString();
                        iColNo = arrITPRFUs.Tables[0].Columns["Decommission"].Ordinal;
                        int iDecommission = Convert.ToInt32(arrITPRFUs.Tables[0].Rows[j].ItemArray[iColNo]);
                        iColNo = arrITPRFUs.Tables[0].Columns["Commission"].Ordinal;
                        int iCommission = Convert.ToInt32(arrITPRFUs.Tables[0].Rows[j].ItemArray[iColNo]);

                        bDisableRow = RFUPwrIdCommitted(sPwrId);

                        UILabel hfRowRFUStatus = new UILabel();
                        hfRowRFUStatus.Text = "0";
                        hfRowRFUStatus.Tag = (ihfRowRFUStatusTagId + (j+1)) * (ii+1);
                        hfRowRFUStatus.Hidden = true;
                        arrItems6[0] = hfRowRFUStatus;

                        //Put in the PwrId Label
                        iUtils.CreateFormGridItem rowPwrIdLabel = new iUtils.CreateFormGridItem();
                        UIView rowPwrIdLabelVw = new UIView();
                        rowPwrIdLabel.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                        rowPwrIdLabel.SetDimensions(0f,iRFURowVert, 100f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f);
                        rowPwrIdLabel.SetLabelText(sPwrId);
                        rowPwrIdLabel.SetBorderWidth(0.0f);
                        rowPwrIdLabel.SetFontName("Verdana");
                        rowPwrIdLabel.SetFontSize(14f);
                        rowPwrIdLabel.SetTag((iRFUPwrIdRowLabelTagId + (j+1)) * (ii+1));

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

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

                        //Put in the PwrId Label
                        iUtils.CreateFormGridItem rowDesignLoadLabel = new iUtils.CreateFormGridItem();
                        UIView rowDesignLoadLabelVw = new UIView();
                        iColNo = arrITPRFUs.Tables[0].Columns["DesignLoad"].Ordinal;
                        string sDesignLoad = arrITPRFUs.Tables[0].Rows[j].ItemArray[iColNo].ToString();
                        rowDesignLoadLabel.SetLabelWrap(0); //This means the text will NOT be wrapped in the label
                        rowDesignLoadLabel.SetDimensions(100f,iRFURowVert, 100f, iSectionHdrRowHeight, 20f, 2.5f, 20f, 2.5f);
                        rowDesignLoadLabel.SetLabelText(sDesignLoad);
                        rowDesignLoadLabel.SetTextAlignment("right");
                        rowDesignLoadLabel.SetBorderWidth(0.0f);
                        rowDesignLoadLabel.SetFontName("Verdana");
                        rowDesignLoadLabel.SetFontSize(14f);
                        rowDesignLoadLabel.SetTag((iRFUDesignLoadRowLabelTagId + (j+1)) * (ii+1));

                        if (j % 2 == 0)
                        {
                            rowDesignLoadLabel.SetCellColour("Pale Blue");
                        }
                        else
                        {
                            rowDesignLoadLabel.SetCellColour("Sky Blue");
                        }

                        rowDesignLoadLabelVw = rowDesignLoadLabel.GetLabelCell();
                        iHeightToAdd = iSectionHdrRowHeight;
                        arrItems6[2] = rowDesignLoadLabelVw;

                        iUtils.CreateFormGridItem txtCutoverLoad = new iUtils.CreateFormGridItem();
                        UIView txtCutoverLoadVw = new UIView();
                        txtCutoverLoad.SetDimensions(200f,iRFURowVert, 100f, iSectionHdrRowHeight, 15f, 2.5f, 15f, 2.5f);
                        txtCutoverLoad.SetLabelText(sCutoverLoad);
                        txtCutoverLoad.SetTextAlignment("right");
                        txtCutoverLoad.SetBorderWidth(0.0f);
                        txtCutoverLoad.SetFontName("Verdana");
                        txtCutoverLoad.SetFontSize(14f);
                        txtCutoverLoad.SetTag((iRFUCutoverLoadRowLabelTagId + (j+1)) * (ii+1));

                        if (j % 2 == 0)
                        {
                            txtCutoverLoad.SetCellColour("Pale Blue");
                        }
                        else
                        {
                            txtCutoverLoad.SetCellColour("Sky Blue");
                        }

                        txtCutoverLoadVw = txtCutoverLoad.GetTextFieldCell();
                        UITextField txtCutoverLoadView = txtCutoverLoad.GetTextFieldView();
                        txtCutoverLoadView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
                        txtCutoverLoadView.ReturnKeyType = UIReturnKeyType.Next;
                        txtCutoverLoadView.ShouldBeginEditing += (sender) => {
                            return SetGlobalEditItems(sender, 9);};
                        txtCutoverLoadView.ShouldEndEditing += (sender) => {
                            return ValidateCutoverLoad(sender, 0);};
                        txtCutoverLoadView.ShouldReturn += (sender) => {
                            return MoveNextTextField(sender, 9);};

                        if(bDisableRow)
                        {
                            txtCutoverLoadView.Enabled = false;
                        }
                        arrItems6[3] = txtCutoverLoadVw;

                        UILabel hfCurrentCutoverLoad = new UILabel();
                        hfCurrentCutoverLoad.Text = sCutoverLoad;
                        hfCurrentCutoverLoad.Tag = (ihfCutoverLoadRowLabelTagId + (j + 1)) * (ii + 1);
                        hfCurrentCutoverLoad.Hidden = true;
                        arrItems6 [4] = hfCurrentCutoverLoad;

                        iUtils.CreateFormGridItem txtCutoverDate = new iUtils.CreateFormGridItem();
                        UIView txtCutoverDateVw = new UIView();
                        txtCutoverDate.SetDimensions(300f,iRFURowVert, 100f, iSectionHdrRowHeight, 8f, 2.5f, 8f, 2.5f);
                        if (sCutoverDate == "" || sCutoverDate == "0")
                        {
                            sCutoverDate = "01/01/1900";
                        }
                        DateTime dtCutover = Convert.ToDateTime(sCutoverDate);
                        string sCutoverDisplay = dt.Get_Date_String(dtCutover, "dd/mm/yy");
                        txtCutoverDate.SetLabelText(sCutoverDisplay);
                        txtCutoverDate.SetTextAlignment("right");
                        txtCutoverDate.SetBorderWidth(0.0f);
                        txtCutoverDate.SetFontName("Verdana");
                        txtCutoverDate.SetFontSize(14f);
                        txtCutoverDate.SetTag((iRFUCutoverDateRowLabelTagId + (j+1)) * (ii+1));

                        if (j % 2 == 0)
                        {
                            txtCutoverDate.SetCellColour("Pale Blue");
                        }
                        else
                        {
                            txtCutoverDate.SetCellColour("Sky Blue");
                        }

                        txtCutoverDateVw = txtCutoverDate.GetTextFieldCell();
                        UITextField txtCutoverDateView = txtCutoverDate.GetTextFieldView();
                        txtCutoverDateView.KeyboardType = UIKeyboardType.NumbersAndPunctuation;
                        txtCutoverDateView.ReturnKeyType = UIReturnKeyType.Next;
                        txtCutoverDateView.ShouldBeginEditing += (sender) => {
                            return SetGlobalEditItems(sender, 10);};
                        txtCutoverDateView.ShouldEndEditing += (sender) => {
                            return ValidateCutoverDate(sender, 0);};
                        txtCutoverDateView.ShouldReturn += (sender) => {
                            return MoveNextTextField(sender, 10);};

                        if(bDisableRow)
                        {
                            txtCutoverDateView.Enabled = false;
                        }

                        arrItems6[5] = txtCutoverDateVw;

                        UILabel hfCurrentCutoverDate = new UILabel();
                        hfCurrentCutoverDate.Text = sCutoverDisplay;
                        hfCurrentCutoverDate.Tag = (ihfCutoverDateRowLabelTagId + (j + 1)) * (ii + 1);
                        hfCurrentCutoverDate.Hidden = true;
                        arrItems6[6] = hfCurrentCutoverDate;

                        iUtils.CreateFormGridItem chkDecommission = new iUtils.CreateFormGridItem();
                        UIView chkDecommissionVw = new UIView();
                        chkDecommission.SetDimensions(400f,iRFURowVert, 150f, iSectionHdrRowHeight, 30f, 2.5f, 30f, 2.5f);
                        bool bDecommission = false;
                        if (iDecommission > 0)
                        {
                            bDecommission = true;
                        }
                        chkDecommission.SetCheckboxOnOff(bDecommission);
                        chkDecommission.SetBorderWidth(0.0f);

                        chkDecommission.SetSwitchType(2);
                        chkDecommission.SetTag((iRFUDecommissionRowCheckTagId + (j+1)) * (ii+1));

                        if (j % 2 == 0)
                        {
                            chkDecommission.SetCellColour("Pale Blue");
                        }
                        else
                        {
                            chkDecommission.SetCellColour("Sky Blue");
                        }

                        chkDecommissionVw = chkDecommission.GetCheckboxCell();
                        UISwitch chkDecommissionCheck = chkDecommission.GetCheckbox();
                        chkDecommissionCheck.ValueChanged += (sender,e) => {CheckboxChanged(sender, e, 1);};

                        if(bDisableRow)
                        {
                            chkDecommissionCheck.Enabled = false;
                        }

                        arrItems6[7] = chkDecommissionVw;

                        iUtils.CreateFormGridItem chkCommission = new iUtils.CreateFormGridItem();
                        UIView chkCommissionVw = new UIView();
                        chkCommission.SetDimensions(550f,iRFURowVert, 150f, iSectionHdrRowHeight, 30f, 2.5f, 30f, 2.5f);
                        bool bCommission = false;
                        if (iCommission > 0)
                        {
                            bCommission = true;
                        }
                        chkCommission.SetCheckboxOnOff(bCommission);
                        chkCommission.SetBorderWidth(0.0f);
                        chkCommission.SetSwitchType(2);
                        chkCommission.SetTag((iRFUCommissionRowCheckTagId + (j+1)) * (ii+1));

                        if (j % 2 == 0)
                        {
                            chkCommission.SetCellColour("Pale Blue");
                        }
                        else
                        {
                            chkCommission.SetCellColour("Sky Blue");
                        }

                        chkCommissionVw = chkCommission.GetCheckboxCell();
                        UISwitch chkCommissionCheck = chkCommission.GetCheckbox();
                        chkCommissionCheck.ValueChanged += (sender,e) => {CheckboxChanged(sender, e, 2);};

                        if(bDisableRow)
                        {
                            chkCommissionCheck.Enabled = false;
                        }

                        arrItems6[8] = chkCommissionVw;

                        iUtils.CreateFormGridItem btnRFU = new iUtils.CreateFormGridItem();
                        UIView btnRFUVw = new UIView();
                        btnRFU.SetDimensions(700f,iRFURowVert, 130f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f);
                        if(bDisableRow)
                        {
                            btnRFU.SetLabelText("Committed");
                        }
                        else
                        {
                            btnRFU.SetLabelText("Commit RFU");
                        }
                        btnRFU.SetBorderWidth(0.0f);
                        btnRFU.SetFontName("Verdana");
                        btnRFU.SetFontSize(14f);
                        btnRFU.SetTag((iRFUButtonSaveTagId + (j+1)) * (ii+1));

                        if (j % 2 == 0)
                        {
                            btnRFU.SetCellColour("Pale Blue");
                        }
                        else
                        {
                            btnRFU.SetCellColour("Sky Blue");
                        }

                        btnRFUVw = btnRFU.GetButtonCell();

                        UIButton btnRFUButton = new UIButton();
                        btnRFUButton = btnRFU.GetButton();
                        btnRFUButton.TouchUpInside += (sender,e) => {CommitRFU(sender, e);};

                        if(bDisableRow)
                        {
                            btnRFUButton.Enabled = false;
                        }

                        arrItems6[9] = btnRFUVw;

                        iColNo = arrITPRFUs.Tables[0].Columns["BatteryCapacity"].Ordinal;
                        string sBatteryCapacity = arrITPRFUs.Tables[0].Rows[j].ItemArray[iColNo].ToString();
                        UILabel hfRFUBatteryCapacity = new UILabel();
                        hfRFUBatteryCapacity.Text = sBatteryCapacity;
                        hfRFUBatteryCapacity.Tag = (ihfRowRFUBatteryCapacityTagId + (j+1)) * (ii+1);
                        hfRFUBatteryCapacity.Hidden = true;
                        arrItems6[10] = hfRFUBatteryCapacity;

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

                        iSectionRFUHeight += iHeightToAdd;
                        iRFURowVert += iHeightToAdd;
                        iVert += iHeightToAdd;

                        vwPwrInternalRowId.Frame = new RectangleF(0f, iRFURowInnerTop, 1000f, iRFURowVert);
                        RFUTableRow.AddSubview(vwPwrInternalRowId);
                        iRFURowInnerTop += iRFURowVert;
                        iRFURowVert = 0f;

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

                iTotalHeight = iVert + 380f;
                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);

                //Now determine what is to be contrated by default
                for(int iiii=0;iiii< m_iQuestionSections; iiii++)
                {
                    if(bHideSections[iiii])
                    {
                        UIButton btnContract = (UIButton)View.ViewWithTag (iContractSectionBtnTagId * (iiii+1));

                        ContractSection(btnContract, null);
                        //Also display the completed item
                        UILabel lblComplete = (UILabel)View.ViewWithTag(iSectionCompleteLabelTagId * (iiii+1));
                        lblComplete.Hidden = false;
                    }
                }

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