Monday, December 22, 2008

Simple Class used by a form

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

namespace SampleProj
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}

private void Form3_Load(object sender, EventArgs e)
{
Sample obj = new Sample();
dataGridView1.DataSource = obj.getEmployeeDetail();
}

private void btnFind_Click(object sender, EventArgs e)
{
Sample obj = new Sample();
txtEmpName.Text = obj.getEmployeeDetail(1);
//use emp id instead of the constant 1
}


}
}


////////////////////////////////////////////////////////////////////



using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace SampleProj
{
class Sample
{
public String getEmployeeName(int nEmpID)
{
string strName = "";
//code to get the Employee Name
return strName;
}

public DataTable getEmployeeDetail()
{
DataTable ds = new DataTable();
//code to Fill DataTable
return ds;
}
}
}

No comments:

Post a Comment