public void Update(HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T businessObject, HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_TKeys businessObjectKey) { try { List <string> ExceptList = new List <string>(); if (businessObject.TrafficID_bint == businessObjectKey.TrafficID_bint) { ExceptList.Add("UniqueTrafficID_bint"); } if (businessObject.IsValid(Hepsa.Core.Validation.ValidationExceptionType.Except, ExceptList.ToArray()) == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } _dataObject.Update(businessObject, businessObjectKey); // if (businessObject.Picture_vbnry != null) // { // File.WriteAllBytes($@"{BLLTrafficPictures_T.TrafficPicturePath}{businessObject.TrafficID_bint}.jpg", businessObject.Picture_vbnry); // } } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void Update(HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T businessObject, HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_TrafficPictures_T_Update]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter TrafficID_bint = new SqlParameter(); TrafficID_bint.ParameterName = "@TrafficID_bint"; TrafficID_bint.SqlDbType = SqlDbType.BigInt; TrafficID_bint.Direction = ParameterDirection.Input; TrafficID_bint.IsNullable = false; TrafficID_bint.Value = businessObject.TrafficID_bint; this.Command.Parameters.Add(TrafficID_bint); SqlParameter Picture_vbnry = new SqlParameter(); Picture_vbnry.ParameterName = "@Picture_vbnry"; Picture_vbnry.SqlDbType = SqlDbType.VarBinary; Picture_vbnry.Direction = ParameterDirection.Input; Picture_vbnry.IsNullable = false; Picture_vbnry.Value = businessObject.Picture_vbnry; this.Command.Parameters.Add(Picture_vbnry); SqlParameter pk_TrafficID_bint = new SqlParameter(); pk_TrafficID_bint.ParameterName = "@pk_TrafficID_bint"; pk_TrafficID_bint.SqlDbType = SqlDbType.BigInt; pk_TrafficID_bint.Direction = ParameterDirection.Input; pk_TrafficID_bint.IsNullable = false; pk_TrafficID_bint.Value = businessObjectKey.TrafficID_bint; this.Command.Parameters.Add(pk_TrafficID_bint); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
public HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T SelectByPrimaryKey(HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_TrafficPictures_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter TrafficID_bint = new SqlParameter(); TrafficID_bint.ParameterName = "@TrafficID_bint"; TrafficID_bint.SqlDbType = SqlDbType.BigInt; TrafficID_bint.Direction = ParameterDirection.Input; TrafficID_bint.IsNullable = false; TrafficID_bint.Value = businessObjectKey.TrafficID_bint; this.Command.Parameters.Add(TrafficID_bint); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T businessObject = new HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T(); if (dataReader.Read()) { PopulateBusinessObjectFromReader(businessObject, dataReader); } else { businessObject = null; } if (dataReader.IsClosed == false) { dataReader.Close(); } if (ControlConnection) { this.Commit(); } return(businessObject); } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }
public void PopulateBusinessObjectFromReader(HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T businessObject, IDataReader dataReader) { try { businessObject.TrafficID_bint = dataReader.GetInt64(dataReader.GetOrdinal(HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T.TrafficPictures_TField.TrafficID_bint.ToString())); businessObject.Picture_vbnry = (Byte[])dataReader.GetValue(dataReader.GetOrdinal(HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T.TrafficPictures_TField.Picture_vbnry.ToString())); } catch (System.Exception ex) { dataReader.Close(); throw ex; } }
public List <HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T> PopulateObjectsFromReader(IDataReader dataReader) { try { List <HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T> list = new List <HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T>(); while (dataReader.Read()) { HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T businessObject = new HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); } catch (System.Exception ex) { dataReader.Close(); throw ex; } }
public void Insert(HPS.BLL.TrafficPicturesBLL.BLLTrafficPictures_T businessObject) { try { if (businessObject.IsValid() == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } _dataObject.Insert(businessObject); // if (businessObject.Picture_vbnry != null) // { // File.WriteAllBytes($@"{BLLTrafficPictures_T.TrafficPicturePath}{businessObject.TrafficID_bint}.jpg", businessObject.Picture_vbnry); // } } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }