private bool DeleteProperty(tInput oInput, ILambdaContext context, ref SqlConnection oSqlConnection) { SqlCommand sqlComm; string strQuery; try { strQuery = " Update Property Set " + " Deleted = 1 " + " Where " + " PropertyID = @PropertyID "; sqlComm = oSqlConnection.CreateCommand(); sqlComm.CommandText = strQuery; SqlParameter sqlParamPropertyID = new SqlParameter("@PropertyID", SqlDbType.Int); sqlParamPropertyID.Value = oInput.PropertyID; sqlComm.Parameters.Add(sqlParamPropertyID); sqlComm.ExecuteNonQuery(); sqlComm.Dispose(); } catch (Exception ex) { context.Logger.LogLine("UpdateSite Ex " + ex.Message); return(false); } return(true); }
private bool UpdateProperty(tInput oInput, ILambdaContext context, ref SqlConnection oSqlConnection) { SqlCommand sqlComm; string strQuery; try { strQuery = " Update Property Set " + " SiteID = @SiteID, " + " PropertyNumber = @PropertyNumber, " + " BlockName = @BlockName, " + " BlockKey = @BlockKey, " + " PropertyReference = @PropertyReference, " + " BlockAddress = @BlockAddress, " + " BlockPostCode = @BlockPostCode, " + " ArchivedProperty = @ArchivedProperty, " + " ArchivedReason = @ArchivedReason, " + " ArchivedWho = @ArchivedWho, " + " ArchivedWhen = @ArchivedWhen, " + " Deleted = 0 " + " Where " + " PropertyID = @PropertyID "; sqlComm = oSqlConnection.CreateCommand(); sqlComm.CommandText = strQuery; SqlParameter sqlParamPropertyID = new SqlParameter("@PropertyID", SqlDbType.Int); sqlParamPropertyID.Value = oInput.PropertyID; sqlComm.Parameters.Add(sqlParamPropertyID); SqlParameter sqlParamSiteID = new SqlParameter("@SiteID", SqlDbType.Int); sqlParamSiteID.Value = oInput.SiteID; sqlComm.Parameters.Add(sqlParamSiteID); SqlParameter sqlParamPropertyNumber = new SqlParameter("@PropertyNumber", SqlDbType.NVarChar); sqlParamPropertyNumber.Value = oInput.PropertyNumber; sqlComm.Parameters.Add(sqlParamPropertyNumber); SqlParameter sqlParamBlockName = new SqlParameter("@BlockName", SqlDbType.NVarChar); sqlParamBlockName.Value = oInput.BlockName; sqlComm.Parameters.Add(sqlParamBlockName); SqlParameter sqlParamBlockKey = new SqlParameter("@BlockKey", SqlDbType.NVarChar); sqlParamBlockKey.Value = oInput.BlockKey; sqlComm.Parameters.Add(sqlParamBlockKey); SqlParameter sqlParamPropertyReference = new SqlParameter("@PropertyReference", SqlDbType.NVarChar); sqlParamPropertyReference.Value = oInput.PropertyReference; sqlComm.Parameters.Add(sqlParamPropertyReference); SqlParameter sqlParamBlockAddress = new SqlParameter("@BlockAddress", SqlDbType.NVarChar); sqlParamBlockAddress.Value = oInput.BlockAddress; sqlComm.Parameters.Add(sqlParamBlockAddress); SqlParameter sqlParamBlockPostCode = new SqlParameter("@BlockPostCode", SqlDbType.NVarChar); sqlParamBlockPostCode.Value = oInput.BlockPostCode; sqlComm.Parameters.Add(sqlParamBlockPostCode); SqlParameter sqlParamArchivedProperty = new SqlParameter("@ArchivedProperty", SqlDbType.Bit); sqlParamArchivedProperty.Value = oInput.ArchivedProperty; sqlComm.Parameters.Add(sqlParamArchivedProperty); SqlParameter sqlParamArchivedReason = new SqlParameter("@ArchivedReason", SqlDbType.NVarChar); sqlParamArchivedReason.Value = oInput.ArchivedReason; sqlComm.Parameters.Add(sqlParamArchivedReason); SqlParameter sqlParamArchivedWho = new SqlParameter("@ArchivedWho", SqlDbType.NVarChar); sqlParamArchivedWho.Value = oInput.ArchivedWho; sqlComm.Parameters.Add(sqlParamArchivedWho); SqlParameter sqlParamArchivedWhen = new SqlParameter("@ArchivedWhen", SqlDbType.DateTime); if (oInput.ArchivedWhen == "") { sqlParamArchivedWhen.Value = DBNull.Value; } else { sqlParamArchivedWhen.Value = ecoCommon.DateJson(oInput.ArchivedWhen); } sqlComm.Parameters.Add(sqlParamArchivedWhen); sqlComm.ExecuteNonQuery(); sqlComm.Dispose(); } catch (Exception ex) { context.Logger.LogLine("UpdateSite Ex " + ex.Message); return(false); } return(true); }