public void PopulateBusinessObjectFromReader(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T businessObject, IDataReader dataReader) { try { businessObject.InCameraPicturesID_bint = dataReader.GetInt64(dataReader.GetOrdinal(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T.InCameraPictures_TField.InCameraPicturesID_bint.ToString())); businessObject.Date_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T.InCameraPictures_TField.Date_vc.ToString())); businessObject.Time_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T.InCameraPictures_TField.Time_vc.ToString())); businessObject.Picture_img = (Byte[])dataReader.GetValue(dataReader.GetOrdinal(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T.InCameraPictures_TField.Picture_img.ToString())); businessObject.PlateNumber_nvc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T.InCameraPictures_TField.PlateNumber_nvc.ToString())); businessObject.PlateSerial_vc = dataReader.GetString(dataReader.GetOrdinal(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T.InCameraPictures_TField.PlateSerial_vc.ToString())); if (dataReader.IsDBNull(dataReader.GetOrdinal(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T.InCameraPictures_TField.TrafficTypeID_int.ToString())) == false) { businessObject.TrafficTypeID_int = dataReader.GetInt32(dataReader.GetOrdinal(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T.InCameraPictures_TField.TrafficTypeID_int.ToString())); } else { businessObject.TrafficTypeID_int = null; } } catch (System.Exception ex) { dataReader.Close(); throw ex; } }
public HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T SelectByPrimaryKey(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_TKeys businessObjectKey) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_InCameraPictures_T_SelectByPrimaryKey]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter InCameraPicturesID_bint = new SqlParameter(); InCameraPicturesID_bint.ParameterName = "@InCameraPicturesID_bint"; InCameraPicturesID_bint.SqlDbType = SqlDbType.BigInt; InCameraPicturesID_bint.Direction = ParameterDirection.Input; InCameraPicturesID_bint.IsNullable = false; InCameraPicturesID_bint.Value = businessObjectKey.InCameraPicturesID_bint; this.Command.Parameters.Add(InCameraPicturesID_bint); if (ControlConnection) { this.BeginTransaction(); } IDataReader dataReader = this.Command.ExecuteReader(); HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T businessObject = new HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_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 Insert(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T businessObject) { try { if (businessObject.IsValid() == false) { throw new Hepsa.Core.Validation.InvalidBusinessObjectException(businessObject.BrokenRulesList().ToString()); } _dataObject.Insert(businessObject); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public List <HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T> PopulateObjectsFromReader(IDataReader dataReader) { try { List <HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T> list = new List <HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T>(); while (dataReader.Read()) { HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T businessObject = new HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T(); PopulateBusinessObjectFromReader(businessObject, dataReader); list.Add(businessObject); } return(list); } catch (System.Exception ex) { dataReader.Close(); throw ex; } }
public void Update(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T businessObject, HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_TKeys businessObjectKey) { try { List <string> ExceptList = new List <string>(); if (businessObject.InCameraPicturesID_bint == businessObjectKey.InCameraPicturesID_bint) { ExceptList.Add("UniqueInCameraPicturesID_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); } catch (System.Exception ex) { throw Hepsa.Core.Exception.HandleException.ChangeExceptionLanguage(ex, this); } }
public void Insert(HPS.BLL.InCameraPicturesBLL.BLLInCameraPictures_T businessObject) { bool ControlConnection = !(this.ConnectionState == System.Data.ConnectionState.Open); this.Command.CommandText = "[sp_InCameraPictures_T_Add]"; this.Command.CommandType = CommandType.StoredProcedure; try { this.Command.Parameters.Clear(); SqlParameter InCameraPicturesID_bint = new SqlParameter(); InCameraPicturesID_bint.ParameterName = "@InCameraPicturesID_bint"; InCameraPicturesID_bint.SqlDbType = SqlDbType.BigInt; InCameraPicturesID_bint.Direction = ParameterDirection.Output; InCameraPicturesID_bint.IsNullable = false; InCameraPicturesID_bint.Value = businessObject.InCameraPicturesID_bint; this.Command.Parameters.Add(InCameraPicturesID_bint); SqlParameter Date_vc = new SqlParameter(); Date_vc.ParameterName = "@Date_vc"; Date_vc.SqlDbType = SqlDbType.VarChar; Date_vc.Direction = ParameterDirection.Input; Date_vc.IsNullable = false; Date_vc.Value = businessObject.Date_vc; this.Command.Parameters.Add(Date_vc); SqlParameter Time_vc = new SqlParameter(); Time_vc.ParameterName = "@Time_vc"; Time_vc.SqlDbType = SqlDbType.VarChar; Time_vc.Direction = ParameterDirection.Input; Time_vc.IsNullable = false; Time_vc.Value = businessObject.Time_vc; this.Command.Parameters.Add(Time_vc); SqlParameter Picture_img = new SqlParameter(); Picture_img.ParameterName = "@Picture_img"; Picture_img.SqlDbType = SqlDbType.Image; Picture_img.Direction = ParameterDirection.Input; Picture_img.IsNullable = false; Picture_img.Value = businessObject.Picture_img; this.Command.Parameters.Add(Picture_img); SqlParameter PlateNumber_nvc = new SqlParameter(); PlateNumber_nvc.ParameterName = "@PlateNumber_nvc"; PlateNumber_nvc.SqlDbType = SqlDbType.NVarChar; PlateNumber_nvc.Direction = ParameterDirection.Input; PlateNumber_nvc.IsNullable = false; PlateNumber_nvc.Value = businessObject.PlateNumber_nvc; this.Command.Parameters.Add(PlateNumber_nvc); SqlParameter PlateSerial_vc = new SqlParameter(); PlateSerial_vc.ParameterName = "@PlateSerial_vc"; PlateSerial_vc.SqlDbType = SqlDbType.VarChar; PlateSerial_vc.Direction = ParameterDirection.Input; PlateSerial_vc.IsNullable = false; PlateSerial_vc.Value = businessObject.PlateSerial_vc; this.Command.Parameters.Add(PlateSerial_vc); SqlParameter TrafficTypeID_int = new SqlParameter(); TrafficTypeID_int.ParameterName = "@TrafficTypeID_int"; TrafficTypeID_int.SqlDbType = SqlDbType.Int; TrafficTypeID_int.Direction = ParameterDirection.Input; TrafficTypeID_int.IsNullable = true; if (businessObject.TrafficTypeID_int.HasValue == false) { TrafficTypeID_int.Value = DBNull.Value; } else { TrafficTypeID_int.Value = businessObject.TrafficTypeID_int; } this.Command.Parameters.Add(TrafficTypeID_int); if (ControlConnection) { this.BeginTransaction(); } this.Command.ExecuteNonQuery(); businessObject.InCameraPicturesID_bint = (Int64)(this.Command.Parameters["@InCameraPicturesID_bint"].Value); if (ControlConnection) { this.Commit(); } } catch (System.Exception ex) { if (ControlConnection) { this.RollBack(); } throw ex; } }