Bài Tập C# Nâng Cao 3 Tier - Load Data Vào ComboBox

Bài Tập C# Nâng Cao 3 Tier - Load Data Vào ComboBox

B1 Thiết Kế Form Main
Bài Tập C# Nâng Cao 3 Tier - Load Data Vào ComboBox
B2 Thiết Kế Mô Hình 3 Tầng Như Sau
 
B3 Viết Code Cho 3 Tầng.
Tầng Data Viết Lớp Kết Nối và class DataLop

namespace TangData
{
public class KetNoi
{
private OleDbConnection con;
public OleDbConnection Con
{
set { con=value; }
get { return this.con; }
}
public KetNoi()
{
Con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0 ; Data Source=QLDiem.accdb");
Con.Open();

}

public DataSet getdataset(string sql,string tenbang)
{

DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(sql,Con);
da.Fill(ds,tenbang);
return ds;
}  }  }

namespace TangData
{
public class clsDataLop:KetNoi
{
public DataSet getdatasetlop(string tenbang)
{
string sql = @"Select * From " + tenbang;
return getdataset(sql,tenbang);
}
}
}
Tầng Xử Lý Viết Class clsXulyLop

namespace TangXuly
{
    public class clsXulyLop
    {
        clsDataLop objlop = new clsDataLop();
     public   DataSet getLop(string TenBang)
        {
            return objlop.getdatasetlop("Lop");
        }
    }
}
Và Tầng Main

#region "Khai Báo Chung"
        DataSet dsSV, dsLop;
        DataTable tblLop, tblSV;
        clsXulyLop objLOP=new clsXulyLop();
        clsXulySV objSV = new clsXulySV();
#endregion
        private void FrmMain_Load(object sender, EventArgs e)
        {
            cboLop.DisplayMember = "TenLop";
            cboLop.ValueMember = "MaLop";
            cboLop.DataSource = objLOP.getLop("Lop").Tables[0];

        }

Bạn thấy bài viết này như thế nào?: 
Average: 10 (1 vote)
Ảnh của Tommy Tran

Tommy owner Express Magazine

Drupal Developer having 9+ year experience, implementation and having strong knowledge of technical specifications, workflow development. Ability to perform effectively and efficiently in team and individually. Always enthusiastic and interseted to study new technologies

  • Skype ID: tthanhthuy

Advertisement

 

jobsora

Dich vu khu trung tphcm

Dich vu diet chuot tphcm

Dich vu diet con trung

Quảng Cáo Bài Viết

 
Hướng dẫn set Your Performance Page trong Drupal 7

Hướng dẫn set Your Performance Page trong Drupal 7

When Drupal comes out of the box, it's configured for ease of development – not performance

Wanda Nara thường xuyên đăng "ảnh nóng" lên mạng xã hội, một phần cũng giúp đánh bóng tên tuổi chồng mình

Siêu cò nữ bốc lửa nhất thế giới Wanda Nara đốt cháy mạng xã hội

Bằng tài thương lượng khéo léo và sự khêu gợi của mình, người đẹp Wanda Nara đã giúp chồng mình, tiền đạo Mauro Icardi tháo chạy được khỏi Inter Milan để đến PSG hồi tháng 9 năm ngoái.

Brief Review for Samsung Galaxy S 4G

Brief Review for Samsung Galaxy S 4G

Nowadays, technology has become a way to represent somebody’s status. Telecommunication represents one of the technologies which has transformed its appearance from a basic need to a style statement.

Công ty diệt chuột T&C

 

Diet con trung