DataSet Bind() { SpecialtyInfoData data = new SpecialtyInfoData(); data.Specialtyid = txtSpecialtyid.Text; data.Specialtymc = txtSpecialtymc.Text; Classes.SpecialtyInfoOperation op = new Classes.SpecialtyInfoOperation(); ds = op.GetSpecialtyInfo(data); return(ds); }
//删除 private void button3_Click(object sender, EventArgs e) { string specialtyid = txtSpecialtyid1.Text; Classes.SpecialtyInfoOperation op = new Classes.SpecialtyInfoOperation(); if (op.DeleteSpecialty(specialtyid)) { MessageBox.Show("成功"); } else { MessageBox.Show("失败了"); } dataGridView1.DataSource = Bind().Tables[0]; }
//修改 private void button2_Click(object sender, EventArgs e) { SpecialtyInfoData data = new SpecialtyInfoData(); data.Specialtyid = txtSpecialtyid1.Text; data.Specialtymc = txtSpecialtymc1.Text; Classes.SpecialtyInfoOperation op = new Classes.SpecialtyInfoOperation(); if (op.UpdateSpecialty(data)) { MessageBox.Show("成功了"); } else { MessageBox.Show("失败了"); } dataGridView1.DataSource = Bind().Tables[0]; }
private void button1_Click(object sender, EventArgs e) { SpecialtyInfoData data = new SpecialtyInfoData(); data.Specialtymc = txtSpecialtymc.Text; data.Specialtyid = txtSpecialtyid.Text; if (txtSpecialtyid.Text == "" || txtSpecialtyid.Text == null) { MessageBox.Show("用户名不能为空"); txtSpecialtyid.Focus(); return; } Classes.SpecialtyInfoOperation op = new Classes.SpecialtyInfoOperation(); if (op.InsertSpecialtyInfo(data)) { MessageBox.Show("插入成功"); } else { MessageBox.Show("失败"); } }