public static long Tinh_Tong_So_Laptop_Chon(XmlElement Danh_sach_Laptop) { var Kq = 0L; foreach (XmlElement Laptop in Danh_sach_Laptop.GetElementsByTagName("Laptop")) { var Ban_hang = (XmlElement)Laptop.GetElementsByTagName("Ban_hang")[0]; Kq += long.Parse(Ban_hang.GetAttribute("So_luong")); } return(Kq); }
public static string Tao_Chuoi_HTML_Danh_sach_Laptop_Chon(List <XmlElement> Danh_sach_Laptop) { var Chuoi_HTML_Danh_sach = "<div class='row' >"; if (Danh_sach_Laptop.Count > 0) { Chuoi_HTML_Danh_sach = "<div class='row' style='border:1px solid blue;margin:5px;padding:5px'>"; var Chuoi_Chuc_nang_Dat_hang = "<div class='col-md-12'><form method='post'>" + "<input name='Th_Ma_so_Chuc_nang' type='hidden' value='DAT_HANG' />" + "<button type='submit' class='btn btn-danger'>Đặt hàng</button>" + "</form></div>"; Chuoi_HTML_Danh_sach += Chuoi_Chuc_nang_Dat_hang; } foreach (XmlElement Laptop in Danh_sach_Laptop) { var Ten = Laptop.GetAttribute("Ten"); var Ma_so = Laptop.GetAttribute("Ma_so"); var Don_gia_Ban = long.Parse(Laptop.GetAttribute("Don_gia_Ban")); var Ban_hang = (XmlElement)Laptop.GetElementsByTagName("Ban_hang")[0]; var So_luong = Laptop.GetAttribute("So_luong"); var Chuoi_Hinh = $"<img src='{Dia_chi_Media}/{ Ma_so}.png' " + "style='width:90px;height:90px;' />"; var Chuoi_Chuc_nang_Giam_So_luong = "<form method='post'>" + "<input name='Th_Ma_so_Chuc_nang' type='hidden' value='GIAM_SO_LUONG_LAPTOP' />" + $"<input name='Th_Ma_so_Laptop' type='hidden' value='{Ma_so}' />" + "<button type='submit' class='btn btn-danger'>-</button>" + "</form>"; var Chuoi_Thong_tin = $"<div> " + $"<strong>{Ten}</strong>" + $"<br />{ Don_gia_Ban.ToString("c0", Dinh_dang_VN) }" + $"<br />Số lượng: { So_luong}" + $"{Chuoi_Chuc_nang_Giam_So_luong}" + $"</div>"; var Chuoi_HTML = $"<div class='col-md-3' style='margin-bottom:10px' >" + $"{Chuoi_Hinh}" + $"{Chuoi_Thong_tin}" + "</div>"; Chuoi_HTML_Danh_sach += Chuoi_HTML; } Chuoi_HTML_Danh_sach += "</div>"; return(Chuoi_HTML_Danh_sach); }