/// <summary> /// Select tat ca hang hoa trong kho /// </summary> /// <returns></returns> public Entities.ChiTietKhoHang[] SelectAll() { List<Entities.ChiTietKhoHang> arrC = new List<ChiTietKhoHang>(); try { string sql = ""; sql = "Select b.MaKho, b.MaHangHoa, a.TenHangHoa, b.NgayNhap,b.HanSuDung,b.SoLuong,b.GhiChu from HangHoa a join ChiTietKhoHang b on a.MaHangHoa=b.MaHangHoa where b.Deleted='false'"; conn = new Connection(); cn = conn.openConnection(); cmd = new SqlCommand(sql, cn); dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { Entities.ChiTietKhoHang ctkho = new Entities.ChiTietKhoHang(); ctkho.MaKho = dr["MaKho"].ToString(); ctkho.MaHangHoa = dr["MaHangHoa"].ToString(); ctkho.TenHangHoa = dr["TenHangHoa"].ToString(); ctkho.SoLuong = Convert.ToInt32(dr["SoLuong"].ToString()); ctkho.NgayNhap = DateTime.Parse(dr["NgayNhap"].ToString()); ctkho.HanSuDung = DateTime.Parse(dr["HanSuDung"].ToString()); ctkho.GhiChu = dr["GhiChu"].ToString(); arrC.Add(ctkho); } } catch (Exception ex) { string s = ex.Message.ToString(); } finally { cmd.Connection.Dispose(); cn.Close(); conn.closeConnection(); } return arrC.ToArray(); }