public List<GioHangViewModels> GetGioHangCookies(string idSanPham) { HtmlHelperGeneral.openConnection(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = "GetGioHangCookies"; sqlCommand.CommandType = CommandType.StoredProcedure; SqlParameter i_QLSP_ID = sqlCommand.Parameters.Add("@idSanPham", SqlDbType.VarChar); i_QLSP_ID.Direction = ParameterDirection.Input; i_QLSP_ID.Value = idSanPham; sqlCommand.Connection = HtmlHelperGeneral.con; SqlDataReader reader = sqlCommand.ExecuteReader(); List<GioHangViewModels> ghSanPham = new List<GioHangViewModels>(); while (reader.Read()) { GioHangViewModels h = new GioHangViewModels(); h.QLSP_ID = reader.GetInt32NullCheck(0); h.tenSanPham = reader.GetStringNullCheck(1); h.Gia = reader.GetFloatNullCheck(2); h.tenShop = reader.GetStringNullCheck(3); h.hinhAnh = reader.GetStringNullCheck(4); h.AccountID = reader.GetInt32NullCheck(5); ghSanPham.Add(h); } reader.NextResult(); HtmlHelperGeneral.Close(); return ghSanPham; }
public List<GioHangViewModels> GetGioHang(int? accountID) { SqlConnection sqlConnection = new SqlConnection(); sqlConnection.ConnectionString = MyConnectionString1; SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = "GetGioHang"; sqlCommand.CommandType = CommandType.StoredProcedure; SqlParameter i_QLSP_ID = sqlCommand.Parameters.Add("@AccountID", SqlDbType.Int); i_QLSP_ID.Direction = ParameterDirection.Input; i_QLSP_ID.Value = accountID; sqlCommand.Connection = sqlConnection; sqlConnection.Open(); SqlDataReader reader = sqlCommand.ExecuteReader(); List<GioHangViewModels> ghSanPham = new List<GioHangViewModels>(); while (reader.Read()) { GioHangViewModels h = new GioHangViewModels(); h.QLSP_ID = reader.GetInt32(0); h.GioHang_ID = reader.GetInt32(1); h.tenSanPham = reader.GetString(2); h.Gia = reader.GetDouble(3); h.SoLuong = reader.GetInt32(4); h.ThanhTien = reader.GetDouble(5); h.tenShop = reader.GetString(6); ghSanPham.Add(h); } reader.NextResult(); return ghSanPham; }
public List<GioHangViewModels> GetGioHang(int? accountID) { HtmlHelperGeneral.openConnection(); SqlCommand sqlCommand = new SqlCommand(); sqlCommand.CommandText = "GetGioHang"; sqlCommand.CommandType = CommandType.StoredProcedure; SqlParameter i_QLSP_ID = sqlCommand.Parameters.Add("@AccountID", SqlDbType.Int); i_QLSP_ID.Direction = ParameterDirection.Input; i_QLSP_ID.Value = accountID; sqlCommand.Connection = HtmlHelperGeneral.con; SqlDataReader reader = sqlCommand.ExecuteReader(); List<GioHangViewModels> ghSanPham = new List<GioHangViewModels>(); while (reader.Read()) { GioHangViewModels h = new GioHangViewModels(); h.QLSP_ID = reader.GetInt32NullCheck(0); h.GioHang_ID = reader.GetInt32NullCheck(1); h.tenSanPham = reader.GetStringNullCheck(2); h.Gia = reader.GetDouble(3); h.SoLuong = reader.GetInt32NullCheck(4); h.ThanhTien = reader.GetDouble(5); h.tenShop = reader.GetStringNullCheck(6); h.hinhAnh = reader.GetStringNullCheck(7); h.AccountID = reader.GetInt32NullCheck(8); ghSanPham.Add(h); } reader.NextResult(); HtmlHelperGeneral.Close(); return ghSanPham; }