0% found this document useful (0 votes)
41 views2 pages

DATAGRIDENCAPSULATION

This document defines an Employee class with properties for employee ID, first name, last name, and position. It also defines a form class with methods for adding new employee records to a data grid view when a button is clicked. The form initializes components and handles user input to instantiate Employee objects and populate the grid.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views2 pages

DATAGRIDENCAPSULATION

This document defines an Employee class with properties for employee ID, first name, last name, and position. It also defines a form class with methods for adding new employee records to a data grid view when a button is clicked. The form initializes components and handles user input to instantiate Employee objects and populate the grid.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace EmployeeApplication
{

public partial class frmEmployeeDatabase : Form


{
DataGridView table = new DataGridView();
public frmEmployeeDatabase()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string employeeId = txtEmployee.Text;
string firstName = txtFirstName.Text;
string lastName = txtLastName.Text;
string position = txtPosition.Text;

Employee employee = new Employee(employeeId, firstName, lastName,


position);
dataGridView2.Rows.Add(employeeId, firstName, lastName, position);
}
private void dataGridView2_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
}
}
public class Employee
{
private string employeeId;
private string firstName;
private string lastName;
private string position;
public Employee()
{
}
// Constructor with parameters
public Employee(string employeeId, string firstName, string lastName,
string position)
{
this.employeeId = employeeId;
this.firstName = firstName;
this.lastName = lastName;
this.position = position;
}

// Properties
public string EmployeeId
{
get { return employeeId; }
set { employeeId = value; }
}

public string FirstName


{
get { return firstName; }
set { firstName = value; }
}

public string LastName


{
get { return lastName; }
set { lastName = value; }
}

public string Position


{
get { return position; }
set { position = value; }
}
}
}

You might also like