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