Пример #1
0
        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;
            }
        }
Пример #2
0
        //Here iType means 1 = Batteries, 2 = Solar strings
        public bool ValidateBankNo(object sender, int iType, int iFromBackButton)
        {
            if(gbSuppressSecondCheck)
            {
                return true;
            }

            if(iFromBackButton == 1)
            {
                gbSuppressSecondCheck = true;
            }

            UITextField txtBankNo = (UITextField)sender;
            string sBankNo = txtBankNo.Text;
            sBankNo = sBankNo.ToUpper();
            txtBankNo.Text = sBankNo;
            clsTabletDB.ITPValidHierarchy ITPValidHierarchy = new clsTabletDB.ITPValidHierarchy();
            bool bBankCheck = ITPValidHierarchy.IsValidItem(sBankNo, iType + 5);
            int iTagId = txtBankNo.Tag;
            int iPwrIdRow =  iTagId/ iEquipmentStringTagId;
            int iStringRow = iTagId - (iPwrIdRow * iEquipmentStringTagId);
            int iHiddenBankId =  iEquipmentStringHiddenTagId * iPwrIdRow + iStringRow;
            UILabel hfHiddenBankNo = (UILabel)View.ViewWithTag (iHiddenBankId);

            if (!bBankCheck && sBankNo != "")
            {
                iUtils.AlertBox alert = new iUtils.AlertBox ();
                alert.CreateErrorAlertDialog ("Please enter a valid bank no or select from the list by using the button to the immediate right");
                txtBankNo.Text = hfHiddenBankNo.Text;
                txtBankNo.ResignFirstResponder();
                txtBankNo.BecomeFirstResponder();
                m_bSuppressMove = true;
                return false;
            }
            else
            {
                if(hfHiddenBankNo.Text != txtBankNo.Text)
                {
                    hfHiddenBankNo.Text = txtBankNo.Text;
                    UILabel hfRowStatus = (UILabel)View.ViewWithTag(iEquipmentRowStatusTagId * iPwrIdRow + iStringRow);
                    hfRowStatus.Text = "1";
                    SetSectionValueChanged(m_iEquipmentSectionCounter + 1);
                    SetAnyValueChanged(sender, null);
                }
                return true;
            }
        }