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

📄 datasetproduct.cs

📁 《C#数据库项目案例导航》一书的配套光盘
💻 CS
📖 第 1 页 / 共 2 页
字号:
                        ProductRemark};
                this.Rows.Add(rowProductRow);
                return rowProductRow;
            }
            
            public ProductRow FindByProductID(string ProductID) {
                return ((ProductRow)(this.Rows.Find(new object[] {
                            ProductID})));
            }
            
            public System.Collections.IEnumerator GetEnumerator() {
                return this.Rows.GetEnumerator();
            }
            
            public override DataTable Clone() {
                ProductDataTable cln = ((ProductDataTable)(base.Clone()));
                cln.InitVars();
                return cln;
            }
            
            protected override DataTable CreateInstance() {
                return new ProductDataTable();
            }
            
            internal void InitVars() {
                this.columnProductID = this.Columns["ProductID"];
                this.columnProductName = this.Columns["ProductName"];
                this.columnProductSort = this.Columns["ProductSort"];
                this.columnProductUnit = this.Columns["ProductUnit"];
                this.columnProductRemark = this.Columns["ProductRemark"];
            }
            
            private void InitClass() {
                this.columnProductID = new DataColumn("ProductID", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnProductID);
                this.columnProductName = new DataColumn("ProductName", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnProductName);
                this.columnProductSort = new DataColumn("ProductSort", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnProductSort);
                this.columnProductUnit = new DataColumn("ProductUnit", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnProductUnit);
                this.columnProductRemark = new DataColumn("ProductRemark", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnProductRemark);
                this.Constraints.Add(new UniqueConstraint("Constraint1", new DataColumn[] {
                                this.columnProductID}, true));
                this.columnProductID.AllowDBNull = false;
                this.columnProductID.Unique = true;
            }
            
            public ProductRow NewProductRow() {
                return ((ProductRow)(this.NewRow()));
            }
            
            protected override DataRow NewRowFromBuilder(DataRowBuilder builder) {
                return new ProductRow(builder);
            }
            
            protected override System.Type GetRowType() {
                return typeof(ProductRow);
            }
            
            protected override void OnRowChanged(DataRowChangeEventArgs e) {
                base.OnRowChanged(e);
                if ((this.ProductRowChanged != null)) {
                    this.ProductRowChanged(this, new ProductRowChangeEvent(((ProductRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowChanging(DataRowChangeEventArgs e) {
                base.OnRowChanging(e);
                if ((this.ProductRowChanging != null)) {
                    this.ProductRowChanging(this, new ProductRowChangeEvent(((ProductRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleted(DataRowChangeEventArgs e) {
                base.OnRowDeleted(e);
                if ((this.ProductRowDeleted != null)) {
                    this.ProductRowDeleted(this, new ProductRowChangeEvent(((ProductRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleting(DataRowChangeEventArgs e) {
                base.OnRowDeleting(e);
                if ((this.ProductRowDeleting != null)) {
                    this.ProductRowDeleting(this, new ProductRowChangeEvent(((ProductRow)(e.Row)), e.Action));
                }
            }
            
            public void RemoveProductRow(ProductRow row) {
                this.Rows.Remove(row);
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ProductRow : DataRow {
            
            private ProductDataTable tableProduct;
            
            internal ProductRow(DataRowBuilder rb) : 
                    base(rb) {
                this.tableProduct = ((ProductDataTable)(this.Table));
            }
            
            public string ProductID {
                get {
                    return ((string)(this[this.tableProduct.ProductIDColumn]));
                }
                set {
                    this[this.tableProduct.ProductIDColumn] = value;
                }
            }
            
            public string ProductName {
                get {
                    try {
                        return ((string)(this[this.tableProduct.ProductNameColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableProduct.ProductNameColumn] = value;
                }
            }
            
            public string ProductSort {
                get {
                    try {
                        return ((string)(this[this.tableProduct.ProductSortColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableProduct.ProductSortColumn] = value;
                }
            }
            
            public string ProductUnit {
                get {
                    try {
                        return ((string)(this[this.tableProduct.ProductUnitColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableProduct.ProductUnitColumn] = value;
                }
            }
            
            public string ProductRemark {
                get {
                    try {
                        return ((string)(this[this.tableProduct.ProductRemarkColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tableProduct.ProductRemarkColumn] = value;
                }
            }
            
            public bool IsProductNameNull() {
                return this.IsNull(this.tableProduct.ProductNameColumn);
            }
            
            public void SetProductNameNull() {
                this[this.tableProduct.ProductNameColumn] = System.Convert.DBNull;
            }
            
            public bool IsProductSortNull() {
                return this.IsNull(this.tableProduct.ProductSortColumn);
            }
            
            public void SetProductSortNull() {
                this[this.tableProduct.ProductSortColumn] = System.Convert.DBNull;
            }
            
            public bool IsProductUnitNull() {
                return this.IsNull(this.tableProduct.ProductUnitColumn);
            }
            
            public void SetProductUnitNull() {
                this[this.tableProduct.ProductUnitColumn] = System.Convert.DBNull;
            }
            
            public bool IsProductRemarkNull() {
                return this.IsNull(this.tableProduct.ProductRemarkColumn);
            }
            
            public void SetProductRemarkNull() {
                this[this.tableProduct.ProductRemarkColumn] = System.Convert.DBNull;
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class ProductRowChangeEvent : EventArgs {
            
            private ProductRow eventRow;
            
            private DataRowAction eventAction;
            
            public ProductRowChangeEvent(ProductRow row, DataRowAction action) {
                this.eventRow = row;
                this.eventAction = action;
            }
            
            public ProductRow Row {
                get {
                    return this.eventRow;
                }
            }
            
            public DataRowAction Action {
                get {
                    return this.eventAction;
                }
            }
        }
    }
}

⌨️ 快捷键说明

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