Exemple #1
0
        /// <summary>
        /// Update the specified id, name and value.
        /// </summary>
        /// <returns>The update success.</returns>
        /// <param name="id">Identifier.</param>
        /// <param name="name">Name.</param>
        /// <param name="value">Value.</param>
        public bool Update(int id, string name, string value)
        {
            if (name == ID)
            {
                ErrorControl.Instance().AddError(string.Format("Attribute 'Id' can not be modified. Table={0}, Id={1}.", tableName, id.ToString()));
                return(false);
            }
            if (doc == null)
            {
                Load();
            }
            XElement row = ReadX(id);

            if (row == null)
            {
                ErrorControl.Instance().AddError(string.Format("Row not found. Table={0}, Id={1}.", tableName, id.ToString()));
                return(false);
            }
            if (row.Attribute(name) == null)
            {
                ErrorControl.Instance().AddError(string.Format("Attribute not found. Table={0}, Id={1}, Attribute name={2}.", tableName, id.ToString(), name));
                return(false);
            }
            row.Attribute(name).Value = value;
            return(true);
        }
        public static ErrorControl Instance()
        {
            if (_errorControl == null)
            {
                // The class reference
                _errorControl = new ErrorControl();

                // Configuration
                textElements         = new List <string>();
                _isLogUtilSwitchedOn = LogUtil.Instance.GetSwitchedOn();

                // Data
                errorMessage = new DataTable();
                errorMessage.Columns.Add(Column_UserId, typeof(int));
                errorMessage.Columns.Add(Column_Message, typeof(string));

                warningMessage = new DataTable();
                warningMessage.Columns.Add(Column_UserId, typeof(int));
                warningMessage.Columns.Add(Column_Message, typeof(string));
            }
            return(_errorControl);
        }