public bool FillITPValidHierarchyTable(string sSessionId, string sUser, ref string sRtnMsg) { try { clsTabletDB.ITPStaticTable Static = new clsTabletDB.ITPStaticTable(); clsTabletDB.ITPValidHierarchy ITPValidHierarchy = new clsTabletDB.ITPValidHierarchy(); LocalDB DB = new LocalDB(); double dNewVersionNumber = 0.0; DateTime dtLastVersionDate; string sITPValidHierarchyTableName = ITPValidHierarchy.sITPValidHierarchyTableName; //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, sITPValidHierarchyTableName, ref dNewVersionNumber, ref dtLastVersionDate); if (!DB.TableExists(sITPValidHierarchyTableName) || bNewVersion) { clsLocalUtils util = new clsLocalUtils(); string sURL = util.GetEnvironment_wbsURL("wbsITP_External"); wbsITP_External ws = new wbsITP_External(); ws.Url = sURL; object[] objValidHierarchy = ws.GetITPValidHierarchyInfo(sSessionId, sUser); if (objValidHierarchy[0].ToString() == "Success") { if (ITPValidHierarchy.TableITPValidHierarchyDeleteAllRecords(ref sRtnMsg)) { string sITPValidHierarchyInfo = objValidHierarchy[1].ToString(); string[] sHeaderInfo = sITPValidHierarchyInfo.Split('~'); if (sHeaderInfo[0] == "ITPValidHierarchyInfo") { string[] delimiters = new string[] { "||" }; string[] sITPValidHierarchyItems = sHeaderInfo[1].Split(delimiters, StringSplitOptions.RemoveEmptyEntries); int iValidHierarchyCount = sITPValidHierarchyItems.Length; if (iValidHierarchyCount > 0) { this.InvokeOnMainThread(() => { progBarValidHierarchyVw.ShowProgressBar(iValidHierarchyCount); }); //First check if the ITPValidHierarchy table exists and if not create it if (ITPValidHierarchy.CheckFullITPValidHierarchyTable()) { SqliteConnection conn = DB.OpenConnection(); for (int i = 0; i < iValidHierarchyCount; i++) { string[] delimiters2 = new string[] { "^" }; string[] sValidHierarchyItems = sITPValidHierarchyItems[i].Split(delimiters2, StringSplitOptions.None); string sFieldValue = sValidHierarchyItems[0]; string sFieldType = sValidHierarchyItems[1]; Array.Resize<string>(ref sValidHierarchyItems, sValidHierarchyItems.Length + 1); sValidHierarchyItems[sValidHierarchyItems.Length - 1] = sFieldType; sValidHierarchyItems[sValidHierarchyItems.Length - 2] = sFieldValue; sValidHierarchyItems[0] = i.ToString(); ITPValidHierarchy.TableITPValidHierarchyAddRecord(sValidHierarchyItems, conn); this.InvokeOnMainThread(() => { progBarValidHierarchyVw.UpdateProgressBar(i + 1); }); } DB.CloseConnection(conn); } } } } //Update the version number locally Static.UpdateVersionNumber(sITPValidHierarchyTableName, dNewVersionNumber); this.InvokeOnMainThread(() => { progBarValidHierarchyVw.CloseProgressBar(); }); return true; } else { sRtnMsg = objValidHierarchy[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 bool ValidateSuite(object sender, int iFromBackButton) { if(gbSuppressSecondCheck) { return true; } if(iFromBackButton == 1) { gbSuppressSecondCheck = true; } UITextField txtSuite = (UITextField)sender; string sSuite = txtSuite.Text; sSuite = sSuite.ToUpper(); txtSuite.Text = sSuite; clsTabletDB.ITPValidHierarchy ITPValidHierarchy = new clsTabletDB.ITPValidHierarchy(); bool bSuiteCheck = ITPValidHierarchy.IsValidItem(sSuite, 2); int iTagId = txtSuite.Tag; int iPwrIdRow = iTagId/ iEquipmentSuiteTagId; int iStringRow = iTagId - (iPwrIdRow * iEquipmentSuiteTagId); int iHiddenBankId = iEquipmentSuiteHiddenTagId * iPwrIdRow + iStringRow; UILabel hfHiddenSuite = (UILabel)View.ViewWithTag (iHiddenBankId); string sOldSuite = hfHiddenSuite.Text; if (!bSuiteCheck && sSuite != "") { iUtils.AlertBox alert = new iUtils.AlertBox (); alert.CreateErrorAlertDialog ("Please enter a valid suite or search from the list by using the button underneath"); txtSuite.Text = hfHiddenSuite.Text; txtSuite.ResignFirstResponder(); txtSuite.BecomeFirstResponder(); m_bSuppressMove = true; return false; } else { if(sOldSuite != sSuite) //Only do something if there has been a chnage { hfHiddenSuite.Text = txtSuite.Text; UILabel hfRowStatus = (UILabel)View.ViewWithTag(iEquipmentRowStatusTagId * iPwrIdRow + iStringRow); hfRowStatus.Text = "1"; SetSectionValueChanged(m_iEquipmentSectionCounter + 1); SetAnyValueChanged(sender, null); //Ask the question if(iFromBackButton == 0) { int iSectionTagId = iEquipmentRowSectionCounterTagId * iPwrIdRow + iStringRow; UILabel hfSectionId = (UILabel)View.ViewWithTag (iSectionTagId); int iSectionId = Convert.ToInt32(hfSectionId.Text); int iPwrIdTagId = iEquipmentRowPwrIdTagId * iPwrIdRow + iStringRow; UILabel hfPwrId = (UILabel)View.ViewWithTag (iPwrIdTagId); string sPwrId = hfPwrId.Text; int iFloorId = iEquipmentFloorTagId * iPwrIdRow + iStringRow; UITextField txtFloor = (UITextField)View.ViewWithTag (iFloorId); string sFloor = txtFloor.Text; if(sOldSuite != sSuite) { if(CheckSameSuiteExists(sFloor, sOldSuite,iSectionId, iPwrIdRow, sPwrId, iStringRow)) { iUtils.AlertBox alert2 = new iUtils.AlertBox(); alert2.CreateAlertYesNoDialog(); alert2.SetAlertMessage("Do you wish to change all other items on PwrId " + sPwrId + " on the floor " + sFloor + " and the suite " + sOldSuite + " to suite " + sSuite + " ?"); alert2.ShowAlertBox(); UIAlertView alert3 = alert2.GetAlertDialog(); alert3.Clicked += (sender2, e2) => { CheckSuiteChangesQuestion(sender2, e2, e2.ButtonIndex, iStringRow, sPwrId, sFloor, sSuite, sOldSuite, iSectionId, iPwrIdRow); }; } } } } return true; } }
public void OpenStringList(object sender, EventArgs e) { UIButton btnBankNoSearch = (UIButton)sender; ScreenUtils scnUtils = new ScreenUtils (); scnUtils.GetAbsolutePosition (btnBankNoSearch); float iTop = scnUtils.GetPositionTop (); float iLeft = scnUtils.GetPositionLeft (); int iBtnTagId = btnBankNoSearch.Tag; int iPwrIdRow = iBtnTagId / iEquipmentStringSearchTagId; int iStringRow = iBtnTagId - (iPwrIdRow * iEquipmentStringSearchTagId); int iSectionCounterTagId = iEquipmentRowSectionCounterTagId * iPwrIdRow + iStringRow; UILabel hfSectionCounter = (UILabel)View.ViewWithTag (iSectionCounterTagId); int iSectionCounterId = Convert.ToInt32 (hfSectionCounter.Text); clsTabletDB.ITPValidHierarchy ITPHierarchy = new clsTabletDB.ITPValidHierarchy(); string[] sSolarStringNos = ITPHierarchy.GetValidHierarchy(7); //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> listStringNo = new List<string> (); Array.ForEach (sSolarStringNos, value => listStringNo.Add (value.ToString ())); TableViewSource tabdata = new TableViewSource (listStringNo, true); tabdata.SetFont("Verdana",10f); UITableView cmbStringNo = 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) { cmbStringNo.Frame = new RectangleF(iLeft, iTop - 190f, 90f, 200f); } else { cmbStringNo.Frame = new RectangleF(iLeft, iTop, 90f, 200f); } tabdata.SetParent(cmbStringNo); tabdata.SetUpdateFieldType("UITextField"); UITextField lblVwUpdate = (UITextField)View.ViewWithTag (iEquipmentStringTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetTextFieldToUpdate(lblVwUpdate); 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); UILabel lblUnsavedSectionFlag = (UILabel)View.ViewWithTag ((iSectionCounterId + 1) * iSectionStatusTagId); tabdata.SetUnsavedChangesSectionHiddenLabel(lblUnsavedSectionFlag); cmbStringNo.Source = tabdata; iUtils.SESTable thistable = new iUtils.SESTable(); string sSelectedValue = lblVwUpdate.Text; thistable.SetTableSelectedText(cmbStringNo, sSelectedValue, sSolarStringNos, true); //Get the main scroll view UIScrollView scrollVw = (UIScrollView)View.ViewWithTag (2); scrollVw.AddSubview(cmbStringNo); }
//Here iType means 1 = Batteries, 2 = Solar strings public bool ValidateBankNo(object sender, int iType, int iFromBackButton) { if(gbSuppressSecondCheck) { return true; } if(iFromBackButton == 1) { gbSuppressSecondCheck = true; } UITextField txtBankNo = (UITextField)sender; string sBankNo = txtBankNo.Text; sBankNo = sBankNo.ToUpper(); txtBankNo.Text = sBankNo; clsTabletDB.ITPValidHierarchy ITPValidHierarchy = new clsTabletDB.ITPValidHierarchy(); bool bBankCheck = ITPValidHierarchy.IsValidItem(sBankNo, iType + 5); int iTagId = txtBankNo.Tag; int iPwrIdRow = iTagId/ iEquipmentStringTagId; int iStringRow = iTagId - (iPwrIdRow * iEquipmentStringTagId); int iHiddenBankId = iEquipmentStringHiddenTagId * iPwrIdRow + iStringRow; UILabel hfHiddenBankNo = (UILabel)View.ViewWithTag (iHiddenBankId); if (!bBankCheck && sBankNo != "") { iUtils.AlertBox alert = new iUtils.AlertBox (); alert.CreateErrorAlertDialog ("Please enter a valid bank no or select from the list by using the button to the immediate right"); txtBankNo.Text = hfHiddenBankNo.Text; txtBankNo.ResignFirstResponder(); txtBankNo.BecomeFirstResponder(); m_bSuppressMove = true; return false; } else { if(hfHiddenBankNo.Text != txtBankNo.Text) { hfHiddenBankNo.Text = txtBankNo.Text; UILabel hfRowStatus = (UILabel)View.ViewWithTag(iEquipmentRowStatusTagId * iPwrIdRow + iStringRow); hfRowStatus.Text = "1"; SetSectionValueChanged(m_iEquipmentSectionCounter + 1); SetAnyValueChanged(sender, null); } return true; } }
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); }