allcontacts.cs

来自「Sams Teach Yourself C# Web Programming i」· CS 代码 · 共 361 行

CS
361
字号
//------------------------------------------------------------------------------
// <autogenerated>
//     This code was generated by a tool.
//     Runtime Version: 1.0.3617.0
//
//     Changes to this file may cause incorrect behavior and will be lost if 
//     the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

namespace Data_Form_Example {
    using System;
    using System.Data;
    using System.Xml;
    using System.Runtime.Serialization;
    
    
    [Serializable()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Diagnostics.DebuggerStepThrough()]
    [System.ComponentModel.ToolboxItem(true)]
    public class AllContacts : DataSet {
        
        private ContactsDataTable tableContacts;
        
        public AllContacts() {
            this.InitClass();
            System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
            this.Tables.CollectionChanged += schemaChangedHandler;
            this.Relations.CollectionChanged += schemaChangedHandler;
        }
        
        protected AllContacts(SerializationInfo info, StreamingContext context) {
            string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
            if ((strSchema != null)) {
                DataSet ds = new DataSet();
                ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));
                if ((ds.Tables["Contacts"] != null)) {
                    this.Tables.Add(new ContactsDataTable(ds.Tables["Contacts"]));
                }
                this.DataSetName = ds.DataSetName;
                this.Prefix = ds.Prefix;
                this.Namespace = ds.Namespace;
                this.Locale = ds.Locale;
                this.CaseSensitive = ds.CaseSensitive;
                this.EnforceConstraints = ds.EnforceConstraints;
                this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
                this.InitVars();
            }
            else {
                this.InitClass();
            }
            this.GetSerializationData(info, context);
            System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
            this.Tables.CollectionChanged += schemaChangedHandler;
            this.Relations.CollectionChanged += schemaChangedHandler;
        }
        
        [System.ComponentModel.Browsable(false)]
        [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
        public ContactsDataTable Contacts {
            get {
                return this.tableContacts;
            }
        }
        
        public override DataSet Clone() {
            AllContacts cln = ((AllContacts)(base.Clone()));
            cln.InitVars();
            return cln;
        }
        
        protected override bool ShouldSerializeTables() {
            return false;
        }
        
        protected override bool ShouldSerializeRelations() {
            return false;
        }
        
        protected override void ReadXmlSerializable(XmlReader reader) {
            this.Reset();
            DataSet ds = new DataSet();
            ds.ReadXml(reader);
            if ((ds.Tables["Contacts"] != null)) {
                this.Tables.Add(new ContactsDataTable(ds.Tables["Contacts"]));
            }
            this.DataSetName = ds.DataSetName;
            this.Prefix = ds.Prefix;
            this.Namespace = ds.Namespace;
            this.Locale = ds.Locale;
            this.CaseSensitive = ds.CaseSensitive;
            this.EnforceConstraints = ds.EnforceConstraints;
            this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
            this.InitVars();
        }
        
        protected override System.Xml.Schema.XmlSchema GetSchemaSerializable() {
            System.IO.MemoryStream stream = new System.IO.MemoryStream();
            this.WriteXmlSchema(new XmlTextWriter(stream, null));
            stream.Position = 0;
            return System.Xml.Schema.XmlSchema.Read(new XmlTextReader(stream), null);
        }
        
        internal void InitVars() {
            this.tableContacts = ((ContactsDataTable)(this.Tables["Contacts"]));
            if ((this.tableContacts != null)) {
                this.tableContacts.InitVars();
            }
        }
        
        private void InitClass() {
            this.DataSetName = "AllContacts";
            this.Prefix = "";
            this.Namespace = "http://www.tempuri.org/AllContacts.xsd";
            this.Locale = new System.Globalization.CultureInfo("en-US");
            this.CaseSensitive = false;
            this.EnforceConstraints = true;
            this.tableContacts = new ContactsDataTable();
            this.Tables.Add(this.tableContacts);
        }
        
        private bool ShouldSerializeContacts() {
            return false;
        }
        
        private void SchemaChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) {
            if ((e.Action == System.ComponentModel.CollectionChangeAction.Remove)) {
                this.InitVars();
            }
        }
        
        public delegate void ContactsRowChangeEventHandler(object sender, ContactsRowChangeEvent e);
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ContactsDataTable : DataTable, System.Collections.IEnumerable {
            
            private DataColumn columnContactName;
            
            private DataColumn columnState;
            
            internal ContactsDataTable() : 
                    base("Contacts") {
                this.InitClass();
            }
            
            internal ContactsDataTable(DataTable table) : 
                    base(table.TableName) {
                if ((table.CaseSensitive != table.DataSet.CaseSensitive)) {
                    this.CaseSensitive = table.CaseSensitive;
                }
                if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) {
                    this.Locale = table.Locale;
                }
                if ((table.Namespace != table.DataSet.Namespace)) {
                    this.Namespace = table.Namespace;
                }
                this.Prefix = table.Prefix;
                this.MinimumCapacity = table.MinimumCapacity;
                this.DisplayExpression = table.DisplayExpression;
            }
            
            [System.ComponentModel.Browsable(false)]
            public int Count {
                get {
                    return this.Rows.Count;
                }
            }
            
            internal DataColumn ContactNameColumn {
                get {
                    return this.columnContactName;
                }
            }
            
            internal DataColumn StateColumn {
                get {
                    return this.columnState;
                }
            }
            
            public ContactsRow this[int index] {
                get {
                    return ((ContactsRow)(this.Rows[index]));
                }
            }
            
            public event ContactsRowChangeEventHandler ContactsRowChanged;
            
            public event ContactsRowChangeEventHandler ContactsRowChanging;
            
            public event ContactsRowChangeEventHandler ContactsRowDeleted;
            
            public event ContactsRowChangeEventHandler ContactsRowDeleting;
            
            public void AddContactsRow(ContactsRow row) {
                this.Rows.Add(row);
            }
            
            public ContactsRow AddContactsRow(string ContactName, string State) {
                ContactsRow rowContactsRow = ((ContactsRow)(this.NewRow()));
                rowContactsRow.ItemArray = new object[] {
                        ContactName,
                        State};
                this.Rows.Add(rowContactsRow);
                return rowContactsRow;
            }
            
            public System.Collections.IEnumerator GetEnumerator() {
                return this.Rows.GetEnumerator();
            }
            
            public override DataTable Clone() {
                ContactsDataTable cln = ((ContactsDataTable)(base.Clone()));
                cln.InitVars();
                return cln;
            }
            
            protected override DataTable CreateInstance() {
                return new ContactsDataTable();
            }
            
            internal void InitVars() {
                this.columnContactName = this.Columns["ContactName"];
                this.columnState = this.Columns["State"];
            }
            
            private void InitClass() {
                this.columnContactName = new DataColumn("ContactName", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnContactName);
                this.columnState = new DataColumn("State", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnState);
            }
            
            public ContactsRow NewContactsRow() {
                return ((ContactsRow)(this.NewRow()));
            }
            
            protected override DataRow NewRowFromBuilder(DataRowBuilder builder) {
                return new ContactsRow(builder);
            }
            
            protected override System.Type GetRowType() {
                return typeof(ContactsRow);
            }
            
            protected override void OnRowChanged(DataRowChangeEventArgs e) {
                base.OnRowChanged(e);
                if ((this.ContactsRowChanged != null)) {
                    this.ContactsRowChanged(this, new ContactsRowChangeEvent(((ContactsRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowChanging(DataRowChangeEventArgs e) {
                base.OnRowChanging(e);
                if ((this.ContactsRowChanging != null)) {
                    this.ContactsRowChanging(this, new ContactsRowChangeEvent(((ContactsRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleted(DataRowChangeEventArgs e) {
                base.OnRowDeleted(e);
                if ((this.ContactsRowDeleted != null)) {
                    this.ContactsRowDeleted(this, new ContactsRowChangeEvent(((ContactsRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleting(DataRowChangeEventArgs e) {
                base.OnRowDeleting(e);
                if ((this.ContactsRowDeleting != null)) {
                    this.ContactsRowDeleting(this, new ContactsRowChangeEvent(((ContactsRow)(e.Row)), e.Action));
                }
            }
            
            public void RemoveContactsRow(ContactsRow row) {
                this.Rows.Remove(row);
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ContactsRow : DataRow {
            
            private ContactsDataTable tableContacts;
            
            internal ContactsRow(DataRowBuilder rb) : 
                    base(rb) {
                this.tableContacts = ((ContactsDataTable)(this.Table));
            }
            
            public string ContactName {
                get {
                    try {
                        return ((string)(this[this.tableContacts.ContactNameColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                    }
                }
                set {
                    this[this.tableContacts.ContactNameColumn] = value;
                }
            }
            
            public string State {
                get {
                    try {
                        return ((string)(this[this.tableContacts.StateColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                    }
                }
                set {
                    this[this.tableContacts.StateColumn] = value;
                }
            }
            
            public bool IsContactNameNull() {
                return this.IsNull(this.tableContacts.ContactNameColumn);
            }
            
            public void SetContactNameNull() {
                this[this.tableContacts.ContactNameColumn] = System.Convert.DBNull;
            }
            
            public bool IsStateNull() {
                return this.IsNull(this.tableContacts.StateColumn);
            }
            
            public void SetStateNull() {
                this[this.tableContacts.StateColumn] = System.Convert.DBNull;
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ContactsRowChangeEvent : EventArgs {
            
            private ContactsRow eventRow;
            
            private DataRowAction eventAction;
            
            public ContactsRowChangeEvent(ContactsRow row, DataRowAction action) {
                this.eventRow = row;
                this.eventAction = action;
            }
            
            public ContactsRow Row {
                get {
                    return this.eventRow;
                }
            }
            
            public DataRowAction Action {
                get {
                    return this.eventAction;
                }
            }
        }
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?