//-------------------------------------------------------------- public Stores Get() { Stores retVal = new Stores(); int RowCount = 0; string DateFrom = ""; string DateTo = ""; string OrderBy = ""; int PageSize = 1; int PageNumber = 0; try { List <Stores> list = GetPage(DateFrom, DateTo, OrderBy, PageSize, PageNumber, ref RowCount); if (list.Count > 0) { retVal = list[0]; } } catch (Exception ex) { throw ex; } return(retVal); }
//----------------------------------------------------------- #region Method private List <Stores> Init(SqlCommand cmd) { SqlConnection con = db.getConnection(); cmd.Connection = con; List <Stores> l_Stores = new List <Stores>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); SmartDataReader smartReader = new SmartDataReader(reader); while (smartReader.Read()) { Stores m_Stores = new Stores(); m_Stores.StoreId = smartReader.GetByte("StoreId"); m_Stores.StoreName = smartReader.GetString("StoreName"); m_Stores.StoreDesc = smartReader.GetString("StoreDesc"); m_Stores.Address = smartReader.GetString("Address"); m_Stores.Mobile = smartReader.GetString("Mobile"); m_Stores.Email = smartReader.GetString("Email"); m_Stores.Website = smartReader.GetString("Website"); l_Stores.Add(m_Stores); } reader.Close(); return(l_Stores); } catch (SqlException err) { throw new ApplicationException("Data error: " + err.Message); } finally { db.closeConnection(con); } }