private void Part2_Save_Click(object sender, EventArgs e) { try { //添加数据 NeckDataInfo.id = txt2ID.Text; NeckDataInfo.cervixThickness = txtCervixThickness.Text; NeckDataInfo.midNeckGirth = txtMidNeckGirth.Text; NeckDataInfo.neckGirth = txtNeckGirth.Text; //执行添加 int id = MyMC.AddNeckData(NeckDataInfo); MessageBox.Show("新增--肩部数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } dataGridView2.DataSource = MyMC.GetAllNeckData("NeckData").Tables[0].DefaultView; this.SetdataGridView2HeadText(); }
private void tlBtnSave_Click(object sender, EventArgs e) { //判断是添加还是修改数据 if (G_Int_addOrUpdate == 0) { try { //添加数据 NeckDataInfo.id = txtID.Text; NeckDataInfo.cervixThickness = txtCervixThickness.Text; NeckDataInfo.midNeckGirth = txtMidNeckGirth.Text; NeckDataInfo.neckGirth = txtNeckGirth.Text; //执行添加 int id = baseinfo.AddNeckData(NeckDataInfo); MessageBox.Show("新增--肩部数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { //修改数据 NeckDataInfo.id = txtID.Text; NeckDataInfo.cervixThickness = txtCervixThickness.Text; NeckDataInfo.midNeckGirth = txtMidNeckGirth.Text; NeckDataInfo.neckGirth = txtNeckGirth.Text; //执行修改 int id = baseinfo.UpdateNeckData(NeckDataInfo); MessageBox.Show("修改--肩部数据--成功!", "成功提示!", MessageBoxButtons.OK, MessageBoxIcon.Information); } dgvNeckDataList.DataSource = baseinfo.GetAllNeckData("NeckData").Tables[0].DefaultView; this.SetdgvNeckDataListHeadText(); this.cancelEnabled(); }