public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent(); //
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
} /// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null) 
{
components.Dispose();
}
}
base.Dispose( disposing );
} #region Windows 窗体设计器生成的代码
/// <summary>

private void groupBox1_Enter(object sender, System.EventArgs e)
{

} private void groupBox2_Enter(object sender, System.EventArgs e)
{

} private void groupBox4_Enter(object sender, System.EventArgs e)
{

} private void groupBox3_Enter(object sender, System.EventArgs e)
{

} private void Form1_Load(object sender, System.EventArgs e)
{
try
{ //this.textju.Text=this.mybind.Count.ToString();
this.ccDS = new DataSet();
this.ccDA = new System.Data.OleDb.OleDbDataAdapter(sql,cnn);
this.ccDA.Fill(this.ccDS,"schedule");
this.ccCMD = new System.Data.OleDb.OleDbCommandBuilder(this.ccDA);
this.mybind = this.BindingContext[this.ccDS,"schedule"];
this.dataGrid1.DataSource = this.ccDS;
this.dataGrid1.DataMember = "schedule";
绑定控件
this.txtNO.DataBindings.Add("Text",this.ccDS,"cc_students.stu_no");
this.txtPrice.DataBindings.Add("Text",this.ccDS,"cc_students.stu_addr");
this.txtName.DataBindings.Add("Text",this.ccDS,"cc_students.stu_name");
this.txtCB.DataBindings.Add("Text",this.ccDS,"cc_students.stu_DS");
this.txtSort.DataBindings.Add("Text",this.ccDS,"cc_students.stu_sort");
this.txtTime.DataBindings.Add("Text",this.ccDS,"cc_students.stu_addtime");
this.textju.Text=this.mybind.Count.ToString()+"本图书";*/


}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

} private void btnPre_Click(object sender, System.EventArgs e)
{
if (this.mybind.Position>0)
this.mybind.Position-=1;
else
MessageBox.Show("当前记录已经是第一条","图书管理系统",MessageBoxButtons.OK,MessageBoxIcon.Information );

} private void btnNext_Click(object sender, System.EventArgs e)
{
/*if (this.mybind.Position<this.mybind.Count-1)
this.mybind.Position+=1;
else
MessageBox.Show("当前记录已经是最后一条","图书管理系统",MessageBoxButtons.OK,MessageBoxIcon.Information );

*/} private void btnDelete_Click(object sender, System.EventArgs e)
{
//Delete();
}

public void Delete()
{
// TODO:  添加 UserControl1.Delete 实现
//MessageBox.Show("Test?ok");
//if(this.txtNO.Text =="")
//{
//MessageBox.Show("没有数据可以被删除","图书管理系统",MessageBoxButtons.OK,MessageBoxIcon.Information  );
//return;
//}
//string msg = "您确定要删除选定的记录吗?"; //if(MessageBox.Show(msg, "图书管理系统", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No )
//return ;
/*try
{
//连接到数据库
string strCon = @"Integrated Security=SSPI;Packet Size=4096;Data Source=localhost;Tag with column collation when possible=False;Initial Catalog=Book;Use Procedure for Prepare=1;Auto Translate=True;Persist Security Info=False;Provider=""SQLOLEDB.1"";Workstation ID=FEI;Use Encryption for Data=False";
OleDbConnection myConn = new OleDbConnection ( strCon ) ;
myConn.Open ( ) ;
string strDele = "DELETE FROM cc_students WHERE stu_no= '" + this.txtNO.Text +"'" ;
OleDbCommand myCommand = new OleDbCommand ( strDele , myConn ) ;
//从数据库中删除指定记录
myCommand.ExecuteNonQuery ( ) ;
//从DataSet中删除指定记录
this.ccDS.Tables [ "cc_students" ] . Rows [ mybind.Position ] . Delete ( ) ;
this.ccDS.Tables [ "cc_students" ] . AcceptChanges ( ) ;
myConn.Close ( ) ;
}
catch ( Exception ed )
{
MessageBox.Show ( "删除记录错误信息: " + ed.ToString ( ) , "图书管理系统",MessageBoxButtons.OK,MessageBoxIcon.Information  ) ;
}*/
} private void btnFind_Click(object sender, System.EventArgs e)
{/*
if(this.txtKeyWord.Text == "")
{
MessageBox.Show("查询关键字不能为空!","图书管理系统",MessageBoxButtons.OK,MessageBoxIcon.Information );
return;
} try
{
string sql2;
sql2 = "SELECT * FROM cc_students WHERE stu_no like '%" + this.txtKeyWord.Text + "%'";
this.ccDA2 = new System.Data.OleDb.OleDbDataAdapter(sql2,cnn);
this.ccDS.Clear();
this.ccDA2.Fill(this.ccDS,"cc_students");
this.txtKeyWord.Text = "";
}
catch (Exception e1)
{
MessageBox.Show(e1.Message);
}*/
} private void btnLoad_Click(object sender, System.EventArgs e)
{
/*t/**his.ccDS.Clear();
this.ccDA.Fill(this.ccDS,"cc_students");
this.textju.Text=this.mybind.Count.ToString();*/

} private void btnSave_Click(object sender, System.EventArgs e)
{
//信息合法性检查
/*if (txtNO.Text=="" || txtPrice.Text =="" || txtName.Text=="" || txtCB.Text=="" || txtSort.Text=="")
{
MessageBox.Show("提交的信息不完全!","图书管理系统",MessageBoxButtons.OK,MessageBoxIcon.Information );
return;
}
try
{
this.dataGrid1.EndInit();
this.mybind.EndCurrentEdit();
this.ccDA.Update(this.ccDS,"cc_students");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}*/
}