//This is all in a separate thread so to display anything you have to use the RunOnUiThread method
        public bool RunDownload(string sId, string sDescription, UIButton button, string sUser, string sSessionId)
        {
            try
            {
                string sRtnMsg = "";
                if (!DownloadProjectITPInfo(sId, sDescription,sUser, sSessionId))
                {
                    this.InvokeOnMainThread(() => {
                        iUtils.AlertBox alert = new iUtils.AlertBox();
                        alert.CreateAlertDialog();
                        alert.SetAlertMessage("Cannot download ITP info for Project " + sId);
                        alert.ShowAlertBox();
                        ReEnableButtons();
                        UILabel btnStatus = (UILabel)View.ViewWithTag (button.Tag /12000 * 13000);
                        button.Enabled = false; btnStatus.Text = "1"; });
                    return false;
                }
                else
                {
                    if (!SetITPDownloaded(sId, sUser, sSessionId, ref sRtnMsg))
                    {
                        this.InvokeOnMainThread(() => {
                            iUtils.AlertBox alert = new iUtils.AlertBox();
                            alert.CreateAlertDialog();
                            alert.SetAlertMessage("Cannot mark ITP info for Project " + sId + " as successfully downloaded. Please contact SCMS admin for help.");
                            alert.ShowAlertBox();
                            ReEnableButtons();
                            UILabel btnStatus = (UILabel)View.ViewWithTag (button.Tag /12000 * 13000);
                            button.Enabled = false; btnStatus.Text = "1"; });
                        return false;
                    }
                    else
                    {
                        this.InvokeOnMainThread(() => {
                            iUtils.AlertBox alert = new iUtils.AlertBox();
                            alert.CreateAlertDialog();
                            alert.SetAlertMessage("ITP info for Project " + sId + " successfully downloaded. You can now work offline.");
                            alert.ShowAlertBox();
                            ReEnableButtons();
                            UILabel btnStatus = (UILabel)View.ViewWithTag (button.Tag /12000 * 13000);
                            button.Enabled = false; btnStatus.Text = "1"; });
                        return true;
                    }
                }
            }
            catch (Exception ex)
            {

                this.InvokeOnMainThread(() => {
                    iUtils.AlertBox alert = new iUtils.AlertBox();
                    alert.CreateAlertDialog();
                    alert.SetAlertMessage(ex.Message.ToString());
                    alert.ShowAlertBox();
                    ReEnableButtons();
                });

                return false;
            }
        }
        public bool DownloadProjectITPInfo(string sId, string sDescription, string sUser, string sSessionId)
        {
            //			var txtName = (UILabel)View.ViewWithTag (20);
            //			string sUser = txtName.Text;
            //			var hfSessionId = (UILabel)View.ViewWithTag (70);
            //			string sSessionId = hfSessionId.Text;

            //First get all the static info
            if (DownloadStaticTables(sUser, sSessionId))
            {
                clsITPFramework csITP = new clsITPFramework();
                clsTabletDB.ITPHeaderTable clsTabDB = new clsTabletDB.ITPHeaderTable();
                clsTabletDB.ITPDocumentSection clsITPSection = new clsTabletDB.ITPDocumentSection();
                string sRtnMsg = "";

                //****************************************************************************************//
                //                      DOCUMENT HEADER                                                   //
                //****************************************************************************************//
                object[] objListITPs = csITP.DownloadITPInfo(sSessionId, sUser, sId);

                if (objListITPs[0].ToString() == "Success")
                {
                    //Get the header info from the website version. This has to exist before you can download.
                    if (clsTabDB.TableHeaderDeleteAllRecords(sId, ref sRtnMsg))
                    {
                        string sITPDocumentHeaderInfo = objListITPs[1].ToString();
                        string[] sHeaderInfo = sITPDocumentHeaderInfo.Split('~');
                        if (sHeaderInfo[0] == "ITPDocumentHeaderInfo")
                        {
                            string[] delimiters = new string[] { "||" };
                            string[] sHeaderItems = sHeaderInfo[1].Split(delimiters, StringSplitOptions.RemoveEmptyEntries);
                            int iHeaderCount = sHeaderItems.Length;
                            if (iHeaderCount > 0)
                            {
                                //First check if the header table exists and if not create it
                                clsTabletDB.ITPHeaderTable ITPDB = new clsTabletDB.ITPHeaderTable();
                                if (ITPDB.CheckHeaderTable())
                                {
                                    this.InvokeOnMainThread(() => {
                                        progBarProjITPHeaderVw.SetProgressBarTitle("Downloading ITP header info for project " + sId);
                                        progBarProjITPHeaderVw.ShowProgressBar(iHeaderCount);
                                    });
                                    for (int i = 0; i < iHeaderCount; i++)
                                    {
                                        string[] delimiters2 = new string[] { "^" };
                                        string[] sHeaderSplitItems = sHeaderItems[i].Split(delimiters2, StringSplitOptions.None);
                                        Array.Resize<string>(ref sHeaderSplitItems, sHeaderSplitItems.Length + 1);
                                        sHeaderSplitItems[sHeaderSplitItems.Length - 1] = sDescription;
                                        ITPDB.TableHeaderAddRecord(sHeaderSplitItems);
                                        this.InvokeOnMainThread(() => { progBarProjITPHeaderVw.UpdateProgressBar(i + 1); });
                                    }
                                    this.InvokeOnMainThread(() => { progBarProjITPHeaderVw.CloseProgressBar(); });
                                }
                            }
                        }
                        //return true;
                    }
                    else
                    {
                        this.InvokeOnMainThread(() => {
                            iUtils.AlertBox alert = new iUtils.AlertBox();
                            alert.SetAlertMessage(sRtnMsg);
                            alert.ShowAlertBox(); });
                        return false;
                    }

                    //****************************************************************************************//
                    //                      QUESTIONNAIRE MASTER                                              //
                    //****************************************************************************************//
                    object[] objITPQuestions = csITP.DownloadProjectITPQuestions(sSessionId, sUser, sId);

                    //Get any questions already raised on the website version into the local DB
                    if (objITPQuestions[0].ToString() == "Success")
                    {
                        if (clsITPSection.ITPProjectSectionDeleteAllQuestions(sId, ref sRtnMsg))
                        {
                            string sITPProjectQuesitonsInfo = objITPQuestions[1].ToString();
                            string[] sProjQuestionInfo = sITPProjectQuesitonsInfo.Split('~');
                            if (sProjQuestionInfo[0] == "ITPProjectQuestionnaireInfo")
                            {
                                string[] delimiters3 = new string[] { "||" };
                                string[] sProjectQuestions = sProjQuestionInfo[1].Split(delimiters3, StringSplitOptions.RemoveEmptyEntries);
                                int iHeaderCount3 = sProjectQuestions.Length;
                                if (iHeaderCount3 > 0)
                                {
                                    //First check if the question master table exists and if not create it
                                    clsTabletDB.ITPDocumentSection ITPQuest = new clsTabletDB.ITPDocumentSection();
                                    if (ITPQuest.CheckQuestionTableMst())
                                    {
                                        this.InvokeOnMainThread(() => {
                                            progBarProjITPQuestionsVw.SetProgressBarTitle("Downloading ITP questions for project " + sId);
                                            progBarProjITPQuestionsVw.ShowProgressBar(iHeaderCount3);
                                        });
                                        for (int i = 0; i < iHeaderCount3; i++)
                                        {
                                            string[] delimiters4 = new string[] { "^" };
                                            string[] sProjectQuestionItems = sProjectQuestions[i].Split(delimiters4, StringSplitOptions.None);
                                            ITPQuest.ITPProjectQuestionAddRecord(sProjectQuestionItems);
                                            this.InvokeOnMainThread(() => { progBarProjITPQuestionsVw.UpdateProgressBar(i + 1); });
                                        }
                                        this.InvokeOnMainThread(() => { progBarProjITPQuestionsVw.CloseProgressBar(); });
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.InvokeOnMainThread(() => {
                                iUtils.AlertBox alert = new iUtils.AlertBox();
                                alert.SetAlertMessage(sRtnMsg);
                                alert.ShowAlertBox();
                            });
                            return false;
                        }
                    }
                    else
                    {
                        return false;
                    } //Close the if block for success on project ITP questions

                    //****************************************************************************************//
                    //                      SECTION 10                                                       //
                    //****************************************************************************************//
                    object[] objITPSection10Info = csITP.DownloadProjectITPSection10(sSessionId, sUser, sId);

                    //Get any section 10 info already raised on the website version into the local DB
                    if (objITPSection10Info[0].ToString() == "Success")
                    {
                        if (clsITPSection.ITPProjectSectionDeleteAllSection10Items(sId, ref sRtnMsg))
                        {
                            string sITPProjectSection10Info = objITPSection10Info[1].ToString();
                            string[] sProjSection10Info = sITPProjectSection10Info.Split('~');
                            if (sProjSection10Info[0] == "ITPProjectSection10Info")
                            {
                                string[] delimiters5 = new string[] { "||" };
                                string[] sProjectSection10Items = sProjSection10Info[1].Split(delimiters5, StringSplitOptions.RemoveEmptyEntries);
                                int iHeaderCount5 = sProjectSection10Items.Length;
                                if (iHeaderCount5 > 0)
                                {
                                    //First check if the section 10 table exists and if not create it
                                    clsTabletDB.ITPDocumentSection ITPSection10 = new clsTabletDB.ITPDocumentSection();
                                    if (ITPSection10.CheckSection10Table())
                                    {
                                        this.InvokeOnMainThread(() => {
                                            progBarProjITPSection10Vw.SetProgressBarTitle("Downloading ITP section 10 items for project " + sId);
                                            progBarProjITPSection10Vw.ShowProgressBar(iHeaderCount5);
                                        });
                                        for (int i = 0; i < iHeaderCount5; i++)
                                        {
                                            string[] delimiters6 = new string[] { "^" };
                                            string[] sProjectSection10ItemArray = sProjectSection10Items[i].Split(delimiters6, StringSplitOptions.None);
                                            ITPSection10.ITPSection10AddRecord(sProjectSection10ItemArray);
                                            this.InvokeOnMainThread(() => { progBarProjITPSection10Vw.UpdateProgressBar(i + 1); });
                                        }
                                        this.InvokeOnMainThread(() => { progBarProjITPSection10Vw.CloseProgressBar(); });
                                    }
                                }
                            }
                        }
                        else
                        {
                            this.InvokeOnMainThread(() => {
                                iUtils.AlertBox alert = new iUtils.AlertBox();
                                alert.SetAlertMessage(sRtnMsg);
                                alert.ShowAlertBox();
                            });
                            return false;
                        }
                    }
                    else
                    {
                        return false;
                    } //Close the if block for success on project ITP section 10

                    //****************************************************************************************//
                    //                      RFU HEADER INFO                                                   //
                    //****************************************************************************************//
                    object[] objITPRFUInfo = csITP.DownloadProjectITPRFU(sSessionId, sUser, sId);

                    //Get any RFU info already raised on the website version into the local DB
                    if (objITPRFUInfo[0].ToString() == "Success")
                    {
                        if (clsITPSection.ITPProjectSectionDeleteAllRFUItems(sId, ref sRtnMsg))
                        {
                            string sITPProjectRFUInfo = objITPRFUInfo[1].ToString();
                            string[] sProjRFUInfo = sITPProjectRFUInfo.Split('~');
                            if (sProjRFUInfo[0] == "ITPProjectRFUInfo")
                            {
                                string[] delimiters5 = new string[] { "||" };
                                string[] sProjectRFUItems = sProjRFUInfo[1].Split(delimiters5, StringSplitOptions.RemoveEmptyEntries);
                                int iHeaderCount5 = sProjectRFUItems.Length;
                                if (iHeaderCount5 > 0)
                                {
                                    //First check if the RFU table exists and if not create it
                                    clsTabletDB.ITPDocumentSection ITPRFU = new clsTabletDB.ITPDocumentSection();
                                    if (ITPRFU.CheckRFUTable())
                                    {
                                        this.InvokeOnMainThread(() => {
                                            progBarProjITPRFUVw.SetProgressBarTitle("Downloading ITP RFU PwrId items for project " + sId);
                                            progBarProjITPRFUVw.ShowProgressBar(iHeaderCount5);
                                        });
                                        for (int i = 0; i < iHeaderCount5; i++)
                                        {
                                            string[] delimiters6 = new string[] { "^" };
                                            string[] sProjectRFUItemArray = sProjectRFUItems[i].Split(delimiters6, StringSplitOptions.None);
                                            ITPRFU.ITPRFUAddRecord(sProjectRFUItemArray);
                                            this.InvokeOnMainThread(() => { progBarProjITPRFUVw.UpdateProgressBar(i + 1); });
                                        }
                                        this.InvokeOnMainThread(() => { progBarProjITPRFUVw.CloseProgressBar(); });
                                    }
                                }
                            }
                            return true;
                        }
                        else
                        {
                            this.InvokeOnMainThread(() => {
                                iUtils.AlertBox alert = new iUtils.AlertBox();
                                alert.SetAlertMessage(sRtnMsg);
                                alert.ShowAlertBox();
                            });
                            return false;
                        }
                    }
                    else
                    {
                        return false;
                    } //Close the if block for success on project ITP section 10
                }
                else
                {
                    return false;
                } //Close the if block for success on project ITP document header
            }
            else
            {
                return false;
            } //Close the if block for success on downlaod of static tables
        }
        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 override void ViewDidLoad()
        {
            string sRtnMsg = "";
            base.ViewDidLoad ();
            UIBarButtonItem mybackbtn = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, delegate (object sender, EventArgs e) {CheckUnsaved();});
            NavigationItem.SetHidesBackButton(true, true);
            NavigationItem.SetLeftBarButtonItem(mybackbtn, true);

            // Perform any additional setup after loading the view, typically from a nib.
            DrawMenu();

            //Load up the data for each section should it not exist
            clsTabletDB.ITPDocumentSection ITPSection = new clsTabletDB.ITPDocumentSection();
            if(!ITPSection.FillLocalITPSections(m_sPassedId, ref sRtnMsg))
            {
                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateAlertDialog();
                alert.SetAlertMessage(sRtnMsg);
                alert.ShowAlertBox();
            }
            try
            {
                DrawOpeningPage();
            }
            catch (Exception ex)
            {
                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateAlertDialog();
                alert.SetAlertMessage(ex.Message.ToString());
                alert.ShowAlertBox();

            }
        }
        public void CheckUnsaved()
        {
            //First of all validate anything required
            switch(m_iValidateType)
            {
                case 1: //Floor
                    if(!ValidateFloor(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 2: //Suite
                    if(!ValidateSuite(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 3: //Rack
                    if(!ValidateRack(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 4: //SubRack
                    if(!ValidateSubRack(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 5: //Position
                    if(!ValidatePosition(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 6: //Solar String
                    if(!ValidateBankNo(m_sender, 2, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 7: //DOM
                    if(!ValidateDOM(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 8: //Serial No
                    if(!ValidateSerialNo(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 9: //Maximo Asset Id
                    if(!ValidateMaximoAssetId(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
            }

            UILabel txtEditStatus = (UILabel)View.ViewWithTag (80);
            int iStatus = Convert.ToInt32 (txtEditStatus.Text);
            if (iStatus == 0)
            {
                ProjectITPage QuestionsScreen = new ProjectITPage ();
                QuestionsScreen = GetProjectITPPage ();
                this.NavigationController.PopToViewController (QuestionsScreen, true);
            }
            else
            {
                //Ask the question
                iUtils.AlertBox alert2 = new iUtils.AlertBox();
                alert2.CreateAlertYesNoCancelDialog();
                alert2.SetAlertMessage("You have unsaved changes. Do you wish to save these changes before going back to the downloaded screen?");
                alert2.ShowAlertBox();

                UIAlertView alert3 = alert2.GetAlertDialog();
                alert3.Clicked += (sender2, e2)  => {CheckSaveChangesQuestion(sender2, e2, e2.ButtonIndex);};

            }
        }
        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;
            }
        }
Exemple #7
0
        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;
            }
        }
        public void AddNewEquipment(object sender, EventArgs e)
        {
            UIButton btnAddNew = (UIButton)sender;
            int iTagId = btnAddNew.Tag;
            int iPwrIdRow = iTagId /(m_iEquipmentSectionCounter+1)  - iPwrIdNewBtnTagId; //This is 1 based

            iUtils.AlertBox alert2 = new iUtils.AlertBox();
            alert2.CreateAlertRackSubRackPositionStringDialog();
            alert2.SetAlertMessage("Are you adding a rack, subrack, position item or solar panel string?");
            alert2.ShowAlertBox();

            UIAlertView alert3 = alert2.GetAlertDialog();
            alert3.Clicked += (sender2, e2)  => {AddNewItem(sender2, e2, e2.ButtonIndex, iPwrIdRow);};
        }
        void UploadITPQuestion(object sender, EventArgs e, int iMarkUploadType)
        {
            UIButton btnClicked = (UIButton)sender;
            int iClicked = btnClicked.Tag;
            UILabel projId = (UILabel)View.ViewWithTag (iClicked/iUploadBtnTagId*iProjectIdTagId);
            string sId = projId.Text;
            int iOpenBtnId = -1;
            if(iMarkUploadType == 1)
            {
                iOpenBtnId = iClicked/iUploadBtnTagId*iOpenBtnTagId;
            }
            else
            {
                iOpenBtnId = iClicked/iBackupBtnTagId*iOpenBtnTagId;
            }

            var bConnStatus = GetConnectionStatus ();

            if (!bConnStatus)
            {
                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateAlertDialog();
                alert.SetAlertMessage("The is no network coverage so you cannot upload at this stage");
                alert.ShowAlertBox();
                return;
            }
            else
            {
                //Has the project been made available online again and if so you cannot upload
                clsITPFramework ITPFwrk = new clsITPFramework();
                object[] objUploadable = ITPFwrk.IsITPUploadable(m_sSessionId, m_sUser, sId);
                if (objUploadable[0].ToString() != "Success")
                {
                    iUtils.AlertBox alert4 = new iUtils.AlertBox();
                    alert4.CreateErrorAlertDialog(objUploadable[1].ToString());
                    return;
                }
            }

            if(iMarkUploadType == 1)
            {
                iUtils.AlertBox alert2 = new iUtils.AlertBox();
                alert2.CreateAlertYesNoDialog();
                alert2.SetAlertMessage("This will upload ITP info for Project " + sId + " and lock you out from any further changes. Do you wish to continue?");
                alert2.ShowAlertBox();
                UIAlertView alert3 = alert2.GetAlertDialog();
                alert3.Clicked += (sender2, e2)  => {CheckUploadQuestion(sender2, e2, e2.ButtonIndex, sId, iOpenBtnId, 0);};
            }
            else
            {
                iUtils.AlertBox alert2 = new iUtils.AlertBox();
                alert2.CreateAlertYesNoDialog();
                alert2.SetAlertMessage("This will backup ITP info for Project " + sId + " and allow you to make further changes once complete. Do you wish to continue?");
                alert2.ShowAlertBox();
                UIAlertView alert3 = alert2.GetAlertDialog();
                alert3.Clicked += (sender2, e2)  => {CheckUploadQuestion(sender2, e2, e2.ButtonIndex, sId, iOpenBtnId, 1);};
            }

            return;
        }
        bool UploadITP(string sId, int iOpenBtnId, int iUploadOrBackup)
        {
            string sUser = m_sUser;
            string sSessionId = m_sSessionId;
            clsITPFramework ITPFwrk = new clsITPFramework();
            string sRtnMsg = "";
            bool bUpload = ITPFwrk.UploadITPInfo(sSessionId, sUser, sId, iUploadOrBackup, ref sRtnMsg);
            if (bUpload && sRtnMsg == "")
            {
                //Now also disable the open button for this project
                if(iUploadOrBackup == 0)
                {
                    UIButton btnOpen = (UIButton)View.ViewWithTag (iOpenBtnId);
                    btnOpen.Enabled = false;
                    UILabel hfbtnOpenStatus = (UILabel)View.ViewWithTag (iOpenBtnId/iOpenBtnTagId * iOpenBtnStatusTagId);
                    hfbtnOpenStatus.Text = "0";

                    UIButton btnUpload = (UIButton)View.ViewWithTag (iOpenBtnId/ iOpenBtnTagId * iUploadBtnTagId);
                    btnUpload.Enabled = false;
                    UILabel hfbtnUploadStatus = (UILabel)View.ViewWithTag (iOpenBtnId/iOpenBtnTagId * iUploadBtnStatusTagId);
                    hfbtnUploadStatus.Text = "0";

                    UIButton btnBackup = (UIButton)View.ViewWithTag (iOpenBtnId/ iOpenBtnTagId * iBackupBtnTagId);
                    btnBackup.Enabled = false;

                    //Enable the remove button
                    UIButton btnRemove = (UIButton)View.ViewWithTag (iOpenBtnId/ iOpenBtnTagId * iRemoveBtnTagId);
                    btnRemove.Enabled = true;
                    UILabel hfbtnRemoveStatus = (UILabel)View.ViewWithTag (iOpenBtnId/iOpenBtnTagId * iRemoveBtnStatusTagId);
                    hfbtnRemoveStatus.Text = "1";
                }

                //Change the status text too
                if(iUploadOrBackup == 0)
                {
                    UILabel lblStatus = (UILabel)View.ViewWithTag (iOpenBtnId/ iOpenBtnTagId * iProjStatusTagId);
                    lblStatus.Text = "Uploaded already. You must download again to make changes.";
                }

                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateAlertDialog();
                if(iUploadOrBackup == 0)
                {
                    alert.SetAlertMessage("ITP info for Project " + sId + " successfully uploaded.");
                }
                else
                {
                    alert.SetAlertMessage("ITP info for Project " + sId + " successfully backed up.");
                }
                alert.ShowAlertBox();
            }
            else
            {
                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateAlertDialog();
                alert.SetAlertMessage(sRtnMsg);
                alert.ShowAlertBox();
            }

            return bUpload;
        }
        public void RemoveITP(object sender, EventArgs e)
        {
            clsTabletDB.ITPCollection coll = new clsTabletDB.ITPCollection ();
            UIButton btnClicked = (UIButton)sender;
            int iClicked = btnClicked.Tag;
            UILabel projId = (UILabel)View.ViewWithTag (iClicked / iRemoveBtnTagId * iProjectIdTagId);
            string sId = projId.Text;
            string sRtnMsg = "";

            if (!coll.ITPLocalRemove (sId, ref sRtnMsg))
            {
                iUtils.AlertBox alert = new iUtils.AlertBox ();
                alert.CreateAlertDialog ();
                alert.SetAlertMessage (sRtnMsg);
                alert.ShowAlertBox ();
            }
            else //Disable the remove, open and upload buttons for this row
            {
                UIButton btnOpen = (UIButton)View.ViewWithTag (iOpenBtnTagId * iClicked / iRemoveBtnTagId);
                UIButton btnUpload = (UIButton)View.ViewWithTag (iUploadBtnTagId * iClicked / iRemoveBtnTagId);
                UIButton btnRemove = (UIButton)View.ViewWithTag (iRemoveBtnTagId * iClicked / iRemoveBtnTagId);
                btnOpen.Enabled = false;
                btnUpload.Enabled = false;
                btnRemove.Enabled = false;

                UILabel hfbtnOpenStatus = (UILabel)View.ViewWithTag (iOpenBtnStatusTagId * iClicked / iRemoveBtnTagId);
                UILabel hfbtnUploadStatus = (UILabel)View.ViewWithTag (iUploadBtnStatusTagId * iClicked / iRemoveBtnTagId);
                UILabel hfbtnRemoveStatus = (UILabel)View.ViewWithTag (iRemoveBtnStatusTagId * iClicked / iRemoveBtnTagId);
                hfbtnOpenStatus.Text = "0";
                hfbtnUploadStatus.Text = "0";
                hfbtnRemoveStatus.Text = "0";

                //Update the status text too
                UILabel lblStatus = (UILabel)View.ViewWithTag (iClicked/ iRemoveBtnTagId * iProjStatusTagId);
                lblStatus.Text = "Removed completely. Reopening thsi screen will remove the project from this listing.";

                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateAlertDialog();
                alert.SetAlertMessage("ITP info for Project " + sId + " successfully removed.");
                alert.ShowAlertBox();
            }
        }
Exemple #12
0
        public bool SaveRFURow(string sId, int iRow, bool bCheckSectionStatus, bool bSaveOnly)
        {
            clsTabletDB.ITPDocumentSection DB = new clsTabletDB.ITPDocumentSection();
            string[] sItemValues = new string[9];
            int i;

            UILabel hfRFURowStatus = (UILabel)View.ViewWithTag((ihfRowRFUStatusTagId + (iRow + 1)) * (m_iRFUSectionCounter + 1));
            UILabel lblPwrId = (UILabel)View.ViewWithTag((iRFUPwrIdRowLabelTagId + (iRow + 1)) * (m_iRFUSectionCounter + 1));
            string sPwrId = lblPwrId.Text;
            UILabel lblDesignLoad = (UILabel)View.ViewWithTag((iRFUDesignLoadRowLabelTagId + (iRow + 1)) * (m_iRFUSectionCounter + 1));
            string sDesignLoad = lblDesignLoad.Text;
            UITextField txtCutoverLoad = (UITextField)View.ViewWithTag((iRFUCutoverLoadRowLabelTagId + (iRow + 1)) * (m_iRFUSectionCounter + 1));
            string sCutoverLoad = txtCutoverLoad.Text;
            UITextField txtCutoverDate = (UITextField)View.ViewWithTag((iRFUCutoverDateRowLabelTagId + (iRow + 1)) * (m_iRFUSectionCounter + 1));
            string sCutoverDate = txtCutoverDate.Text;
            UISwitch chkDecommission = (UISwitch)View.ViewWithTag((iRFUDecommissionRowCheckTagId + (iRow + 1)) * (m_iRFUSectionCounter + 1));
            bool bDecommission = chkDecommission.On;
            int iDecommission;
            if (bDecommission)
            {
                iDecommission = 1;
            }
            else
            {
                iDecommission = 0;
            }
            UISwitch chkCommission = (UISwitch)View.ViewWithTag((iRFUCommissionRowCheckTagId + (iRow + 1)) * (m_iRFUSectionCounter + 1));
            bool bCommission = chkCommission.On;
            int iCommission;
            if (bCommission)
            {
                iCommission = 1;
            }
            else
            {
                iCommission = 0;
            }
            string sCurrentDateAndTime = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
            UILabel hfBatteryCapacity = (UILabel)View.ViewWithTag((ihfRowRFUBatteryCapacityTagId + (iRow + 1)) * (m_iRFUSectionCounter + 1));
            string sBatteryCapacity = hfBatteryCapacity.Text;

            //Get all the info for this RFU row
            sItemValues [0] = sId;
            sItemValues [1] = sPwrId;
            sItemValues [2] = sDesignLoad;
            sItemValues [3] = sCutoverLoad;
            sItemValues [4] = sCutoverDate;
            sItemValues [5] = iDecommission.ToString();
            sItemValues [6] = iCommission.ToString();
            sItemValues [7] = sCurrentDateAndTime;
            sItemValues [8] = sBatteryCapacity;

            if (sCutoverLoad == "" || sCutoverDate == "" || (iDecommission == 0 && iCommission == 0) ||
                (iDecommission == 1 && iCommission == 1))
            {
                iUtils.AlertBox alert = new iUtils.AlertBox();
                alert.CreateAlertDialog();
                alert.SetAlertMessage("The Power Id " + sPwrId + " RFU info is not complete. You cannot commit the RFU at this stage.");
                alert.ShowAlertBox();
                return false;
            }

            //Update or insert into the local DB
            if (DB.ITPRFUSetRecord(sId, sPwrId, sItemValues))
            {
                //Update the row status
                hfRFURowStatus.Text = "0";

                if(!bSaveOnly)
                {
                    UIButton btnRFU = (UIButton)View.ViewWithTag((iRFUButtonSaveTagId + (iRow+1)) * (m_iRFUSectionCounter+1));
                    btnRFU.SetTitle("Committed", UIControlState.Normal);
                }
            }
            else
            {
                return false;
            }

            //Now check to see if the section should be marked as complete and ultimately the whole page
            if (bCheckSectionStatus)
            {
                UILabel hfSectionPwrIds = (UILabel)View.ViewWithTag(iSectionRowsTagId * (m_iRFUSectionCounter + 1));
                int iTotalPwrIds = Convert.ToInt32(hfSectionPwrIds.Text);
                bool bResetSectionFlag = true;

                for (i=0; i<iTotalPwrIds; i++)
                {
                    UILabel hfRFURowStatus1 = (UILabel)View.ViewWithTag((ihfRowRFUStatusTagId + (i + 1)) * (m_iRFUSectionCounter + 1));
                    int iRowStatus1 = Convert.ToInt32(hfRFURowStatus1.Text);
                    if(iRowStatus1 == 1)
                    {
                        bResetSectionFlag = false;
                        break;
                    }

                }

                if(bResetSectionFlag)
                {
                    UILabel hfSectionStatus = (UILabel)View.ViewWithTag(iSectionStatusTagId * (m_iRFUSectionCounter + 1));
                    hfSectionStatus.Text = "0";
                    SetAnyValueChangedOff(false);
                    return true;
                }
            }

            return true;
        }
Exemple #13
0
        public void CheckUnsaved()
        {
            //First of all validate anything required
            switch(m_iValidateType)
            {
                case 9: //Cutover Load
                    if(!ValidateCutoverLoad(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
                case 10: //Cutover Date
                    if(!ValidateCutoverDate(m_sender, 1))
                    {
                        gbSuppressSecondCheck = false;
                        return;
                    }
                    break;
            }

            UILabel txtEditStatus = (UILabel)View.ViewWithTag (80);
            int iStatus = Convert.ToInt32 (txtEditStatus.Text);
            if (iStatus == 0)
            {
                DownloadedITPsScreen downloadScreen = new DownloadedITPsScreen ();
                downloadScreen = GetDownloadedITPsScreen ();
                this.NavigationController.PopToViewController (downloadScreen, true);
            }
            else
            {
                //Ask the question
                iUtils.AlertBox alert2 = new iUtils.AlertBox();
                alert2.CreateAlertYesNoCancelDialog();
                alert2.SetAlertMessage("You have unsaved changes. Only chnages to questions will be saved. RFU changes must be committed using the buttons. Do you wish to save these changes before going back to the downloaded screen?");
                alert2.ShowAlertBox();

                UIAlertView alert3 = alert2.GetAlertDialog();
                alert3.Clicked += (sender2, e2)  => {CheckSaveChangesQuestion(sender2, e2, e2.ButtonIndex);};

            }
        }