public override global::System.Data.DataTable Clone() { DepartmentsDataTable cln = ((DepartmentsDataTable)(base.Clone())); cln.InitVars(); return(cln); }
private void InitClass() { this.DataSetName = "DepartmentsDataSet"; this.Prefix = ""; this.Namespace = "http://schemas.microsoft.com/office/project/server/webservices/DepartmentsDataSet" + "/"; this.EnforceConstraints = false; this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.IncludeSchema; this.tableDepartments = new DepartmentsDataTable(); base.Tables.Add(this.tableDepartments); }
internal void InitVars(bool initTable) { this.tableDepartments = ((DepartmentsDataTable)(base.Tables["Departments"])); if ((initTable == true)) { if ((this.tableDepartments != null)) { this.tableDepartments.InitVars(); } } }
// create the data tables from lists set up with initial data // we won't use these lists or the classes after the data tables are created private void CreateRegistrationDataTables() { // set the shorter table names registrationTable = studentRegistrationDataSet.Registration; coursesTable = studentRegistrationDataSet.Courses; studentsTable = studentRegistrationDataSet.Students; departmentsTable = studentRegistrationDataSet.Departments; // seed all the table data // students data List <Student> students = new List <Student>() { new Student { StudentFirstName = "Svetlana", StudentLastName = "Rostov", StudentMajor = "CSIS" }, new Student { StudentFirstName = "Claire", StudentLastName = "Bloome", StudentMajor = "ACCT" }, new Student { StudentFirstName = "Sven", StudentLastName = "Baertschi", StudentMajor = "MKTG" }, new Student { StudentFirstName = "Cesar", StudentLastName = "Chavez", StudentMajor = "FINC" }, new Student { StudentFirstName = "Debra", StudentLastName = "Manning", StudentMajor = "CSIS" }, new Student { StudentFirstName = "Fadi", StudentLastName = "Hadari", StudentMajor = "ACCT" }, new Student { StudentFirstName = "Hanyeng", StudentLastName = "Fen", StudentMajor = "MKTG" }, new Student { StudentFirstName = "Hugo", StudentLastName = "Victor", StudentMajor = "FINC" }, new Student { StudentFirstName = "Lance", StudentLastName = "Armstrong", StudentMajor = "MKTG" }, new Student { StudentFirstName = "Terry", StudentLastName = "Matthews", StudentMajor = "CSIS" }, new Student { StudentFirstName = "Eugene", StudentLastName = "Fei", StudentMajor = "FINC" }, new Student { StudentFirstName = "Michael", StudentLastName = "Thorson", StudentMajor = "CSIS" }, new Student { StudentFirstName = "Simon", StudentLastName = "Li", StudentMajor = "CSIS" }, }; // departments data List <Department> departments = new List <Department>() { new Department { DepartmentId = "CSIS", DepartmentName = "Computing Studies" }, new Department { DepartmentId = "ACCT", DepartmentName = "Accounting" }, new Department { DepartmentId = "MKTG", DepartmentName = "Marketing" }, new Department { DepartmentId = "FINC", DepartmentName = "Finance" }, }; // courses data List <Course> courses = new List <Course>() { new Course { CourseId = 101, CourseDepartmentId = "CSIS", CourseName = "Programming I" }, new Course { CourseId = 102, CourseDepartmentId = "CSIS", CourseName = "Programming II" }, new Course { CourseId = 101, CourseDepartmentId = "ACCT", CourseName = "Accounting I" }, new Course { CourseId = 102, CourseDepartmentId = "ACCT", CourseName = "Accounting II" }, new Course { CourseId = 101, CourseDepartmentId = "FINC", CourseName = "Corporate Finance" }, }; // registration data - note consists of a registration object, and a student id. // if the students table is set up with a different autoincrement that starting at 1, this won't work List <Registration> registrations = new List <Registration>() { new Registration { RegisteredCourse = courses[0], StudentId = 1 }, new Registration { RegisteredCourse = courses[0], StudentId = 2 }, new Registration { RegisteredCourse = courses[1], StudentId = 1 }, new Registration { RegisteredCourse = courses[4], StudentId = 1 }, }; // for each table, Fill the dataset table with data from the database (should be zero). // this also instantiates sql commands registrationTableAdapter.Fill(registrationTable); coursesTableAdapter.Fill(coursesTable); studentsTableAdapter.Fill(studentsTable); departmentsTableAdapter.Fill(departmentsTable); // make sure student id starts at 1 ReseedTable(studentsTableAdapter.Connection, studentsTable.TableName, studentsTable.Count()); // remove any data that is in the data tables. // assumes that the tables have been set up properly using the sql project in this solution DeleteData(registrationTableAdapter.Adapter, registrationTable); DeleteData(coursesTableAdapter.Adapter, coursesTable); DeleteData(studentsTableAdapter.Adapter, studentsTable); DeleteData(departmentsTableAdapter.Adapter, departmentsTable); // for each object in the lists above that corresponds to the data table, insert a record // then Update, and re Fill the data table // add Students using adapter insert, then update and fill // then bind the datasource to the table // this is already done for you foreach (Student s in students) { // an alternative to using the Insert method //StudentRegistrationDataSet.StudentsRow row = studentRegistrationDataSet.Students.NewStudentsRow(); //row.StudentFirstName = s.StudentFirstName; //row.StudentLastName = s.StudentLastName; //row.StudentMajor = s.StudentMajor; //studentRegistrationDataSet.Students.AddStudentsRow(row); studentsTableAdapter.Insert(s.StudentFirstName, s.StudentLastName, s.StudentMajor); } studentsTableAdapter.Update(studentsTable); studentsTableAdapter.Fill(studentsTable); dataGridViewStudents.DataSource = studentsTable; // add Departments, then update and fill, and bind datasource // your code here foreach (Department d in departments) { departmentsTableAdapter.Insert(d.DepartmentId, d.DepartmentName); } departmentsTableAdapter.Update(departmentsTable); departmentsTableAdapter.Fill(departmentsTable); dataGridViewDepartments.DataSource = departmentsTable; // add Courses, then update and fill, and bind datasource // your code here foreach (Course c in courses) { coursesTableAdapter.Insert(c.CourseId, c.CourseDepartmentId, c.CourseName); } coursesTableAdapter.Update(coursesTable); coursesTableAdapter.Fill(coursesTable); dataGridViewCourses.DataSource = coursesTable; // sort the courses in gridview // hint: use the Sort() method on column 0, ascending // your code here dataGridViewCourses.Sort(dataGridViewCourses.Columns[0], ListSortDirection.Ascending); // add Registration last. add the registrations then update and fill again // finally, set DataSource to the table foreach (Registration r in registrations) { registrationTableAdapter.Insert(r.StudentId, r.RegisteredCourse.CourseId, r.RegisteredCourse.CourseDepartmentId); } registrationTableAdapter.Update(registrationTable); registrationTableAdapter.Fill(registrationTable); dataGridViewRegistration.DataSource = registrationTable; //registrationTableAdapter.Fill(registrationTable); // instantiates sql commands // your code here }
internal DepartmentsRow(global::System.Data.DataRowBuilder rb) : base(rb) { this.tableDepartments = ((DepartmentsDataTable)(this.Table)); }
private void InitClass() { this.DataSetName = "CallButlerDataset"; this.Prefix = ""; this.Namespace = "http://www.worksoutsoft.com/Schemas/CallButlerDataset.xsd"; this.EnforceConstraints = true; this.SchemaSerializationMode = global::System.Data.SchemaSerializationMode.ExcludeSchema; this.tableGreetings = new GreetingsDataTable(); base.Tables.Add(this.tableGreetings); this.tableLocalizedGreetings = new LocalizedGreetingsDataTable(); base.Tables.Add(this.tableLocalizedGreetings); this.tableCallHistory = new CallHistoryDataTable(); base.Tables.Add(this.tableCallHistory); this.tableDepartments = new DepartmentsDataTable(); base.Tables.Add(this.tableDepartments); this.tableExtensions = new ExtensionsDataTable(); base.Tables.Add(this.tableExtensions); this.tableExtensionContactNumbers = new ExtensionContactNumbersDataTable(); base.Tables.Add(this.tableExtensionContactNumbers); this.tableVoicemails = new VoicemailsDataTable(); base.Tables.Add(this.tableVoicemails); this.tablePersonalizedGreetings = new PersonalizedGreetingsDataTable(); base.Tables.Add(this.tablePersonalizedGreetings); this.tableProviders = new ProvidersDataTable(); base.Tables.Add(this.tableProviders); this.tableScriptSchedules = new ScriptSchedulesDataTable(); base.Tables.Add(this.tableScriptSchedules); global::System.Data.ForeignKeyConstraint fkc; fkc = new global::System.Data.ForeignKeyConstraint("FK_Greetings_LocalizedGreetings", new global::System.Data.DataColumn[] { this.tableGreetings.GreetingIDColumn}, new global::System.Data.DataColumn[] { this.tableLocalizedGreetings.GreetingIDColumn}); this.tableLocalizedGreetings.Constraints.Add(fkc); fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None; fkc.DeleteRule = global::System.Data.Rule.Cascade; fkc.UpdateRule = global::System.Data.Rule.Cascade; fkc = new global::System.Data.ForeignKeyConstraint("FK_Extensions_ExtensionContactNumbers", new global::System.Data.DataColumn[] { this.tableExtensions.ExtensionIDColumn}, new global::System.Data.DataColumn[] { this.tableExtensionContactNumbers.ExtensionIDColumn}); this.tableExtensionContactNumbers.Constraints.Add(fkc); fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None; fkc.DeleteRule = global::System.Data.Rule.Cascade; fkc.UpdateRule = global::System.Data.Rule.Cascade; fkc = new global::System.Data.ForeignKeyConstraint("FK_Extensions_Voicemails", new global::System.Data.DataColumn[] { this.tableExtensions.ExtensionIDColumn}, new global::System.Data.DataColumn[] { this.tableVoicemails.ExtensionIDColumn}); this.tableVoicemails.Constraints.Add(fkc); fkc.AcceptRejectRule = global::System.Data.AcceptRejectRule.None; fkc.DeleteRule = global::System.Data.Rule.Cascade; fkc.UpdateRule = global::System.Data.Rule.Cascade; this.relationFK_Greetings_LocalizedGreetings = new global::System.Data.DataRelation("FK_Greetings_LocalizedGreetings", new global::System.Data.DataColumn[] { this.tableGreetings.GreetingIDColumn}, new global::System.Data.DataColumn[] { this.tableLocalizedGreetings.GreetingIDColumn}, false); this.relationFK_Greetings_LocalizedGreetings.Nested = true; this.Relations.Add(this.relationFK_Greetings_LocalizedGreetings); this.relationFK_Extensions_ExtensionContactNumbers = new global::System.Data.DataRelation("FK_Extensions_ExtensionContactNumbers", new global::System.Data.DataColumn[] { this.tableExtensions.ExtensionIDColumn}, new global::System.Data.DataColumn[] { this.tableExtensionContactNumbers.ExtensionIDColumn}, false); this.relationFK_Extensions_ExtensionContactNumbers.Nested = true; this.Relations.Add(this.relationFK_Extensions_ExtensionContactNumbers); this.relationFK_Extensions_Voicemails = new global::System.Data.DataRelation("FK_Extensions_Voicemails", new global::System.Data.DataColumn[] { this.tableExtensions.ExtensionIDColumn}, new global::System.Data.DataColumn[] { this.tableVoicemails.ExtensionIDColumn}, false); this.relationFK_Extensions_Voicemails.Nested = true; this.Relations.Add(this.relationFK_Extensions_Voicemails); }
internal void InitVars(bool initTable) { this.tableGreetings = ((GreetingsDataTable)(base.Tables["Greetings"])); if ((initTable == true)) { if ((this.tableGreetings != null)) { this.tableGreetings.InitVars(); } } this.tableLocalizedGreetings = ((LocalizedGreetingsDataTable)(base.Tables["LocalizedGreetings"])); if ((initTable == true)) { if ((this.tableLocalizedGreetings != null)) { this.tableLocalizedGreetings.InitVars(); } } this.tableCallHistory = ((CallHistoryDataTable)(base.Tables["CallHistory"])); if ((initTable == true)) { if ((this.tableCallHistory != null)) { this.tableCallHistory.InitVars(); } } this.tableDepartments = ((DepartmentsDataTable)(base.Tables["Departments"])); if ((initTable == true)) { if ((this.tableDepartments != null)) { this.tableDepartments.InitVars(); } } this.tableExtensions = ((ExtensionsDataTable)(base.Tables["Extensions"])); if ((initTable == true)) { if ((this.tableExtensions != null)) { this.tableExtensions.InitVars(); } } this.tableExtensionContactNumbers = ((ExtensionContactNumbersDataTable)(base.Tables["ExtensionContactNumbers"])); if ((initTable == true)) { if ((this.tableExtensionContactNumbers != null)) { this.tableExtensionContactNumbers.InitVars(); } } this.tableVoicemails = ((VoicemailsDataTable)(base.Tables["Voicemails"])); if ((initTable == true)) { if ((this.tableVoicemails != null)) { this.tableVoicemails.InitVars(); } } this.tablePersonalizedGreetings = ((PersonalizedGreetingsDataTable)(base.Tables["PersonalizedGreetings"])); if ((initTable == true)) { if ((this.tablePersonalizedGreetings != null)) { this.tablePersonalizedGreetings.InitVars(); } } this.tableProviders = ((ProvidersDataTable)(base.Tables["Providers"])); if ((initTable == true)) { if ((this.tableProviders != null)) { this.tableProviders.InitVars(); } } this.tableScriptSchedules = ((ScriptSchedulesDataTable)(base.Tables["ScriptSchedules"])); if ((initTable == true)) { if ((this.tableScriptSchedules != null)) { this.tableScriptSchedules.InitVars(); } } this.relationFK_Greetings_LocalizedGreetings = this.Relations["FK_Greetings_LocalizedGreetings"]; this.relationFK_Extensions_ExtensionContactNumbers = this.Relations["FK_Extensions_ExtensionContactNumbers"]; this.relationFK_Extensions_Voicemails = this.Relations["FK_Extensions_Voicemails"]; }