public ActionResult ModifyTicketNew(ModifyTicket ticket) { var db = new AirLineDbContext(); var KH = db.KhachHangs.Find(ticket.MaKhachHang); KH.HoTenKhachHang = ticket.FullName; KH.DienThoai = ticket.SDT; KH.Email = ticket.Email; KH.Diachi = ticket.DiaChi; db.SaveChanges(); for (var i = 0; i < ticket.HanhKhach.Count; i++) { var HK = db.HanhKhaches.Find(ticket.HanhKhach[i].MaHanhKhach); DateTime outTemp; outTemp = DateTime.Parse(ticket.HanhKhach[i].NgaySinh + " 12:00:00 AM"); HK.NgaySinh = outTemp.Date; HK.GioiTinh = ticket.HanhKhach[i].GioiTinh; HK.HoTen = ticket.HanhKhach[i].HoTen; db.SaveChanges(); } return(Json(new { msg = "M" })); }
public ActionResult ModifyFlight(ThongTinChuyenBay ThongTin) { try { var id = ThongTin.flightID; var date = ThongTin.date.Date.ToString("yyyy/MM/dd"); var connect = new AirLineDbContext(); var info = connect.ChuyenBays.SingleOrDefault(x => x.MaChuyenBay == id); info.Title = "VietJet"; info.UrlAnh = "vietJet.png"; info.DiemDi = ThongTin.depAirport; info.DiemDen = ThongTin.arvAirport; info.Ngay = ThongTin.date.Date; info.ChuyenBay1 = ThongTin.chuyenBay; info.KhoiHanh = ThongTin.gioDi; info.Den = ThongTin.gioDen; info.Gia = int.Parse(ThongTin.gia); info.Thue = int.Parse(ThongTin.thue); info.GiaTreEm = int.Parse(ThongTin.giatreem); info.ThueTreEm = int.Parse(ThongTin.thuetreem); info.GiaVeTreSoSinh = int.Parse(ThongTin.giavetresosinh); info.SoCho = int.Parse(ThongTin.sochocontrong); info.PlaneID = ThongTin.planeID; info.PilotID1 = ThongTin.pilotID1; info.PilotID2 = ThongTin.pilotID2; connect.SaveChanges(); } catch { } return(RedirectToAction("ModifyFlight", "Home")); }
public ActionResult AddFlight(ThongTinChuyenBay ThongTin) { try { var connect = new AirLineDbContext(); connect.ChuyenBays.Add(new ChuyenBay { Title = "VietJet", UrlAnh = "vietJet.png", MaChuyenBay = ThongTin.flightID, DiemDi = ThongTin.depAirport, DiemDen = ThongTin.arvAirport, Ngay = ThongTin.date.Date, ChuyenBay1 = ThongTin.chuyenBay, KhoiHanh = ThongTin.gioDi, Den = ThongTin.gioDen, Gia = int.Parse(ThongTin.gia), Thue = int.Parse(ThongTin.thue), GiaTreEm = int.Parse(ThongTin.giatreem), ThueTreEm = int.Parse(ThongTin.thuetreem), GiaVeTreSoSinh = int.Parse(ThongTin.giavetresosinh), SoCho = int.Parse(ThongTin.sochocontrong), PlaneID = ThongTin.planeID, PilotID1 = ThongTin.pilotID1, PilotID2 = ThongTin.pilotID2, }); connect.SaveChanges(); return(View("Success", TempData["notice"] = "Thêm chuyến bay thành công!")); } catch { return(View("Success", TempData["notice"] = "Đã có lỗi xảy ra!")); } }
public ActionResult SuaVe(ThongTinKhachHang ThongTin) { try { string ticketcode = ThongTin.ticketcode; var connection = new AirLineDbContext(); string passengercode = connection.KhachHang_ChuyenBay.Find(ticketcode).MaKhachHang; var ticket = connection.KhachHangs.Find(passengercode); if (ticket == null) { return(HttpNotFound()); } else { ticket.HoTenKhachHang = ThongTin.fullname; ticket.KhuVuc = ThongTin.country; ticket.DienThoai = ThongTin.phone; ticket.Email = ThongTin.email; ticket.Diachi = ThongTin.address; connection.SaveChanges(); return(View("Success", TempData["notice"] = "Sửa vé thành công!")); } } catch { return(View("Success", TempData["notice"] = "Đã có lỗi xảy ra!")); } }
public ActionResult XoaHanhLiThanhCong(string mahanhli) { var connect = new AirLineDbContext(); var info = connect.HanhLies.Find(mahanhli); connect.HanhLies.Remove(info); connect.SaveChanges(); return(View()); }
public ActionResult SuaHanhLiThanhCong(string mahanhli, string tenhanhli, int Loaihanhli, int giatien) { var connect = new AirLineDbContext(); var info = connect.HanhLies.SingleOrDefault(x => x.MaHanhLy == mahanhli); info.TenHanhLy = tenhanhli; info.LoaiHanhLy = Loaihanhli; info.GiaTien = giatien; connect.SaveChanges(); return(View()); }
public ActionResult ThemHanhLiThanhCong(string MaHanhLy, string TenHanhLy, int LoaiHanhLy, int GiaTien) { var connect = new AirLineDbContext(); connect.HanhLies.Add(new HanhLy { MaHanhLy = MaHanhLy, TenHanhLy = TenHanhLy, LoaiHanhLy = LoaiHanhLy, GiaTien = GiaTien, }); connect.SaveChanges(); return(View()); }
public ActionResult Delete(Ve ve) { var connection = new AirLineDbContext(); try { var ticket = connection.KhachHang_ChuyenBay.SingleOrDefault(x => x.MaCode == ve.MaVe); connection.KhachHang_ChuyenBay.Remove(ticket); connection.SaveChanges(); } catch (ArgumentNullException e) { TempData["notice"] = "Ticket not found"; return(View("DeleteTicket")); } TempData["notice"] = "Ticket has been delete"; return(View("DeleteTicket")); }
public ActionResult Register(Member member) { var db = new AirLineDbContext(); var user = db.Admins.SingleOrDefault(x => x.UserName == member.UserName); if (member.Password != member.RePassword) { return(Json(new { status = "LoiMatKhau", msg = "Nhập lại mật khẩu không trùng khớp" })); } if (user != null) { return(Json(new { status = "ThatBai", msg = "Tên đăng nhập đã tồn tại" })); } var counter = db.Admins.Count() + 1; string str = counter.ToString(); string encpsw = EncMD5(member.Password); db.Admins.Add(new Admin { MaThanhVien = str, TenThanhVien = member.FullName, UserName = member.UserName, Password = encpsw, //Password = member.Password, GroupID = "MEMBER" }); db.SaveChanges(); return(Json(new { status = "ThanhCong", msg = "Đăng ký thành công" })); }