コード例 #1
0
        public void AddStudent(StudentViewModel student)
        {
            StudentsRow row = dataset.Students.NewStudentsRow();

            row.name    = student.Name;
            row.surname = student.Surname;
            if (student.Sex.HasValue)
            {
                row.sex = student.Sex.Value;
            }
            else
            {
                row.SetsexNull();
            }

            if (student.Birthday.HasValue)
            {
                row.birthday = student.Birthday.Value;
            }
            else
            {
                row.SetbirthdayNull();
            }

            dataset.Students.AddStudentsRow(row);
            student.StudentID = row.studentId;
        }
コード例 #2
0
        public static void DisconnectedArchitecture_9()
        {
            DisconnectedDataAccess <StudentsDataTable> dbAccess = new DisconnectedDataAccess <StudentsDataTable>();

            initSelectCommand(dbAccess);
            initUpdateCommand(dbAccess);
            initInsertCommand(dbAccess);
            initDeleteCommand(dbAccess);

            StudentsDataTable table = new StudentsDataTable();

            dbAccess.Fill(table);

            Console.WriteLine("All datatable data:");
            printRows(table.Rows);

            // Change row in DataTable
            StudentsRow row = (StudentsRow)table.Rows[0];

            row.first_name = "Mickey";

            Console.WriteLine("All datatable data - after datarow change:");
            printRows(table.Rows);

            // Compare to data in db
            Console.WriteLine("All db data - before update:");
            ConnectedExamples.BasicReaderQuery_1();

            dbAccess.Update(table);

            // Compare to data in db after update
            Console.WriteLine("All db data - after update:");
            ConnectedExamples.BasicReaderQuery_1();

            // Do not forget to dispose!
            dbAccess.Dispose();
        }
コード例 #3
0
 public StudentsRowChangeEvent(StudentsRow row, global::System.Data.DataRowAction action)
 {
     this.eventRow    = row;
     this.eventAction = action;
 }