public bool GetRepNameCheck(string TableName, StringDictionary dicItemData, StringDictionary dicPrimarName, string strRepFiledName, Common.DataModifyMode ScanMode) { throw new Exception("The method or operation is not implemented."); }
/// <summary> /// 数据重名检查(主键重复) /// </summary> /// <param name="TableName">数据表名称</param> /// <param name="dicItemData">数据内容</param> /// <param name="dicPrimarName">主键列名</param> /// <param name="strRepFiledName">重名检测列名</param> /// <param name="ScanMode">画面模式</param> /// <returns></returns> public bool GetRepNameCheck(String TableName, StringDictionary dicItemData, StringDictionary dicPrimarName, String strRepFiledName, Common.DataModifyMode ScanMode) { bool IsExist = false; DataTable dt = new DataTable(); int rowIndex = 0; SqlParameter[] cmdParamters = null; SqlParameter SqlParameter = null; string w_strWhere = ""; strRepFiledName = strRepFiledName.ToLower(); try { if (dicItemData == null || dicItemData.Count <= 0 || dicPrimarName == null || dicPrimarName.Count <= 0 || string.IsNullOrEmpty(strRepFiledName) == true) { return(false); } string strSql = "SELECT CAST('0' AS Bit) AS SlctValue," + TableName + ".* " + " FROM " + TableName + " WHERE 1=1 "; Common.AdoConnect.Connect.ConnectOpen(); cmdParamters = new SqlParameter[dicPrimarName.Count + 1]; foreach (string strKey in dicPrimarName.Keys) { if (dicItemData.ContainsKey(strKey) == true && ScanMode == Common.DataModifyMode.upd) { w_strWhere += " AND " + strKey + "<>@" + strKey; SqlParameter = new SqlParameter("@" + strKey, DataFiledType.FiledType[strKey]); SqlParameter.Value = dicItemData[strKey]; SqlParameter.Direction = ParameterDirection.Input; cmdParamters[rowIndex] = SqlParameter; rowIndex++; } } if (dicItemData.ContainsKey(strRepFiledName) == true) { w_strWhere += " AND " + strRepFiledName + "=@" + strRepFiledName; SqlParameter = new SqlParameter("@" + strRepFiledName, DataFiledType.FiledType[strRepFiledName]); SqlParameter.Value = dicItemData[strRepFiledName]; SqlParameter.Direction = ParameterDirection.Input; cmdParamters[rowIndex] = SqlParameter; } strSql += w_strWhere; dt = Common.AdoConnect.Connect.GetDataSet(strSql, cmdParamters); if (dt != null) { if (dt.Rows.Count > 0) { IsExist = true; } } return(IsExist); } catch (Exception ex) { throw ex; } }