private void button6_Click(object sender, EventArgs e)//确认修改 { StudentData studentData = new StudentData(); studentData.StuNo = textBox2.Text; studentData.StuPwd = textBox3.Text; studentData.StuName = textBox4.Text; studentData.StuNianji = textBox5.Text; studentData.Academy = textBox6.Text; studentData.Profession = textBox7.Text; studentData.StuClass = Convert.ToInt32(textBox8.Text); studentData.Grade = Convert.ToInt32(textBox9.Text); ad_ServicesBLL BLL = new ad_ServicesBLL(); if (BLL.UpdateStudatabll(studentData) > 0) { MessageBox.Show("修改成功", "提示", MessageBoxButtons.OK); textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = "2016"; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; DataTable table = BLL.SelectStubll(); dataGridView1.DataSource = table; } else { MessageBox.Show("更新失败", "提示", MessageBoxButtons.OKCancel); } }
private void StudentList_Load(object sender, EventArgs e) { ad_ServicesBLL BLL = new ad_ServicesBLL(); DataTable studentTable = BLL.SelectStubll(); dataGridView1.DataSource = studentTable; textBox5.Text = "2016"; }
private void button7_Click_1(object sender, EventArgs e)//删除 { string id = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value.ToString(); ad_ServicesBLL bLL = new ad_ServicesBLL(); if (bLL.RemoveStudata(id)) { MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK); ad_ServicesBLL BLL = new ad_ServicesBLL(); DataTable table = BLL.SelectStubll(); dataGridView1.DataSource = table; } else { MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK); } }
private void button5_Click(object sender, EventArgs e)//添加单个信息 { ad_ServicesBLL BLL = new ad_ServicesBLL(); StudentData studentData = new StudentData(); studentData.StuNo = textBox2.Text; studentData.StuPwd = textBox3.Text; studentData.StuName = textBox4.Text; studentData.StuNianji = textBox5.Text; studentData.Academy = textBox6.Text; studentData.Profession = textBox6.Text; studentData.StuClass = Convert.ToInt32(textBox8.Text); studentData.Grade = Convert.ToInt32(textBox9.Text); //if (BLL.Check(studentData.StuNo))//true代表数据库中已有该值 //{ // MessageBox.Show("该学号已存在,不可重复录入", "警示", MessageBoxButtons.OK); //} //else //{ if (BLL.InsertStubll(studentData)) { MessageBox.Show("导入成功", "提示", MessageBoxButtons.OK); textBox2.Text = ""; textBox3.Text = ""; textBox4.Text = ""; textBox5.Text = ""; textBox6.Text = ""; textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; DataTable table = BLL.SelectStubll(); dataGridView1.DataSource = table; } else { MessageBox.Show("导入失败", "提示", MessageBoxButtons.OKCancel); } //} }