//-------------------------------------------------------------- public Materials Get() { Materials retVal = new Materials(); int RowCount = 0; string DateFrom = ""; string DateTo = ""; string OrderBy = ""; int PageSize = 1; int PageNumber = 0; try { List <Materials> 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 <Materials> Init(SqlCommand cmd) { SqlConnection con = db.getConnection(); cmd.Connection = con; List <Materials> l_Materials = new List <Materials>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); SmartDataReader smartReader = new SmartDataReader(reader); while (smartReader.Read()) { Materials m_Materials = new Materials(); m_Materials.MaterialId = smartReader.GetInt32("MaterialId"); m_Materials.MaterialName = smartReader.GetString("MaterialName"); m_Materials.UnitId = smartReader.GetInt16("UnitId"); m_Materials.Percentage = smartReader.Get("Percentage"); m_Materials.ImagePath = smartReader.GetString("ImagePath"); m_Materials.CrUserId = smartReader.GetInt32("CrUserId"); m_Materials.CrDateTime = smartReader.GetDateTime("CrDateTime"); l_Materials.Add(m_Materials); } reader.Close(); return(l_Materials); } catch (SqlException err) { throw new ApplicationException("Data error: " + err.Message); } finally { db.closeConnection(con); } }