//判断当前下拉框内容是否使用过,使用过返回true(不可被删除),没使用过返回false(可以被删除)。 private bool DoValidData(string sDetailIndex, string sComboValue) { string sql = "select TableName,FieldName from ComboData as c,ComboDataDetail as cd where c.ComboDataIndex = cd.ComboDataIndex and cd.DetailIndex = '" + sDetailIndex + "'"; DataTable dt = SQLDBBase.ExecuteDataTable(sql); string sTableName = dt.Rows[0]["TableName"].ToString(); string sFieldName = dt.Rows[0]["FieldName"].ToString(); string sSQL = "select * from " + sTableName + " where " + sFieldName + " = '" + sComboValue + "'";// return(SQLDBBase.RecordExists(sSQL)); }
//检验数据是否重复录入,返回true则已存在,禁止添加;返回false则不存在,可以添加。 private bool DoRepeat() { string sSQL = "SELECT * FROM ComboDataDetail as c, ComboData as cd WHERE c.ComboDataIndex = cd.ComboDataIndex and cd.ComboDataIndex = '" + tvComboName.SelectedNode.Tag.ToString() + "' and c.ComboValue = '" + TbComboValue.Text.Trim() + "'"; return(SQLDBBase.RecordExists(sSQL)); }