/// <summary> /// Generate sql sentence /// </summary> /// <param name="pkValue"></param> /// <returns></returns> /// 业务主键验证,sql private string GenerateSQLToCheckBUSPK(string tableName, DataRow dr, string busPKName, string deletedParas) { string sql = ""; string errMsg = ""; if (busPKName == "") { return(""); } sql = ConstructDMLSql.ConstructCheckBusPKSql(tableName, dr, busPKName); sql += deletedParas; if (sql == "") { return(BUSDATERR_SQL); } try { DataTable dt = _da.GetDataTable(sql); if ((int)dt.Rows[0][0] == 0) { errMsg = ""; } else { errMsg = BUSDATERR_PK; } } catch (SqlException e) { errMsg = BUSDATERR_SQL; } return(errMsg); }
/// <summary> /// if business pk exists then return the physical pk of this table,else return ""; /// </summary> /// <param name="pkValue"></param> /// <returns></returns> /// 业务主键验证,以确认新增记录应该是insert还是update private string CheckBUSPKExistForInsert(string tableName, DataRow dr, string busPKName, string pkFieldName, out string pkValue) { string sql = ""; string errMsg = ""; pkValue = ""; sql = ConstructDMLSql.ConstructCheckBusPKSql(tableName, dr, busPKName, pkFieldName); if (sql == "") { return(ERR_DAE_SAVE_PKCHECK); } try { DataTable dt = _da.GetDataTable(sql); if (dt.Rows.Count == 0) { pkValue = ""; } else { pkValue = dt.Rows[0][0].ToString(); } } catch (SqlException e) { errMsg = GetDataBaseErrorsMessage(e); } return(errMsg); }