Exemplo n.º 1
0
        //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;
            }
        }
Exemplo n.º 2
0
        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;
            }
        }
Exemplo n.º 3
0
        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();

            }
        }
Exemplo n.º 4
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;
            }
        }
Exemplo n.º 5
0
        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;
        }
Exemplo n.º 6
0
        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;
        }
Exemplo n.º 7
0
        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();
            }
        }
Exemplo n.º 8
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;
        }