public bool FillITPInventoryMainTable(string sSessionId, string sUser, ref string sRtnMsg) { try { clsTabletDB.ITPStaticTable Static = new clsTabletDB.ITPStaticTable(); clsTabletDB.ITPInventory ITPInventory = new clsTabletDB.ITPInventory(); LocalDB DB = new LocalDB(); double dNewVersionNumber = 0.0; DateTime dtLastVersionDate; DateTime dtToday = DateTime.Now; string sITPInventoryTableName = ITPInventory.sITPInventoryTableName; //Only do all of this if the version has changed. So get the local version number and compare to that on the DB. If different do all of this. - WRITE LATER as a general function bool bNewVersion = Static.IsNewVersionOfTable(sSessionId, sUser, sITPInventoryTableName, ref dNewVersionNumber, ref dtLastVersionDate); TimeSpan ts = dtToday - dtLastVersionDate; int iDaysSinceUpdate = ts.Days; if (!DB.TableExists(sITPInventoryTableName) || bNewVersion || iDaysSinceUpdate >= 30) { clsLocalUtils util = new clsLocalUtils(); string sURL = util.GetEnvironment_wbsURL("wbsITP_External"); wbsITP_External ws = new wbsITP_External(); ws.Url = sURL; object[] objInventory = ws.GetITPInventoryInfo(sSessionId, sUser); if (objInventory[0].ToString() == "Success") { if (ITPInventory.TableITPInventoryDeleteAllRecords(ref sRtnMsg)) { string sITPInventoryInfo = objInventory[1].ToString(); string[] sHeaderInfo = sITPInventoryInfo.Split('~'); if (sHeaderInfo[0] == "ITPInventoryMakeAndModelInfo") { string[] delimiters = new string[] { "||" }; string[] sITPInventoryItems = sHeaderInfo[1].Split(delimiters, StringSplitOptions.RemoveEmptyEntries); int iInventoryCount = sITPInventoryItems.Length; if (iInventoryCount > 0) { this.InvokeOnMainThread(() => { progBarInventoryVw.ShowProgressBar(iInventoryCount); }); //First check if the ITPInventory table exists and if not create it if (ITPInventory.CheckFullITPInventoryTable()) { for (int i = 0; i < iInventoryCount; i++) { string[] delimiters2 = new string[] { "^" }; string[] sInventoryItems = sITPInventoryItems[i].Split(delimiters2, StringSplitOptions.None); ITPInventory.TableITPInventoryAddRecord(sInventoryItems); this.InvokeOnMainThread(() => { progBarInventoryVw.UpdateProgressBar(i + 1); }); } } } } } //Update the version number locally Static.UpdateVersionNumber(sITPInventoryTableName, dNewVersionNumber); this.InvokeOnMainThread(() => { progBarInventoryVw.CloseProgressBar(); }); return true; } else { sRtnMsg = objInventory[1].ToString(); return false; } } else { //This means you don't have to fill this static table return true; } } catch (Exception ex) { sRtnMsg = "Failure" + ex.Message.ToString(); return false; } }
public void OpenMakeList(object sender, EventArgs e) { UIButton btnMakeSearch = (UIButton)sender; ScreenUtils scnUtils = new ScreenUtils (); scnUtils.GetAbsolutePosition (btnMakeSearch); float iTop = scnUtils.GetPositionTop (); float iLeft = scnUtils.GetPositionLeft (); int iBtnTagId = btnMakeSearch.Tag; int iPwrIdRow = iBtnTagId / iEquipmentMakeSearchTagId; int iStringRow = iBtnTagId - (iPwrIdRow * iEquipmentMakeSearchTagId); int iSectionCounterTagId = iEquipmentRowSectionCounterTagId * iPwrIdRow + iStringRow; UILabel hfSectionCounter = (UILabel)View.ViewWithTag (iSectionCounterTagId); int iSectionCounterId = Convert.ToInt32(hfSectionCounter.Text); //Create a list and convert the string array to the list. Why the system cannot take a simple string arary is beyond me!!! UILabel lblEquipmentType = (UILabel)View.ViewWithTag (iEquipmentTypeTagId * (iPwrIdRow) + (iStringRow)); int iEquipmentType = Convert.ToInt32(lblEquipmentType.Text); List<string> mylist = new List<string> (); clsTabletDB.ITPInventory ITPInventory = new clsTabletDB.ITPInventory (); string[] sMakes; switch(iEquipmentType) { case 3: sMakes = ITPInventory.GetRackMakes (); m_sRackMakes = sMakes; Array.ForEach (m_sRackMakes, value => mylist.Add (value.ToString ())); break; case 4: sMakes = ITPInventory.GetSubRackMakes (); m_sSubRackMakes = sMakes; Array.ForEach (m_sSubRackMakes, value => mylist.Add (value.ToString ())); break; case 5: sMakes = ITPInventory.GetPositionMakes (); m_sPositionMakes = sMakes; Array.ForEach (m_sPositionMakes, value => mylist.Add (value.ToString ())); break; case 7: sMakes = ITPInventory.GetSolarStringMakes (); m_sSolarStringMakes = sMakes; Array.ForEach (m_sSolarStringMakes, value => mylist.Add (value.ToString ())); break; default: sMakes = ITPInventory.GetPositionMakes (); m_sPositionMakes = sMakes; Array.ForEach (m_sPositionMakes, value => mylist.Add (value.ToString ())); break; } TableViewSource tabdata = new TableViewSource (mylist, true); tabdata.SetFont("Verdana",10f); UITableView cmbMake = new UITableView (); //If the bottom of the frame would be outside the main content frame make it go upwards instead of downwards UILabel hfContentHeight = (UILabel)View.ViewWithTag (3); int iContentHeight = Convert.ToInt32 (hfContentHeight.Text); if (iTop + 190f > (float)iContentHeight) { cmbMake.Frame = new RectangleF(iLeft, iTop - 190f, 290f, 200f); } else { cmbMake.Frame = new RectangleF(iLeft, iTop, 290f, 200f); } tabdata.SetParent(cmbMake); tabdata.SetUpdateFieldType("UILabel"); UILabel txtVwUpdate = (UILabel)View.ViewWithTag (iEquipmentMakeTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetLabelViewToUpdate(txtVwUpdate); UIView vwUnsaved = (UIView)View.ViewWithTag (60); tabdata.SetUnsavedChangesView(vwUnsaved); tabdata.SetShowUnsavedOnChange(true); //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); UILabel lblViewModel = (UILabel)View.ViewWithTag (iEquipmentModelTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetMakePostUpdate(1, lblViewModel); cmbMake.Source = tabdata; iUtils.SESTable thistable = new iUtils.SESTable(); string sSelectedValue = txtVwUpdate.Text; switch(iEquipmentType) { case 3: thistable.SetTableSelectedText(cmbMake, sSelectedValue, m_sRackMakes, true); break; case 4: thistable.SetTableSelectedText(cmbMake, sSelectedValue, m_sSubRackMakes, true); break; case 5: thistable.SetTableSelectedText(cmbMake, sSelectedValue, m_sPositionMakes, true); break; case 7: thistable.SetTableSelectedText(cmbMake, sSelectedValue, m_sSolarStringMakes, true); break; default: thistable.SetTableSelectedText(cmbMake, sSelectedValue, m_sPositionMakes, true); break; } //Get the main scroll view UIScrollView scrollVw = (UIScrollView)View.ViewWithTag (2); scrollVw.AddSubview(cmbMake); }
public void OpenModelList(object sender, EventArgs e) { UIButton btnModelSearch = (UIButton)sender; ScreenUtils scnUtils = new ScreenUtils (); scnUtils.GetAbsolutePosition (btnModelSearch); float iTop = scnUtils.GetPositionTop (); float iLeft = scnUtils.GetPositionLeft (); int iBtnTagId = btnModelSearch.Tag; int iPwrIdRow = iBtnTagId / iEquipmentModelSearchTagId; int iStringRow = iBtnTagId - (iPwrIdRow * iEquipmentModelSearchTagId); int iSectionCounterTagId = iEquipmentRowSectionCounterTagId * iPwrIdRow + iStringRow; UILabel hfSectionCounter = (UILabel)View.ViewWithTag (iSectionCounterTagId); int iSectionCounterId = Convert.ToInt32 (hfSectionCounter.Text); UILabel lblSupplier = (UILabel)View.ViewWithTag (iEquipmentMakeTagId * (iPwrIdRow) + (iStringRow)); string sSupplier = lblSupplier.Text; if (sSupplier == "") { iUtils.AlertBox alert = new iUtils.AlertBox (); alert.CreateErrorAlertDialog ("You must select a make before you can select a model"); return; } UILabel lblEquipmentType = (UILabel)View.ViewWithTag (iEquipmentTypeTagId * (iPwrIdRow) + (iStringRow)); int iEquipmentType = Convert.ToInt32(lblEquipmentType.Text); //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> listModel = new List<string> (); clsTabletDB.ITPInventory ITPInventory = new clsTabletDB.ITPInventory (); string[] sModels; switch(iEquipmentType) { case 3: sModels = ITPInventory.GetRackModels (sSupplier); m_sRackModels = sModels; Array.ForEach (m_sRackModels, value => listModel.Add (value.ToString ())); break; case 4: sModels = ITPInventory.GetSubRackModels (sSupplier); m_sSubRackModels = sModels; Array.ForEach (m_sSubRackModels, value => listModel.Add (value.ToString ())); break; case 5: sModels = ITPInventory.GetPositionModels (sSupplier); m_sPositionModels = sModels; Array.ForEach (m_sPositionModels, value => listModel.Add (value.ToString ())); break; case 7: sModels = ITPInventory.GetSolarStringModels (sSupplier); m_sSolarStringModels = sModels; Array.ForEach (m_sSolarStringModels, value => listModel.Add (value.ToString ())); break; default: sModels = ITPInventory.GetPositionModels (sSupplier); m_sPositionModels = sModels; Array.ForEach (m_sPositionModels, value => listModel.Add (value.ToString ())); break; } TableViewSource tabdata = new TableViewSource (listModel, true); tabdata.SetFont("Verdana",10f); UITableView cmbModel = new UITableView (); //If the bottom of the frame would be outside the main content frame make it go upwards instead of downwards UILabel hfContentHeight = (UILabel)View.ViewWithTag (3); int iContentHeight = Convert.ToInt32 (hfContentHeight.Text); if (iTop + 190f > (float)iContentHeight) { if (iLeft + 290f > 1000f) { cmbModel.Frame = new RectangleF(iLeft - 300f, iTop - 190f, 290f, 200f); } else { cmbModel.Frame = new RectangleF(iLeft, iTop - 190f, 290f, 200f); } } else { if (iLeft + 290f > 1000f) { cmbModel.Frame = new RectangleF(iLeft - 300f, iTop, 290f, 200f); } else { cmbModel.Frame = new RectangleF(iLeft, iTop, 290f, 200f); } } tabdata.SetParent(cmbModel); tabdata.SetUpdateFieldType("UILabel"); UILabel lblVwUpdate = (UILabel)View.ViewWithTag (iEquipmentModelTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetLabelViewToUpdate(lblVwUpdate); UIView vwUnsaved = (UIView)View.ViewWithTag (60); tabdata.SetUnsavedChangesView(vwUnsaved); tabdata.SetShowUnsavedOnChange(true); UILabel hfRowStatus = (UILabel)View.ViewWithTag (iEquipmentRowStatusTagId * (iPwrIdRow) + (iStringRow)); UILabel lblSPN = (UILabel)View.ViewWithTag (iEquipmentSPNHiddenTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetModelPostUpdate(6, hfRowStatus, lblSPN, sSupplier); //Here the 6 refers to the post update index and NOT batteries as the equipment type //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); cmbModel.Source = tabdata; iUtils.SESTable thistable = new iUtils.SESTable(); string sSelectedValue = lblVwUpdate.Text; switch(iEquipmentType) { case 3: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sRackModels, true); break; case 4: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sSubRackModels, true); break; case 5: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sPositionModels, true); break; case 7: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sSolarStringModels, true); break; default: thistable.SetTableSelectedText(cmbModel, sSelectedValue, m_sPositionModels, true); break; } //Get the main scroll view UIScrollView scrollVw = (UIScrollView)View.ViewWithTag (2); scrollVw.AddSubview(cmbModel); }
public void DrawOpeningPage() { try { int iColNo = 0; int iSectionId = 0; string sId = m_sPassedId; float iVert = 0f; float iPwrIdRowVertInner = 0f; float iSectionHdrRowHeight = 40f; float iQuestionRowHeight = 30f; float iTotalHeight = 0f; float iHeightToAdd = iQuestionRowHeight; bool bHideComplete = true; bool bHideSectionComplete = true; bool bFullyCommitted = false; bool bRFUPwrIdCommitted = false; UIView[] arrItems4 = new UIView[8]; UIView[] arrItems5 = new UIView[8]; //Get some static data for dropdowns only once so we don't reprocess unecessarily clsTabletDB.ITPInventory ITPInventory = new clsTabletDB.ITPInventory(); string[] sRackMakes = ITPInventory.GetRackMakes(); m_sRackMakes = sRackMakes; string[] sSubRackMakes = ITPInventory.GetSubRackMakes(); m_sSubRackMakes = sSubRackMakes; string[] sPositionMakes = ITPInventory.GetPositionMakes(); m_sPositionMakes = sPositionMakes; string[] sSolarStringMakes = ITPInventory.GetSolarStringMakes(); m_sSolarStringMakes = sSolarStringMakes; UIScrollView layout = new UIScrollView(); layout.Frame = new RectangleF(0f,35f,1000f,620f); layout.Tag = 2; clsTabletDB.ITPDocumentSection ITPSection = new clsTabletDB.ITPDocumentSection(); //******************************************************************************************// // 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 batteries 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, 400f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f); SectionEquipment.SetLabelText("POWER CONVERSION"); 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(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(400f,0f, 150f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f); if(bFullyCommitted) { SectionCompleteLabel.SetLabelText("COMMITTED"); } else { SectionCompleteLabel.SetLabelText("COMPLETED"); } SectionCompleteLabel.SetBorderWidth(0.0f); SectionCompleteLabel.SetFontName("Verdana-Bold"); SectionCompleteLabel.SetTextColour("Bright Yellow"); SectionCompleteLabel.SetFontSize(12f); 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(550f,0f, 150f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f); btnSaveEquipment.SetLabelText("Save Section"); btnSaveEquipment.SetBorderWidth(0.0f); btnSaveEquipment.SetFontName("Verdana"); btnSaveEquipment.SetFontSize(12f); btnSaveEquipment.SetHidden(true); btnSaveEquipment.SetTag(iSaveSectionBtnTagId * (iii+1)); btnSaveEquipment.SetCellColour("DarkSlateGrey"); btnSaveEquipmentVw = btnSaveEquipment.GetButtonCell(); UIButton btnSaveEquipmentButton = new UIButton(); btnSaveEquipmentButton = btnSaveEquipment.GetButton(); btnSaveEquipmentButton.TouchUpInside += (sender,e) => {SaveThisSection(sender, e);}; arrItems4[2] = btnSaveEquipmentVw; iUtils.CreateFormGridItem btnExpandEquipment = new iUtils.CreateFormGridItem(); UIView btnExpandEquipmentVw = new UIView(); btnExpandEquipment.SetDimensions(700f,0f, 50f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f); btnExpandEquipment.SetLabelText("+"); btnExpandEquipment.SetBorderWidth(0.0f); btnExpandEquipment.SetFontName("Verdana"); btnExpandEquipment.SetFontSize(12f); btnExpandEquipment.SetTag(iExpandSectionBtnTagId * (iii+1)); btnExpandEquipment.SetCellColour("DarkSlateGrey"); btnExpandEquipmentVw = btnExpandEquipment.GetButtonCell(); UIButton btnExpandEquipmentButton = new UIButton(); btnExpandEquipmentButton = btnExpandEquipment.GetButton(); btnExpandEquipmentButton.Enabled = false; btnExpandEquipmentButton.TouchUpInside += (sender,e) => {ExpandSection(sender, e);}; arrItems4[3] = btnExpandEquipmentVw; iUtils.CreateFormGridItem btnContractEquipment = new iUtils.CreateFormGridItem(); UIView btnContractEquipmentVw = new UIView(); btnContractEquipment.SetDimensions(750f,0f, 50f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f); btnContractEquipment.SetLabelText("-"); btnContractEquipment.SetBorderWidth(0.0f); btnContractEquipment.SetFontName("Verdana"); btnContractEquipment.SetFontSize(12f); btnContractEquipment.SetTag(iContractSectionBtnTagId * (iii+1)); btnContractEquipment.SetCellColour("DarkSlateGrey"); btnContractEquipmentVw = btnContractEquipment.GetButtonCell(); UIButton btnContractEquipmentButton = new UIButton(); btnContractEquipmentButton = btnContractEquipment.GetButton(); btnContractEquipmentButton.TouchUpInside += (sender,e) => {ContractSection(sender, e);}; arrItems4[4] = btnContractEquipmentVw; UILabel hfSectionEquipmentHeight = new UILabel(); hfSectionEquipmentHeight.Tag = iSectionHeightTagId * (iii+1); hfSectionEquipmentHeight.Hidden = true; hfSectionEquipmentHeight.Text = "0"; arrItems4[5] = hfSectionEquipmentHeight; UILabel hfSectionEquipmentRows = new UILabel(); hfSectionEquipmentRows.Tag = iSectionRowsTagId * (iii+1); hfSectionEquipmentRows.Hidden = true; hfSectionEquipmentRows.Text = iPwrIdRows.ToString(); arrItems4[6] = hfSectionEquipmentRows; UILabel hfSectionEquipmentStatus = new UILabel(); hfSectionEquipmentStatus.Tag = iSectionStatusTagId * (iii+1); hfSectionEquipmentStatus.Hidden = true; hfSectionEquipmentStatus.Text = "0"; arrItems4[7] = 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,iSectionHdrRowHeight); iSectionId = iContainerSectionTagId * (iii+1); PwrIdTableRow.Tag = iSectionId; layout.AddSubview(PwrIdTableRow); float iPwrIdRowVert = 0.0f; float iSectionPwrIdHeight = 0.0f; float iPwrIdRowVertTop = iVert; float iPwrIdRowInnerTop = 0.0f; float iPwrIdRowInnerTop2 = 0.0f; m_iEquipmentPwrIds = iPwrIdRows; for (int jj = 0; jj < iPwrIdRows; jj++) { iPwrIdRowInnerTop2 = 0.0f; UIView vwPwrInternalRowId = new UIView(); vwPwrInternalRowId.Frame = new RectangleF(0f,iPwrIdRowVert,1000f,200f); //This will be resized later on vwPwrInternalRowId.Tag = (iPwrIdSectionTagId + (jj+1)) * (iii+1); UILabel hfRow10Status = new UILabel(); hfRow10Status.Text = "0"; hfRow10Status.Tag = (ihfRow10StatusTagId + (jj+1)) * (iii+1); hfRow10Status.Hidden = true; arrItems5[0] = hfRow10Status; //Put in the PwrId Label iUtils.CreateFormGridItem rowPwrIdLabel = new iUtils.CreateFormGridItem(); UIView rowPwrIdLabelVw = new UIView(); iColNo = arrITPSectionEquipmentPwrIds.Tables[0].Columns["PwrId"].Ordinal; string sPwrId = arrITPSectionEquipmentPwrIds.Tables[0].Rows[jj].ItemArray[iColNo].ToString(); rowPwrIdLabel.SetLabelWrap(0); //This means the text will NOT be wrapped in the label rowPwrIdLabel.SetDimensions(0f,iPwrIdRowVert, 200f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f); rowPwrIdLabel.SetLabelText(sPwrId); rowPwrIdLabel.SetBorderWidth(0.0f); rowPwrIdLabel.SetFontName("Verdana-Bold"); rowPwrIdLabel.SetFontSize(18f); rowPwrIdLabel.SetTag((iPwrIdRowLabelTagId + (jj+1)) * (iii+1)); if (jj % 2 == 0) { rowPwrIdLabel.SetCellColour("Pale Yellow"); } else { rowPwrIdLabel.SetCellColour("Pale Orange"); } rowPwrIdLabelVw = rowPwrIdLabel.GetLabelCell(); iHeightToAdd = iSectionHdrRowHeight; arrItems5[1] = rowPwrIdLabelVw; bRFUPwrIdCommitted = RFUPwrIdCommitted(sPwrId); iUtils.CreateFormGridItem btnNewEquipment = new iUtils.CreateFormGridItem(); UIView btnNewEquipmentVw = new UIView(); btnNewEquipment.SetDimensions(200f,iPwrIdRowVert, 200f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f); btnNewEquipment.SetLabelText("New Item"); btnNewEquipment.SetBorderWidth(0.0f); btnNewEquipment.SetFontName("Verdana"); btnNewEquipment.SetFontSize(12f); btnNewEquipment.SetTag((iPwrIdNewBtnTagId + (jj+1)) * (iii+1)); if (jj % 2 == 0) { btnNewEquipment.SetCellColour("Pale Yellow"); } else { btnNewEquipment.SetCellColour("Pale Orange"); } btnNewEquipmentVw = btnNewEquipment.GetButtonCell(); UIButton btnNewEquipmentButton = new UIButton(); btnNewEquipmentButton = btnNewEquipment.GetButton(); btnNewEquipmentButton.TouchUpInside += (sender,e) => {AddNewEquipment(sender, e);}; if(bRFUPwrIdCommitted) { btnNewEquipmentButton.Enabled = false; } arrItems5[2] = btnNewEquipmentVw; if(PowerConversionPwrIdComplete(sPwrId)) { bHideSectionComplete = false; } else { bHideSectionComplete = true; } iUtils.CreateFormGridItem PwrIdCompleteLabel = new iUtils.CreateFormGridItem(); UIView PwrIdCompleteLabelVw = new UIView(); PwrIdCompleteLabel.SetDimensions(400f,0f, 150f, iSectionHdrRowHeight, 4f, 7.5f, 4f, 7.5f); if(bRFUPwrIdCommitted) { PwrIdCompleteLabel.SetLabelText("COMMITTED"); bHideSectionComplete = false; } else { PwrIdCompleteLabel.SetLabelText("COMPLETED"); } PwrIdCompleteLabel.SetBorderWidth(0.0f); PwrIdCompleteLabel.SetFontName("Verdana-Bold"); PwrIdCompleteLabel.SetTextColour("Royal Blue"); PwrIdCompleteLabel.SetFontSize(14f); if (jj % 2 == 0) { PwrIdCompleteLabel.SetCellColour("Pale Yellow"); } else { PwrIdCompleteLabel.SetCellColour("Pale Orange"); } PwrIdCompleteLabel.SetTag((iPwrIdSectionCompleteLabelTagId + (jj+1)) * (iii+1)); PwrIdCompleteLabel.SetHidden(bHideSectionComplete); PwrIdCompleteLabelVw = PwrIdCompleteLabel.GetLabelCell(); arrItems5[3] = PwrIdCompleteLabelVw; iUtils.CreateFormGridItem rowPwrIdBlank = new iUtils.CreateFormGridItem(); UIView rowPwrIdBlankVw = new UIView(); rowPwrIdBlank.SetLabelWrap(0); //This means the text will NOT be wrapped in the label rowPwrIdBlank.SetDimensions(550f,iPwrIdRowVert, 350f, iSectionHdrRowHeight, 2f, 2.5f, 2f, 2.5f); rowPwrIdBlank.SetLabelText(""); rowPwrIdBlank.SetBorderWidth(0.0f); rowPwrIdBlank.SetFontName("Verdana"); rowPwrIdBlank.SetFontSize(12f); rowPwrIdBlank.SetTag((iPwrIdRowLabelTagId + (jj+1)) * (iii+1)); if (jj % 2 == 0) { rowPwrIdBlank.SetCellColour("Pale Yellow"); } else { rowPwrIdBlank.SetCellColour("Pale Orange"); } rowPwrIdBlankVw = rowPwrIdBlank.GetLabelCell(); arrItems5[4] = rowPwrIdBlankVw; iUtils.CreateFormGridItem btnExpandPwrId = new iUtils.CreateFormGridItem(); UIView btnExpandPwrIdVw = new UIView(); btnExpandPwrId.SetDimensions(900f,0f, 50f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f); btnExpandPwrId.SetLabelText("+"); btnExpandPwrId.SetBorderWidth(0.0f); btnExpandPwrId.SetFontName("Verdana"); btnExpandPwrId.SetFontSize(12f); btnExpandPwrId.SetTag((iPwrIdExpandTagId + (jj+1)) * (iii+1)); if (jj % 2 == 0) { btnExpandPwrId.SetCellColour("Pale Yellow"); } else { btnExpandPwrId.SetCellColour("Pale Orange"); } btnExpandPwrIdVw = btnExpandPwrId.GetButtonCell(); UIButton btnExpandPwrIdButton = new UIButton(); btnExpandPwrIdButton = btnExpandPwrId.GetButton(); btnExpandPwrIdButton.Enabled = false; btnExpandPwrIdButton.TouchUpInside += (sender,e) => {ExpandPwrId(sender, e, 2);}; arrItems5[5] = btnExpandPwrIdVw; iUtils.CreateFormGridItem btnContractPwrId = new iUtils.CreateFormGridItem(); UIView btnContractPwrIdVw = new UIView(); btnContractPwrId.SetDimensions(950f,0f, 50f, iSectionHdrRowHeight, 8f, 4f, 8f, 4f); btnContractPwrId.SetLabelText("-"); btnContractPwrId.SetBorderWidth(0.0f); btnContractPwrId.SetFontName("Verdana"); btnContractPwrId.SetFontSize(12f); btnContractPwrId.SetTag((iPwrIdContractTagId + (jj+1)) * (iii+1)); if (jj % 2 == 0) { btnContractPwrId.SetCellColour("Pale Yellow"); } else { btnContractPwrId.SetCellColour("Pale Orange"); } btnContractPwrIdVw = btnContractPwrId.GetButtonCell(); UIButton btnContractPwrIdButton = new UIButton(); btnContractPwrIdButton = btnContractPwrId.GetButton(); btnContractPwrIdButton.TouchUpInside += (sender,e) => {ContractPwrId(sender, e, 2);}; arrItems5[6] = btnContractPwrIdVw; UILabel hfPwrIdSectionHeight = new UILabel(); hfPwrIdSectionHeight.Tag = (iPwrIdHeightTagId + (jj+1)) * (iii+1); hfPwrIdSectionHeight.Hidden = true; hfPwrIdSectionHeight.Text = "0"; arrItems5[7] = hfPwrIdSectionHeight; iHeightToAdd = iSectionHdrRowHeight; //Now add the row details into the view vwPwrInternalRowId.AddSubviews(arrItems5); iSectionPwrIdHeight += iHeightToAdd; iPwrIdRowVert += iHeightToAdd; iVert += iHeightToAdd; iPwrIdRowInnerTop2 += iHeightToAdd; iPwrIdRowVertInner = 0f; UIView vwPwrInternalRowIdInnner = new UIView(); vwPwrInternalRowIdInnner.Tag = (iPwrIdSectionInnerTagId + (jj+1)) * (iii+1); vwPwrInternalRowIdInnner.Frame = new RectangleF(0f,iPwrIdRowVertInner,1000f,200f); //This will be resized later on // vwPwrInternalRowIdInnner.Hidden = true; UIView PwrIdHdr = BuildEquipmentHeader(jj, ref iHeightToAdd); PwrIdHdr.Frame = new RectangleF(0f, iPwrIdRowVertInner, 1000f, iHeightToAdd); vwPwrInternalRowIdInnner.AddSubview(PwrIdHdr); vwPwrInternalRowId.AddSubview(vwPwrInternalRowIdInnner); iSectionPwrIdHeight += iHeightToAdd; iPwrIdRowVert += iHeightToAdd; iPwrIdRowVertInner += iHeightToAdd; iVert += iHeightToAdd; //Now for each PwrId get the details for each string DataSet arrITPSection10PwrIdItems = ITPSection.GetLocalITPSection10PwrIdEquipmentDetails(sId, sPwrId); if (arrITPSection10PwrIdItems.Tables.Count > 0) { int iPwrIdItemRows = arrITPSection10PwrIdItems.Tables[0].Rows.Count; //Add the rows to a hidden field so we know how many rows are in each PwrId battery block UILabel hfPwrIdStringRows = new UILabel(); hfPwrIdStringRows.Text = iPwrIdItemRows.ToString(); hfPwrIdStringRows.Tag = (ihfPwrIdStringRowsTagId + (jj+1)) * (iii+1); hfPwrIdStringRows.Hidden = true; vwPwrInternalRowIdInnner.AddSubview(hfPwrIdStringRows); for (var kk = 0; kk < iPwrIdItemRows; kk++) { iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["AutoId"].Ordinal; int iAutoId = Convert.ToInt32(arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo]); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["BankNo"].Ordinal; string sBankNo = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Make"].Ordinal; string sMake = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Model"].Ordinal; string sModel = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["SPN"].Ordinal; string sSPN = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["DOM"].Ordinal; string sDOM = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Floor"].Ordinal; string sFloor = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Suite"].Ordinal; string sSuite = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Rack"].Ordinal; string sRack = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["SubRack"].Ordinal; string sSubRack = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Position"].Ordinal; string sPosition = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Equipment_Condition"].Ordinal; string sEquipType = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["SerialBatch"].Ordinal; string sSerialNo = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["tblMaximoPSA_ID"].Ordinal; string sMaximoPSAId = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["tblMaximoTransfer_Eqnum"].Ordinal; string sMaximoTransferId = arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo].ToString(); if(sMaximoPSAId == "" || sMaximoPSAId == "0") { sMaximoPSAId = "-1"; } if(sMaximoTransferId == "" || sMaximoTransferId == "0") { sMaximoTransferId = "-1"; } int iMaximoPSAId = Convert.ToInt32(sMaximoPSAId); int iMaximoTransferId = Convert.ToInt32(sMaximoTransferId); int iMaximoAssetId = -1; if(iMaximoPSAId > 0) { iMaximoAssetId = iMaximoPSAId; } else if(iMaximoTransferId > 0 || sMaximoTransferId == "0000000000") { iMaximoAssetId = iMaximoTransferId; } else { iMaximoAssetId = -1; } iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Equipment_Type"].Ordinal; int iEquipmentType = Convert.ToInt32(arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo]); iColNo = arrITPSection10PwrIdItems.Tables[0].Columns["Duplicate"].Ordinal; int iDuplicate = Convert.ToInt32(arrITPSection10PwrIdItems.Tables[0].Rows[kk].ItemArray[iColNo]); //Add in the row UIView EquipmentItemRow = BuildEquipmentItemRowDetails(iii, jj, kk, sPwrId, iAutoId, iMaximoAssetId, sBankNo, sMake, sModel, sSPN, sDOM, sFloor, sSuite, sRack, sSubRack, sPosition, sEquipType, sSerialNo, iEquipmentType, iDuplicate, false, bRFUPwrIdCommitted,ref iHeightToAdd); EquipmentItemRow.Frame = new RectangleF(0f, iPwrIdRowVertInner, 1000f, iHeightToAdd); EquipmentItemRow.Tag = iEquipmentFullRowTagId * (jj + 1) + (kk + 1); vwPwrInternalRowIdInnner.AddSubview(EquipmentItemRow); m_iEquipmentRowHeight = iHeightToAdd; iSectionPwrIdHeight += iHeightToAdd; iPwrIdRowVert += iHeightToAdd; iPwrIdRowVertInner += iHeightToAdd; iVert += iHeightToAdd; } hfPwrIdSectionHeight.Text = iPwrIdRowVertInner.ToString(); vwPwrInternalRowIdInnner.Frame = new RectangleF(0f, iPwrIdRowInnerTop2, 1000f, iPwrIdRowVertInner); vwPwrInternalRowId.Frame = new RectangleF(0f, iPwrIdRowInnerTop, 1000f, iPwrIdRowVert); PwrIdTableRow.AddSubview(vwPwrInternalRowId); iPwrIdRowInnerTop += iPwrIdRowVert; //iPwrIdRowInnerTop2 += iPwrIdRowVertInner; iPwrIdRowVert = 0f; } } //Now resize the UIView that is effectively the container for the battery info for this section //And also store this height in a hidden field for use in the contract and expand functions PwrIdTableRow.Frame = new RectangleF(0f,iPwrIdRowVertTop,1000f,iSectionPwrIdHeight); hfSectionEquipmentHeight.Text = iSectionPwrIdHeight.ToString(); } iTotalHeight = iVert + 280f; SizeF layoutSize = new SizeF(1000f, iTotalHeight); layout.ContentSize = layoutSize; UILabel hfScrollContentHeight = new UILabel(); hfScrollContentHeight.Text = iTotalHeight.ToString(); hfScrollContentHeight.Tag = 3; hfScrollContentHeight.Hidden = true; layout.AddSubview(hfScrollContentHeight); View.AddSubview(layout); //Contract all the power conversion PwrIds for(int iiii=0;iiii< m_iEquipmentPwrIds; iiii++) { UIButton btnContract = (UIButton)View.ViewWithTag ((iPwrIdContractTagId + (iiii+1)) * (m_iEquipmentSectionCounter+1)); ContractPwrId(btnContract, null, 2); } } catch (Exception except) { string sTest = except.Message.ToString(); iUtils.AlertBox alert = new iUtils.AlertBox (); alert.CreateErrorAlertDialog (sTest); } }