Beispiel #1
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;
        }