public BOXuliTinhTien(Transit transit,BOBanHang banhang)
        {
            mTransit = transit;
            mBanHang = new BANHANG();            
            Copy(banhang.BANHANG, mBanHang);
            mBanHang.TongTien = banhang.TongTien();

        }
 public static IQueryable<BOChiTietBanHang> Query(BANHANG banhang, KaraokeEntities kara)
 {
     var iQuery =
         //from chitiet in banhang.CHITIETBANHANGs.Where(o=>o.ChiTietBanHangID_Ref==null)
         from chitiet in kara.CHITIETBANHANGs.Where(o => o.ChiTietBanHangID_Ref == null&&o.BanHangID==banhang.BanHangID)
         join kichthuoc in kara.MENUKICHTHUOCMONs on chitiet.KichThuocMonID equals kichthuoc.KichThuocMonID
         join menu in kara.MENUMONs on kichthuoc.MonID equals menu.MonID                
         select new BOChiTietBanHang
         {
             MenuKichThuocMon = kichthuoc,
             ChiTietBanHang = chitiet,
             MenuMon = menu
         };
     return iQuery;
 }
 public void Copy(BANHANG bhFrom,BANHANG bhTo)
 {
     bhTo.BanHangID = bhFrom.BanHangID;
     bhTo.NhanVienID = bhFrom.NhanVienID;
     bhTo.BanID = bhFrom.BanID;
     bhTo.TrangThaiID = bhFrom.TrangThaiID;
     bhTo.NgayBan = bhFrom.NgayBan;
     bhTo.MaHoaDon = bhFrom.MaHoaDon;
     bhTo.TheID = bhFrom.TheID;
     bhTo.KhachHangID = bhFrom.KhachHangID;
     bhTo.GiamGia = bhFrom.GiamGia;
     bhTo.PhiDichVu = bhFrom.PhiDichVu;
     bhTo.ThueVAT = bhFrom.ThueVAT;
     bhTo.TienMat = bhFrom.TienMat;
     bhTo.TienThe = bhFrom.TienThe;
     bhTo.TienTraLai = bhFrom.TienTraLai;
     bhTo.ChietKhau = bhFrom.ChietKhau;
     bhTo.TienBo = bhFrom.TienBo;
     bhTo.TongTien = bhFrom.TongTien;
     bhTo.TienKhacHang = bhFrom.TienKhacHang;
 }        
        public void LoadBanHang(BAN ban)
        {
            BAN = ban;
            BOBanHang bh=null;
            if (ban!=null)
            {
                 bh= GetAllBanHang(ban).FirstOrDefault();
            }
            if (bh!=null)
            {                
                BANHANG = bh.BANHANG;
                KHACHHANG = bh.KHACHHANG;
                LoadChiTiet();
                ReloadGioKaraoke();
            }
            else
            {
                BANHANG = new BANHANG();
                BANHANG.NhanVienID = mTransit.NhanVien.NhanVienID;
                if (BANHANG.NhanVienID == 0)
                {
                    BANHANG.NhanVienID = null;
                }
                if (ban!=null)
                {
                    BANHANG.BanID = ban.BanID;
                }
                BANHANG.NgayBan=BANHANG.NgayKetThuc = DateTime.Now;
                BANHANG.MaHoaDon = String.Format("HD-{0:00}-{1:000000}", mTransit.ThamSo.SoMay, mTransit.ThamSo.ThuTuMaHoaDon);                
                BANHANG.TrangThaiID = 1;
                if (_CAIDATBANHANG.ChoPhepPhiDichVu)
                {
                    BANHANG.PhiDichVu = _CAIDATBANHANG.PhiDichVu;
                }
                if (_CAIDATBANHANG.ChoPhepThueVAT)
                {
                    BANHANG.ThueVAT = _CAIDATBANHANG.ThueVAT;
                }
            }

        }
 /// <summary>
 /// Create a new BANHANG object.
 /// </summary>
 /// <param name="banHangID">Initial value of the BanHangID property.</param>
 /// <param name="giamGia">Initial value of the GiamGia property.</param>
 /// <param name="phiDichVu">Initial value of the PhiDichVu property.</param>
 /// <param name="thueVAT">Initial value of the ThueVAT property.</param>
 /// <param name="soPhut">Initial value of the SoPhut property.</param>
 /// <param name="tienMat">Initial value of the TienMat property.</param>
 /// <param name="tienThe">Initial value of the TienThe property.</param>
 /// <param name="tienTraLai">Initial value of the TienTraLai property.</param>
 /// <param name="chietKhau">Initial value of the ChietKhau property.</param>
 /// <param name="tienBo">Initial value of the TienBo property.</param>
 /// <param name="tongTien">Initial value of the TongTien property.</param>
 /// <param name="tienKhacHang">Initial value of the TienKhacHang property.</param>
 public static BANHANG CreateBANHANG(global::System.Int32 banHangID, global::System.Int32 giamGia, global::System.Int32 phiDichVu, global::System.Int32 thueVAT, global::System.Int32 soPhut, global::System.Decimal tienMat, global::System.Decimal tienThe, global::System.Decimal tienTraLai, global::System.Decimal chietKhau, global::System.Decimal tienBo, global::System.Decimal tongTien, global::System.Decimal tienKhacHang)
 {
     BANHANG bANHANG = new BANHANG();
     bANHANG.BanHangID = banHangID;
     bANHANG.GiamGia = giamGia;
     bANHANG.PhiDichVu = phiDichVu;
     bANHANG.ThueVAT = thueVAT;
     bANHANG.SoPhut = soPhut;
     bANHANG.TienMat = tienMat;
     bANHANG.TienThe = tienThe;
     bANHANG.TienTraLai = tienTraLai;
     bANHANG.ChietKhau = chietKhau;
     bANHANG.TienBo = tienBo;
     bANHANG.TongTien = tongTien;
     bANHANG.TienKhacHang = tienKhacHang;
     return bANHANG;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the BANHANGs EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToBANHANGs(BANHANG bANHANG)
 {
     base.AddObject("BANHANGs", bANHANG);
 }