#Region
"AddNew Methods"
' Note: Exception handling code has
not yet been added to the AddNewMethods.
' Ajax Customer AddNew Method
Public
Function AjaxCustomerAddNew()
As AjaxDataSet.CustomerRow
' Declare a variable named
newAjaxCustomerRow of type CustomerRow.
Dim newAjaxCustomerRow
As
DataService.AjaxDataSet.CustomerRow
' Call the Ajax CustomerTable
class's NewCustomerRow method through the DAL.
' Assign the new CustomerRow that is
returned to the newAjaxCustomerRow variable.
newAjaxCustomerRow = AjaxDataService.Customer.NewCustomerRow
' ***** Set the value of the columns
in the new CustomerRow. ******
' Customer table's primary key is
CustomerID, a GUID in string form.
' Create a new GUID.
Dim customerId =
New
Guid(System.Guid.NewGuid.ToString)
' Assign the GUID, as a string, to
the CustomerID column of the newAjaxCustomerRow.
newAjaxCustomerRow.CustomerId = customerId.ToString
' Default the value in the Customer
Name colum to 'New Customer'.
newAjaxCustomerRow.Name = "New
Customer"
' .... the value in other columns
could be set here but for this demo, are not.
' ***** Add the new CustomerRow to
the CustomerDataTable ******
AjaxDataService.Customer.AddCustomerRow(newAjaxCustomerRow)
' Return the new row in case the
calling code needs it.
Return newAjaxCustomerRow
End
Function
' Ajax Orders AddNew Method
Public
Function AjaxOrdersAddNew()
As AjaxDataSet.OrdersRow
' Declare a variable named
newAjaxOrdersRow of type OrdersRow.
Dim newAjaxOrdersRow
As
DataService.AjaxDataSet.OrdersRow
' Call the Ajax CustomerTable
class's NewOrdersRow method through the DAL.
' Assign the new OrdersRow that is
returned to the newAjaxOrdersRow variable.
newAjaxOrdersRow
= AjaxDataService.Orders.NewOrdersRow
' ***** Set the value of the columns
in the new OrdersRow. ******
' Order table's primary key is
OrderID, a GUID in string form.
' Create a new GUID.
Dim orderId =
New
Guid(System.Guid.NewGuid.ToString)
' Assign the GUID, as a string, to
the OrderID column of the newAjaxOrdersRow.
newAjaxOrdersRow.CustomerId = orderId.ToString
' .... the value in other columns
could be set here but for this demo, are not.
' ***** Add the new OrdersRow to the
OrdersDataTable ******
AjaxDataService.Orders.AddOrdersRow(newAjaxOrdersRow)
' Return the new row in case the
calling code needs it.
Return newAjaxOrdersRow
End
Function
' Northwind Employees AddNew Method
Public
Function
NorthwindEmployeesAddNew() As
NorthwindDataSet.EmployeesRow
Dim newNorthwindEmployeesRow
As
NorthwindDataSet.EmployeesRow
newNorthwindEmployeesRow =
NorthwindDataService.Employees.NewEmployeesRow
' The primary key in Employees table
is AutoNumber; it will be assigned
' by the Northwind database when the
row table is updated.
' Default the new Employee's last
name to 'New'.
newNorthwindEmployeesRow.LastName =
"New"
' .... the value in other columns
could be set here but for this demo, are not.
NorthwindDataService.Employees.AddEmployeesRow(newNorthwindEmployeesRow)
Return
newNorthwindEmployeesRow
End
Function
' Northwind Products AddNew Method
Public
Function
NorthwindProductsAddNew() As
NorthwindDataSet.ProductsRow
Dim newNorthwindProductsRow
As
NorthwindDataSet.ProductsRow
newNorthwindProductsRow =
NorthwindDataService.Products.NewProductsRow
' The primary key in Employees table
is AutoNumber; it will be assigned
' by the Northwind database when the
row table is updated.
' Default the new Product's product
name to 'New'.
newNorthwindProductsRow.ProductName =
"New"
' .... the value in other columns
could be set here but for this demo, are not.
NorthwindDataService.Products.AddProductsRow(newNorthwindProductsRow)
Return newNorthwindProductsRow
End
Function
#End
Region
#Region
"Delete Methods"
' NOTE: Exception handling code has
not yet been added to the Delete methods.
' Ajax Customer Delete method.
Public
Sub AjaxCustomerDelete(ByVal
theRow As
AjaxDataSet.CustomerRow)
theRow.Delete()
End
Sub
' Ajax Orders Delete Method
Public
Sub AjaxOrdersDelete(ByVal
theRow As
AjaxDataSet.CustomerRow)
theRow.Delete()
End
Sub
' Northwind Employees Delete Method
Public
Sub NorthwindEmployeesDelete(ByVal
theRow As
AjaxDataSet.CustomerRow)
theRow.Delete()
End
Sub
' Northwind Products Delete Method
Public
Sub NorthwindProductsDelete(ByVal
theRow As
AjaxDataSet.CustomerRow)
theRow.Delete()
End
Sub
#End
Region