Beispiel #1
0
        /// <summary>
        /// Saves the input back into the dataset. </summary>
        /// <returns> true if the data was saved successfuly.  False if not. </returns>
        private bool saveData()
        {
            string routine = "StateMod_Reservoir_AreaCap_JFrame.saveData";

            if (!__worksheet.stopEditing())
            {
                // don't save if there are errors.
                Message.printWarning(1, routine, "There are errors in the data " + "that must be corrected before data can be saved.", this);
                return(false);
            }

            if (checkInput() > 0)
            {
                return(false);
            }

            // now only save data if any are different.
            bool needToSave = false;

            // if the Vectors are differently-sized, they're different
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") java.util.List<StateMod_ReservoirAreaCap> wv = (java.util.List<StateMod_ReservoirAreaCap>)__worksheet.getAllData();
            IList <StateMod_ReservoirAreaCap> wv = (IList <StateMod_ReservoirAreaCap>)__worksheet.getAllData();   // w for worksheet
            IList <StateMod_ReservoirAreaCap> rv = __currentRes.getAreaCaps();

            needToSave = !(StateMod_ReservoirAreaCap.Equals(wv, rv));

            Message.printStatus(1, routine, "Saving? .........[" + needToSave + "]");

            if (!needToSave)
            {
                // there's nothing different -- users may even have deleted
                // some rights and added back in identical values
                return(true);
            }

            // now add the elements from the new Vector to the reservoirRights
            // Vector.
            int size = wv.Count;
            IList <StateMod_ReservoirAreaCap> clone = new List <StateMod_ReservoirAreaCap>();

            for (int i = 0; i < size; i++)
            {
                clone.Add((StateMod_ReservoirAreaCap)wv[i].clone());
            }

            __currentRes.setAreaCaps(clone);
            __dataset.setDirty(StateMod_DataSet.COMP_DIVERSION_STATIONS, true);
            return(true);
        }