public List <Date> Read() { string command = "Select * from Date"; var db = new DataAccess.DataBaseManager(); var result = db.GetData(command); var karbarList = new Karbar().Read(); var booktyoelist = new BookType().Read(); List <Date> lstResult = new List <Date>(); foreach (DataRow r in result.Rows) { Date date = new Date(); date.ID = Convert.ToInt32(r["ID"]); date.EntranceDate = Convert.ToDateTime(r["EntranceDate"]); Date daate = new Date(); daate.ID = Convert.ToInt32(r["ID"]); daate.EntranceDate = Convert.ToDateTime(r["bargasht"]); //User Karbar karbar = new Karbar(); var karbarID = Convert.ToInt64(r["KarbarId"]); date.Karbar = karbarList.FirstOrDefault(a => a.ID == karbarID); //CarType BookType bookType = new BookType(); var BookTypeID = Convert.ToInt64(r[" BookTypeID"]); date.BookType = booktyoelist.FirstOrDefault(a => a.ID == BookTypeID); lstResult.Add(date); } return(lstResult); }
public List <Karbar> Read() { string command = "Select * from [karbar]"; var db = new DataAccess.DataBaseManager(); var result = db.GetData(command); List <Karbar> lstResult = new List <Karbar>(); foreach (DataRow r in result.Rows) { Karbar karbar = new Karbar(); karbar.ID = Convert.ToInt32(r["ID"]); karbar.Name = r["Name"].ToString(); karbar.SurName = r["SurName"].ToString(); karbar.Username = r["Username"].ToString(); karbar.Password = r["Password"].ToString(); lstResult.Add(karbar); } return(lstResult); }