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

📄 product.cs

📁 Professional C# 2nd Edition
💻 CS
📖 第 1 页 / 共 2 页
字号:
            this.columnUnitPrice = this.Columns["UnitPrice"];
            this.columnUnitsInStock = this.Columns["UnitsInStock"];
            this.columnUnitsOnOrder = this.Columns["UnitsOnOrder"];
            this.columnReorderLevel = this.Columns["ReorderLevel"];
            this.columnDiscontinued = this.Columns["Discontinued"];
        }
        
        private void InitClass() {
            this.columnProductID = new DataColumn("ProductID", typeof(int), 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.columnSupplierID = new DataColumn("SupplierID", typeof(int), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnSupplierID);
            this.columnCategoryID = new DataColumn("CategoryID", typeof(int), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnCategoryID);
            this.columnQuantityPerUnit = new DataColumn("QuantityPerUnit", typeof(string), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnQuantityPerUnit);
            this.columnUnitPrice = new DataColumn("UnitPrice", typeof(System.Decimal), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnUnitPrice);
            this.columnUnitsInStock = new DataColumn("UnitsInStock", typeof(short), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnUnitsInStock);
            this.columnUnitsOnOrder = new DataColumn("UnitsOnOrder", typeof(short), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnUnitsOnOrder);
            this.columnReorderLevel = new DataColumn("ReorderLevel", typeof(short), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnReorderLevel);
            this.columnDiscontinued = new DataColumn("Discontinued", typeof(bool), null, System.Data.MappingType.Element);
            this.Columns.Add(this.columnDiscontinued);
            this.columnProductID.AutoIncrement = true;
            this.columnProductID.AllowDBNull = false;
            this.columnProductID.ReadOnly = true;
            this.columnProductName.AllowDBNull = false;
            this.columnDiscontinued.AllowDBNull = false;
        }
        
        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 int ProductID {
            get {
                return ((int)(this[this.tableProduct.ProductIDColumn]));
            }
            set {
                this[this.tableProduct.ProductIDColumn] = value;
            }
        }
        
        public string ProductName {
            get {
                return ((string)(this[this.tableProduct.ProductNameColumn]));
            }
            set {
                this[this.tableProduct.ProductNameColumn] = value;
            }
        }
        
        public int SupplierID {
            get {
                try {
                    return ((int)(this[this.tableProduct.SupplierIDColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tableProduct.SupplierIDColumn] = value;
            }
        }
        
        public int CategoryID {
            get {
                try {
                    return ((int)(this[this.tableProduct.CategoryIDColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tableProduct.CategoryIDColumn] = value;
            }
        }
        
        public string QuantityPerUnit {
            get {
                try {
                    return ((string)(this[this.tableProduct.QuantityPerUnitColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tableProduct.QuantityPerUnitColumn] = value;
            }
        }
        
        public System.Decimal UnitPrice {
            get {
                try {
                    return ((System.Decimal)(this[this.tableProduct.UnitPriceColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tableProduct.UnitPriceColumn] = value;
            }
        }
        
        public short UnitsInStock {
            get {
                try {
                    return ((short)(this[this.tableProduct.UnitsInStockColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tableProduct.UnitsInStockColumn] = value;
            }
        }
        
        public short UnitsOnOrder {
            get {
                try {
                    return ((short)(this[this.tableProduct.UnitsOnOrderColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tableProduct.UnitsOnOrderColumn] = value;
            }
        }
        
        public short ReorderLevel {
            get {
                try {
                    return ((short)(this[this.tableProduct.ReorderLevelColumn]));
                }
                catch (InvalidCastException e) {
                    throw new StrongTypingException("Cannot get value because it is DBNull.", e);
                }
            }
            set {
                this[this.tableProduct.ReorderLevelColumn] = value;
            }
        }
        
        public bool Discontinued {
            get {
                return ((bool)(this[this.tableProduct.DiscontinuedColumn]));
            }
            set {
                this[this.tableProduct.DiscontinuedColumn] = value;
            }
        }
        
        public bool IsSupplierIDNull() {
            return this.IsNull(this.tableProduct.SupplierIDColumn);
        }
        
        public void SetSupplierIDNull() {
            this[this.tableProduct.SupplierIDColumn] = System.Convert.DBNull;
        }
        
        public bool IsCategoryIDNull() {
            return this.IsNull(this.tableProduct.CategoryIDColumn);
        }
        
        public void SetCategoryIDNull() {
            this[this.tableProduct.CategoryIDColumn] = System.Convert.DBNull;
        }
        
        public bool IsQuantityPerUnitNull() {
            return this.IsNull(this.tableProduct.QuantityPerUnitColumn);
        }
        
        public void SetQuantityPerUnitNull() {
            this[this.tableProduct.QuantityPerUnitColumn] = System.Convert.DBNull;
        }
        
        public bool IsUnitPriceNull() {
            return this.IsNull(this.tableProduct.UnitPriceColumn);
        }
        
        public void SetUnitPriceNull() {
            this[this.tableProduct.UnitPriceColumn] = System.Convert.DBNull;
        }
        
        public bool IsUnitsInStockNull() {
            return this.IsNull(this.tableProduct.UnitsInStockColumn);
        }
        
        public void SetUnitsInStockNull() {
            this[this.tableProduct.UnitsInStockColumn] = System.Convert.DBNull;
        }
        
        public bool IsUnitsOnOrderNull() {
            return this.IsNull(this.tableProduct.UnitsOnOrderColumn);
        }
        
        public void SetUnitsOnOrderNull() {
            this[this.tableProduct.UnitsOnOrderColumn] = System.Convert.DBNull;
        }
        
        public bool IsReorderLevelNull() {
            return this.IsNull(this.tableProduct.ReorderLevelColumn);
        }
        
        public void SetReorderLevelNull() {
            this[this.tableProduct.ReorderLevelColumn] = 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 + -