public void thanhToanHoaDon(string maHD, string maNV, string maKH, string tongTien, string dungDiemTichLuy, string tichDiem, List <CHITIET_HD> gioHang)
        {
            HOA_DON newHD = new HOA_DON();

            newHD.MAHD     = maHD;
            newHD.MANV     = maNV;
            newHD.MAKH     = maKH;
            newHD.TONGTIEN = Double.Parse(tongTien);
            newHD.NGAYLAP  = DateTime.Today;
            newHD.GIAMGIA  = Double.Parse(dungDiemTichLuy);
            context.HOA_DONs.InsertOnSubmit(newHD);
            context.SubmitChanges();
            context.CHITIET_HDs.InsertAllOnSubmit(gioHang);
            foreach (var item in gioHang)
            {
                context.HANGHOAs.Where(t => t.MASP == item.MASP).FirstOrDefault().SOLUONG -= item.SL_MUA;
            }
            context.SubmitChanges();
            context.KHACH_HANGs.Where(t => t.MAKH == maKH).FirstOrDefault().TICHLUY += (int.Parse(tichDiem) - int.Parse(dungDiemTichLuy));
        }
Example #2
0
 public void hoadonmoi_id(HOA_DON ex)
 {
     cn.ExecuteReader(@" INSERT INTO HOA_DON(MA_HD,NGAYBAN ) VALUES ('" + ex.MaHD + "','" + ex.NgayBan + "')");
 }