⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datasetclient.cs

📁 《C#数据库项目案例导航》一书的配套光盘
💻 CS
📖 第 1 页 / 共 2 页
字号:
                cln.InitVars();
                return cln;
            }
            
            protected override DataTable CreateInstance() {
                return new ClientDataTable();
            }
            
            internal void InitVars() {
                this.columnClientID = this.Columns["ClientID"];
                this.columnClientName = this.Columns["ClientName"];
                this.columnClientAddress = this.Columns["ClientAddress"];
                this.columnClientPhoneNo = this.Columns["ClientPhoneNo"];
                this.columnClientEmail = this.Columns["ClientEmail"];
                this.columnClientPeople = this.Columns["ClientPeople"];
                this.columnClientRemark = this.Columns["ClientRemark"];
            }
            
            private void InitClass() {
                this.columnClientID = new DataColumn("ClientID", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnClientID);
                this.columnClientName = new DataColumn("ClientName", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnClientName);
                this.columnClientAddress = new DataColumn("ClientAddress", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnClientAddress);
                this.columnClientPhoneNo = new DataColumn("ClientPhoneNo", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnClientPhoneNo);
                this.columnClientEmail = new DataColumn("ClientEmail", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnClientEmail);
                this.columnClientPeople = new DataColumn("ClientPeople", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnClientPeople);
                this.columnClientRemark = new DataColumn("ClientRemark", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnClientRemark);
                this.Constraints.Add(new UniqueConstraint("Constraint1", new DataColumn[] {
                                this.columnClientID}, true));
                this.columnClientID.AllowDBNull = false;
                this.columnClientID.Unique = true;
            }
            
            public ClientRow NewClientRow() {
                return ((ClientRow)(this.NewRow()));
            }
            
            protected override DataRow NewRowFromBuilder(DataRowBuilder builder) {
                return new ClientRow(builder);
            }
            
            protected override System.Type GetRowType() {
                return typeof(ClientRow);
            }
            
            protected override void OnRowChanged(DataRowChangeEventArgs e) {
                base.OnRowChanged(e);
                if ((this.ClientRowChanged != null)) {
                    this.ClientRowChanged(this, new ClientRowChangeEvent(((ClientRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowChanging(DataRowChangeEventArgs e) {
                base.OnRowChanging(e);
                if ((this.ClientRowChanging != null)) {
                    this.ClientRowChanging(this, new ClientRowChangeEvent(((ClientRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleted(DataRowChangeEventArgs e) {
                base.OnRowDeleted(e);
                if ((this.ClientRowDeleted != null)) {
                    this.ClientRowDeleted(this, new ClientRowChangeEvent(((ClientRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleting(DataRowChangeEventArgs e) {
                base.OnRowDeleting(e);
                if ((this.ClientRowDeleting != null)) {
                    this.ClientRowDeleting(this, new ClientRowChangeEvent(((ClientRow)(e.Row)), e.Action));
                }
            }
            
            public void RemoveClientRow(ClientRow row) {
                this.Rows.Remove(row);
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ClientRow : DataRow {
            
            private ClientDataTable tableClient;
            
            internal ClientRow(DataRowBuilder rb) : 
                    base(rb) {
                this.tableClient = ((ClientDataTable)(this.Table));
            }
            
            public string ClientID {
                get {
                    return ((string)(this[this.tableClient.ClientIDColumn]));
                }
                set {
                    this[this.tableClient.ClientIDColumn] = value;
                }
            }
            
            public string ClientName {
                get {
                    try {
                        return ((string)(this[this.tableClient.ClientNameColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableClient.ClientNameColumn] = value;
                }
            }
            
            public string ClientAddress {
                get {
                    try {
                        return ((string)(this[this.tableClient.ClientAddressColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableClient.ClientAddressColumn] = value;
                }
            }
            
            public string ClientPhoneNo {
                get {
                    try {
                        return ((string)(this[this.tableClient.ClientPhoneNoColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableClient.ClientPhoneNoColumn] = value;
                }
            }
            
            public string ClientEmail {
                get {
                    try {
                        return ((string)(this[this.tableClient.ClientEmailColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableClient.ClientEmailColumn] = value;
                }
            }
            
            public string ClientPeople {
                get {
                    try {
                        return ((string)(this[this.tableClient.ClientPeopleColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableClient.ClientPeopleColumn] = value;
                }
            }
            
            public string ClientRemark {
                get {
                    try {
                        return ((string)(this[this.tableClient.ClientRemarkColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableClient.ClientRemarkColumn] = value;
                }
            }
            
            public bool IsClientNameNull() {
                return this.IsNull(this.tableClient.ClientNameColumn);
            }
            
            public void SetClientNameNull() {
                this[this.tableClient.ClientNameColumn] = System.Convert.DBNull;
            }
            
            public bool IsClientAddressNull() {
                return this.IsNull(this.tableClient.ClientAddressColumn);
            }
            
            public void SetClientAddressNull() {
                this[this.tableClient.ClientAddressColumn] = System.Convert.DBNull;
            }
            
            public bool IsClientPhoneNoNull() {
                return this.IsNull(this.tableClient.ClientPhoneNoColumn);
            }
            
            public void SetClientPhoneNoNull() {
                this[this.tableClient.ClientPhoneNoColumn] = System.Convert.DBNull;
            }
            
            public bool IsClientEmailNull() {
                return this.IsNull(this.tableClient.ClientEmailColumn);
            }
            
            public void SetClientEmailNull() {
                this[this.tableClient.ClientEmailColumn] = System.Convert.DBNull;
            }
            
            public bool IsClientPeopleNull() {
                return this.IsNull(this.tableClient.ClientPeopleColumn);
            }
            
            public void SetClientPeopleNull() {
                this[this.tableClient.ClientPeopleColumn] = System.Convert.DBNull;
            }
            
            public bool IsClientRemarkNull() {
                return this.IsNull(this.tableClient.ClientRemarkColumn);
            }
            
            public void SetClientRemarkNull() {
                this[this.tableClient.ClientRemarkColumn] = System.Convert.DBNull;
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ClientRowChangeEvent : EventArgs {
            
            private ClientRow eventRow;
            
            private DataRowAction eventAction;
            
            public ClientRowChangeEvent(ClientRow row, DataRowAction action) {
                this.eventRow = row;
                this.eventAction = action;
            }
            
            public ClientRow Row {
                get {
                    return this.eventRow;
                }
            }
            
            public DataRowAction Action {
                get {
                    return this.eventAction;
                }
            }
        }
    }
}

⌨️ 快捷键说明

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