Ejemplo n.º 1
0
        public void OpenItemsList(object sender, EventArgs e, UIView vwSearch, int iSectionCounterId)
        {
            clsTabletDB.ITPValidHierarchy ITPHierarchy = new clsTabletDB.ITPValidHierarchy();
            UILabel hfSearching = (UILabel)View.ViewWithTag (iSearchHiddenLabelTagId);
            int iSearchTypeId = Convert.ToInt32(hfSearching.Text);
            UILabel hfPwrIdRow = (UILabel)View.ViewWithTag (iPwrIdRowHiddenLabelTagId);
            int iPwrIdRow = Convert.ToInt32(hfPwrIdRow.Text);
            UILabel hfStringRow = (UILabel)View.ViewWithTag (iStringRowHiddenLabelTagId);
            int iStringRow = Convert.ToInt32(hfStringRow.Text);
            UITextField txtSearch = (UITextField)View.ViewWithTag(90);
            string sSearchText = txtSearch.Text;
            string[] sItems = ITPHierarchy.GetValidHierarchySearch(iSearchTypeId, sSearchText);
            int iTypeTagId = -1;
            int ihfTypeTagId = -1;

            switch (iSearchTypeId)
            {
                case 1:
                    iTypeTagId = iEquipmentFloorTagId;
                    ihfTypeTagId = iEquipmentFloorHiddenTagId;
                    break;

                case 2:
                    iTypeTagId = iEquipmentSuiteTagId;
                    ihfTypeTagId = iEquipmentSuiteHiddenTagId;
                    break;

                case 3:
                    iTypeTagId = iEquipmentRackTagId;
                    ihfTypeTagId = iEquipmentRackHiddenTagId;
                    break;

                case 4:
                    iTypeTagId = iEquipmentSubRackTagId;
                    ihfTypeTagId = iEquipmentSubRackHiddenTagId;
                    break;

                case 5:
                    iTypeTagId = iEquipmentPositionTagId;
                    ihfTypeTagId = iEquipmentPositionHiddenTagId;
                    break;

                case 7:
                    iTypeTagId = iEquipmentStringTagId;
                    ihfTypeTagId = iEquipmentStringHiddenTagId;
                    break;
            }
            //Create a list and convert the string array to the list. Why the system cannot take a simple string array is beyond me!!!
            List<string> listItems = new List<string>();
            Array.ForEach(sItems, value => listItems.Add(value.ToString()));

            TableViewSource tabdata = new TableViewSource(listItems, true);
            tabdata.SetFont("Verdana", 10f);
            if (m_cmbSearch == null)
            {
                UITableView cmbItems = new UITableView();
                cmbItems.Frame = new RectangleF(100f, 88f, 90f, 200f);
                cmbItems.Tag = iSearchTableTagId;
                m_cmbSearch = cmbItems;
            }

            m_cmbSearch.Hidden = false;
            tabdata.SetParent(m_cmbSearch);
            tabdata.SetUpdateFieldType("UITextField");
            UITextField lblVwUpdate = (UITextField)View.ViewWithTag (iTypeTagId * (iPwrIdRow) + (iStringRow));
            tabdata.SetTextFieldToUpdate(lblVwUpdate);
            UILabel lblhfVwUpdate = (UILabel)View.ViewWithTag (ihfTypeTagId * (iPwrIdRow) + (iStringRow));
            tabdata.SetSearchView(vwSearch);
            UIView vwUnsaved = (UIView)View.ViewWithTag (60);
            tabdata.SetUnsavedChangesView(vwUnsaved);
            tabdata.SetShowUnsavedOnChange(true);
            UILabel hfRowStatus = (UILabel)View.ViewWithTag(iEquipmentRowStatusTagId * iPwrIdRow + iStringRow);
            tabdata.SetItemPostUpdate(iSearchTypeId + 1, lblhfVwUpdate, hfRowStatus);

            //Also set the section flag to 1 that it has changed and the overall flag that it has changed
            UILabel lblUnsavedFlag = (UILabel)View.ViewWithTag (80);
            tabdata.SetUnsavedChangesHiddenLabel(lblUnsavedFlag);
            UIButton btnSectionSave = (UIButton)View.ViewWithTag ((iSectionCounterId + 1) * iSaveSectionBtnTagId);
            tabdata.SetSectionSaveButton(btnSectionSave);
            UILabel lblUnsavedSectionFlag = (UILabel)View.ViewWithTag ((iSectionCounterId + 1) * iSectionStatusTagId);
            tabdata.SetUnsavedChangesSectionHiddenLabel(lblUnsavedSectionFlag);
            m_cmbSearch.Source = tabdata;
            vwSearch.AddSubview(m_cmbSearch);
        }