public bool FillITPBatteryFuseTypesTable(string sSessionId, string sUser, ref string sRtnMsg) { try { clsTabletDB.ITPStaticTable Static = new clsTabletDB.ITPStaticTable(); clsTabletDB.ITPBatteryFuseTypes ITPBatteryFuseTypes = new clsTabletDB.ITPBatteryFuseTypes(); LocalDB DB = new LocalDB(); double dNewVersionNumber = 0.0; DateTime dtLastVersionDate; string sITPBatteryFuseTypesTableName = ITPBatteryFuseTypes.sITPBatteryFuseTypeTableName; //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, sITPBatteryFuseTypesTableName, ref dNewVersionNumber, ref dtLastVersionDate); if (!DB.TableExists(sITPBatteryFuseTypesTableName) || bNewVersion) { clsLocalUtils util = new clsLocalUtils(); string sURL = util.GetEnvironment_wbsURL("wbsITP_External"); wbsITP_External ws = new wbsITP_External(); ws.Url = sURL; object[] objBatteryFuseTypes = ws.GetITPBatteryFuseTypeInfo(sSessionId, sUser); if (objBatteryFuseTypes[0].ToString() == "Success") { if (ITPBatteryFuseTypes.TableITPBatteryFuseTypeDeleteAllRecords(ref sRtnMsg)) { string sITPBatteryFuseTypesInfo = objBatteryFuseTypes[1].ToString(); string[] sHeaderInfo = sITPBatteryFuseTypesInfo.Split('~'); if (sHeaderInfo[0] == "ITPBatteryFuseTypeInfo") { string[] delimiters = new string[] { "||" }; string[] sITPBatteryFuseTypesItems = sHeaderInfo[1].Split(delimiters, StringSplitOptions.RemoveEmptyEntries); int iBatteryFuseTypesCount = sITPBatteryFuseTypesItems.Length; if (iBatteryFuseTypesCount > 0) { this.InvokeOnMainThread(() => { progBarBatteryFuseTypesVw.ShowProgressBar(iBatteryFuseTypesCount); }); //First check if the ITPBatteryFuseTypes table exists and if not create it if (ITPBatteryFuseTypes.CheckFullITPBatteryFuseTypeTable()) { for (int i = 0; i < iBatteryFuseTypesCount; i++) { string[] delimiters2 = new string[] { "^" }; string[] sBatteryFuseTypesItems = sITPBatteryFuseTypesItems[i].Split(delimiters2, StringSplitOptions.None); string sFuseType = sBatteryFuseTypesItems[0]; Array.Resize<string>(ref sBatteryFuseTypesItems, sBatteryFuseTypesItems.Length + 1); sBatteryFuseTypesItems[sBatteryFuseTypesItems.Length - 1] = sFuseType; sBatteryFuseTypesItems[0] = i.ToString(); ITPBatteryFuseTypes.TableITPBatteryFuseTypeAddRecord(sBatteryFuseTypesItems); this.InvokeOnMainThread(() => { progBarBatteryFuseTypesVw.UpdateProgressBar(i + 1); }); } } } } } //Update the version number locally Static.UpdateVersionNumber(sITPBatteryFuseTypesTableName, dNewVersionNumber); this.InvokeOnMainThread(() => { progBarBatteryFuseTypesVw.CloseProgressBar(); }); return true; } else { sRtnMsg = objBatteryFuseTypes[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 OpenFuseOrCBList(object sender, EventArgs e) { UIButton btnFuseOrCBSearch = (UIButton)sender; ScreenUtils scnUtils = new ScreenUtils (); scnUtils.GetAbsolutePosition (btnFuseOrCBSearch); float iTop = scnUtils.GetPositionTop (); float iLeft = scnUtils.GetPositionLeft (); int iBtnTagId = btnFuseOrCBSearch.Tag; int iPwrIdRow = iBtnTagId / iBankFuseOrCBSearchTagId; int iStringRow = iBtnTagId - (iPwrIdRow * iBankFuseOrCBSearchTagId); int iSectionCounterTagId = iStringRowSectionCounterTagId * iPwrIdRow + iStringRow; UILabel hfSectionCounter = (UILabel)View.ViewWithTag (iSectionCounterTagId); int iSectionCounterId = Convert.ToInt32 (hfSectionCounter.Text); clsTabletDB.ITPBatteryFuseTypes ITPFuseTypes = new clsTabletDB.ITPBatteryFuseTypes(); string[] sBatteryFuseOrCBs = ITPFuseTypes.GetBatteryFuseTypes(); //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> listFuseOrCB = new List<string> (); Array.ForEach (sBatteryFuseOrCBs, value => listFuseOrCB.Add (value.ToString ())); TableViewSource tabdata = new TableViewSource (listFuseOrCB, true); tabdata.SetFont("Verdana",10f); UITableView cmbFuseOrCB = 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) { cmbFuseOrCB.Frame = new RectangleF(iLeft, iTop - 190f, 90f, 100f); } else { cmbFuseOrCB.Frame = new RectangleF(iLeft, iTop, 90f, 100f); } tabdata.SetParent(cmbFuseOrCB); tabdata.SetUpdateFieldType("UILabel"); UILabel lblVwUpdate = (UILabel)View.ViewWithTag (iBankFuseOrCBTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetLabelViewToUpdate(lblVwUpdate); UIView vwUnsaved = (UIView)View.ViewWithTag (60); tabdata.SetUnsavedChangesView(vwUnsaved); tabdata.SetShowUnsavedOnChange(true); UILabel hfRowStatus = (UILabel)View.ViewWithTag (iStringRowStatusTagId * (iPwrIdRow) + (iStringRow)); tabdata.SetFusePostUpdate(7, 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); UILabel lblUnsavedSectionFlag = (UILabel)View.ViewWithTag ((iSectionCounterId + 1) * iSectionStatusTagId); tabdata.SetUnsavedChangesSectionHiddenLabel(lblUnsavedSectionFlag); cmbFuseOrCB.Source = tabdata; iUtils.SESTable thistable = new iUtils.SESTable(); string sSelectedValue = lblVwUpdate.Text; thistable.SetTableSelectedText(cmbFuseOrCB, sSelectedValue, sBatteryFuseOrCBs, true); //Get the main scroll view UIScrollView scrollVw = (UIScrollView)View.ViewWithTag (2); scrollVw.AddSubview(cmbFuseOrCB); }