public frmFlightEditing(ChuyenBay cb) { onloading = true; chuyenBay = cb; InitializeComponent(); checkState(); loadData(); cthvs = BLL_CTHV.GetCTHVs(chuyenBay.maCB); ctcbs = BLL_CTCB.GetCTCBs(chuyenBay.maCB); tbMaCB.Text = chuyenBay.strMaCB; nGiaVe.Value = chuyenBay.DonGia; cbSBDi.SelectedValue = chuyenBay.TB.SBDi.maSB; cbSBDen.SelectedValue = chuyenBay.TB.SBDen.maSB; dtpNgay.Value = chuyenBay.ThoiGian; dtpGio.Value = chuyenBay.ThoiGian; nTGBayH.Value = chuyenBay.ThoiLuong / 60; nTGBayM.Value = chuyenBay.ThoiLuong % 60; nSLGhe1.Value = cthvs[0].SLGhe; nSLGhe2.Value = cthvs[1].SLGhe; // thông tin chuyến bay trung gian loaddgv(); //TuyenBay tb = new TuyenBay(); //int donGia = Convert.ToInt32(nGiaVe.Value); //DateTime tg = dtpNgay.Value.Date + dtpGio.Value.TimeOfDay; //int tl = Convert.ToInt32(nTGBayH.Value * 60 + nTGBayM.Value); //int sg = Convert.ToInt32(nSLGhe1.Value + nSLGhe2.Value); }
public override void Create() { AppState.state = Actions.ADD; var dialog = new frmFlightEditing(); DialogResult res = dialog.ShowDialog(); if (res == DialogResult.OK) { if (BLL_ChuyenBay.InsertChuyenBay(dialog.chuyenBay)) { int lastCB = BLL_ChuyenBay.GetLastMaCB(); for (int i = 0; i < dialog.ctcbs.Count; i++) { BLL_CTCB.InsertCTCB(dialog.ctcbs[i], lastCB); } for (int i = 0; i < dialog.cthvs.Count; i++) { BLL_CTHV.InsertCTHV(dialog.cthvs[i], lastCB); } reloadData(); Notification.Show("Thêm chuyến bay thành công", Status.SUCCESS); } } AppState.state = Actions.NOTHING; }
public frmFlightEditing() { onloading = true; InitializeComponent(); checkState(); loadData(); cthvs = BLL_CTHV.GetNewCTHVs(); ctcbs = new List <CTCB>(); loaddgv(); }
private void Edit(DataGridViewRow row) { AppState.state = Actions.EDIT; var dialog = new frmFlightEditing(currentCB); DialogResult res = dialog.ShowDialog(); if (res == DialogResult.OK) { BLL_ChuyenBay.UpdateChuyenBay(dialog.chuyenBay); BLL_CTCB.DeleteCTCB(dialog.chuyenBay.maCB); for (int i = 0; i < dialog.ctcbs.Count; i++) { BLL_CTCB.InsertCTCB(dialog.ctcbs[i], dialog.chuyenBay.maCB); } for (int i = 0; i < dialog.cthvs.Count; i++) { BLL_CTHV.UpdateCTHV(dialog.cthvs[i]); } reloadData(); } AppState.state = Actions.NOTHING; }
private void btnOK_Click(object sender, EventArgs e) { if (!BLL_ChuyenBay.CheckGhe((int)cbMaCB.SelectedValue)) { lbNoti.Text = "Chuyến bay này đã hết ghế"; lbNoti.Show(); return; } if (!BLL_CTHV.CheckGhe((int)cbMaCB.SelectedValue, (int)cbHangVe.SelectedValue)) { lbNoti.Text = "Hạng vé này đã hết ghế"; lbNoti.Show(); return; } if ((((ChuyenBay)cbMaCB.SelectedItem).ThoiGian - DateTime.Now).Days < ThamSo.TGDatVeChamNhat) { lbNoti.Text = "Chỉ được đặt vé chậm nhất trước " + ThamSo.TGDatVeChamNhat + " ngày trước ngày xuất phát"; lbNoti.Show(); return; } if (tbTenHK.Text == "") { lbNoti.Text = "Tên khách hàng không được bỏ trống"; lbNoti.Show(); return; } if (tbCMND.Text == "") { lbNoti.Text = "CMND không được bỏ trống"; lbNoti.Show(); return; } if (tbDienThoai.Text == "") { lbNoti.Text = "Điện thoại không được bỏ trống"; lbNoti.Show(); return; } pdc.maCB = (int)cbMaCB.SelectedValue; pdc.GiaVe = Convert.ToInt32(((ChuyenBay)cbMaCB.SelectedItem).DonGia * ((HangVe)cbHangVe.SelectedItem).TiLe); pdc.ThoiGian = DateTime.ParseExact(tbNgayGio.Text, "hh:mm tt dd/MM/yyyy", null); pdc.TenHK = tbTenHK.Text; pdc.HV = cbHangVe.SelectedItem as HangVe; pdc.CMND = tbCMND.Text; pdc.DienThoai = tbDienThoai.Text; if (rbDat.Checked) { pdc.tinhTrang = 1; } else if (rbDaBan.Checked) { pdc.tinhTrang = 2; var dialog = new frmWarning("Cảnh Báo!!!", "Bạn có muốn bán vé không?"); var res = dialog.ShowDialog(); if (res == DialogResult.OK) { BLL_PhieuDatCho.SalePhieuDatCho(pdc); } else if (res == DialogResult.Cancel) { return; } } else if (rbDaHuy.Checked) { pdc.tinhTrang = 3; var dialog = new frmWarning("Cảnh Báo!!!", "Bạn có muốn hủy phiếu đặt ghế không?"); var res = dialog.ShowDialog(); if (res == DialogResult.OK) { } else if (res == DialogResult.Cancel) { return; } } button1.PerformClick(); }