コード例 #1
0
        public void ThemMA(string maMA, int soLuong)
        {
            MonAn i = cthd.Find(x => x.GetMa().Equals(maMA));

            if (i != null)
            {
                i.TangSL(soLuong);
                tongTien += (i.GetDonGia() * soLuong);
                Data.Update("CTHD", "SoLuong =" + i.GetSL() + ", ThanhTien =" + i.GetThanhTien(), "MaHD = " + maHD + " and MaMA =" + maMA);
                Data.Update("HoaDon", "TongTien =" + tongTien, "MaHD =" + this.maHD);
                return;
            }
            else
            {
                this.cthd.Add(new MonAn(maMA, soLuong));
                MonAn  ma        = cthd[cthd.Count() - 1];
                double thanhtien = ma.GetDonGia() * soLuong;
                tongTien += thanhtien;
                Data.Add("CTHD", "MaHD, MaMA, TenMA, SoLuong, DonGia, ThanhTien", "'" + maHD + "','" + maMA + "','" + ma.GetTen() + "','" + soLuong + "','" + ma.GetDonGia() + "','" + thanhtien + "'");
                Data.Update("HoaDon", "TongTien =" + tongTien, "MaHD =" + this.maHD);
            }
        }