public void DeleteEquipmentRow(object sender, EventArgs e) { string sRtnMsg = ""; clsTabletDB.ITPDocumentSection DBQ = new clsTabletDB.ITPDocumentSection(); UIButton btnDelete = (UIButton)sender; int iTagId = btnDelete.Tag; int iPwrIdRow = iTagId / iEquipmentDeleteBtnTagId; int iStringRow = iTagId - (iPwrIdRow * iEquipmentDeleteBtnTagId); UILabel hfRowStatus = (UILabel)View.ViewWithTag(iEquipmentRowStatusTagId * (iPwrIdRow) + (iStringRow)); int iRowStatus = Convert.ToInt32(hfRowStatus.Text); UILabel hfAutoId = (UILabel)View.ViewWithTag(iEquipmentRowAutoIdTagId * (iPwrIdRow) + (iStringRow)); int iAutoId = Convert.ToInt32(hfAutoId.Text); UILabel hfMaximoAssetId = (UILabel)View.ViewWithTag(iEquipmentRowMaximoAssetIdTagId * (iPwrIdRow) + (iStringRow)); string sMaximoId = hfMaximoAssetId.Text; if (sMaximoId == "" || sMaximoId == "0") { sMaximoId = "-1"; } int iMaximoAssetId = Convert.ToInt32(sMaximoId); UILabel hfPwrId = (UILabel)View.ViewWithTag(iEquipmentRowPwrIdTagId * (iPwrIdRow) + (iStringRow)); string sPwrId = hfPwrId.Text; UILabel hfEquipmentType = (UILabel)View.ViewWithTag(iEquipmentTypeTagId * (iPwrIdRow) + (iStringRow)); int iEquipmentType = Convert.ToInt32(hfEquipmentType.Text); string sRack = ""; string sSubRack = ""; string sPosition = ""; string sString = ""; string sMessage = ""; UITextField txtFloor = (UITextField)View.ViewWithTag(iEquipmentFloorTagId * (iPwrIdRow) + (iStringRow)); string sFloor = txtFloor.Text; UITextField txtSuite = (UITextField)View.ViewWithTag(iEquipmentSuiteTagId * (iPwrIdRow) + (iStringRow)); string sSuite = txtSuite.Text; switch(iEquipmentType) { case 3: //Rack UITextField txtRack = (UITextField)View.ViewWithTag(iEquipmentRackTagId * (iPwrIdRow) + (iStringRow)); sRack = txtRack.Text; sMessage = ", Floor " + sFloor + ", Suite " + sSuite + " and Rack " + sRack; break; case 4: //SubRack UITextField txtRack1 = (UITextField)View.ViewWithTag(iEquipmentRackTagId * (iPwrIdRow) + (iStringRow)); sRack = txtRack1.Text; UITextField txtSubRack1 = (UITextField)View.ViewWithTag(iEquipmentSubRackTagId * (iPwrIdRow) + (iStringRow)); sSubRack = txtSubRack1.Text; sMessage = ", Floor " + sFloor + ", Suite " + sSuite + ", Rack " + sRack + " and SubRack " + sSubRack; break; case 5: //Position UITextField txtRack2 = (UITextField)View.ViewWithTag(iEquipmentRackTagId * (iPwrIdRow) + (iStringRow)); sRack = txtRack2.Text; UITextField txtSubRack2 = (UITextField)View.ViewWithTag(iEquipmentSubRackTagId * (iPwrIdRow) + (iStringRow)); sSubRack = txtSubRack2.Text; UITextField txtPosition2 = (UITextField)View.ViewWithTag(iEquipmentPositionTagId * (iPwrIdRow) + (iStringRow)); sPosition = txtPosition2.Text; sMessage = ", Floor " + sFloor + ", Suite " + sSuite + ", Rack " + sRack + " ,SubRack " + sSubRack + " and Position " + sPosition; break; case 7: //String UITextField txtRack3 = (UITextField)View.ViewWithTag(iEquipmentRackTagId * (iPwrIdRow) + (iStringRow)); sRack = txtRack3.Text; UITextField txtSubRack3 = (UITextField)View.ViewWithTag(iEquipmentSubRackTagId * (iPwrIdRow) + (iStringRow)); sSubRack = txtSubRack3.Text; UITextField txtPosition3 = (UITextField)View.ViewWithTag(iEquipmentPositionTagId * (iPwrIdRow) + (iStringRow)); sPosition = txtPosition3.Text; UITextField txtString3 = (UITextField)View.ViewWithTag(iEquipmentStringTagId * (iPwrIdRow) + (iStringRow)); sString = txtString3.Text; sMessage = ", Floor " + sFloor + ", Suite " + sSuite + ", Rack " + sRack + " ,SubRack " + sSubRack + " ,Position " + sPosition + " and Solar String " + sString; break; } //You can only delete an item you have added and these have iMaximoAssetId = -1 if (iMaximoAssetId < 0) { //This means the current row is either not changed or has been updated, so it has to be removed from the DB if (iRowStatus == 0 || iRowStatus == 1) { //Don't actaully delete at this stage, just mark as deleted. Delete on the upload success. if(!DBQ.ITPProjectSectionDeleteSection10Item(m_sPassedId, iAutoId, false, ref sRtnMsg)) { iUtils.AlertBox alert = new iUtils.AlertBox(); alert.CreateErrorAlertDialog("Could not delete power conversion item on project " + m_sPassedId + ", Power Id " + sPwrId + sMessage); return; } } //Remove the line from the page (well hide it really so all the loops still work) UIView vwStringRow = (UIView)View.ViewWithTag(iEquipmentFullRowTagId * (iPwrIdRow) + (iStringRow)); vwStringRow.Hidden = true; hfRowStatus.Text = "3"; //Means deleted, so no save required ReduceHeightAfter(m_iEquipmentRowHeight, iPwrIdRow, iStringRow, 2); UIView vwPwrInternalRowId = (UIView)View.ViewWithTag((iPwrIdSectionInnerTagId + (iPwrIdRow)) * (m_iEquipmentSectionCounter+1)); RectangleF frame1 = vwPwrInternalRowId.Frame; frame1.Height -= m_iEquipmentRowHeight; vwPwrInternalRowId.Frame = frame1; //Now increase the view height for this new row (The whole section height is handled in the ReduceHeightAfter function) UILabel hfPwrIdSectionHeight = (UILabel)View.ViewWithTag((iPwrIdHeightTagId + iPwrIdRow ) * (m_iEquipmentSectionCounter + 1)); int iPwrIdHeight = Convert.ToInt32(hfPwrIdSectionHeight.Text); hfPwrIdSectionHeight.Text = (iPwrIdHeight - m_iEquipmentRowHeight).ToString(); //Set the unsaved tags on (do this even though the record is removed for consistency) SetSectionValueChanged(m_iEquipmentSectionCounter + 1); SetAnyValueChanged(sender, null); } return; }
public void DeleteBatteryString(object sender, EventArgs e) { string sRtnMsg = ""; clsTabletDB.ITPDocumentSection DBQ = new clsTabletDB.ITPDocumentSection(); UIButton btnDelete = (UIButton)sender; int iTagId = btnDelete.Tag; int iPwrIdRow = iTagId / iDeleteBatteryStringBtnTagId; int iStringRow = iTagId - (iPwrIdRow * iDeleteBatteryStringBtnTagId); UILabel hfRowStatus = (UILabel)View.ViewWithTag(iStringRowStatusTagId * (iPwrIdRow) + (iStringRow)); int iRowStatus = Convert.ToInt32(hfRowStatus.Text); UILabel hfAutoId = (UILabel)View.ViewWithTag(iStringRowAutoIdTagId * (iPwrIdRow) + (iStringRow)); int iAutoId = Convert.ToInt32(hfAutoId.Text); UILabel hfMaximoAssetId = (UILabel)View.ViewWithTag(iStringRowMaximoAssetIdTagId * (iPwrIdRow) + (iStringRow)); string sMaximoId = hfMaximoAssetId.Text; if (sMaximoId == "" || sMaximoId == "0") { sMaximoId = "-1"; } int iMaximoAssetId = Convert.ToInt32(sMaximoId); UILabel hfPwrId = (UILabel)View.ViewWithTag(iStringRowPwrIdTagId * (iPwrIdRow) + (iStringRow)); string sPwrId = hfPwrId.Text; UITextField txtBankNo = (UITextField)View.ViewWithTag(iBankNoTagId * (iPwrIdRow) + (iStringRow)); string sBankNo = txtBankNo.Text; if (sBankNo == "") { sBankNo = "0"; } int iBankNo = Convert.ToInt32(sBankNo); //You can only delete an item you have added and these have iMaximoAssetId = -1 if (iMaximoAssetId < 0) { //This means the current row is either not changed or has been updated, so it has to be removed from the DB if (iRowStatus == 0 || iRowStatus == 1) { //Don't actaully delete at this stage, just mark as deleted. Delete on the upload success. if(!DBQ.ITPProjectSectionDeleteSection10Item(m_sPassedId, iAutoId, false, ref sRtnMsg)) { iUtils.AlertBox alert = new iUtils.AlertBox(); alert.CreateErrorAlertDialog("Could not delete battery string record on project " + m_sPassedId + ", Power Id " + sPwrId + " and bank number " + iBankNo.ToString()); return; } } //Remove the line from the page (well hide it really so all the loops still work) UIView vwStringRow = (UIView)View.ViewWithTag(iStringFullRowTagId * (iPwrIdRow) + (iStringRow)); vwStringRow.Hidden = true; hfRowStatus.Text = "3"; //Means deleted, so no save required ReduceHeightAfter(m_iBatteryRowHeight, iPwrIdRow, iStringRow, 1); UIView vwPwrInternalRowId = (UIView)View.ViewWithTag((iPwrIdSectionInnerTagId + (iPwrIdRow)) * (m_iBatterySectionCounter+1)); RectangleF frame1 = vwPwrInternalRowId.Frame; frame1.Height -= m_iBatteryRowHeight; vwPwrInternalRowId.Frame = frame1; //Now increase the view height for this new row (The whole section height is handled in the ReduceHeightAfter function) UILabel hfPwrIdSectionHeight = (UILabel)View.ViewWithTag((iPwrIdHeightTagId + iPwrIdRow ) * (m_iBatterySectionCounter + 1)); int iPwrIdHeight = Convert.ToInt32(hfPwrIdSectionHeight.Text); hfPwrIdSectionHeight.Text = (iPwrIdHeight - m_iBatteryRowHeight).ToString(); //Set the unsaved tags on (do this even though the record is removed for consistency) SetSectionValueChanged(m_iBatterySectionCounter + 1); SetAnyValueChanged(sender, null); } return; }