Data Access has been discontinued. Please refer to this page for more information.

Preparing the Windows Forms Project

The WinForms project will have two different forms in it - one to display, filter and delete cars in the database, the other to add new cars or edit existing ones. In this step you will create and setup a new Windows Forms project and add the required RadControls controls to the forms.

Preparing the project:

  1. Add to your solution a new Windows Forms Application and name it SofiaCarRental.Forms.
  2. Integrate the Telerik.DataAccess.Core NuGet package with the SofiaCarRental.Forms project.
  3. Add a reference to SofiaCarRental.Model in the SofiaCarRental.Forms project.
  4. Copy the App.config file from the model SofiaCarRental.Model to the WinForms project SofiaCarRental.Forms.

  5. Remove the default form Form1 from the project.

  6. Add a new RadForm named MainForm to the project.
  7. Add a new RadForm named AddEditForm to the project.
  8. Set MainForm to be the startup form for the project:

    • For C#, go to Program.cs, in the Main() method, initialize MainForm in the call to Application.Run():

      [STAThread]
      static void Main()
      {
          Application.EnableVisualStyles();
          Application.SetCompatibleTextRenderingDefault(false);
          Application.Run(new MainForm());
      } 
      
    • For VB.NET, open the properties window of the project, in the Application select MainForm from the Startup form dropdown list.

Defining the user interface of MainForm

  1. Add two RadLabels to the form. From the properties window, Change the Text of one of the labels to Car maker:. For the other label change the Name property to lblResultCount.
  2. Add a RadTextBoxControl to the form. In the Properties window name it rtbCarMaker.
  3. Add a RadButton to the form. Change its Name property to rbtnFilterByMaker and its Text property to Filter.
  4. Add a RadButton to the form. Change its Name property to rbtnResetFilter and its Text property to Reset.
  5. Add a RadButton to the form. Change its Name property to rbtnAddCar and its Text property to Add.
  6. Add a RadButton to the form. Change its Name property to rbtnEditCar and its Text property to Edit.
  7. Add a RadButton to the form. Change its Name property to rbtnDeleteCar and its Text property to Delete.
  8. Add a RadButton to the form. Change its Name property to rbtnRefresh and its Text property to Refresh.

Defining the user interface of AddEditForm:

  1. Add a RadLabel to the form. Change its Text property to Tag number:. Next to the label, add a RadTextBoxControl. Change its Name property to rtbTagNumber.
  2. Add a RadLabel to the form. Change its Text property to Maker:. Next to the label, add a RadTextBoxControl. Change its Name property to rtbMaker.
  3. Add a RadLabel to the form. Change its Text property to Model:. Next to the label, add a RadTextBoxControl. Change its Name property to rtbModel.
  4. Add a RadLabel to the form. Change its Text property to Year:. Next to the label, add a RadSpinEditor. Change its Name property to rseCarYear. Set its DecimalPlaces property to 0 and its Increment property to 1. Set the Maximum and Minimum properties to 1900 and 2100 respectively.
  5. Add a RadLabel to the form. Change its Text property to Mp3 player:. Next to the label, add a RadCheckBox. Change its Name property to rcbMp3 and clear its Text property.
  6. Add a RadLabel to the form. Change its Text property to DVD player:. Next to the label, add a RadCheckBox. Change its Name property to rcbDvd and clear its Text property.
  7. Add a RadLabel to the form. Change its Text property to Air conditioner:. Next to the label, add a RadCheckBox. Change its Name property to rcbAirCond and clear its Text property.
  8. Add a RadLabel to the form. Change its Text property to ABS:. Next to the label, add a RadCheckBox. Change its Name property to rcbAbs and clear its Text property.
  9. Add a RadLabel to the form. Change its Text property to ASR:. Next to the label, add a RadCheckBox. Change its Name property to rcbAsr and clear its Text property.
  10. Add a RadLabel to the form. Change its Text property to Navigation:. Next to the label, add a RadCheckBox. Change its Name property to rcbNavigation and clear its Text property.
  11. Add a RadLabel to the form. Change its Text property to Available:. Next to the label, add a RadCheckBox. Change its Name property to rcbAvailable and clear its Text property.
  12. Add a RadLabel to the form. Change its Text property to Latitude:. Next to the label , add a RadSpinEditor. Change its Name property to rseLatitude, set its DecimalPlaces property to 6, set its Increment property to 0.000001 and finally, set the Maximum and Minimum properties to 100 and -100 respectively.
  13. Add a RadLabel to the form. Change its Text property to Longitude:. Next to the label , add a RadSpinEditor. Change its Name property to rseLongitude, set its DecimalPlaces property to 6, set its Increment property to 0.000001 and finally, set the Maximum and Minimum properties to 100 and -100 respectively.
  14. Add a RadButton to the form. Set its Name property to rbtnSave and its Text property to Save. Set the DialogResult property to OK.
  15. Add a RadButton to the form. Set its Name property to rbtnCancel and its Text property to Cancel. Set the DialogResult property to Cancel.

Next Step: Retrieving Cars from the Database