- •About the Authors
- •Contents at a Glance
- •Contents
- •Introduction
- •Goal of the Book
- •How to Use this Book
- •Introduction to the .NET Framework
- •Common Language Runtime (CLR)
- •Class Library
- •Assembly
- •Versioning
- •Exceptions
- •Threads
- •Delegates
- •Summary
- •Introduction to C#
- •Variables
- •Initializing Variables
- •Variable Modifiers
- •Variable Data Types
- •Types of Variables
- •Variable Scope
- •Types of Data Type Casting
- •Arrays
- •Strings
- •Initializing Strings
- •Working with Strings
- •Statements and Expressions
- •Types of Statements
- •Expressions
- •Summary
- •Classes
- •Declaring Classes
- •Inheritance
- •Constructors
- •Destructors
- •Methods
- •Declaring a Method
- •Calling a Method
- •Passing Parameters to Methods
- •Method Modifiers
- •Overloading a Method
- •Namespaces
- •Declaring Namespaces
- •Aliases
- •Structs
- •Enumerations
- •Interfaces
- •Writing, Compiling, and Executing
- •Writing a C# Program
- •Compiling a C# Program
- •Executing a C# Program
- •Summary
- •Arrays
- •Single-Dimensional Arrays
- •Multidimensional Arrays
- •Methods in Arrays
- •Collections
- •Creating Collections
- •Working with Collections
- •Indexers
- •Boxing and Unboxing
- •Preprocessor Directives
- •Summary
- •Attributes
- •Declaring Attributes
- •Attribute Class
- •Attribute Parameters
- •Default Attributes
- •Properties
- •Declaring Properties
- •Accessors
- •Types of Properties
- •Summary
- •Introduction to Threads
- •Creating Threads
- •Aborting Threads
- •Joining Threads
- •Suspending Threads
- •Making Threads Sleep
- •Thread States
- •Thread Priorities
- •Synchronization
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Primary and Foreign Keys
- •Referential Integrity
- •Normalization
- •Designing a Database
- •Low-Level Design
- •Construction
- •Integration and Testing
- •User Acceptance Testing
- •Implementation
- •Operations and Maintenance
- •Summary
- •Creating a New Project
- •Console Application
- •Windows Applications
- •Creating a Windows Application for the Customer Maintenance Project
- •Creating an Interface for Form1
- •Creating an Interface for WorkerForm
- •Creating an Interface for CustomerForm
- •Creating an Interface for ReportsForm
- •Creating an Interface for JobDetailsForm
- •Summary
- •Performing Validations
- •Identifying the Validation Mechanism
- •Using the ErrorProvider Control
- •Handling Exceptions
- •Using the try and catch Statements
- •Using the Debug and Trace Classes
- •Using the Debugging Features of Visual Studio .NET
- •Using the Task List
- •Summary
- •Creating Form1
- •Connecting WorkerForm to the Workers Table
- •Connecting CustomerForm to the tblCustomer Table
- •Connecting the JobDetails Form
- •to the tblJobDetails Table
- •Summary
- •Introduction to the Crystal Reports Designer Tool
- •Creating the Reports Form
- •Creating Crystal Reports
- •Creating the Windows Forms Viewer Control
- •Creating the Monthly Worker Report
- •Summary
- •Introduction to Deploying a Windows Application
- •Deployment Projects Available in Visual Studio .NET
- •Deployment Project Editors
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Populating the TreeView Control
- •Displaying Employee Codes in the TreeView Control
- •Event Handling
- •Displaying Employee Details in the ListView Control
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Adding the Programming Logic to the Application
- •Adding Code to the Form Load() Method
- •Adding Code to the OK Button
- •Adding Code to the Exit Button
- •Summary
- •The Created Event
- •Adding Code to the Created Event
- •Overview of XML
- •The XmlReader Class
- •The XmlWriter Class
- •Displaying Data in an XML Document
- •Displaying an Error Message in the Event Log
- •Displaying Event Entries from Event Viewer
- •Displaying Data from the Summary.xml Document in a Message Box
- •Summary
- •Airline Profile
- •Role of a Business Manager
- •Role of a Network Administrator
- •Role of a Line-of-Business Executive
- •Project Requirements
- •Creation and Deletion of User Accounts
- •Addition of Flight Details
- •Reservations
- •Cancellations
- •Query of Status
- •Confirmation of Tickets
- •Creation of Reports
- •Launch of Frequent Flier Programs
- •Summarizing the Tasks
- •Project Design
- •Database Design
- •Web Forms Design
- •Enabling Security with the Directory Structure
- •Summary
- •Getting Started with ASP.NET
- •Prerequisites for ASP.NET Applications
- •New Features in ASP.NET
- •Types of ASP.NET Applications
- •Exploring ASP.NET Web Applications
- •Introducing Web Forms
- •Web Form Server Controls
- •Configuring ASP.NET Applications
- •Configuring Security for ASP.NET Applications
- •Deploying ASP.NET Applications
- •Creating a Sample ASP.NET Application
- •Creating a New Project
- •Adding Controls to the Project
- •Coding the Application
- •Summary
- •Creating the Database Schema
- •Creating Database Tables
- •Managing Primary Keys and Relationships
- •Viewing the Database Schema
- •Designing Application Forms
- •Standardizing the Interface of the Application
- •Common Forms in the Application
- •Forms for Network Administrators
- •Forms for Business Managers
- •Forms for Line-of-Business Executives
- •Summary
- •The Default.aspx Form
- •The Logoff.aspx Form
- •The ManageUsers.aspx Form
- •The ManageDatabases.aspx Form
- •The ChangePassword.aspx Form
- •Restricting Access to Web Forms
- •The AddFl.aspx Form
- •The RequestID.aspx Form
- •The Reports.aspx Form
- •The FreqFl.aspx Form
- •Coding the Forms for LOB Executives
- •The CreateRes.aspx Form
- •The CancelRes.aspx Form
- •The QueryStat.aspx Form
- •The ConfirmRes.aspx Form
- •Summary
- •Designing the Form
- •The View New Flights Option
- •The View Ticket Status Option
- •The View Flight Status Option
- •The Confirm Reservation Option
- •Testing the Application
- •Summary
- •Locating Errors in Programs
- •Watch Window
- •Locals Window
- •Call Stack Window
- •Autos Window
- •Command Window
- •Testing the Application
- •Summary
- •Managing the Databases
- •Backing Up the SkyShark Airlines Databases
- •Exporting Data from Databases
- •Examining Database Logs
- •Scheduling Database Maintenance Tasks
- •Managing Internet Information Server
- •Configuring IIS Error Pages
- •Managing Web Server Log Files
- •Summary
- •Authentication Mechanisms
- •Securing a Web Site with IIS and ASP.NET
- •Configuring IIS Authentication
- •Configuring Authentication in ASP.NET
- •Securing SQL Server
- •Summary
- •Deployment Scenarios
- •Deployment Editors
- •Creating a Deployment Project
- •Adding the Output of SkySharkDeploy to the Deployment Project
- •Deploying the Project to a Web Server on Another Computer
- •Summary
- •Organization Profile
- •Project Requirements
- •Querying for Information about All Books
- •Querying for Information about Books Based on Criteria
- •Ordering a Book on the Web Site
- •Project Design
- •Database Design
- •Database Schema
- •Web Forms Design
- •Flowcharts for the Web Forms Modules
- •Summary
- •Introduction to ASP.NET Web Services
- •Web Service Architecture
- •Working of a Web Service
- •Technologies Used in Web Services
- •XML in a Web Service
- •WSDL in a Web Service
- •SOAP in a Web Service
- •UDDI in a Web Service
- •Web Services in the .NET Framework
- •The Default Code Generated for a Web Service
- •Testing the SampleWebService Web Service
- •Summary
- •Creating the SearchAll() Web Method
- •Creating the SrchISBN() Web Method
- •Creating the AcceptDetails() Web Method
- •Creating the GenerateOrder() Web Method
- •Testing the Web Service
- •Securing a Web Service
- •Summary
- •Creating the Web Forms for the Bookers Paradise Web Site
- •Adding Code to the Web Forms
- •Summary
- •Case Study
- •Project Life Cycle
- •Analyzing Requirements
- •High-Level Design
- •Low-Level Design
- •Summary
- •Overview of Mobile Applications
- •The Microsoft Mobile Internet Toolkit
- •Overview of WAP
- •The WAP Architecture
- •Overview of WML
- •The Mobile Web Form
- •The Design of the MobileTimeRetriever Application
- •Creating the Interface for the Mobile Web Forms
- •Adding Code to the MobileTimeRetriever Application
- •Summary
- •Creating the Forms Required for the MobileCallStatus Application
- •Creating the frmLogon Form
- •Creating the frmSelectOption Form
- •Creating the frmPending Form
- •Creating the frmUnattended Form
- •Adding Code to the Submit Button in the frmLogon Form
- •Adding Code to the Query Button in the frmSelectOption Form
- •Adding Code to the Mark checked as complete Button in the frmPending Form
- •Adding Code to the Back Button in the frmPending Form
- •Adding Code to the Accept checked call(s) Button in the frmUnattended Form
- •Adding Code to the Back Button in the frmUnattended Form
- •Summary
- •What Is COM?
- •Windows DNA
- •Microsoft Transaction Server (MTS)
- •.NET Interoperability
- •COM Interoperability
- •Messaging
- •Benefits of Message Queues
- •Limitations
- •Key Messaging Terms
- •Summary
- •Pointers
- •Declaring Pointers
- •Types of Code
- •Implementing Pointers
- •Using Pointers with Managed Code
- •Working with Pointers
- •Compiling Unsafe Code
- •Summary
- •Introduction to the Languages of Visual Studio .NET
- •Visual C# .NET
- •Visual Basic .NET
- •Visual C++ .NET
- •Overview of Visual Basic .NET
- •Abstraction
- •Encapsulation
- •Inheritance
- •Polymorphism
- •Components of Visual Basic .NET
- •Variables
- •Constants
- •Operators
- •Arrays
- •Collections
- •Procedures
- •Arguments
- •Functions
- •Adding Code to the Submit Button
- •Adding Code to the Exit Button
- •Summary
- •Introduction to Visual Studio .NET IDE
- •Menu Bar
- •Toolbars
- •Visual Studio .NET IDE Windows
- •Toolbox
- •The Task List Window
- •Managing Windows
- •Customizing Visual Studio .NET IDE
- •The Options Dialog Box
- •The Customize Dialog Box
- •Summary
- •Index
DATABASE INTERACTION USING ADO.NET |
Chapter 10 |
211 |
|
|
|
|
|
Update, Insert, and Delete are included in the WorkerForm class. This class also contains a default constructor with the name WorkerForm. The constructor is used to call the InitializeComponent() method, which is a private void method declared in the #region preprocessor directives. The InitializeComponent() method contains the statements used to initialize the controls and commands used in the code.
The WorkerForm class also includes a protected override of the Dispose() method, which is used to deallocate memory to the components that are no longer used by the program code. Finally, the code includes the Click event of the button controls that you added in the previous sections.
WorkerForm that you have created is now functional. To test the form, perform the following steps:
1.On the Debug menu, click on the Start option. Alternatively, you can press the F5 key to start debugging.
You can now click on each button to test the functionality.
2.Click on the Edit button.
The records in the tblWorker table are displayed.
3.Edit a record and click on the Save button.
A message box showing the text The Worker table is updated. is displayed.
Similarly, you can add or delete a record by clicking the Save button. You can also cancel the changes that you made to the records in the dataset by pressing the Cancel button and return to the main form by pressing the Exit button.
As you can see, the main form, Form1, is displayed when you click on the Exit button. Form1 contains the links to the WorkerForm, CustomerForm,JobDetails, and Reports forms. After creating the WorkerForm form, you can now add the functionality to the CustomerForm form.
Connecting CustomerForm to the tblCustomer Table
The CustomerForm is used to display the records from the tblCustomer table. To do this, you need to create the DataSet object for the customer records similar to the ones that you created for the worker records. The steps for creating a dataset
212 Project 1 CREATING A CUSTOMER MAINTENANCE PROJECT
are the same as discussed earlier, except for the SQL query that you create to select the records from the database.
To create a DataSet object, run the Data Adapter Configuration Wizard. The wizard creates the sqlDataAdapter and sqlConnection objects that you can use to connect to the tblCustomer table. However, in the Generate the SQL statements page of the Data Adapter Configuration Wizard, type the following SQL query that selects all the records from the tblCustomer table:
SELECT CarNo, Name, Address, Make
FROM tblCustomer
The previous SQL statement enables the sqlDataAdapter data adapter to connect to the tblCustomer table. However, a dataset is still not created. To enable Visual Studio .NET to create a dataset, perform the following steps:
1.Click anywhere in the form to make it active.
2.In the Data menu, select the Generate Dataset option. The Generate Dataset window is displayed.
3.From the Choose a dataset: group box, select the New radio button. In the text box adjacent to the New radio button, type the name of the
dataset as customerDataSet.
Make sure that the tblCustomer table is selected in the Choose which table(s) to add to the dataset text box.
4.Check the Add this dataset to the designer. check box.
5.Click on the OK button to close the Generate Dataset window.
A DataSet object with the name customerDataSet1 is added to the component tray at the bottom of the form. Figure 10-4 shows the Cus-
tomerForm form with sqlDataAdapter1, sqlConnection1, and customerDataSet1 added to the form.
However, generating a DataSet object does not display records in the form. To display records, you can either use a DataGrid control or bind the controls to the fields in the underlying table. In the previous section, you have seen that a DataGrid control displays all the records in the form of a grid. However, you can also display each field in a separate control by binding each control to a field in the table. The following section discusses binding controls to the fields in a table.
DATABASE INTERACTION USING ADO.NET |
Chapter 10 |
|
213 |
|
|
||||
|
|
|
|
|
FIGURE 10-4 CustomerForm in the design view
Binding TextBox Controls to Fields in the tblCustomer Table
In Chapter 7, you created the interface for the CustomerForm form. CustomerForm includes four text boxes that you can bind to the four column headings in the tblCustomer table. You can bind a control to a field in a table by changing the properties of the control. To do so, perform the following steps:
1.Click on a TextBox control to change its properties.
In the Properties window, change the properties of the TextBox controls.
2.Click on the plus (+) sign to the left of the DataBindings property. A list of properties is displayed.
3.Click on the Down Arrow button of the Text property. A list of datasets is displayed.
4.Expand the customerDataSet1 dataset by clicking the plus (+) sign.
5.Expand the list of tables that is displayed.
6.Select the CarNo option to bind the text box control to the CarNo field.
The TextBox control will now display the records in the CarNo field. Similarly, you can bind the rest of the text boxes to display records from
the Name, Address, and Make fields of the tblCustomer table.
214 Project 1 CREATING A CUSTOMER MAINTENANCE PROJECT
Even after binding the controls to the fields in the table, records are not automatically loaded in the CustomerForm at run time. To load the records, you need to call the Fill() method of the data adapter in the Click event of the Edit button. You can now write the code to load the records in the CustomerForm form at run time.
Adding Functionality to the Edit Button
To write the code for the Edit button, perform the following steps:
1.Double-click on the Edit button to display the code window.
2.Add the following code to the Click event of the Edit button.
private void btnEdit_Click(object sender, System.EventArgs e)
{
customerDataSet1.Clear(); sqlDataAdapter1.Fill(customerDataSet1);
}
The previous code calls the Clear() method to clear all the records in the dataset. Next, it calls the Fill() method to load the records from customerDataSet1 to CustomerForm. If you are using OleDbDataAdapter, you need to make the following changes to the Click event of the Edit button.
private void btnEdit_Click(object sender, System.EventArgs e)
{
customerDataSet1.Clear(); oleDbDataAdapter1.Fill(customerDataSet1);
}
When the user clicks on the Edit button, the records are displayed in the CustomerForm form. Figure 10-5 shows the CustomerForm form with the records displayed.
When the records are loaded, you can make changes to the records. In addition, you can add or delete a record. To save the changes that you make to the records, you need to write the code for the Save button. The following section discusses how to add code to the Save button.
DATABASE INTERACTION USING ADO.NET |
Chapter 10 |
215 |
|
|
|
|
|
FIGURE 10-5 CustomerForm with the records displayed
Adding Functionality to the Save Button
The Save button is used to save the changes that you make to the records in the tblCustomer table. To do so, you need to add the following code to the Click event of the Save button.
private void btnSave_Click(object sender, System.EventArgs e)
{
bool flag; flag=true;
if (textBox1.Text==””)
{
errCustForm.SetError(textBox1,”Please specify a valid car number.”); flag=false;
}
else
errCustForm.SetError(textBox1,””); if (textBox2.Text==””)
{
errCustForm.SetError(textBox2,”Please specify a valid name.”); flag=false;
}
else
errCustForm.SetError(textBox2,””); if (textBox3.Text==””)
{
errCustForm.SetError(textBox3,”Please specify a valid address.”); flag=false;
}
216 Project 1 CREATING A CUSTOMER MAINTENANCE PROJECT
else
errCustForm.SetError(textBox3,””); if (textBox4.Text==””)
{
errCustForm.SetError(textBox4,”Please specify a valid make.”); flag=false;
}
else
errCustForm.SetError(textBox4,””); if (flag==false)
return; else
{
sqlDataAdapter1.Update(customerDataSet1); MessageBox.Show(“Database updated!”);
}
}
Similar to the Cancel and Exit buttons in the WorkerForm, you need to add the functionality to the Cancel and Exit buttons in the CustomerForm form.
As you have seen, a DataGrid control displays all the records in a grid. However, if you are using individual controls to display the fields of a table, as in the case of CustomerForm, a single record is displayed at a time. To view all the records, you need to add Back and Next buttons that allow you to navigate through multiple records.
All the column headings in the tblCustomer table are mandatory. Therefore, before saving the changes that a user has made to the records to the underlying tblCustomer table, you first need to check whether the user has entered the data in all fields. To do so, the previous code declares a bool type variable flag and initializes it to true.
The code then tests if any of the fields are left blank. If a field is left blank, an error message is displayed adjacent to the corresponding field. For example, if the user does not enter a value for the Address field, an error message with the text “Please specify a valid address” is displayed.
Next, the value in the variable flag is changed to false.
Finally, the code uses an if statement to check the value of the variable flag. If the value of the variable flag is false, the return statement is used to retrieve the changes made by the user.
DATABASE INTERACTION USING ADO.NET |
Chapter 10 |
|
217 |
|
|
||||
|
|
|
|
|
Alternatively, if the value of the variable flag is true, the changes made by the user are replicated in the tblCustomer table and a message box confirming the same is displayed.
Adding Functionality to the Back Button
The Back button allows you to display the previous record of the tblCustomer table. To do so, add the following code to the Click event of the Back button.
private void btnBack_Click_1(object sender, System.EventArgs e)
{
btnBack.BindingContext[customerDataSet1, “tblCustomer”].Position -=1 ; CurrentPosition();
}
The previous code uses the Position property of the BindingContext object to find the position of the record. To navigate to the previous record, the value of the Position property is decremented by one. The code then calls the CurrentPosition() method that is used to display the position of the record in the txtDis-
playPosition text box.
NOTE
A BindingContext object is used to manage objects derived from the Control class. These controls include all Windows Forms controls, such as TextBox, GroupBox, ListBox, and so on. Each of these controls has an associated BindingContext object.The BindingContext class contains several methods that can be used to perform operations on these objects.
The CurrentPosition() method is a custom-defined private void method. You can add the code of the CurrentPosition() method to the public class CustomerForm.
private void CurrentPosition()
{
int currentPosition, ctr;
ctr = this.BindingContext[customerDataSet1, “tblCustomer”].Count; if(ctr == 0)
{
txtDisplayPosition.Text = “(There are no records in the Customer table.)”;
}
218 Project 1 CREATING A CUSTOMER MAINTENANCE PROJECT
else
{
currentPosition = this.BindingContext[customerDataSet1, “tblCustomer”].Position + 1;
txtDisplayPosition.Text = currentPosition.ToString() + “ of “ + ctr.ToString() ;
}
}
The previous code declares two integer variables, currentPosition and ctr. The |
||
|
|
Y |
Count property of the BindingContext object is used to find the number of records |
||
|
L |
|
in customerDataSet. The value returned by the Count property is stored in the vari- |
||
able ctr. |
F |
|
|
M |
|
The if construct is used to check the value of ctr. If the value of ctr is equal to |
zero, it implies that there are no records in the table. However, if the value of ctr is not equal to zero, the value of the current record is converted to a string by using the ToString() method and is then displayed in the txtDisplayPosition text box.
A E Similarly, you canTwrite the code for the Next button. The Next button enables
the user to navigate to the next record in the table. To make the Next button functional, add the following code to the Click event of the Next button:
private void btnNext_Click(object sender, System.EventArgs e)
{
btnNext.BindingContext[customerDataSet1, “tblCustomer”].Position +=1 ; CurrentPosition();
}
Figure 10-6 shows CustomerForm.
FIGURE 10-6 CustomerForm
Team-Fly®
DATABASE INTERACTION USING ADO.NET |
Chapter 10 |
219 |
|
|
|
|
|
After adding the functionality for all the controls, the complete code for the CustomerForm form is as follows:
using System;
using System.Drawing; using System.Collections;
using System.ComponentModel; using System.Windows.Forms;
namespace Customer_Maintenance_Project
{
public class CustomerForm : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnSave; private System.Windows.Forms.Button btnEdit; private System.Windows.Forms.Button btnCancel; private System.Windows.Forms.Label lblCarNo; private System.Windows.Forms.Label lblName; private System.Windows.Forms.Label lblAddress; private System.Windows.Forms.Label lblMake; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.TextBox textBox2; private System.Windows.Forms.TextBox textBox3; private System.Windows.Forms.TextBox textBox4;
private System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1; private System.Data.SqlClient.SqlCommand sqlSelectCommand1; private System.Data.SqlClient.SqlCommand sqlInsertCommand1; private System.Data.SqlClient.SqlCommand sqlUpdateCommand1; private System.Data.SqlClient.SqlCommand sqlDeleteCommand1; private System.Data.SqlClient.SqlConnection sqlConnection1;
private Customer_Maintenance_Project.CustomerDataSet customerDataSet1; private System.Windows.Forms.Button btnNext;
private System.Windows.Forms.Button Exit;
private System.Windows.Forms.TextBox txtDisplayPosition; private System.Windows.Forms.Button btnBack;
private System.ComponentModel.Container components = null; public CustomerForm()
220 Project 1 CREATING A CUSTOMER MAINTENANCE PROJECT
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void btnEdit_Click(object sender, System.EventArgs e)
{
customerDataSet1.Clear(); sqlDataAdapter1.Fill(customerDataSet1); CurrentPosition();
}
private void btnSave_Click(object sender, System.EventArgs e)
{
bool flag; flag=true;
if (textBox1.Text==””)
{
errCustForm.SetError(textBox1,”Please specify a valid car number.”); flag=false;
}
else errCustForm.SetError(textBox1,””);
if (textBox2.Text==””)
{
errCustForm.SetError(textBox2,”Please specify a valid name.”); flag=false;
}
DATABASE INTERACTION USING ADO.NET |
Chapter 10 |
221 |
|
|
|
|
|
else errCustForm.SetError(textBox2,””);
if (textBox3.Text==””)
{
errCustForm.SetError(textBox3,”Please specify a valid address.”); flag=false;
}
else errCustForm.SetError(textBox3,””);
if (textBox4.Text==””)
{
errCustForm.SetError(textBox4,”Please specify a valid make.”); flag=false;
}
else errCustForm.SetError(textBox4,””);
if (flag==false) return;
else
{
sqlDataAdapter1.Update(customerDataSet1); MessageBox.Show(“Database updated!”);
}
}
private void btnBack_Click(object sender, System.EventArgs e)
{
btnBack.BindingContext[customerDataSet1, “tblCustomer”].Position -=1 ; CurrentPosition();
}
private void btnNext_Click(object sender, System.EventArgs e)
{
btnNext.BindingContext[customerDataSet1, “tblCustomer”].Position +=1 ; CurrentPosition();
}
222 Project 1 CREATING A CUSTOMER MAINTENANCE PROJECT
private void CustomerForm_Load(object sender, System.EventArgs e)
{
errCustForm.SetError(textBox1,””); errCustForm.SetError(textBox2,””); errCustForm.SetError(textBox3,””); errCustForm.SetError(textBox4,””);
}
private void CurrentPosition()
{
int currentPosition, ctr;
ctr = this.BindingContext[customerDataSet1, “tblCustomer”].Count; if(ctr == 0)
{
txtDisplayPosition.Text = “(There are no records in the Customer table.)”;
}
else
{
currentPosition = this.BindingContext[customerDataSet1, “tblCustomer”].Position + 1;
txtDisplayPosition.Text = currentPosition.ToString() + “ of “ + ctr.ToString() ;
}
}
private void btnCancel_Click(object sender, System.EventArgs e)
{
}
private void Exit_Click(object sender, System.EventArgs e)
{
Form1 newForm1 = new Form1(); newForm1.Show();
this.Hide();
}