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

namespace HISClinic.DataModel {
    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 Patients : DataSet {
        
        private t_PatientDataTable tablet_Patient;
        
        public Patients() {
            this.InitClass();
            System.ComponentModel.CollectionChangeEventHandler schemaChangedHandler = new System.ComponentModel.CollectionChangeEventHandler(this.SchemaChanged);
            this.Tables.CollectionChanged += schemaChangedHandler;
            this.Relations.CollectionChanged += schemaChangedHandler;
        }
        
        protected Patients(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["t_Patient"] != null)) {
                    this.Tables.Add(new t_PatientDataTable(ds.Tables["t_Patient"]));
                }
                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 t_PatientDataTable t_Patient {
            get {
                return this.tablet_Patient;
            }
        }
        
        public override DataSet Clone() {
            Patients cln = ((Patients)(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["t_Patient"] != null)) {
                this.Tables.Add(new t_PatientDataTable(ds.Tables["t_Patient"]));
            }
            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.tablet_Patient = ((t_PatientDataTable)(this.Tables["t_Patient"]));
            if ((this.tablet_Patient != null)) {
                this.tablet_Patient.InitVars();
            }
        }
        
        private void InitClass() {
            this.DataSetName = "Patients";
            this.Prefix = "";
            this.Namespace = "http://tempuri.org/Patients.xsd";
            this.Locale = new System.Globalization.CultureInfo("en-US");
            this.CaseSensitive = false;
            this.EnforceConstraints = true;
            this.tablet_Patient = new t_PatientDataTable();
            this.Tables.Add(this.tablet_Patient);
        }
        
        private bool ShouldSerializet_Patient() {
            return false;
        }
        
        private void SchemaChanged(object sender, System.ComponentModel.CollectionChangeEventArgs e) {
            if ((e.Action == System.ComponentModel.CollectionChangeAction.Remove)) {
                this.InitVars();
            }
        }
        
        public delegate void t_PatientRowChangeEventHandler(object sender, t_PatientRowChangeEvent e);
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class t_PatientDataTable : DataTable, System.Collections.IEnumerable {
            
            private DataColumn columnPatientID;
            
            private DataColumn columnName;
            
            private DataColumn columnSex;
            
            private DataColumn columnBirthDate;
            
            private DataColumn columnAddress;
            
            private DataColumn columnTelephone;
            
            private DataColumn columnMobile;
            
            private DataColumn columnCardNumber;
            
            private DataColumn columnAge;
            
            internal t_PatientDataTable() : 
                    base("t_Patient") {
                this.InitClass();
            }
            
            internal t_PatientDataTable(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 PatientIDColumn {
                get {
                    return this.columnPatientID;
                }
            }
            
            internal DataColumn NameColumn {
                get {
                    return this.columnName;
                }
            }
            
            internal DataColumn SexColumn {
                get {
                    return this.columnSex;
                }
            }
            
            internal DataColumn BirthDateColumn {
                get {
                    return this.columnBirthDate;
                }
            }
            
            internal DataColumn AddressColumn {
                get {
                    return this.columnAddress;
                }
            }
            
            internal DataColumn TelephoneColumn {
                get {
                    return this.columnTelephone;
                }
            }
            
            internal DataColumn MobileColumn {
                get {
                    return this.columnMobile;
                }
            }
            
            internal DataColumn CardNumberColumn {
                get {
                    return this.columnCardNumber;
                }
            }
            
            internal DataColumn AgeColumn {
                get {
                    return this.columnAge;
                }
            }
            
            public t_PatientRow this[int index] {
                get {
                    return ((t_PatientRow)(this.Rows[index]));
                }
            }
            
            public event t_PatientRowChangeEventHandler t_PatientRowChanged;
            
            public event t_PatientRowChangeEventHandler t_PatientRowChanging;
            
            public event t_PatientRowChangeEventHandler t_PatientRowDeleted;
            
            public event t_PatientRowChangeEventHandler t_PatientRowDeleting;
            
            public void Addt_PatientRow(t_PatientRow row) {
                this.Rows.Add(row);
            }
            
            public t_PatientRow Addt_PatientRow(string Name, bool Sex, System.DateTime BirthDate, string Address, string Telephone, string Mobile, string CardNumber, int Age) {
                t_PatientRow rowt_PatientRow = ((t_PatientRow)(this.NewRow()));
                rowt_PatientRow.ItemArray = new object[] {
                        null,
                        Name,
                        Sex,
                        BirthDate,
                        Address,
                        Telephone,
                        Mobile,
                        CardNumber,
                        Age};
                this.Rows.Add(rowt_PatientRow);
                return rowt_PatientRow;
            }
            
            public t_PatientRow FindByPatientID(int PatientID) {
                return ((t_PatientRow)(this.Rows.Find(new object[] {
                            PatientID})));
            }
            
            public System.Collections.IEnumerator GetEnumerator() {
                return this.Rows.GetEnumerator();
            }
            
            public override DataTable Clone() {
                t_PatientDataTable cln = ((t_PatientDataTable)(base.Clone()));
                cln.InitVars();
                return cln;
            }
            
            protected override DataTable CreateInstance() {
                return new t_PatientDataTable();
            }
            
            internal void InitVars() {
                this.columnPatientID = this.Columns["PatientID"];
                this.columnName = this.Columns["Name"];
                this.columnSex = this.Columns["Sex"];
                this.columnBirthDate = this.Columns["BirthDate"];
                this.columnAddress = this.Columns["Address"];
                this.columnTelephone = this.Columns["Telephone"];
                this.columnMobile = this.Columns["Mobile"];
                this.columnCardNumber = this.Columns["CardNumber"];
                this.columnAge = this.Columns["Age"];
            }
            
            private void InitClass() {
                this.columnPatientID = new DataColumn("PatientID", typeof(int), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnPatientID);
                this.columnName = new DataColumn("Name", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnName);
                this.columnSex = new DataColumn("Sex", typeof(bool), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnSex);
                this.columnBirthDate = new DataColumn("BirthDate", typeof(System.DateTime), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnBirthDate);
                this.columnAddress = new DataColumn("Address", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnAddress);
                this.columnTelephone = new DataColumn("Telephone", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnTelephone);
                this.columnMobile = new DataColumn("Mobile", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnMobile);
                this.columnCardNumber = new DataColumn("CardNumber", typeof(string), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnCardNumber);
                this.columnAge = new DataColumn("Age", typeof(int), null, System.Data.MappingType.Element);
                this.Columns.Add(this.columnAge);
                this.Constraints.Add(new UniqueConstraint("PatientsKey1", new DataColumn[] {
                                this.columnPatientID}, true));
                this.columnPatientID.AutoIncrement = true;
                this.columnPatientID.AllowDBNull = false;
                this.columnPatientID.ReadOnly = true;
                this.columnPatientID.Unique = true;
                this.columnName.AllowDBNull = false;
                this.columnSex.AllowDBNull = false;
                this.columnCardNumber.AllowDBNull = false;
            }
            
            public t_PatientRow Newt_PatientRow() {
                return ((t_PatientRow)(this.NewRow()));
            }
            
            protected override DataRow NewRowFromBuilder(DataRowBuilder builder) {
                return new t_PatientRow(builder);
            }
            
            protected override System.Type GetRowType() {
                return typeof(t_PatientRow);
            }
            
            protected override void OnRowChanged(DataRowChangeEventArgs e) {
                base.OnRowChanged(e);
                if ((this.t_PatientRowChanged != null)) {
                    this.t_PatientRowChanged(this, new t_PatientRowChangeEvent(((t_PatientRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowChanging(DataRowChangeEventArgs e) {
                base.OnRowChanging(e);
                if ((this.t_PatientRowChanging != null)) {
                    this.t_PatientRowChanging(this, new t_PatientRowChangeEvent(((t_PatientRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleted(DataRowChangeEventArgs e) {
                base.OnRowDeleted(e);
                if ((this.t_PatientRowDeleted != null)) {
                    this.t_PatientRowDeleted(this, new t_PatientRowChangeEvent(((t_PatientRow)(e.Row)), e.Action));
                }
            }
            
            protected override void OnRowDeleting(DataRowChangeEventArgs e) {
                base.OnRowDeleting(e);
                if ((this.t_PatientRowDeleting != null)) {
                    this.t_PatientRowDeleting(this, new t_PatientRowChangeEvent(((t_PatientRow)(e.Row)), e.Action));
                }
            }
            
            public void Removet_PatientRow(t_PatientRow row) {
                this.Rows.Remove(row);
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class t_PatientRow : DataRow {
            
            private t_PatientDataTable tablet_Patient;
            
            internal t_PatientRow(DataRowBuilder rb) : 
                    base(rb) {
                this.tablet_Patient = ((t_PatientDataTable)(this.Table));
            }
            
            public int PatientID {
                get {
                    return ((int)(this[this.tablet_Patient.PatientIDColumn]));
                }
                set {
                    this[this.tablet_Patient.PatientIDColumn] = value;
                }
            }
            
            public string Name {
                get {
                    return ((string)(this[this.tablet_Patient.NameColumn]));
                }
                set {
                    this[this.tablet_Patient.NameColumn] = value;
                }
            }
            
            public bool Sex {
                get {
                    return ((bool)(this[this.tablet_Patient.SexColumn]));
                }
                set {
                    this[this.tablet_Patient.SexColumn] = value;
                }
            }
            
            public System.DateTime BirthDate {
                get {
                    try {
                        return ((System.DateTime)(this[this.tablet_Patient.BirthDateColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值，因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tablet_Patient.BirthDateColumn] = value;
                }
            }
            
            public string Address {
                get {
                    try {
                        return ((string)(this[this.tablet_Patient.AddressColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值，因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tablet_Patient.AddressColumn] = value;
                }
            }
            
            public string Telephone {
                get {
                    try {
                        return ((string)(this[this.tablet_Patient.TelephoneColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值，因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tablet_Patient.TelephoneColumn] = value;
                }
            }
            
            public string Mobile {
                get {
                    try {
                        return ((string)(this[this.tablet_Patient.MobileColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值，因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tablet_Patient.MobileColumn] = value;
                }
            }
            
            public string CardNumber {
                get {
                    return ((string)(this[this.tablet_Patient.CardNumberColumn]));
                }
                set {
                    this[this.tablet_Patient.CardNumberColumn] = value;
                }
            }
            
            public int Age {
                get {
                    try {
                        return ((int)(this[this.tablet_Patient.AgeColumn]));
                    }
                    catch (InvalidCastException e) {
                        throw new StrongTypingException("无法获取值，因为它是 DBNull。", e);
                    }
                }
                set {
                    this[this.tablet_Patient.AgeColumn] = value;
                }
            }
            
            public bool IsBirthDateNull() {
                return this.IsNull(this.tablet_Patient.BirthDateColumn);
            }
            
            public void SetBirthDateNull() {
                this[this.tablet_Patient.BirthDateColumn] = System.Convert.DBNull;
            }
            
            public bool IsAddressNull() {
                return this.IsNull(this.tablet_Patient.AddressColumn);
            }
            
            public void SetAddressNull() {
                this[this.tablet_Patient.AddressColumn] = System.Convert.DBNull;
            }
            
            public bool IsTelephoneNull() {
                return this.IsNull(this.tablet_Patient.TelephoneColumn);
            }
            
            public void SetTelephoneNull() {
                this[this.tablet_Patient.TelephoneColumn] = System.Convert.DBNull;
            }
            
            public bool IsMobileNull() {
                return this.IsNull(this.tablet_Patient.MobileColumn);
            }
            
            public void SetMobileNull() {
                this[this.tablet_Patient.MobileColumn] = System.Convert.DBNull;
            }
            
            public bool IsAgeNull() {
                return this.IsNull(this.tablet_Patient.AgeColumn);
            }
            
            public void SetAgeNull() {
                this[this.tablet_Patient.AgeColumn] = System.Convert.DBNull;
            }
        }
        
        [System.Diagnostics.DebuggerStepThrough()]
        public class t_PatientRowChangeEvent : EventArgs {
            
            private t_PatientRow eventRow;
            
            private DataRowAction eventAction;
            
            public t_PatientRowChangeEvent(t_PatientRow row, DataRowAction action) {
                this.eventRow = row;
                this.eventAction = action;
            }
            
            public t_PatientRow Row {
                get {
                    return this.eventRow;
                }
            }
            
            public DataRowAction Action {
                get {
                    return this.eventAction;
                }
            }
        }
    }
}
