public async Task <IActionResult> Edit(string ChuyenBayID, [Bind("ChuyenBayID,NgayGioBay,GiaVe,ThoiGianBay,BusinessClass,EconomyClass,DenId,KhoiHanhId")] LichChuyenBay lichChuyenBay) { if (ChuyenBayID != lichChuyenBay.ChuyenBayID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(lichChuyenBay); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LichChuyenBayExists(lichChuyenBay.ChuyenBayID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(lichChuyenBay)); }
private void btnXacNhan_Click(object sender, EventArgs e) { BUL_LichChuyenBay bUL_LichChuyenBay = new BUL_LichChuyenBay(); if (txtMaCB.Text != "" && txtThoiGianBay.Text != "" && cBsanBayDen.Text != "" && cBsanBayDi.Text != "" && txtGiaVe.Text != "" && txtSLGheHang1.Text != "" && txtSLGheHang2.Text != "") { LichChuyenBay lcb = new LichChuyenBay(txtMaCB.Text, cBsanBayDi.SelectedValue.ToString(), cBsanBayDen.SelectedValue.ToString(), Convert.ToInt32(txtGiaVe.Text), Convert.ToString(dTPngayGio.Value), txtThoiGianBay.Text, Convert.ToInt32(txtSLGheHang1.Text), Convert.ToInt32(txtSLGheHang2.Text)); if (bUL_LichChuyenBay.themLichChuyenBay(lcb)) { MessageBox.Show("Thêm thành công"); txtGiaVe.Text = ""; txtSLGheHang1.Text = ""; txtSLGheHang2.Text = ""; txtThoiGianBay.Text = "00:00:00"; txtMaCB.Text = "CB"; dGVthemLichCB.DataSource = bUL_LichChuyenBay.getLichChuyenBay(); // refresh datagridview } else { MessageBox.Show("Đã có lỗi xảy ra", "Lỗi"); } } else { MessageBox.Show("Xin hãy nhập đầy đủ"); } }
private void btnTimKiem_Click(object sender, EventArgs e) { BUL_LichChuyenBay bUL_LichChuyenBay = new BUL_LichChuyenBay(); if (txtTraCuu.Text != "") { LichChuyenBay lcb = new LichChuyenBay(txtTraCuu.Text); dGVtraCuuCB.DataSource = bUL_LichChuyenBay.getTimKiemCB(lcb); } else { xemdulieu(); } }
private void btnXoa_Click(object sender, EventArgs e) { BUL_LichChuyenBay bUL_LichChuyenBay = new BUL_LichChuyenBay(); if (txtMaCB.Text != "") { LichChuyenBay lcb = new LichChuyenBay(txtMaCB.Text, cBsanBayDi.SelectedValue.ToString(), cBsanBayDen.SelectedValue.ToString(), Convert.ToInt32(txtGiaVe.Text), Convert.ToString(dTPngayGio.Value), txtThoiGianBay.Text, Convert.ToInt32(txtSLGheHang1.Text), Convert.ToInt32(txtSLGheHang2.Text)); if (bUL_LichChuyenBay.xoaLichChuyenBay(lcb)) { MessageBox.Show("Xóa thành công"); xemdulieu(); addbinding(); } else { MessageBox.Show("Đã có lỗi xảy ra", "Lỗi"); } } else { MessageBox.Show("Kiểm tra lại"); } }
public DataTable getTimKiemCB(LichChuyenBay lCB) { Ultilies ultilies = new Ultilies(); return(ultilies.GetDataTimKiemCB(lCB)); }
public bool xoaLichChuyenBay(LichChuyenBay lCB) { Ultilies ultilies = new Ultilies(); return(ultilies.xoaLichChuyenBay(lCB)); }
public async Task <IActionResult> Create(int?[] ThoiGianDung, string[] TramDung, string[] GhiChu, string SanBayDi, string SanBayDen, [Bind("ChuyenBayID,NgayGioBay,GiaVe,ThoiGianBay,BusinessClass,EconomyClass,DenId,KhoiHanhId")] LichChuyenBay lichChuyenBay) { if (ModelState.IsValid) { //string[] s = ChiTietTrungGian.Split(' '); //string s = ChiTietTrungGian; _context.Add(lichChuyenBay); await _context.SaveChangesAsync(); int dem = 0; if (ThoiGianDung == null || ThoiGianDung[0] == null) { _context.Add(new ChiTietTrungGian() { ChuyenBayID = lichChuyenBay.ChuyenBayID, ChiTietID = lichChuyenBay.ChuyenBayID + "01", SanBayId = SanBayDi, SanBayDen = SanBayDen, ThoiGian = null, GhiChu = "Bay Thẳng" }); } else { _context.Add(new ChiTietTrungGian() { ChuyenBayID = lichChuyenBay.ChuyenBayID, ChiTietID = lichChuyenBay.ChuyenBayID + "01", SanBayId = SanBayDi, SanBayDen = TramDung[0], ThoiGian = ThoiGianDung[0], GhiChu = GhiChu[0] }); for (int i = 1; i < ThoiGianDung.Length; i++) { if (ThoiGianDung[i] == null) { dem = i; break; } _context.Add(new ChiTietTrungGian() { ChuyenBayID = lichChuyenBay.ChuyenBayID, ChiTietID = lichChuyenBay.ChuyenBayID + "0" + (i + 1), SanBayId = TramDung[i - 1], SanBayDen = TramDung[i], ThoiGian = ThoiGianDung[i], GhiChu = GhiChu[i] }); } dem = ThoiGianDung.Length; _context.Add(new ChiTietTrungGian() { ChuyenBayID = lichChuyenBay.ChuyenBayID, ChiTietID = lichChuyenBay.ChuyenBayID + "0" + (dem + 2), SanBayId = TramDung[dem - 1], SanBayDen = SanBayDen, ThoiGian = null, GhiChu = "Đến nơi" }); } _context.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(lichChuyenBay)); }
public IActionResult Index(LichChuyenBay lichCB) { ViewData["ChuyenBayID"] = new SelectList(_context.LichChuyenBays, "ChuyenBayID", "ChuyenBayID", lichCB.ChuyenBayID); return(View(lichCB)); }