private void btnCheck_Click(object sender, EventArgs e) { try { DataTable tb = DAODonHangVe.ThongTinDonHang(txtSeries.Text, rap); txtEmail.Text = tb.Rows[0]["email"].ToString(); txtTenKhach.Text = tb.Rows[0]["tenkhachhang"].ToString(); string donHangID = tb.Rows[0]["donhangVeid"].ToString(); dgvVe.DataSource = DAOVe.GetAll(donHangID, rap); }catch (Exception exx) { MessageBox.Show("mã số không tồn tại hoặc đã được sử dụng"); } }
private void btnInVe_Click(object sender, EventArgs e) { if (ValidateOfMe.ValidateOfMe.isHaveEmptyTextBox(ref pnCheck)) { return; } DataTable tb = DAODonHangVe.ThongTinDonHang(txtSeries.Text, rap); string donHangID = tb.Rows[0]["donhangVeid"].ToString(); DataTable tbVe = DAOVe.GetAll(donHangID, rap); #region In Dãy vé string Ve = ""; foreach (DataRow dr in tbVe.Rows) { Ve += "Phim : " + dr["tenphim"].ToString() + "\r\n" + "Rap : " + rap + "\r\n" + "khan dai : " + dr["khandaiid"].ToString() + "\r\n" + "Ngay Chieu : " + dr["ngaychieu"].ToString() + "\r\n" + "Suat Chieu : " + dr["suatchieu"].ToString() + "\r\n" + "So Ghe : " + dr["gheid"].ToString() + "\r\n" + "Gia ve : " + dr["giave"].ToString() + "\r\n" ; } using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "DPF file|*.pdf", ValidateNames = true }) { if (sfd.ShowDialog() == DialogResult.OK) { iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A6.Rotate()); try { PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create)); doc.Open(); Paragraph a = new Paragraph(Ve); doc.Add(new iTextSharp.text.Paragraph(a)); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { doc.Close(); } } } #endregion try//update da nhan ve { DAODonHangVe.UpdateDaNhanVe(txtSeries.Text, rap); } catch (Exception exx) { MessageBox.Show(exx.Message); } MessageBox.Show("In vé thành công ;>"); }
private void btnThanhToan_Click(object sender, EventArgs e) { if (ValidateOfMe.ValidateOfMe.isHaveEmptyTextBox(ref pnInfor)) { return; } #region InsertDonHangVe GiaVeCuaGhe giaVe = new GiaVeCuaGhe(); giaVe.Rap = rap; giaVe.Suat = lbSuatChieu.SelectedValue.ToString(); giaVe.KhanDai = lbKhanDai.SelectedValue.ToString(); DAODonHangVe.Insert(txtTenKhach.Text, txtTamTinh.Text, lbDiscount.Text, txtSoTienThanhToan.Text, rap); #endregion #region update Trạng thái của ghế foreach (KeyValuePair <string, int> item in lstGheDangChon) { DAOGiaVeCuaGhe.ChuyenTrangThaiDa(item.Key, giaVe); } #endregion string dsGhe = ""; foreach (KeyValuePair <string, int> item in lstGheDangChon) { dsGhe += item.Key + " "; } #region In Hóa Đơn string HoaDon = "Anh / Chi : " + txtTenKhach.Text + "\r\n" + "dia chi : " + txtDiaChi.Text + "\r\n" + "Phim : " + lbTenPhim.Text + "\r\n" + "suat chieu : " + lbSuatChieu.Text + "\r\n" + "khan dai : " + txtDiaChi.Text + "\r\n" + "tam tinh : " + txtTamTinh.Text + "\r\n" + "Disocunt : " + lbDiscount.Text + "\r\n" + "giam : " + txtGiam.Text + "\r\n" + "tong tien : " + txtSoTienThanhToan.Text + "\r\n" + "ghe da chon : " + dsGhe; using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "DPF file|*.pdf", ValidateNames = true }) { if (sfd.ShowDialog() == DialogResult.OK) { iTextSharp.text.Document doc = new iTextSharp.text.Document(PageSize.A6.Rotate()); try { PdfWriter.GetInstance(doc, new FileStream(sfd.FileName, FileMode.Create)); doc.Open(); Paragraph a = new Paragraph(HoaDon); doc.Add(new iTextSharp.text.Paragraph(a)); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { doc.Close(); } } } #endregion InsertVe(); MessageBox.Show("Đã Đặt xong ghế"); Reset();//set default cho form }