smartDBforms.NET LIVE DEMO by Adillis
 
Employees Form
Displays and edits the Employees database table. Image upload, large text, foreign-key columns,date editing popup calendar. Demonstrates the Clone command button. Localization in Spanish.

A drop-down list at the top is prefilled with all available employees. The SmartDBView form displays the details for the currently selected employee. Initially the data is displayed in ReadOnly mode, but the user can select the “Edit” or “New” buttons to switch between other form modes.

The Photo column is of type 'image' which is represented as byte[] in ADO.NET. A FileUpload server control is automatically generated for this column when the form is displayed in edit mode.

The ReportsTo column is a foreign-key self referencing the same table – Employees.

The BirthDate and HireDate columns are of type datetime. In edit mode they a javascript popup calendar allows the user to select the date. A special database trigger is defined for BirthDate that checks that the entered values are in the past. This is validated by ValidateCustomEvent sent by the BirthDate SmartDBControl.

Demonstrates the Clone/Copy command button. The Clone buttons allows creating a new database record by using the data of the current database record.

Demonstrates localization in Spanish. From the top drop-down list select the desired culture and the page will automatically be translated. Along with the translation, the values are formatted according to the rules of the selected culture. You will notice that the calendar rearranges the days of the week and also translates them accordingly.


CREATE TABLE [dbo].[Employees](
	[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
	[LastName] [nvarchar](20) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[FirstName] [nvarchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
	[Title] [nvarchar](30) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[TitleOfCourtesy] [nvarchar](25) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[BirthDate] [datetime] NULL,
	[HireDate] [datetime] NULL,
	[Address] [nvarchar](60) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[City] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Region] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[PostalCode] [nvarchar](10) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Country] [nvarchar](15) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[HomePhone] [nvarchar](24) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Extension] [nvarchar](4) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[Photo] [image] NULL,
	[Notes] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
	[ReportsTo] [int] NULL,
	[PhotoPath] [nvarchar](255) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
 CONSTRAINT [PK_Employees] PRIMARY KEY CLUSTERED 
(
	[EmployeeID] ASC
)WITH (PAD_INDEX  = OFF, IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]

GO
ALTER TABLE [dbo].[Employees]  WITH NOCHECK ADD  CONSTRAINT [FK_Employees_Employees]
                               FOREIGN KEY([ReportsTo])
REFERENCES [dbo].[Employees] ([EmployeeID])
GO
ALTER TABLE [dbo].[Employees] CHECK CONSTRAINT [FK_Employees_Employees]
GO
ALTER TABLE [dbo].[Employees]  WITH NOCHECK ADD  CONSTRAINT [CK_Birthdate] 
                                CHECK  (([BirthDate] < getdate()))
GO
ALTER TABLE [dbo].[Employees] CHECK CONSTRAINT [CK_Birthdate]
   Copyright © 2006-2010 Adillis   |   smartDBforms.NET Forum   |    Send feedback