private void 除检测技术ToolStripMenuItem_Click(object sender, EventArgs e) { try { if (this.gridView4.RowCount > 0) { if (this.gridView4.GetSelectedRows()[0] < 0) { MessageBox.Show("没有选中信息,请选择!", "提示", MessageBoxButtons.OK); return; } else { if (MessageBox.Show("确认删除检测技术信息", "确认信息", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.OK) { DETECTION_TECHNOLOGYInDao dao = new DETECTION_TECHNOLOGYInDao(); string LATHE_ID = this.gridView4.GetRowCellValue(this.gridView4.FocusedRowHandle, this.gridView4.Columns[0]).ToString(); if (dao.delete(LATHE_ID)) { FreshForm(); } } } } } catch (System.Exception ex) { MessageBox.Show("删除失败,这条数据被其他数据所引用,请先删除使用了该数据的子信息!\n\n详细信息:\n" + ex.Message, "提示信息"); return; } }
//添加检测技术 private void simpleButton2_Click(object sender, EventArgs e) { DETECTION_TECHNOLOGYInDao dao = new DETECTION_TECHNOLOGYInDao(); string name = textEdit4.Text.Trim(); //控制参数格式 if (name == "") { MessageBox.Show("信息不能为空!"); return; } string sql1 = "select * from DETECTION_TECHNOLOGY where Detection_Technology_NAME = '" + name + "'"; if (common.SqlHelper.ExcuteSql(sql1) > 0) { MessageBox.Show("该检测技术已被添加过!", "信息提示", MessageBoxButtons.OK); return; } dao.Save(this.textEdit4.Text.Trim()); FreshForm(); }
//保存检测技术信息 private void simpleButton1_Click(object sender, EventArgs e) { DETECTION_TECHNOLOGYInDao dao = new DETECTION_TECHNOLOGYInDao(); string name = Detection_Technology_NAME.Text.Trim(); //控制参数格式 if (name == "") { MessageBox.Show("信息不能为空!"); return; } switch (strOperationFlag) { case "add": string sql1 = "select * from DETECTION_TECHNOLOGY where Detection_Technology_NAME = '" + name + "'"; if (common.SqlHelper.ExcuteSql(sql1) > 0) { MessageBox.Show("该检测技术已被添加过!", "信息提示", MessageBoxButtons.OK); return; } dao.Save(this.Detection_Technology_NAME.Text.Trim()); this.DialogResult = DialogResult.OK; this.Close(); break; case "modify": string sql2 = "select count(*) from DETECTION_TECHNOLOGY where Detection_Technology_NAME = '" + name + "' and DetectionTechnology_ID <> '" + DetectionTechnology_ID + "'"; if (common.SqlHelper.ExcuteSql(sql2) > 0) { MessageBox.Show("该检测技术已被添加过!", "信息提示", MessageBoxButtons.OK); this.Detection_Technology_NAME.Focus(); return; } dao.Modify(DetectionTechnology_ID, this.Detection_Technology_NAME.Text.Trim()); this.DialogResult = DialogResult.OK; this.Close(); break; } }