public void ThemCTHopDong(ChiTietHopDongDTO chiTietHopDongDTO) { ChiTietHopDong hopDong = new ChiTietHopDong() { MaCT_HopDong = chiTietHopDongDTO.MaCT_HopDong, MaHopDong = chiTietHopDongDTO.MaHopDong, MaTour = chiTietHopDongDTO.MaTour, SLTreEm = chiTietHopDongDTO.SoLuongTreEm, SLNguoiLon = chiTietHopDongDTO.SoLuongNguoiLon, ThanhTien = chiTietHopDongDTO.ThanhTien }; entitiy.ChiTietHopDongs.Add(hopDong); entitiy.SaveChanges(); }
private void btn_DatTour_Click(object sender, EventArgs e) { if (KTraThongTinNhap()) { TourBUS datTourBUS = new TourBUS(); Random random = new Random(); string maKH = random.Next(0, 1000000).ToString(); string maHD = random.Next(0, 1000000).ToString(); KhachHangDTO khachHang = new KhachHangDTO() { DiaChi = txt_DiaChi.Text, Email = txt_Email.Text, GioiTinh = int.Parse(cbo_GioiTinh.SelectedValue.ToString()), MaKH = maKH, MaloaiKH = "1", NgaySinh = dateTime_NamSinh.Value, Sdt = txt_Sdt.Text, TenKH = txt_HoTen.Text }; HopDongDTO hopDong = new HopDongDTO() { MaHD = maHD, MaKH = maKH, TongTien = frm_Tour.BookedTour.TongTien, ThoiGianDat = DateTime.Now }; ChiTietHopDongDTO chiTietHopDong = new ChiTietHopDongDTO() { MaCT_HopDong = random.Next(-100, 10000).ToString(), MaHopDong = maHD, MaTour = frm_Tour.BookedTour.MaTour, SoLuongNguoiLon = int.Parse(txt_NguoiLon.Text), SoLuongTreEm = int.Parse(txt_TreEm.Text), ThanhTien = frm_Tour.BookedTour.GiaNguoiLon * int.Parse(txt_NguoiLon.Text) + frm_Tour.BookedTour.GiaTreEm * int.Parse(txt_TreEm.Text) }; try { datTourBUS.ThanhToanTour(khachHang, hopDong, chiTietHopDong); MessageBox.Show("Thông báo", "Đặt tour thành công", MessageBoxButtons.OK); this.Close(); DialogResult xemHopDong = MessageBox.Show("Đặt hợp đồng thành công", "Bạn có muốn in hợp đồng không?", MessageBoxButtons.YesNo); if (xemHopDong == DialogResult.Yes) { DateTime nowValue = DateTime.Now; Dictionary <string, string> dsThamSo = new Dictionary <string, string> { ["MaHD"] = maHD, ["HoTen"] = khachHang.TenKH, ["DiaChi"] = khachHang.DiaChi, ["NgaySinh"] = khachHang.NgaySinh.ToShortDateString(), ["SoDienThoai"] = khachHang.Sdt, ["NoiDi"] = tourChiTiet.Tour.DiemDi, ["NoiDen"] = tourChiTiet.Tour.DiemDen, ["KhachSan"] = tourChiTiet.Tour.TenKhachSan, ["ThoiGian"] = (tourChiTiet.TGDen - tourChiTiet.TGDi).Value.TotalDays.ToString(), ["TGDi"] = tourChiTiet.TGDi.Value.ToShortDateString(), ["TGDen"] = tourChiTiet.TGDen.Value.ToShortDateString(), ["TongTien"] = frm_Tour.BookedTour.TongTien.ToString(), ["TienTamUng"] = ((decimal)HopDongConstants.PHANTRAMTAMUNG * frm_Tour.BookedTour.TongTien).Value.ToString(), ["NgayHD"] = nowValue.Day.ToString(), ["ThangHD"] = nowValue.Month.ToString(), ["NamHD"] = nowValue.Year.ToString(), ["TongSoNguoi"] = (frm_Tour.BookedTour.TreEm + frm_Tour.BookedTour.NguoiLon).ToString(), ["NguoiLon"] = frm_Tour.BookedTour.NguoiLon.ToString(), ["TreEm"] = frm_Tour.BookedTour.TreEm.ToString(), }; WordReportDTO wordReport = new WordReportDTO(dsThamSo); string srcReport = @"D:\Download\winforms_QLTourDulich_perfect\winforms_QLTourDulich_perfect\QLTour\QLTour\Report\report.docx"; string outputReport = @"C:\Users\tranthibay\Desktop\HopDong.docx"; wordReport.XuatReportWord(srcReport, outputReport); } } catch (Exception) { MessageBox.Show("Chú ý", MessageBoxConstants.LOIDULIEU, MessageBoxButtons.OK); } } }
public void ThanhToanTour(KhachHangDTO khachHang, HopDongDTO hopDong, ChiTietHopDongDTO chiTietHopDong) { new KhachHangDAO().ThemKhachHangMoi(khachHang); new HopDongDAO().ThemHopDong(hopDong); new ChiTietHopDongDAO().ThemCTHopDong(chiTietHopDong); }