//-------------------------------------------------------------- public static Districts Static_Get(short DistrictId, List <Districts> list) { Districts RetVal = new Districts(); try { RetVal = list.Find(i => i.DistrictId == DistrictId); if (RetVal == null) { RetVal = new Districts(); } } catch (Exception ex) { throw ex; } return(RetVal); }
//-------------------------------------------------------------- public Districts Get(short DistrictId) { Districts RetVal = new Districts(); try { List <Districts> list = GetListByDistrictId(DistrictId); if (list.Count > 0) { RetVal = (Districts)list[0]; } } catch (Exception ex) { throw ex; } return(RetVal); }
//----------------------------------------------------------------- private List <Districts> Init(SqlCommand cmd) { SqlConnection con = db.GetConnection(); cmd.Connection = con; List <Districts> l_Districts = new List <Districts>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); SmartDataReader smartReader = new SmartDataReader(reader); while (smartReader.Read()) { Districts m_Districts = new Districts(db.ConnectionString); m_Districts.DistrictId = smartReader.GetInt16("DistrictId"); m_Districts.DistrictName = smartReader.GetString("DistrictName"); m_Districts.DistrictDesc = smartReader.GetString("DistrictDesc"); m_Districts.CountryId = smartReader.GetInt16("CountryId"); m_Districts.ProvinceId = smartReader.GetInt16("ProvinceId"); m_Districts.DisplayOrder = smartReader.GetInt16("DisplayOrder"); m_Districts.CrUserId = smartReader.GetInt32("CrUserId"); m_Districts.CrDateTime = smartReader.GetDateTime("CrDateTime"); l_Districts.Add(m_Districts); } reader.Close(); return(l_Districts); } catch (SqlException err) { throw new ApplicationException("Data error: " + err.Message); } finally { db.closeConnection(con); } }