public static int Them(ChiTietGiaoDich ghe) { using (var context = new VeTauEntities(false)) { context.ChiTietGiaoDiches.Add(ghe); return context.SaveChanges(); } }
private void btnCapNhat_Click(object sender, EventArgs e) { if (KiemTraHopLeVaThongBao()) { var chiTietGiaoDich = new List<ChiTietGiaoDich>(); foreach (var lichTrinh in ListLichTrinh) { var chiTiet = new ChiTietGiaoDich { Huy = false, LichTrinhTuyenDuongId = lichTrinh.Id, LoaiGheId = Ghe.LoaiGheId, SoGhe = Ghe.SoShe }; chiTietGiaoDich.Add(chiTiet); } var giaoDich = new GiaoDich { KhachHangId = cbKhachHang.SelectedValue.ToString(), LichTrinhId = ListLichTrinh[0].LichTrinhId, GhiChu = tbGhiChu.Text, HeSo = (double) lbHeSo.Tag, NhanVienId = NhanVienId, SoTien = (double) lbSoTien.Tag, ChiTietGiaoDiches = chiTietGiaoDich, NgayLap = DateTime.Now }; if (GiaoDichDal.Them(giaoDich) > 0) { MessageBox.Show(Resources.TaoDoiTuong + Resources.thanhCong, Resources.MThanhCong); Close(); } else { MessageBox.Show(Resources.TaoDoiTuong + Resources.thatBai, Resources.MThatBai); } } }