public bool SavePowerConvSection(int iBtnId) { int i; int j; int iAutoId; string sId = m_sPassedId; clsTabletDB.ITPDocumentSection DB = new clsTabletDB.ITPDocumentSection(); string[] sItemValues = new string[24]; string sString = ""; string sSubRack = ""; string sPosition = ""; bool bTransferIdBad = false; //Get the number of PwrId's UILabel hfSectionPwrIds = (UILabel)View.ViewWithTag(iSectionRowsTagId * (m_iEquipmentSectionCounter + 1)); int iTotalPwrIds = Convert.ToInt32(hfSectionPwrIds.Text); bool bResetSectionFlag = true; for (i=0; i<iTotalPwrIds; i++) { //For each battery string block in this PwrId save it if necessary UILabel hfThisPwrIdStringRows = (UILabel)View.ViewWithTag((ihfPwrIdStringRowsTagId + (i + 1)) * (m_iEquipmentSectionCounter + 1)); int iTotalStrings = Convert.ToInt32(hfThisPwrIdStringRows.Text); for (j=0; j<iTotalStrings; j++) { UILabel hfRowStatus = (UILabel)View.ViewWithTag(iEquipmentRowStatusTagId * (i + 1) + (j + 1)); int iRowStatus = Convert.ToInt32(hfRowStatus.Text); if (iRowStatus == 1 || iRowStatus == 2 || iRowStatus == 3) { UILabel hfAutoId = (UILabel)View.ViewWithTag(iEquipmentRowAutoIdTagId * (i + 1) + (j + 1)); string sAutoId = hfAutoId.Text; if (sAutoId == "") { iAutoId = -1; } else { iAutoId = Convert.ToInt32(sAutoId); } //Get the type so that we only look at the right level of hierarchy UILabel hfEquipmentType = (UILabel)View.ViewWithTag(iEquipmentTypeTagId * (i + 1) + (j + 1)); int iEquipType = Convert.ToInt32(hfEquipmentType.Text); UILabel lblPwrId = (UILabel)View.ViewWithTag(iEquipmentRowPwrIdTagId * (i + 1) + (j + 1)); string sPwrId = lblPwrId.Text; UITextField txtFloor = (UITextField)View.ViewWithTag(iEquipmentFloorTagId * (i + 1) + (j + 1)); string sFloor = txtFloor.Text; UITextField txtSuite = (UITextField)View.ViewWithTag(iEquipmentSuiteTagId * (i + 1) + (j + 1)); string sSuite = txtSuite.Text; UITextField txtRack = (UITextField)View.ViewWithTag(iEquipmentRackTagId * (i + 1) + (j + 1)); string sRack = txtRack.Text; if(iEquipType >= 4) { UITextField txtSubRack = (UITextField)View.ViewWithTag(iEquipmentSubRackTagId * (i + 1) + (j + 1)); sSubRack = txtSubRack.Text; } if(iEquipType >= 5) { UITextField txtPosition = (UITextField)View.ViewWithTag(iEquipmentPositionTagId * (i + 1) + (j + 1)); sPosition = txtPosition.Text; } if(iEquipType >= 6) { UITextField txtString = (UITextField)View.ViewWithTag(iEquipmentStringTagId * (i + 1) + (j + 1)); sString = txtString.Text; } UILabel lblMake = (UILabel)View.ViewWithTag(iEquipmentMakeTagId * (i + 1) + (j + 1)); string sMake = lblMake.Text; UILabel lblModel = (UILabel)View.ViewWithTag(iEquipmentModelTagId * (i + 1) + (j + 1)); string sModel = lblModel.Text; UILabel lblSPN = (UILabel)View.ViewWithTag(iEquipmentSPNHiddenTagId * (i + 1) + (j + 1)); string sSPN = lblSPN.Text; UITextField txtSerialNo = (UITextField)View.ViewWithTag(iEquipmentSerialNoTagId * (i + 1) + (j + 1)); string sSerialNo = txtSerialNo.Text; UITextField txtDOM = (UITextField)View.ViewWithTag(iEquipmentDOMTagId * (i + 1) + (j + 1)); string sDOM = txtDOM.Text; if (txtDOM.Text == "" || txtDOM.Text == "0") { sDOM = "01/01/1900"; } string sFuseOrCB = ""; string sRating = "0"; string sLinkTest = "0"; string s20MinTest = "0"; UISegmentedControl radGrp = (UISegmentedControl)View.ViewWithTag(iEquipmentEquipTypeTagId * (i + 1) + (j + 1)); int iAnswerIndex = radGrp.SelectedSegment; string sAnswer = ""; string sEquipType = ""; UILabel hfMaximoAssetId = (UILabel)View.ViewWithTag(iEquipmentMaximoAssetHiddenTagId * (i + 1) + (j + 1)); string sMaximoAssetId = hfMaximoAssetId.Text; string sTransferAssetId = ""; string sPSAAssetId = ""; UILabel hfDuplicate = (UILabel)View.ViewWithTag(iDuplicateTagId * (i + 1) + (j + 1)); string sDuplicate = hfDuplicate.Text; if (s20MinTest == "") { s20MinTest = "0"; } if (iAnswerIndex >= 0) { sAnswer = radGrp.TitleAt(iAnswerIndex); } else { sAnswer = ""; } bTransferIdBad = false; switch (sAnswer) { case "New": sEquipType = "N"; sTransferAssetId = ""; sPSAAssetId = sMaximoAssetId; if (sPSAAssetId == "-1") { sDuplicate = "-1"; } break; case "Used": sEquipType = "U"; sTransferAssetId = sMaximoAssetId; if(sTransferAssetId == "-1") { bTransferIdBad= true; } sPSAAssetId = ""; break; default: sEquipType = "N"; sTransferAssetId = ""; sPSAAssetId = sMaximoAssetId; if (sPSAAssetId == "-1") { sDuplicate = "-1"; } break; } string sCurrentDateAndTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); //Get all the info for this string sItemValues [0] = sId; sItemValues [1] = sPwrId; sItemValues [2] = sString; //This comes first because it was set up for battery strings initially sItemValues [3] = sFloor; sItemValues [4] = sSuite; sItemValues [5] = sRack; sItemValues [6] = sSubRack; sItemValues [7] = sPosition; //There is no position for a battery string but of course there could be for a power conversion item sItemValues [8] = sMake; sItemValues [9] = sModel; sItemValues [10] = sSerialNo; sItemValues [11] = sDOM; sItemValues [12] = sFuseOrCB; sItemValues [13] = sRating; sItemValues [14] = sLinkTest; sItemValues [15] = s20MinTest; sItemValues [16] = sCurrentDateAndTime; sItemValues [17] = sTransferAssetId; sItemValues [18] = sPSAAssetId; sItemValues [19] = sEquipType; sItemValues [20] = sSPN; sItemValues [21] = sDuplicate; sItemValues [22] = iEquipType.ToString(); sItemValues [23] = iRowStatus.ToString(); if (sMake == "" || sModel == "" || sEquipType == "" || iEquipType == -1 || bTransferIdBad) { bResetSectionFlag = false; iUtils.AlertBox alert = new iUtils.AlertBox(); alert.CreateAlertDialog(); if(bTransferIdBad) { alert.SetAlertMessage("An item in PwrId " + sPwrId + " is not fully filled out. You must provide an Asset Id for used equipment typically " + "found from Structure Builder. If you do not know the asset id, please provide a number between 0 and 10 " + "(it will be padded with zeros to make a 10 character id) and the " + "relevant asset id will be determined at final RFU submission stage. " + "The system cannot save this item."); } else { alert.SetAlertMessage("An item in PwrId " + sPwrId + " is not fully filled out. The system cannot save this item."); } alert.ShowAlertBox(); } else { //Update or insert into the local DB if (DB.ITPSection10SetRecord(sId, ref iAutoId, sItemValues)) { //Update the row status and the autoid hfAutoId.Text = iAutoId.ToString(); hfRowStatus.Text = "0"; } } } } } //Reset the section flag if (bResetSectionFlag) { UILabel hfSectionStatus = (UILabel)View.ViewWithTag(iSectionStatusTagId * (m_iEquipmentSectionCounter + 1)); hfSectionStatus.Text = "0"; SetAnyValueChangedOff(); gbSuppressSecondCheck = false; return true; } else { gbSuppressSecondCheck = false; return false; } }
public bool SaveBatterySection(int iBtnId) { int i; int j; int iAutoId; string sId = m_sPassedId; clsTabletDB.ITPDocumentSection DB = new clsTabletDB.ITPDocumentSection(); string[] sItemValues = new string[24]; //Get the number of PwrId's UILabel hfSectionPwrIds = (UILabel)View.ViewWithTag(iSectionRowsTagId * (m_iBatterySectionCounter + 1)); int iTotalPwrIds = Convert.ToInt32(hfSectionPwrIds.Text); bool bResetSectionFlag = true; for (i=0; i<iTotalPwrIds; i++) { //For each battery string block in this PwrId save it if necessary UILabel hfThisPwrIdStringRows = (UILabel)View.ViewWithTag((ihfPwrIdStringRowsTagId + (i + 1)) * (m_iBatterySectionCounter + 1)); int iTotalStrings = Convert.ToInt32(hfThisPwrIdStringRows.Text); for (j=0; j<iTotalStrings; j++) { UILabel hfRowStatus = (UILabel)View.ViewWithTag(iStringRowStatusTagId * (i + 1) + (j + 1)); int iRowStatus = Convert.ToInt32(hfRowStatus.Text); if (iRowStatus == 1 || iRowStatus == 2 || iRowStatus == 3) { UILabel hfAutoId = (UILabel)View.ViewWithTag(iStringRowAutoIdTagId * (i + 1) + (j + 1)); string sAutoId = hfAutoId.Text; if (sAutoId == "") { iAutoId = -1; } else { iAutoId = Convert.ToInt32(sAutoId); } UILabel lblPwrId = (UILabel)View.ViewWithTag(iStringRowPwrIdTagId * (i + 1) + (j + 1)); string sPwrId = lblPwrId.Text; UITextField txtBankNo = (UITextField)View.ViewWithTag(iBankNoTagId * (i + 1) + (j + 1)); string sBankNo = txtBankNo.Text; UITextField txtFloor = (UITextField)View.ViewWithTag(iFloorTagId * (i + 1) + (j + 1)); string sFloor = txtFloor.Text; UITextField txtSuite = (UITextField)View.ViewWithTag(iSuiteTagId * (i + 1) + (j + 1)); string sSuite = txtSuite.Text; UITextField txtRack = (UITextField)View.ViewWithTag(iRackTagId * (i + 1) + (j + 1)); string sRack = txtRack.Text; UITextField txtSubRack = (UITextField)View.ViewWithTag(iSubRackTagId * (i + 1) + (j + 1)); string sSubRack = txtSubRack.Text; UILabel lblMake = (UILabel)View.ViewWithTag(iBankMakeTagId * (i + 1) + (j + 1)); string sMake = lblMake.Text; UILabel lblModel = (UILabel)View.ViewWithTag(iBankModelTagId * (i + 1) + (j + 1)); string sModel = lblModel.Text; UILabel lblSPN = (UILabel)View.ViewWithTag(iSPNHiddenTagId * (i + 1) + (j + 1)); string sSPN = lblSPN.Text; UITextField txtSerialNo = (UITextField)View.ViewWithTag(iSerialNoTagId * (i + 1) + (j + 1)); string sSerialNo = txtSerialNo.Text; UITextField txtDOM = (UITextField)View.ViewWithTag(iBankDOMTagId * (i + 1) + (j + 1)); string sDOM = txtDOM.Text; if (txtDOM.Text == "0") { sDOM = "01/01/1900"; } UILabel lblFuseOrCB = (UILabel)View.ViewWithTag(iBankFuseOrCBTagId * (i + 1) + (j + 1)); string sFuseOrCB = lblFuseOrCB.Text; UITextField txtRating = (UITextField)View.ViewWithTag(iBankRatingTagId * (i + 1) + (j + 1)); string sRating = txtRating.Text; if (txtRating.Text == "") { sRating = "0"; } UILabel hfLinkTestStatus = (UILabel)View.ViewWithTag(iLinkTestHiddenTagId * (i + 1) + (j + 1)); string sLinkTest = hfLinkTestStatus.Text; if (sLinkTest == "") { sLinkTest = "0"; } UILabel hf20MinTestStatus = (UILabel)View.ViewWithTag(i20MinTestHiddenTagId * (i + 1) + (j + 1)); string s20MinTest = hf20MinTestStatus.Text; if (s20MinTest == "") { s20MinTest = "0"; } UISegmentedControl radGrp = (UISegmentedControl)View.ViewWithTag(iEquipTypeTagId * (i + 1) + (j + 1)); int iAnswerIndex = radGrp.SelectedSegment; string sAnswer = ""; string sEquipType = ""; UILabel hfMaximoAssetId = (UILabel)View.ViewWithTag(iStringRowMaximoAssetIdTagId * (i + 1) + (j + 1)); string sMaximoAssetId = hfMaximoAssetId.Text; string sTransferAssetId = ""; string sPSAAssetId = ""; string sDuplicate = "0"; if (s20MinTest == "") { s20MinTest = "0"; } if (iAnswerIndex >= 0) { sAnswer = radGrp.TitleAt(iAnswerIndex); } else { sAnswer = ""; } switch (sAnswer) { case "New": sEquipType = "N"; sTransferAssetId = ""; sPSAAssetId = sMaximoAssetId; if (sPSAAssetId == "-1") { sDuplicate = "-1"; } break; case "Used": sEquipType = "U"; sTransferAssetId = sMaximoAssetId; sPSAAssetId = ""; break; default: sEquipType = "N"; sTransferAssetId = ""; sPSAAssetId = sMaximoAssetId; if (sPSAAssetId == "-1") { sDuplicate = "-1"; } break; } string sCurrentDateAndTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss"); //Get all the info for this string sItemValues [0] = sId; sItemValues [1] = sPwrId; sItemValues [2] = sBankNo; sItemValues [3] = sFloor; sItemValues [4] = sSuite; sItemValues [5] = sRack; sItemValues [6] = sSubRack; sItemValues [7] = ""; //There is no position for a battery string sItemValues [8] = sMake; sItemValues [9] = sModel; sItemValues [10] = sSerialNo; sItemValues [11] = sDOM; sItemValues [12] = sFuseOrCB; sItemValues [13] = sRating; sItemValues [14] = sLinkTest; sItemValues [15] = s20MinTest; sItemValues [16] = sCurrentDateAndTime; sItemValues [17] = sTransferAssetId; sItemValues [18] = sPSAAssetId; sItemValues [19] = sEquipType; sItemValues [20] = sSPN; sItemValues [21] = sDuplicate; sItemValues [22] = "6"; //The equipemnt type is 6 for a battery string sItemValues [23] = iRowStatus.ToString(); if (sMake == "" || sModel == "" || sBankNo == "" || sEquipType == "") { bResetSectionFlag = false; iUtils.AlertBox alert = new iUtils.AlertBox(); alert.CreateAlertDialog(); alert.SetAlertMessage("An item in PwrId " + sPwrId + " is not fully filled out. The system cannot save this item."); alert.ShowAlertBox(); } else { //Update or insert into the local DB if (DB.ITPSection10SetRecord(sId, ref iAutoId, sItemValues)) { //Update the row status and the autoid hfAutoId.Text = iAutoId.ToString(); hfRowStatus.Text = "0"; } } } } } //Reset the section flag if (bResetSectionFlag) { UILabel hfSectionStatus = (UILabel)View.ViewWithTag(iSectionStatusTagId * (m_iBatterySectionCounter + 1)); hfSectionStatus.Text = "0"; SetAnyValueChangedOff(); gbSuppressSecondCheck = false; return true; } else { gbSuppressSecondCheck = false; return false; } }