private void button1_Click(object sender, EventArgs e) { AlarmInfo tmp = new AlarmInfo(); tmp.AlarmLevel = textBox1.Text; tmp.AlarmDate = dateTimePicker1.Value; tmp.AlarmLocation = textBox3.Text; tmp.AlarmType = textBox4.Text; tmp.ProcessState = textBox5.Text; tmp.Staff = textBox6.Text; tmp.ProcessDate = dateTimePicker2.Value; tmp.ProcessInfo = textBox8.Text; SqlServerDatabase sqlServer = new SqlServerDatabase(); try { int tmp1 = sqlServer.CommitButton(tmp); if (tmp1 == 0) { TableAdapter.Fill(this.dHCK_ServerDataSet2.报警状态记录表); dataGridView.Refresh(); } else if (tmp1 == 1) { dataGridView1.DataSource = SearchDstable; dataGridView1.DataMember = "testTable"; } else { dataGridView1.DataSource = SearchDstable; dataGridView1.DataMember = "testTable"; } } catch (Exception exception) { Console.WriteLine(exception); throw; } }