//删除数据 private void button2_Click(object sender, EventArgs e) { if (dgvConditionTreatRecordList.SelectedRows.Count >= 1) { TAB_PERSON_DATA userobj = dgvConditionTreatRecordList.SelectedRows[0].Tag as TAB_PERSON_DATA; if (MessageBox.Show("删除所选的记录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { Cursor.Current = Cursors.WaitCursor; try { if (databll.Delete(userobj)) { GetList(txtName.Text.Trim(), SetType(txtType.Text.Trim())); } else { MessageBox.Show("删除失败!", "请联系管理员"); } } finally { Cursor.Current = Cursors.Default; } } } else { MessageBox.Show("请选择要的删除的行!", "系统提示"); } }
private void dgvConditionTreatRecordList_CellClick(object sender, DataGridViewCellEventArgs e) { int indexs = dgvConditionTreatRecordList.RowCount; if (indexs <= 0) { return; } this.data_id = Convert.ToInt32(this.dgvConditionTreatRecordList.SelectedRows[0].Cells[1].Value);//信息id TAB_PERSON_DATA dataobj = databll.Get(data_id); name.Text = dataobj.NAME; code.Text = dataobj.CODE; type.Text = GetType(dataobj.TYPE); }
private void btnInput_Click(object sender, EventArgs e) { TAB_PERSON_DATA newobj = new TAB_PERSON_DATA(); newobj.NAME = name.Text.Trim(); newobj.CODE = code.Text.Trim(); newobj.TYPE = SetType(type.Text.Trim()); if (databll.Add(newobj)) { MessageBox.Show("添加成功!"); GetList(txtName.Text.Trim(), SetType(txtType.Text.Trim())); } else { MessageBox.Show("添加失败!"); } }
//修改数据 private void button1_Click(object sender, EventArgs e) { if (dgvConditionTreatRecordList.SelectedRows.Count >= 1) { TAB_PERSON_DATA updataobj = databll.Get(data_id); updataobj.NAME = name.Text.Trim(); updataobj.CODE = code.Text.Trim(); updataobj.TYPE = SetType(type.Text.Trim()); if (databll.Update(updataobj)) { MessageBox.Show("修改成功!"); GetList(txtName.Text.Trim(), SetType(txtType.Text.Trim())); } else { MessageBox.Show("修改失败!"); } } else { MessageBox.Show("请选择要修改的行!", "系统提示"); } }