DataSet1.cs
上传用户:chinafred
上传日期:2007-08-14
资源大小:10127k
文件大小:17k
源码类别:

数据库编程

开发平台:

C#

  1. //------------------------------------------------------------------------------
  2. // <autogenerated>
  3. //     This code was generated by a tool.
  4. //     Runtime Version: 1.0.3705.0
  5. //
  6. //     Changes to this file may cause incorrect behavior and will be lost if 
  7. //     the code is regenerated.
  8. // </autogenerated>
  9. //------------------------------------------------------------------------------
  10. namespace ch6_5 {
  11.     using System;
  12.     using System.Data;
  13.     using System.Xml;
  14.     using System.Runtime.Serialization;
  15.     
  16.     
  17.     [Serializable()]
  18.     [System.ComponentModel.DesignerCategoryAttribute("code")]
  19.     [System.Diagnostics.DebuggerStepThrough()]
  20.     [System.ComponentModel.ToolboxItem(true)]
  21.     public class DataSet1 : DataSet {
  22.         
  23.         private informationDataTable tableinformation;
  24.         
  25.         public DataSet1() {
  26.             this.InitClass();
  27.             System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
  28.             this.Tables.CollectionChanged += schemaChangedHandler;
  29.             this.Relations.CollectionChanged += schemaChangedHandler;
  30.         }
  31.         
  32.         protected DataSet1(SerializationInfo info, StreamingContext context) {
  33.             string strSchema = ((string)(info.GetValue("XmlSchema", typeof(string))));
  34.             if ((strSchema != null)) {
  35.                 DataSet ds = new DataSet();
  36.                 ds.ReadXmlSchema(new XmlTextReader(new System.IO.StringReader(strSchema)));
  37.                 if ((ds.Tables["information"] != null)) {
  38.                     this.Tables.Add(new informationDataTable(ds.Tables["information"]));
  39.                 }
  40.                 this.DataSetName = ds.DataSetName;
  41.                 this.Prefix = ds.Prefix;
  42.                 this.Namespace = ds.Namespace;
  43.                 this.Locale = ds.Locale;
  44.                 this.CaseSensitive = ds.CaseSensitive;
  45.                 this.EnforceConstraints = ds.EnforceConstraints;
  46.                 this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
  47.                 this.InitVars();
  48.             }
  49.             else {
  50.                 this.InitClass();
  51.             }
  52.             this.GetSerializationData(info, context);
  53.             System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
  54.             this.Tables.CollectionChanged += schemaChangedHandler;
  55.             this.Relations.CollectionChanged += schemaChangedHandler;
  56.         }
  57.         
  58.         [System.ComponentModel.Browsable(false)]
  59.         [System.ComponentModel.DesignerSerializationVisibilityAttribute(System.ComponentModel.DesignerSerializationVisibility.Content)]
  60.         public informationDataTable information {
  61.             get {
  62.                 return this.tableinformation;
  63.             }
  64.         }
  65.         
  66.         public override DataSet Clone() {
  67.             DataSet1 cln = ((DataSet1)(base.Clone()));
  68.             cln.InitVars();
  69.             return cln;
  70.         }
  71.         
  72.         protected override bool ShouldSerializeTables() {
  73.             return false;
  74.         }
  75.         
  76.         protected override bool ShouldSerializeRelations() {
  77.             return false;
  78.         }
  79.         
  80.         protected override void ReadXmlSerializable(XmlReader reader) {
  81.             this.Reset();
  82.             DataSet ds = new DataSet();
  83.             ds.ReadXml(reader);
  84.             if ((ds.Tables["information"] != null)) {
  85.                 this.Tables.Add(new informationDataTable(ds.Tables["information"]));
  86.             }
  87.             this.DataSetName = ds.DataSetName;
  88.             this.Prefix = ds.Prefix;
  89.             this.Namespace = ds.Namespace;
  90.             this.Locale = ds.Locale;
  91.             this.CaseSensitive = ds.CaseSensitive;
  92.             this.EnforceConstraints = ds.EnforceConstraints;
  93.             this.Merge(ds, false, System.Data.MissingSchemaAction.Add);
  94.             this.InitVars();
  95.         }
  96.         
  97.         protected override System.Xml.Schema.XmlSchema GetSchemaSerializable() {
  98.             System.IO.MemoryStream stream = new System.IO.MemoryStream();
  99.             this.WriteXmlSchema(new XmlTextWriter(stream, null));
  100.             stream.Position = 0;
  101.             return System.Xml.Schema.XmlSchema.Read(new XmlTextReader(stream), null);
  102.         }
  103.         
  104.         internal void InitVars() {
  105.             this.tableinformation = ((informationDataTable)(this.Tables["information"]));
  106.             if ((this.tableinformation != null)) {
  107.                 this.tableinformation.InitVars();
  108.             }
  109.         }
  110.         
  111.         private void InitClass() {
  112.             this.DataSetName = "DataSet1";
  113.             this.Prefix = "";
  114.             this.Namespace = "http://www.tempuri.org/DataSet1.xsd";
  115.             this.Locale = new System.Globalization.CultureInfo("zh-CN");
  116.             this.CaseSensitive = false;
  117.             this.EnforceConstraints = true;
  118.             this.tableinformation = new informationDataTable();
  119.             this.Tables.Add(this.tableinformation);
  120.         }
  121.         
  122.         private bool ShouldSerializeinformation() {
  123.             return false;
  124.         }
  125.         
  126.         private void SchemaChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) {
  127.             if ((e.Action == System.ComponentModel.CollectionChangeAction.Remove)) {
  128.                 this.InitVars();
  129.             }
  130.         }
  131.         
  132.         public delegate void informationRowChangeEventHandler(object sender, informationRowChangeEvent e);
  133.         
  134.         [System.Diagnostics.DebuggerStepThrough()]
  135.         public class informationDataTable : DataTable, System.Collections.IEnumerable {
  136.             
  137.             private DataColumn column电话;
  138.             
  139.             private DataColumn column电子邮件;
  140.             
  141.             private DataColumn column年龄;
  142.             
  143.             private DataColumn column姓名;
  144.             
  145.             internal informationDataTable() : 
  146.                     base("information") {
  147.                 this.InitClass();
  148.             }
  149.             
  150.             internal informationDataTable(DataTable table) : 
  151.                     base(table.TableName) {
  152.                 if ((table.CaseSensitive != table.DataSet.CaseSensitive)) {
  153.                     this.CaseSensitive = table.CaseSensitive;
  154.                 }
  155.                 if ((table.Locale.ToString() != table.DataSet.Locale.ToString())) {
  156.                     this.Locale = table.Locale;
  157.                 }
  158.                 if ((table.Namespace != table.DataSet.Namespace)) {
  159.                     this.Namespace = table.Namespace;
  160.                 }
  161.                 this.Prefix = table.Prefix;
  162.                 this.MinimumCapacity = table.MinimumCapacity;
  163.                 this.DisplayExpression = table.DisplayExpression;
  164.             }
  165.             
  166.             [System.ComponentModel.Browsable(false)]
  167.             public int Count {
  168.                 get {
  169.                     return this.Rows.Count;
  170.                 }
  171.             }
  172.             
  173.             internal DataColumn 电话Column {
  174.                 get {
  175.                     return this.column电话;
  176.                 }
  177.             }
  178.             
  179.             internal DataColumn 电子邮件Column {
  180.                 get {
  181.                     return this.column电子邮件;
  182.                 }
  183.             }
  184.             
  185.             internal DataColumn 年龄Column {
  186.                 get {
  187.                     return this.column年龄;
  188.                 }
  189.             }
  190.             
  191.             internal DataColumn 姓名Column {
  192.                 get {
  193.                     return this.column姓名;
  194.                 }
  195.             }
  196.             
  197.             public informationRow this[int index] {
  198.                 get {
  199.                     return ((informationRow)(this.Rows[index]));
  200.                 }
  201.             }
  202.             
  203.             public event informationRowChangeEventHandler informationRowChanged;
  204.             
  205.             public event informationRowChangeEventHandler informationRowChanging;
  206.             
  207.             public event informationRowChangeEventHandler informationRowDeleted;
  208.             
  209.             public event informationRowChangeEventHandler informationRowDeleting;
  210.             
  211.             public void AddinformationRow(informationRow row) {
  212.                 this.Rows.Add(row);
  213.             }
  214.             
  215.             public informationRow AddinformationRow(string 电话, string 电子邮件, int 年龄, string 姓名) {
  216.                 informationRow rowinformationRow = ((informationRow)(this.NewRow()));
  217.                 rowinformationRow.ItemArray = new object[] {
  218.                         电话,
  219.                         电子邮件,
  220.                         年龄,
  221.                         姓名};
  222.                 this.Rows.Add(rowinformationRow);
  223.                 return rowinformationRow;
  224.             }
  225.             
  226.             public informationRow FindBy姓名(string 姓名) {
  227.                 return ((informationRow)(this.Rows.Find(new object[] {
  228.                             姓名})));
  229.             }
  230.             
  231.             public System.Collections.IEnumerator GetEnumerator() {
  232.                 return this.Rows.GetEnumerator();
  233.             }
  234.             
  235.             public override DataTable Clone() {
  236.                 informationDataTable cln = ((informationDataTable)(base.Clone()));
  237.                 cln.InitVars();
  238.                 return cln;
  239.             }
  240.             
  241.             protected override DataTable CreateInstance() {
  242.                 return new informationDataTable();
  243.             }
  244.             
  245.             internal void InitVars() {
  246.                 this.column电话 = this.Columns["电话"];
  247.                 this.column电子邮件 = this.Columns["电子邮件"];
  248.                 this.column年龄 = this.Columns["年龄"];
  249.                 this.column姓名 = this.Columns["姓名"];
  250.             }
  251.             
  252.             private void InitClass() {
  253.                 this.column电话 = new DataColumn("电话", typeof(string), null, System.Data.MappingType.Element);
  254.                 this.Columns.Add(this.column电话);
  255.                 this.column电子邮件 = new DataColumn("电子邮件", typeof(string), null, System.Data.MappingType.Element);
  256.                 this.Columns.Add(this.column电子邮件);
  257.                 this.column年龄 = new DataColumn("年龄", typeof(int), null, System.Data.MappingType.Element);
  258.                 this.Columns.Add(this.column年龄);
  259.                 this.column姓名 = new DataColumn("姓名", typeof(string), null, System.Data.MappingType.Element);
  260.                 this.Columns.Add(this.column姓名);
  261.                 this.Constraints.Add(new UniqueConstraint("Constraint1", new DataColumn[] {
  262.                                 this.column姓名}, true));
  263.                 this.column姓名.AllowDBNull = false;
  264.                 this.column姓名.Unique = true;
  265.             }
  266.             
  267.             public informationRow NewinformationRow() {
  268.                 return ((informationRow)(this.NewRow()));
  269.             }
  270.             
  271.             protected override DataRow NewRowFromBuilder(DataRowBuilder builder) {
  272.                 return new informationRow(builder);
  273.             }
  274.             
  275.             protected override System.Type GetRowType() {
  276.                 return typeof(informationRow);
  277.             }
  278.             
  279.             protected override void OnRowChanged(DataRowChangeEventArgs e) {
  280.                 base.OnRowChanged(e);
  281.                 if ((this.informationRowChanged != null)) {
  282.                     this.informationRowChanged(this, new informationRowChangeEvent(((informationRow)(e.Row)), e.Action));
  283.                 }
  284.             }
  285.             
  286.             protected override void OnRowChanging(DataRowChangeEventArgs e) {
  287.                 base.OnRowChanging(e);
  288.                 if ((this.informationRowChanging != null)) {
  289.                     this.informationRowChanging(this, new informationRowChangeEvent(((informationRow)(e.Row)), e.Action));
  290.                 }
  291.             }
  292.             
  293.             protected override void OnRowDeleted(DataRowChangeEventArgs e) {
  294.                 base.OnRowDeleted(e);
  295.                 if ((this.informationRowDeleted != null)) {
  296.                     this.informationRowDeleted(this, new informationRowChangeEvent(((informationRow)(e.Row)), e.Action));
  297.                 }
  298.             }
  299.             
  300.             protected override void OnRowDeleting(DataRowChangeEventArgs e) {
  301.                 base.OnRowDeleting(e);
  302.                 if ((this.informationRowDeleting != null)) {
  303.                     this.informationRowDeleting(this, new informationRowChangeEvent(((informationRow)(e.Row)), e.Action));
  304.                 }
  305.             }
  306.             
  307.             public void RemoveinformationRow(informationRow row) {
  308.                 this.Rows.Remove(row);
  309.             }
  310.         }
  311.         
  312.         [System.Diagnostics.DebuggerStepThrough()]
  313.         public class informationRow : DataRow {
  314.             
  315.             private informationDataTable tableinformation;
  316.             
  317.             internal informationRow(DataRowBuilder rb) : 
  318.                     base(rb) {
  319.                 this.tableinformation = ((informationDataTable)(this.Table));
  320.             }
  321.             
  322.             public string 电话 {
  323.                 get {
  324.                     try {
  325.                         return ((string)(this[this.tableinformation.电话Column]));
  326.                     }
  327.                     catch (InvalidCastException e) {
  328.                         throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
  329.                     }
  330.                 }
  331.                 set {
  332.                     this[this.tableinformation.电话Column] = value;
  333.                 }
  334.             }
  335.             
  336.             public string 电子邮件 {
  337.                 get {
  338.                     try {
  339.                         return ((string)(this[this.tableinformation.电子邮件Column]));
  340.                     }
  341.                     catch (InvalidCastException e) {
  342.                         throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
  343.                     }
  344.                 }
  345.                 set {
  346.                     this[this.tableinformation.电子邮件Column] = value;
  347.                 }
  348.             }
  349.             
  350.             public int 年龄 {
  351.                 get {
  352.                     try {
  353.                         return ((int)(this[this.tableinformation.年龄Column]));
  354.                     }
  355.                     catch (InvalidCastException e) {
  356.                         throw new StrongTypingException("无法获取值,因为它是 DBNull。", e);
  357.                     }
  358.                 }
  359.                 set {
  360.                     this[this.tableinformation.年龄Column] = value;
  361.                 }
  362.             }
  363.             
  364.             public string 姓名 {
  365.                 get {
  366.                     return ((string)(this[this.tableinformation.姓名Column]));
  367.                 }
  368.                 set {
  369.                     this[this.tableinformation.姓名Column] = value;
  370.                 }
  371.             }
  372.             
  373.             public bool Is电话Null() {
  374.                 return this.IsNull(this.tableinformation.电话Column);
  375.             }
  376.             
  377.             public void Set电话Null() {
  378.                 this[this.tableinformation.电话Column] = System.Convert.DBNull;
  379.             }
  380.             
  381.             public bool Is电子邮件Null() {
  382.                 return this.IsNull(this.tableinformation.电子邮件Column);
  383.             }
  384.             
  385.             public void Set电子邮件Null() {
  386.                 this[this.tableinformation.电子邮件Column] = System.Convert.DBNull;
  387.             }
  388.             
  389.             public bool Is年龄Null() {
  390.                 return this.IsNull(this.tableinformation.年龄Column);
  391.             }
  392.             
  393.             public void Set年龄Null() {
  394.                 this[this.tableinformation.年龄Column] = System.Convert.DBNull;
  395.             }
  396.         }
  397.         
  398.         [System.Diagnostics.DebuggerStepThrough()]
  399.         public class informationRowChangeEvent : EventArgs {
  400.             
  401.             private informationRow eventRow;
  402.             
  403.             private DataRowAction eventAction;
  404.             
  405.             public informationRowChangeEvent(informationRow row, DataRowAction action) {
  406.                 this.eventRow = row;
  407.                 this.eventAction = action;
  408.             }
  409.             
  410.             public informationRow Row {
  411.                 get {
  412.                     return this.eventRow;
  413.                 }
  414.             }
  415.             
  416.             public DataRowAction Action {
  417.                 get {
  418.                     return this.eventAction;
  419.                 }
  420.             }
  421.         }
  422.     }
  423. }