示例#1
0
        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);
            }
            //}
        }