public int Add(Sawtyyat obj) { _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = INSERTSawtyyat; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int); parameterID.Value = obj.ID; parameterID.Direction = ParameterDirection.Output; _command.Parameters.Add(parameterID); SqlParameter parameterName = new SqlParameter(PN_NAME, SqlDbType.NVarChar); parameterName.Value = obj.Name; parameterName.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterName); SqlParameter parameterPath = new SqlParameter(PN_PATH, SqlDbType.NVarChar); parameterPath.Value = obj.Path; parameterPath.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterPath); SqlParameter parameterType = new SqlParameter(PN_TYPE, SqlDbType.Int); parameterType.Value = obj.Type; parameterType.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterType); SqlParameter parameterDetails = new SqlParameter(PN_DETAILS, SqlDbType.NVarChar); parameterDetails.Value = obj.Details; parameterDetails.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterDetails); SqlParameter parameterDate = new SqlParameter(PN_DATE, SqlDbType.NVarChar); parameterDate.Value = obj.Date; parameterDate.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterDate); SqlParameter parameterCategoryID = new SqlParameter(PN_CATEGORY_ID, SqlDbType.Int); parameterCategoryID.Value = obj.CategoryID; parameterCategoryID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterCategoryID); #endregion; _connection.Open(); _command.ExecuteNonQuery(); _connection.Close(); obj.ID = Convert.ToInt32(parameterID.Value); return obj.ID; }
public void PopulateSawtyyat(SqlDataReader _dtr, Sawtyyat obj) { int columnIndex = 0; columnIndex = _dtr.GetOrdinal(SawtyyatDataMapper.CN_ID); if (!_dtr.IsDBNull(columnIndex)) { obj.ID = _dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(SawtyyatDataMapper.CN_NAME); if (!_dtr.IsDBNull(columnIndex)) { obj.Name = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(SawtyyatDataMapper.CN_PATH); if (!_dtr.IsDBNull(columnIndex)) { obj.Path = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(SawtyyatDataMapper.CN_TYPE); if (!_dtr.IsDBNull(columnIndex)) { obj.Type = (RootEnums.AudioVideoType)_dtr.GetInt32((columnIndex)); } columnIndex = _dtr.GetOrdinal(SawtyyatDataMapper.CN_DETAILS); if (!_dtr.IsDBNull(columnIndex)) { obj.Details = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(SawtyyatDataMapper.CN_DATE); if (!_dtr.IsDBNull(columnIndex)) { obj.Date = _dtr.GetString((columnIndex)); } columnIndex = _dtr.GetOrdinal(SawtyyatDataMapper.CN_CATEGORY_ID); if (!_dtr.IsDBNull(columnIndex)) { obj.CategoryID = _dtr.GetInt32((columnIndex)); } }
public IList<Sawtyyat> GetAllByType(RootEnums.AudioVideoType _rootEnums, int from, int to, ref int totalrows, int catid, string keyword) { Sawtyyat obj = null; IList<Sawtyyat> colobj = new List<Sawtyyat>(); _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = "[dbo].[SawtyyatGetAllByTypePaging]"; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_TYPE, SqlDbType.Int); parameterID.Value = Convert.ToInt32(_rootEnums); parameterID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterID); SqlParameter pfrom = new SqlParameter("From", SqlDbType.Int); pfrom.Value = from; pfrom.Direction = ParameterDirection.Input; _command.Parameters.Add(pfrom); SqlParameter pTo = new SqlParameter("To", SqlDbType.Int); pTo.Value = to; pTo.Direction = ParameterDirection.Input; _command.Parameters.Add(pTo); SqlParameter pTotalRows = new SqlParameter("TotalRows", SqlDbType.Int); pTotalRows.Value = 0; pTotalRows.Direction = ParameterDirection.Output; _command.Parameters.Add(pTotalRows); SqlParameter pcatID = new SqlParameter("CategoryID", SqlDbType.Int); pcatID.Value = catid; pcatID.Direction = ParameterDirection.Input; _command.Parameters.Add(pcatID); SqlParameter pKeyword = new SqlParameter("Keyword", SqlDbType.NVarChar); pKeyword.Value = keyword; pKeyword.Direction = ParameterDirection.Input; _command.Parameters.Add(pKeyword); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new Sawtyyat(); colobj = new List<Sawtyyat>(); while (_dtreader.Read()) { obj = GetSawtyyat(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { totalrows = Convert.ToInt32(pTotalRows.Value); _dtreader.Close(); _connection.Close(); } return colobj; }
public Sawtyyat GetSawtyyat(SqlDataReader _dtr, IList<Sawtyyat> colobj) { Sawtyyat obj = colobj.Where(t => t.ID == Convert.ToInt32(_dtr[CN_ID].ToString())).SingleOrDefault(); if (null == obj) { obj = new Sawtyyat(); colobj.Add(obj); } return obj; }
public IList<Sawtyyat> GetAllByType(RootEnums.AudioVideoType _rootEnums) { Sawtyyat obj = null; IList<Sawtyyat> colobj = null; _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = SELECTALLSawtyyat; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_TYPE, SqlDbType.Int); parameterID.Value = Convert.ToInt32(_rootEnums); parameterID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterID); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new Sawtyyat(); colobj = new List<Sawtyyat>(); while (_dtreader.Read()) { obj = GetSawtyyat(_dtreader, colobj); GetEntityFromReader(_dtreader, obj); } } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return colobj; }
private void GetEntityFromReader(SqlDataReader _dtr, Sawtyyat obj) { PopulateSawtyyat(_dtr, obj); }
public Sawtyyat GetByID(int ID) { Sawtyyat obj = null; _connection.ConnectionString = _ConnectionString; _command.Connection = _connection; _command.CommandType = CommandType.StoredProcedure; _command.CommandText = SELECTSawtyyat; #region [Parameters] SqlParameter parameterID = new SqlParameter(PN_ID, SqlDbType.Int); parameterID.Value = ID; parameterID.Direction = ParameterDirection.Input; _command.Parameters.Add(parameterID); #endregion; _connection.Open(); try { using (_dtreader = _command.ExecuteReader()) { if (_dtreader != null && _dtreader.HasRows) { obj = new Sawtyyat(); if (_dtreader.Read()) GetEntityFromReader(_dtreader, obj); } } } catch (Exception ex) { throw ex; } finally { _dtreader.Close(); _connection.Close(); } return obj; }
public static void Update(Sawtyyat obj) { SawtyyatDataMapper objCaller = new SawtyyatDataMapper(); objCaller.Update(obj); }
public static int Add(Sawtyyat obj) { SawtyyatDataMapper objCaller = new SawtyyatDataMapper(); return objCaller.Add(obj); }