private void dgvSYOperatorInfo_CellClick(object sender, DataGridViewCellEventArgs e) { if (toolStrip1.Tag.ToString() == "EDIT") { if (dgvSYOperatorInfo.RowCount > 0) { string strIsAdmin = this.dgvSYOperatorInfo["IsAdmin", this.dgvSYOperatorInfo.CurrentCell.RowIndex].Value.ToString(); //系统管理员不许编辑 if (strIsAdmin == "1") { MessageBox.Show("系统管理员,不许编辑!", "软件提示"); return; } //判断当前记录的主键值是否存在外键约束,若存在不许修改该操作员的编码 if (commUse.IsExistConstraint("SYOperator", dgvSYOperatorInfo["OperatorCode", dgvSYOperatorInfo.CurrentCell.RowIndex].Value.ToString())) { this.txtOperatorCode.Enabled = false; } else { this.txtOperatorCode.Enabled = true; } FillControls(); } } }
private void dgvAccountInfo_CellClick(object sender, DataGridViewCellEventArgs e) { if (toolStrip1.Tag.ToString() == "EDIT") { if (dgvAccountInfo.RowCount > 0) { //对于基础类型帐户信息,不许修改帐户代码、帐户名称、会计科目 if (dgvAccountInfo[0, dgvAccountInfo.CurrentCell.RowIndex].Value.ToString() == "01" || dgvAccountInfo[0, dgvAccountInfo.CurrentCell.RowIndex].Value.ToString() == "02") { txtAccountCode.Enabled = false; txtAccountName.Enabled = false; cbxAccSubject.Enabled = false; } else { txtAccountCode.Enabled = true; txtAccountName.Enabled = true; cbxAccSubject.Enabled = true; } //判断当前记录的主键值是否存在外键约束 if (commUse.IsExistConstraint("BSAccount", dgvAccountInfo[0, dgvAccountInfo.CurrentCell.RowIndex].Value.ToString())) { txtAccountCode.Enabled = false; } else { txtAccountCode.Enabled = true; } FillControls(); } } }
private void btnDelete_Click(object sender, EventArgs e) { string strSql = null; string strInvenTypeCode = null; DataBase db = new DataBase(); if (tvInvenType.SelectedNode != null) { if (tvInvenType.SelectedNode.Tag != null) { strInvenTypeCode = tvInvenType.SelectedNode.Tag.ToString(); //判断是否存在外键约束 if (commUse.IsExistConstraint("BSInvenType", strInvenTypeCode)) { MessageBox.Show("已发生业务关系,无法删除", "软件提示"); return; } if (MessageBox.Show("确定要删除吗?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { strSql = "DELETE FROM BSInvenType WHERE InvenTypeCode = '" + strInvenTypeCode + "'"; try { if (db.ExecDataBySql(strSql) > 0) { MessageBox.Show("删除成功!", "软件提示"); commUse = new CommonUse(); commUse.BuildTree(tvInvenType, imageList1, "存货分类", "BSInvenType", "InvenTypeCode", "InvenTypeName"); } else { MessageBox.Show("删除失败!", "软件提示"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "软件提示"); } } } } }
private void dgvSupplierInfo_CellClick(object sender, DataGridViewCellEventArgs e) { if (toolStrip1.Tag.ToString() == "EDIT") { if (dgvSupplierInfo.RowCount > 0) { //判断当前记录的主键值是否存在外键约束 if (commUse.IsExistConstraint("BSSupplier", dgvSupplierInfo[0, dgvSupplierInfo.CurrentCell.RowIndex].Value.ToString())) { this.txtSupplierCode.Enabled = false; } else { this.txtSupplierCode.Enabled = true; } FillControls(); } } }
private void toolDelete_Click(object sender, EventArgs e) { string strSupplierCode = null; string strSql = null; if (dgvSupplierInfo.RowCount == 0) { return; } strSupplierCode = dgvSupplierInfo[0, dgvSupplierInfo.CurrentCell.RowIndex].Value.ToString(); //判断当前记录的主键值是否存在外键约束 if (commUse.IsExistConstraint("BSSupplier", strSupplierCode)) { MessageBox.Show("已发生业务关系,无法删除", "软件提示"); return; } strSql = "DELETE FROM BSSupplier WHERE SupplierCode = '" + strSupplierCode + "'"; if (MessageBox.Show("确定要删除吗?", "软件提示", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { try { if (db.ExecDataBySql(strSql) > 0) { MessageBox.Show("删除成功!", "软件提示"); } else { MessageBox.Show("删除失败!", "软件提示"); } } catch (Exception ex) { MessageBox.Show(ex.Message, "软件提示"); throw ex; } BindDataGridView(""); } }
private void FormCostTypeInput_Load(object sender, EventArgs e) { formCostType = (FormBSCostType)this.Owner; //在修改操作下打开FormBSCostTypeInput窗体 if (this.Tag.ToString() != "Add") { txtTypeCode.Text = formCostType.tvCostType.SelectedNode.Tag.ToString(); txtTypeName.Text = formCostType.tvCostType.SelectedNode.Text; //判断是否存在外键约束 if (commUse.IsExistConstraint("BSCostType", formCostType.tvCostType.SelectedNode.Tag.ToString())) { txtTypeCode.Enabled = false; } else { txtTypeCode.Enabled = true; } } }
private void FormBSDepartmentInput_Load(object sender, EventArgs e) { formDepartment = (FormBSDepartment)Owner; //在修改操作下打开FormDepartmentInput窗体 if (Tag.ToString() != "Add") { txtTypeCode.Text = formDepartment.tvDepartment.SelectedNode.Tag.ToString(); txtTypeName.Text = formDepartment.tvDepartment.SelectedNode.Text; //判断是否存在外键约束 if (commUse.IsExistConstraint("BSDepartment", formDepartment.tvDepartment.SelectedNode.Tag.ToString())) { txtTypeCode.Enabled = false; } else { txtTypeCode.Enabled = true; } } }