namespace MyForm
{
public partial class TeacherListForm : Form
{
private DataSet dataSet = new DataSet(); // 声名并初始化 dataSet
private OracleDataAdapter dataAdapter; // 声明 dataadapter
public TeacherListForm()
{
InitializeComponent();
}
private void TeacherListForm_Load(object sender, EventArgs e)
{
string sql = "SELECT ID,login_name,PASSWORD,status,name,gender,phone,email,address,grade,class,is_using,to_char(create_time,'yyyy-mm-dd hh24:mi') createTime,to_char(update_time,'yyyy-mm-dd hh24:mi') updateTime,remark FROM t_vs_student ";
dataAdapter = new OracleDataAdapter(sql, DBHelper.connection);
dataAdapter.Fill(dataSet, "t_vs_student");
this.dgvTeacher.DataSource=dataSet.Tables["t_vs_student"];
}
private void btnColseSearchTeacher_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSaveTeacher_Click(object sender, EventArgs e)
{
DialogResult result = MessageBox.Show("您确实要将修改保存到数据库吗?", "操作提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
if (result == DialogResult.OK)
{
OracleCommandBuilder builder = new OracleCommandBuilder(dataAdapter);
dataAdapter.Update(dataSet, "t_vs_student");
}
}
}
}