public static long Tinh_So_luong_ton_Laptop(XmlElement Laptop) { var Ton_Kho = 0L; var So_Ban = 0L; var So_Nhap = 0L; foreach (XmlElement Ban_hang in Laptop.GetElementsByTagName("Ban_hang")) { So_Ban += long.Parse(Ban_hang.GetAttribute("So_luong")); } foreach (XmlElement Nhap_hang in Laptop.GetElementsByTagName("Nhap_hang")) { So_Nhap += long.Parse(Nhap_hang.GetAttribute("So_luong")); } Ton_Kho = So_Nhap - So_Ban; return(Ton_Kho); }
//==== Tính toán ====== public static long Tinh_So_luong_Ton_San_pham(XmlElement San_pham) { var Tong_Nhap_hang = 0L; foreach (XmlElement Nhap_hang in San_pham.GetElementsByTagName("Nhap_hang")) { Tong_Nhap_hang += long.Parse(Nhap_hang.GetAttribute("So_luong")); } var Tong_Ban_hang = 0L; foreach (XmlElement Ban_hang in San_pham.GetElementsByTagName("Ban_hang")) { Tong_Ban_hang += long.Parse(Ban_hang.GetAttribute("So_luong")); } var So_luong_Ton = Tong_Nhap_hang - Tong_Ban_hang; return(So_luong_Ton); }