private void btnADD_Click(object sender, EventArgs e) { if (tbDeviceName.Text == "") { MessageBox.Show(lbDeviceName.Text + "不能为空"); return; } if (tbDeviceAddress.Text == "") { MessageBox.Show(lbDeviceAddress.Text + "不能为空"); return; } string dbPath = "Data Source =" + Environment.CurrentDirectory + @"\dataBase\DeviceInfo.db"; DeviceManagement.DeviceInfo device = new DeviceManagement.DeviceInfo(); device.ID = (UInt32)Convert.ToInt32(tbID.Text); device.name = tbDeviceName.Text; device.mac = tbDeviceAddress.Text; deviceManagement.AddDevice(device); /* 添加设备 */ InitDataGridView(); /* 刷新表格 */ }