Home

Assistance With Data Entry on a Data Set

   

The Unique Value of a Column

 

Introduction

When performing data entry, there are various ways you can either assist the user or impose some behaviors on your application. You can:

  • Configure some columns of a table to accept only some types of value and reject others
  • You can create a scenario that would make sure that each value under a column is unique
  • You can create an expression that would specify the value of a column rather than the user entering it
  • Using the data grid view or some other controls of the Toolbox, you can present a list of values to the user who would only select from that list instead of typing a value 

All these functionalities are already available, either in the classes of the data set system or built-in the available Windows controls.

Practical Learning: Assisting With Data Entry

  1. Start Microsoft Visual Studio and create a Windows Application named WattsALoan1
  2. To create a new form, in the Solution Explorer, right-click WattsALoan1 -> Add -> Windows Forms...
  3. Set the Name to LoansAllocations and click Add
  4. From the Data section of the Toolbox, click DataSet and click the form
  5. Select the Untyped Dataset radio button and click OK
  6. In the Properties window, change the following characteristics:
    DataSetName: dsLoansAllocations
    (Name): LoansAllocations
  7. Click Tables and click its ellipsis button
  8. To create a new table, click Add and change the properties as follows:
    TableName: Loan
    (Name): tblLoan
  9. Click Columns and click its ellipsis button
  10. Click Add 10 times and change the properties as follows:
     
    ColumnName (Name)
    DateAllocated colDateAllocated
    LoanNumber colLoanNumber
    PreparedBy colPreparedBy
    PreparedFor colPreparedFor
    Principal colPrincipal
    InterestRate colInterestRate
    Periods colPeriods
    InterestEarned colInterestEarned
    FutureValue colFutureValue
    MonthlyPayment colMonthlyPayment

Controlling the Unique Value

During data entry, the user is expected to enter various values under each column and each value would belong to a particular record. As a result, it is not unusual to have the same value belonging to different records. For example, it is not surprising to have two employees holding the same first or last name, just as it is not unusual to have two customers living in the same city. On the hand, there are values that should be unique among the records. For example, two employees should not have the same employee number and two customer orders from two different customers should not have the same receipt number. In these cases, you would want each record to hold a different value under the same column. This is referred to as a unique value.

To support unique values, the DataColumn class is equipped with a Boolean property named Unique. The default value of this property is false, which means various records can have the same values for a column.

To visually specify that a column would require (or not require) unique values, in the Members list of the Columns Collection Editor, click the name of the column and, in the Properties list, (accept or) change the value of the Unique field. To programmatically control the uniqueness of values, assign the desired Boolean value to the Unique property of the column.

Practical Learning: Controlling the Uniqueness of a Column

  1. In the Members list, click LoanNumber
  2. In the Properties list, double-click Unique to change its value to True

Controlling the Type of Value of a Column

 

The Data Type of a Column

If you create an application that allows the user to enter some values, you would wish the user enter the right type of data under each column. To assist you with this, the DataColumn class allows you to specify an appropriate or desired data type for each column. The data type of a column allows it to accept or reject an inappropriate value. Although we saw that the name was the most important aspect of a column, in reality, a data type is also required.

To specify the data type of a column, if you are visually creating the table, in the Columns Collection Editor, under Members, create or select the name of a column. In the Properties list, click the arrow of the DataType field and select from the list:

Columns Collection Editor

To supports data types for a column, the DataColumn class relies on the following .NET Framework structures: Boolean, Byte, Char, DateTime, Decimal, Double, Int16, Int32, Int64, SByte, Single, String, TimeSpan, UInt16, UInt32, and UInt64. The DataColumn class can also support an array of Byte values, as in Byte[], for a column.

When creating a new column, if you do not specify its data type, it is assumed to be a string and the string data type is automatically applied to it.

To programmatically specify the data type of a column, you have two main alternatives. When declaring a column, to specify its data type, you can initialize the DataColumn variable using the third constructor of the class. Its syntax is:

public DataColumn(string columnName, Type dataType);

To specify a column's data type, select one from the Type class of the System namespace by calling the Type.GetType() method. The GetType() method is overloaded with three versions. The first version has the following syntax:

public static Type GetType(string typeName);

This method expects as argument a valid data type defined in the .NET Framework. The data type must be retrieved from the Type class of the System namespace. The name of the data type must be qualified with a period operator. Here is an example:

using System;
using System.Data;
using System.Drawing;
using System.Windows.Forms;

public class Exercise : Form
{
    DataSet dsRedOakHighSchool;
    DataTable tblRegistration;
    DataColumn colStudentNumber;

    public Exercise()
    {
        InitializeComponent();
    }

    void InitializeComponent()
    {
        Text = "Students Records";
        Size = new Size(320, 160);

    colStudentNumber = new DataColumn("StudentNumber", Type.GetType("System.Int32"));

        tblRegistration = new DataTable("Student");
        tblRegistration.Columns.Add(colStudentNumber);

        dsRedOakHighSchool = new DataSet("SchoolRecords");
        dsRedOakHighSchool.Tables.Add(tblRegistration);
    }
}

public class Program
{
    static int Main()
    {
        System.Windows.Forms.Application.Run(new Exercise());
        return 0;
    }
}

If you used the default constructor to create a DataColumn, to specify its data type, assign its qualified type to the DataColumn.DataType property. Here is an example:

public class Exercise : Form
{
    DataColumn colStudentNumber;
    DataColumn colFirstName;
    DataColumn colLivesInASingleParentHome;

    public Exercise()
    {
        InitializeComponent();
    }

    void InitializeComponent()
    {
        Text = "Students Records";
        Size = new Size(320, 160);

        colStudentNumber = new DataColumn("StudentNumber",
            Type.GetType("System.Int32"));
        
        colFirstName = new DataColumn("FullName");
        colFirstName .DataType = Type.GetType("System.String");

        colLivesInASingleParentHome = new DataColumn("LSPH");
        colLivesInASingleParentHome.DataType = Type.GetType("System.Boolean");
    }
}

Remember that there are various techniques you can use to create a column by specifying its name and its data type.

Practical Learning: Applying Data Types on Columns

  1. In the Members list, click Principal
  2. In the Properties list, click DataType, click the arrow of its combo box and select System.Double
  3. In the same way, change the data types of the following columns:
     
    Member DataType
    DateAllocated System.DateTime
    LoanNumber System.String
    PreparedBy System.String
    PreparedFor System.String
    Principal System.Double
    InterestRate System.Double
    Periods System.Double
    InterestEarned System.Double
    FutureValue System.Double
    MonthlyPayment System.Double

The Default Value

When performing data entry, the user is expected to enter a value for each column. Sometimes, most values under a certain column would be the same. For example, if you are creating an application that would be used in a tri-state area such as MD-DC-VA and the product would be used to dry-clean items from customers all over the region, most customers would come from the state where the company is based. In the column used to enter the state, you can provide a default value so that, if the user does not enter it, it would be selected by default.

A default value is one that is automatically applied to a column so the user can simply accept it but the user can change it if it does not apply.

To visually create a default value on a column, in the Column Collection Editor, select a column in the Members list. In the Properties list, click DefaultValue and replace <DBNull> with the desired value.

To programmatically specify the default value, assign the desired value to the DefaultValue property of the data column variable.

Practical Learning: Applying Data Types on Columns

  1. In the Members list, click Principal
  2. In the Properties list, click DefaultValue and delete <DBNull>
  3. Type 0
  4. In the same way, change the default values of the following columns:
     
    Member DefaultValue
    InterestRate 8.75
    Periods 36

The Expression of a Column

 

Introduction

So far, to perform data entry, we created the data fields and expected the user to enter values in them. In some cases, instead of the user typing data, you may want to specify your own constant value or you may want to combine some values. An expression can be:

  • A constant value such as 288, "Aaron Watts", or 48550.95
  • A combination of two or more constants such 50 + 428, "HourlySalary" + 25.85, or "John" + " " + "Santini", 
  • The name of a column such as Filename, CountryCode or DateOfBirth
  • The combination of a constant and one or more column names such as Username & "@gmail.com"
  • Or a combination of two or more columns such as FirstName & LastName

Besides the items in this list, you can also use some functions and/or combine them with the items in the above list. The expression then creates or represents a value. To create an expression, there are various rules you must follow:

  • If the expression is algebraic, you can use the normal math operations (+, -, *, and /) applied to one or more constants combined to one or more column names
  • To create a combination of strings, you can use the + operator

Once you have decided about this expression, you can use it as the value assigned to a column.

If you are visually creating a column, under the Members list of the Column Collection Editor, select a column. To specify an expression for it, in the Properties list, click Expression and type the desired expression. Here is an example: 

To programmatically specify the expression used on a column, assign the expression, as a string, to its variable name. Here is an example:

public class Exercise : Form
{
    DataSet dsRedOakHighSchool;
    DataTable tblRegistration;
    DataColumn colFirstName;
    DataColumn colLastName;
    DataColumn colFullName;

    DataGridView dgvStudents;

    public Exercise()
    {
        InitializeComponent();
    }

    void InitializeComponent()
    {
        Text = "Students Records";
        Size = new Size(550, 160);

        colFirstName = new DataColumn("FirstName");
        colFirstName.DataType = Type.GetType("System.String");

        colLastName = new DataColumn("LastName");
        colLastName.DataType = Type.GetType("System.String");

        colFullName = new DataColumn("FullName");
        colFullName.DataType = Type.GetType("System.String");
        colFullName.Expression = "FirstName + ' ' + LastName";

        tblRegistration = new DataTable("Student");
        tblRegistration.Columns.Add(colFirstName);
        tblRegistration.Columns.Add(colLastName);
        tblRegistration.Columns.Add(colFullName);

        dsRedOakHighSchool = new DataSet("StudentsRecords");
        dsRedOakHighSchool.Tables.Add(tblRegistration);

        dgvStudents = new DataGridView();
        dgvStudents.Location = new Point(12, 12);
        dgvStudents.Size = new Size(400, 100);
        dgvStudents.DataSource = dsRedOakHighSchool;
        dgvStudents.DataMember = "Student";

        Controls.Add(dgvStudents);
    }
}

Thanks to this code, the user can type both the first and the last names. Then two things:

  1. When the user moves to the next record, the expression is used to create the value of the full name column
     
  2. The user cannot enter a value in the column that has an expression

Practical Learning: Creating Expressions on Columns

  1. In the Members list, click FutureValue
  2. In the Properties list, click Expression and type Principal + InterestEarned
  3. In the same way, change the data types of the following columns:
     
    Member Expression
    InterestEarned Principal * (InterestRate / 100) * (Periods / 12)
    FutureValue Principal + InterestEarned
    MonthlyPayment FutureValue / Periods

Using Operators and Expressions

To create an expression, you use the logical operators from the Visual Basic language. Most of the operators are the same you are already familiar with from your knowledge of C#, except as follows:

Operator Name C# Visual Basic Data View
Equal == = =
Less Than < < <
Less Than Or Equal To <= <= <=
Greater Than > > >
Greater Than Or Equal To >= >= >=
Not Equal != <> <>

You can also use the other logical operators, such as the negation operator, the conjunction operator, and the disjunction operator. Once again, you must use them as they are implemented in the Visual Basic language as follows:

Operator Name C# Visual Basic Data View
Negation ! NOT NOT
Logical Conjunction && AND AND
Logical Disjunction || OR OR

Using Functions

The ADO.NET system (but remember that ADO.NET is not a library; it is just a name) ships with various functions (because C# does not have the concept of function, consider that a function is a type of method but that does not belong to a (specific) class) you can use for data filtering.

The following logical functions available are (although the names are given here in uppercase, the language is actually case-insensitive):

  • IFF:
  • ISNULL:

The following functions are used to evaluate the values from one particular column. They are called aggregate functions and they are:

  • Avg: This function is used to calculate the average of a series of values. The values would stored in one particular column
  • Sum
  • Min
  • Max
  • Count
  • Var
  • StdDev
  • CONVERT

To manipulate strings, the following functions are available (although the names are given here in uppercase, the language is actually case-insensitive):

  • LEN
  • SUBSTRING
  • TRIM
 
 
 

Text Length and Null Values

 

The Maximum Length of a Column

If a column is configured to receive text, that is, if its data type is set to string, by default, it can hold 0 to 32767 characters. This is (too) long for most cases. For example, if a column is made for people's names, this length is certainly too high. Fortunately, to customize the behavior of a column, you can limit the number of the characters that can be entered in a column.

To support the ability to control the number of characters that a text-based column would allow, the DataColumn class is equipped with a property named MaxLength. The default value of this property is -1, which means there is no limit.

To visually set the maximum length, in the Columns Collection Editor, click a column in the Members list. In the Properties list, click MaxLength and type the desired value. To programmatically specify the maximum length, assign an integer value to the MaxLength property of the column's variable.

Null Values

When performing data entry, if the user does not have a value for a certain column, he or she may skip it. In some cases, you may want a value to be required; that is, you would not let the column to be left empty. When a column is left empty, it is referred to as null.

To support the ability to have a null value or to require it, the DataColumn class is equipped with a Boolean property named AllowDBNull. If you want the user to be able to skip a column and not provide a value, you can ignore this property or set it to true. To require a value for a column, set this property to false.

Practical Learning: Nullifying a Column

  1. In the Members list, click DateAllocated
  2. In the Properties list, double-click the value of the AllowDBNull field to set it to False
  3. In the Members list, click LoanNumber
  4. In the Properties list, double-click the value of the AllowDBNull field to set it to False
  5. Click Close and click Close
  6. To create a new form, in the Solution Explorer, right-click WattsALoan4 -> Add -> Windows Forms...
  7. Set the Name to Employees and click Add
  8. From the Data section of the Toolbox, click DataSet and click the form
  9. Select the Untyped Dataset radio button and click OK
  10. In the Properties window, change the following characteristics:
    DataSetName: dsEmployees
    (Name): Employees
  11. Click Tables and click its ellipsis button
  12. To create a new table, click Add and change the properties as follows:
    TableName: Employee
    (Name): tblEmployee
  13. Click Columns and click its ellipsis button
  14. Click Add 5 times and change the properties as follows:
     
    AllowDBNull ColumnName DefaultValue DataType Expression Unique (Name)
    False EmployeeNumber       True colEmployeeNumber
      FirstName         colFirstName
    False LastName         colLastName
      Title         colTitle
      HourlySalary 8.75 System.Double     colHourlySalary
      EmployeeDetails     EmployeeNumber + ': ' +FirstName + ' ' + LastName   colEmployeeDetails
  15. Click Close and click Close
  16. Design the form as follows:
     
     
    Control Text Name Other Properties
    DataGridView   dgvEmployees DataSource: dsEmployees
    DataMember: Employee
    Button Close btnClose  
    Data Grid Columns
     
    DataPropertyName HeaderText Width
    EmployeeNumber Empl # 70
    FirstName First Name 65
    LastName Last Name 65
    Title   110
    HourlySalary Salary/Hr 55
    colEmployeeDetails Employee Details 150
  17. Double-click an unoccupied area of the form and implement the event as follows:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace WattsALoan1
    {
        public partial class Employees : Form
        {
            public Employees()
            {
                InitializeComponent();
            }
    
            private void Employees_Load(object sender, EventArgs e)
            {
                string strFilename = "employees.xml";
    
                if (File.Exists(strFilename))
                    dsEmployees.ReadXml(strFilename);
            }
        }
    }
  18. Return to the form and click an unoccupied area of its body
  19. In the Properties window, click the Events button and double-click FormClosing
  20. Implement the event as follows:
    private void Employees_FormClosing(object sender, FormClosingEventArgs e)
    {
        dsEmployees.WriteXml("employees.xml");
    }
  21. Return to the form and double-click the Close button
  22. Implement the event as follows:
    private void btnClose_Click(object sender, EventArgs e)
    {
        Close();
    }
  23. Return to the form
  24. Under the form, right-click dsEmployees and click Copy
  25. Display the LoansAllocations form
  26. Right-click it and click Paste
  27. To create a new form, in the Solution Explorer, right-click WattsALoan1 -> Add -> Windows Forms...
  28. Set the Name to Customers and click Add
  29. From the Data section of the Toolbox, click DataSet and click the form
  30. Select the Untyped Dataset radio button and click OK
  31. In the Properties window, change the following characteristics:
    DataSetName: dsCustomers
    (Name): Customers
  32. Click Tables and click its ellipsis button
  33. To create a new table, click Add and change the properties as follows:
    TableName: Customer
    (Name): tblCustomer
  34. Click Columns and click its ellipsis button
  35. Click Add 5 times and change the properties as follows:
     
    AllowDBNull ColumnName Unique Expression (Name)
    False AccountNumber True   colAccountNumber
      FirstName     colFirstName
    False LastName     colLastName
      EmailAddress     colEmailAddress
      PhoneNumber     colPhoneNumber
      CustomerDetails   AccountNumber + ': ' + FirstName + ' ' + LastName colCustomerDetails
  36. Click Close and click Close
  37. Design the form as follows:
     
    Watts A Loan: Customers
     
    Control Text Name Other Properties
    DataGridView   dgvCustomers DataSource: dsCustomers
    DataMember: Customer
    Button Close btnClose  
    Data Grid Columns
     
    DataPropertyName HeaderText Width
    AccountNumber Account # 65
    FirstName First Name 60
    LastName Last Name 65
    EmailAddress Email Address 120
    PhoneNumber Phone # 90
    CustomerDetails Customer Details 150
  38. Double-click an unoccupied area of the form and implement the event as follows:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace WattsALoan1
    {
        public partial class Customers : Form
        {
            public Customers()
            {
                InitializeComponent();
            }
    
            private void Customers_Load(object sender, EventArgs e)
            {
                string strFilename = "customers.xml";
    
                if (File.Exists(strFilename))
                    dsCustomers.ReadXml(strFilename);
            }
        }
    }
  39. Return to the form and click an unoccupied area of its body
  40. In the Properties window, click the Events button and double-click FormClosing
  41. Implement the event as follows:
    private void Customers_FormClosing(object sender, FormClosingEventArgs e)
    {
        dsCustomers.WriteXml("customers.xml");
    }
  42. Return to the form and double-click the Close button
  43. Implement the event as follows:
    private void btnClose_Click(object sender, EventArgs e)
    {
        Close();
    }
  44. Return to the form
  45. Under the form, right-click dsCustomers and click Copy
  46. Display the LoansAllocations form
  47. Right-click it and click Paste
  48. Design the form as follows:

    Watts A Loan - Loans Allocations
     
    Control Text Name Other Properties
    DataGridView   dgvCustomers DataSource: dsCustomers
    DataMember: Customer
    Button Close btnClose  
    Data Grid Columns
     
    DataPropertyName HeaderText Width DefaultCellStyle -> Format  
    LoanNumber Loan # 60    
    DateAllocated Date Allocated 85 Date Time  
    PreparedBy Prepared By 165   ColumnType: DataGridViewComboBoxColumn
    DataSource: dsEmployees
    DisplayMember: Employee.EmployeeDetails
    PreparedFor Prepared For 165   ColumnType: DataGridViewComboBoxColumn
    DataSource: dsCustomers
    DisplayMember: Customer.CustomerDetails
    Principal   65 Currency  
    InterestRate Rate (%) 55 Numeric  
    Periods Prd (Months) 75 Numeric  
    InterestEarned Interest Earned 85 Currency  
    FutureValue Future Value 75 Currency  
    MonthlyPayment Pmt/Month 70 Currency  

  49. Double-click an unoccupied area of the form and implement the event as follows:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace WattsALoan1
    {
        public partial class LoanAllocations : Form
        {
            public LoanAllocations()
            {
                InitializeComponent();
            }
    
            private void LoanAllocations_Load(object sender, EventArgs e)
            {
                string strFilename = "employees.xml";
    
                if (File.Exists(strFilename))
                    dsEmployees.ReadXml(strFilename);
    
                strFilename = "customers.xml";
    
                if (File.Exists(strFilename))
                    dsCustomers.ReadXml(strFilename);
    
                strFilename = "loans.xml";
    
                if (File.Exists(strFilename))
                    dsLoansAllocations.ReadXml(strFilename);
            }
        }
    }
  50. Return to the form and click an unoccupied area of its body
  51. In the Properties window, click the Events button and double-click FormClosing
  52. Implement the event as follows:
    private void LoanAllocations_FormClosing(object sender, FormClosingEventArgs e)
    {
        dsLoansAllocations.WriteXml("loans.xml");
    }
  53. Return to the form and double-click the Close button
  54. Implement the event as follows:
    private void btnClose_Click(object sender, EventArgs e)
    {
        Close();
    }
  55. To create a new form, in the Solution Explorer, right-click WattsALoan1 -> Add -> Windows Forms...
  56. Set the Name to Payments and click Add
  57. Display the Employees form
  58. Right-click dsEmployees and click Copy
  59. Display the Payments form
  60. Right-click it and click Paste
  61. Display the LoanAllocations form
  62. Right-click dsLoanAllocations and click Copy
  63. Display the Payments form
  64. Right-click it and click Paste
  65. From the Data section of the Toolbox, click DataSet and click the Payments form
  66. Select the Untyped Dataset radio button and click OK
  67. In the Properties window, change the following characteristics:
    DataSetName: dsPayments
    (Name): Payments
  68. Click Tables and click its ellipsis button
  69. To create a new table, click Add and change the properties as follows:
    TableName: Payment
    (Name): tblPayment
  70. Click Columns and click its ellipsis button
  71. Click Add 6 times and change the properties as follows:
     
    AllowDBNull ColumnName DataType DefaultValue Expression Unique (Name)
    False PaymentNumber       True colPaymentNumber
    False PaymentDate System.DateTime       colPaymentDate
    False ReceivedBy         colReceivedBy
    False PaymentFor         colPaymentFor
    False PaymentAmount System.Double 0.00     colPaymentAmount
      Balance System.Double 0.00     colBalance
  72. Click Close and click Close
  73. Design the form as follows:
     
    Watts A Loan: Payments
     
    Control Text Name Other Properties
    DataGridView   dgvPayments DataSource: dsPayments
    DataMember: Payment
    Button Loans... btnLoans  
    Button Close btnClose  
    Data Grid Columns
     
    DataPropertyName HeaderText Width DefaultCellStyle -> Format  
    PaymentNumber Pmt # 55    
    PaymentDate Pmt Date 70 Date Time  
    ProcessedBy Processed By     ColumnType: DataGridViewComboBoxColumn
    DataSource: dsEmployees
    DisplayMember: Employee.EmployeeNumber
    PaymentFor Payment For     ColumnType: DataGridViewComboBoxColumn
    DataSource: dsLoansAllocations
    DisplayMember: Loan.LoanNumber
    PaymentAmount Pmt Amt 70 Currency  
    Balance   80 Currency  
  74. Double-click an unoccupied area of the form and implement the event as follows:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.IO;
    
    namespace WattsALoan1
    {
        public partial class Payments : Form
        {
            public Payments()
            {
                InitializeComponent();
            }
    
            private void Payments_Load(object sender, EventArgs e)
            {
                string strFilename = "loans.xml";
    
                if (File.Exists(strFilename))
                    dsLoansAllocations.ReadXml(strFilename);
    
                strFilename = "employees.xml";
    
                if (File.Exists(strFilename))
                    dsEmployees.ReadXml(strFilename);
    
                strFilename = "payments.xml";
    
                if (File.Exists(strFilename))
                    dsPayments.ReadXml(strFilename);
            }
        }
    }
  75. Return to the form and click an unoccupied area of its body
  76. In the Properties window, click the Events button and double-click FormClosing
  77. Implement the event as follows:
    private void Payments_FormClosing(object sender, FormClosingEventArgs e)
    {
        dsPayments.WriteXml("payments.xml");
    }
  78. Return to the form and double-click the Loans button
  79. Implement the event as follows:
    private void btnLoans_Click(object sender, EventArgs e)
    {
        LoanAllocations frmLoans = new LoanAllocations();
        frmLoans.ShowDialog();
    }
  80. Return to the form and double-click the Close button
  81. Implement the event as follows:
    private void btnClose_Click(object sender, EventArgs e)
    {
        Close();
    }
  82. In the Solution Explorer, right-click Form1.cs and click Rename
  83. Type WattsALoan.cs and press Enter twice
  84. Display the form and cesign it as follows:
     
    Watts A Loan
    Control Text Name Font
    Button ... btnPayments  
    Label Loan Payments lblPayments Garamond, Bold, 24
    Button ... btnAllocations  
    Label Loan Allocations lblAllocations Garamond, Bold, 24
    Button ... btnCustomers  
    Label Customers lblCustomers Garamond, Bold, 24
    Button ... btnEmployees  
    Label Employees lblEmployees Garamond, Bold, 24
    Button Close btnClose  
  85. Double-click the top button and implement its event as follows:
    private void btnPayments_Click(object sender, EventArgs e)
    {
        Payments frmPayments = new Payments();
        frmPayments.ShowDialog();
    }
  86. Return to the form and click the Loan Payments label
  87. In the Properties window, click Events, then click the arrow of Click and select btnPayments_Click
  88. On the form, double-click the second button from top
  89. Implement its event as follows:
    private void btnLoanAllocations_Click(object sender, EventArgs e)
    {
        LoansAllocations frmLoans = new LoansAllocations();
        frmLoans.ShowDialog();
    }
  90. Return to the form and click the Loan Allocations label
  91. In the Events section of the Properties window, click the arrow of Click and select btnLoanAllocations_Click
  92. On the form, double-click the third button from top
  93. Implement its event as follows:
    private void btnCustomers_Click(object sender, EventArgs e)
    {
        Customers frmClients = new Customers();
        frmClients.ShowDialog();
    }
  94. Return to the form and click the Customers label
  95. In the Events section of the Properties window, click the arrow of Click and select btnCustomers_Click
  96. On the form, double-click the fourth button from top
  97. Implement its event as follows:
    private void btnEmployees_Click(object sender, EventArgs e)
    {
        Employees frmStaff = new Employees();
        frmStaff.ShowDialog();
    }
  98. In the Events section of the Properties window, click the arrow of Click and select btnEmployees_Click
  99. Return to the form and double-click the Close button
  100. Implement its event as follows:
    private void btnClose_Click(object sender, EventArgs e)
    {
        Close();
    }
  101. Execute the application
  102. Click the Employees label and create the following records:
     
    Employee # First Name Last Name Title Salary/hr
    7973-45 Bernard Wallow Account Manager 24.85
    2497-94 Justine Bogley Sales Representative 12.75
    2930-75 Nestor Rosenblatt Sales Representative 14.25
     
  103. Close the form
  104. Click the Customers label and create the following records:
     
    Account # First Name Last Name Email Address Phone Number
    937-497 Joan Fairbanks fairbie1288@hotmail.com (301) 937-5888
    293-759 Ernie Lipps ernie.rowdie@comcast.net (703) 506-0000
    502-850 Christopher Owens owenchris@yahoo.com (202) 529-6100
    520-840 Ann Rowdy rowdiant@msn.com (301) 855-2090
    602-475 Sarah Thompson lolitta448@yahoo.com (301) 870-7454
     
    Watts A Loan - Customers
  105. Close the form
  106. Click the Loan Allocations label and create the following records:
     
    Loan # Date Allocated Prepared By Prepared For Principal Rate (%) Prd (Months)
    52-9739-5 08/18/14 2497-94 937-497 6500 16.25  
    20-5804-8 10/26/2014 7973-45 602-475 3260    
    77-3907-2 02/06/15 2497-94 502-850 25605 12.50 60
    92-7495-4 03/20/15 2930-75 293-759 14800   48

    Watts A Loan - Loans Allocations

  107. Close the form
  108. Click the Loan Payments label and create the following records:
     
    Pmt # Pmt Date Received By Payment For Pmt Amt Balance
    1001 10/25/14 2497-94 52-9739-5 268.58 9400.17
    1002 11/30/14 2930-75 52-9739-5 268.58 9131.59
    1003 12/24/2014 7973-45 20-5804-8 114.33 4001.42
    1004 12/28/14 2497-94 52-9739-5 268.58 8863.01
    1005 01/26/15 2497-94 20-5804-8 114.33 3887.09
    1006 01/31/15 2930-75 52-9739-5 268.58 8594.43
    1007 02/20/15 2497-94 20-5804-8 114.33 3772.76
    1008 03/02/15 2930-75 52-9739-5 268.58 8325.85
    1009 03/25/2015 2930-75 20-5804-8 114.33 3658.43
    1010 04/25/15 7973-45 92-7495-4 416.25 19563.75
    1011 04/28/15 2497-94 77-3907-2 693.47 40914.66
    1012 04/28/15 7973-45 20-5804-8 114.33 3544.10
    1013 05/01/15 7973-45 52-9739-5 268.58 8057.27
    1014 05/26/15 2497-94 77-3907-2 693.47 40221.19
     
  109. Close the forms and return to your programming environment
 
 
   
 

Previous Copyright © 2005-2016, FunctionX Next