private void btn_Next_Click(object sender, System.EventArgs e)
{
i=i+1;
display (i);
btn_First .Enabled =true;
btn_Previous .Enabled =true;
if(i==dSet.Tables ["student"].Rows.Count -1)
{
btn_Last .Enabled =false;
btn_Next .Enabled =false;
}
}
private void btn_Exit_Click(object sender, System.EventArgs e)
{
DialogResult Dr=MessageBox.Show("你确定要退出么?","消息",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button1,MessageBoxOptions.ServiceNotification);
if(Dr==DialogResult.Yes)
{
this.Close ();
}
else
{}
}
private void btn_First_Click(object sender, System.EventArgs e)
{
i=0;
display (i);
btn_First .Enabled =false;
btn_Previous .Enabled =false;
btn_Last .Enabled =true;
btn_Next .Enabled =true;
}
private void btn_Last_Click(object sender, System.EventArgs e)
{
i=dSet.Tables ["student"].Rows .Count -1;
display (i);
btn_Last .Enabled =false;
btn_Next .Enabled =false;
btn_First .Enabled =true;
btn_Previous .Enabled =true;
}
private void btn_Previous_Click(object sender, System.EventArgs e)
{
i=i-1;
display (i);
btn_Last .Enabled =true;
btn_Next .Enabled =true;
if(i==0)
{
btn_First .Enabled =false;
btn_Previous .Enabled =false;
}
}
private void display(int j)
{
try
{
txt_StuNo.Text =dSet.Tables ["student"].Rows [j][0].ToString ();
txt_StuName .Text =dSet.Tables ["student"].Rows [j][1].ToString ();
comb_StuSex .Text =dSet.Tables ["student"].Rows [j][2].ToString ();
txt_StuAge .Text =dSet.Tables ["student"].Rows [j][3].ToString ();
txt_StuAdd .Text =dSet.Tables ["student"].Rows [j][4].ToString ();
}
catch
{
MessageBox.Show("已经是第一条记录");
display(0);
}
}