示例#1
0
        public ActionResult DsHanhLi()
        {
            var           connect  = new AirLineDbContext();
            List <HanhLy> DShanhli = connect.HanhLies.ToList();

            return(View(DShanhli));
        }
        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 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 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 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"
            }));
        }
示例#6
0
        public ActionResult XoaHanhLiThanhCong(string mahanhli)
        {
            var connect = new AirLineDbContext();
            var info    = connect.HanhLies.Find(mahanhli);

            connect.HanhLies.Remove(info);
            connect.SaveChanges();
            return(View());
        }
示例#7
0
        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());
        }
示例#8
0
        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 SearchResult(Request request)
        {
            try
            {
                //Nếu là chuyến bay một chiều thì chọn chuyến bay sẽ về luôn nhập thông tin
                // Nếu không thì sẽ chuyeenrr sang một action trong controller cho phép chọn thêm một chuyến bay nữa
                if (request.flightType == 0)
                {
                    ViewBag.redirect = "Detail";
                }
                else
                {
                    ViewBag.redirect = "SearchResultReturn";
                }
                SearchResultOneWay result = new SearchResultOneWay();
                //người lớn và trẻ em thì cho ngồi ghế còn trẻ sơ  sinh thì người lớn bế
                int soluonghanhkhach  = request.adultNo + request.childNo;
                List <ChuyenBay> temp = new List <ChuyenBay>();
                DateTime         dt   = DateTime.ParseExact(request.depDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                result.cb = new List <ChuyenBay>();
                temp      = new F_DanhSachChuyenBay().DS_ChuyenBay.Where(x => x.DiemDi == request.depAirport && x.DiemDen == request.arvAirport && x.Ngay == dt).ToList();
                //kiểm tra thử còn chỗ không với các chuyến bay phù hợp với ngày đã chọn
                foreach (ChuyenBay item in temp)
                {
                    int a = new AirLineDbContext().KhachHang_ChuyenBay.Where(x => x.MaChuyenBay == item.MaChuyenBay && x.NgayBay == item.Ngay).ToList().Count();// Lấy ra số chỗ đã đặt thành công
                    if (item.SoCho - a >= soluonghanhkhach)
                    {
                        result.cb.Add(item);
                    }
                }

                result.departAirport  = request.depAirport;
                result.arrivedAirport = request.arvAirport;
                result.date           = request.depDate;
                result.rtndate        = request.rtnDate;
                result.adultNo        = request.adultNo;
                result.childNo        = request.childNo;
                result.infantNo       = request.infantNo;
                var session1 = (UserLogin)Session[CommonSession.USER_SESSION];
                if (session1 != null)
                {
                    TempData["layout"] = "logged in";
                }
                return(View(result));
            }
            catch
            {
                return(View("Index"));
            }
        }
示例#10
0
        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"));
        }
示例#11
0
        public ActionResult GetCustomerInfo(string TicketCode)
        {
            var db = new AirLineDbContext();

            try
            {
                KhachHang_ChuyenBay ticket = db.KhachHang_ChuyenBay.AsNoTracking().Where(x => x.MaCode == TicketCode).ToList()[0];
                if (ticket == null)
                {
                    return(HttpNotFound());
                }
                var hanhkhach = db.KhachHangs.Find(ticket.MaKhachHang.ToString());

                return(PartialView("KhachHang", hanhkhach));
            }
            catch
            {
                return(HttpNotFound());
            }
        }
示例#12
0
        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"
            }));
        }
示例#13
0
        public ActionResult GetGuestInfo(string TicketCode)
        {
            var db = new AirLineDbContext();
            List <KhachHang_ChuyenBay> ticket = new List <KhachHang_ChuyenBay>();

            try
            {
                ticket = db.KhachHang_ChuyenBay.AsNoTracking().Where(x => x.MaCode == TicketCode).ToList();
                if (ticket.Count == 0)
                {
                    return(HttpNotFound());
                }
                List <Flight.Models.Entity.HanhKhach> hanhkhach = new List <Flight.Models.Entity.HanhKhach>();
                foreach (KhachHang_ChuyenBay khcb in ticket)
                {
                    hanhkhach.Add(db.HanhKhaches.Find(khcb.MaHanhKhach.ToString()));
                }
                return(PartialView("HanhKhach", hanhkhach));
            }
            catch
            {
                return(HttpNotFound());
            }
        }
示例#14
0
        public ActionResult SearchResultReturn(SearchReturn SearchReturn)
        {
            SearchResultOneWay result = new SearchResultOneWay();

            result.cb = new List <ChuyenBay>();
            DateTime dt = DateTime.ParseExact(SearchReturn.ReturnDate, "dd/MM/yyyy", CultureInfo.InvariantCulture);
            //người lớn và trẻ em thì cho ngồi ghế còn trẻ sơ  sinh thì người lớn bế
            int soluonghanhkhach  = SearchReturn.adultNo + SearchReturn.childNo;
            List <ChuyenBay> temp = new List <ChuyenBay>();

            result.cb = new F_DanhSachChuyenBay().DS_ChuyenBay.Where(x => x.DiemDi == SearchReturn.arvAirport && x.DiemDen == SearchReturn.depAirport && x.Ngay == dt).ToList();
            //kiểm tra thử còn chỗ không trên các chuyến bay với ngày đã chọn
            foreach (ChuyenBay item in temp)
            {
                int a = new AirLineDbContext().KhachHang_ChuyenBay.Where(x => x.MaChuyenBay == item.MaChuyenBay && x.NgayBay == item.Ngay).ToList().Count();
                if (item.SoCho - a >= soluonghanhkhach)
                {
                    result.cb.Add(item);
                }
            }
            result.departAirport      = SearchReturn.arvAirport;
            result.arrivedAirport     = SearchReturn.depAirport;
            result.date               = null;
            result.rtndate            = SearchReturn.ReturnDate;
            result.adultNo            = SearchReturn.adultNo;
            result.childNo            = SearchReturn.childNo;
            result.infantNo           = SearchReturn.infantNo;
            ViewBag.MaChuyenBayLuotDi = SearchReturn.MaChuyenBayLuotDi;
            var session1 = (UserLogin)Session[CommonSession.USER_SESSION];

            if (session1 != null)
            {
                TempData["layout"] = "logged in";
            }
            return(View(result));
        }
示例#15
0
 public F_DanhSachChuyenBay()
 {
     context = new AirLineDbContext();
 }
示例#16
0
 public F_ThemHanhKhach()
 {
     context = new AirLineDbContext();
 }
示例#17
0
 public F_ThemKhachHang()
 {
     context = new AirLineDbContext();
 }
示例#18
0
        public ActionResult Review(KhachHangModel khmodel, IList <adult> adults, IList <child> childs, IList <infant> infants, int radiopayment)
        {
            //Lưu Khách hàng(người đặt vé) vào cơ sở dữ liệu
            new F_ThemKhachHang().ThemKhachHang(khmodel.fullname, khmodel.txtPax1_Ctry, khmodel.phone, khmodel.email, khmodel.address, radiopayment);
            string         makhachhang = new F_ThemKhachHang().Find(khmodel.fullname, khmodel.phone, khmodel.email);
            HanhKhachModel hkModel     = new HanhKhachModel();

            hkModel.adultList   = new List <adult>();
            hkModel.childList   = new List <child>();
            hkModel.infantList  = new List <infant>();
            ViewBag.tongtien    = 0;
            ViewBag.makhachhang = makhachhang;
            foreach (adult item in adults)
            {
                if (item.adultName != null)
                {
                    HanhLy adultBaggage = new F_ThemHanhKhach().FindEntity(item.adultBaggage);
                    item.adultBaggageType = adultBaggage.TenHanhLy;
                    ViewBag.tongtien     += adultBaggage.GiaTien;
                    // them hanh khach vao co so du lieu va gan cho mot ma
                    new F_ThemHanhKhach().ThemHanhKhach(item);
                    // lay len tu co so du lieu ma hanh khach
                    DateTime  ngaysinh = DateTime.ParseExact(item.adultBirthday, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    HanhKhach temp1    = new AirLineDbContext().HanhKhaches.Where(x => x.GioiTinh == item.adultSex &&
                                                                                  x.HoTen == item.adultName &&
                                                                                  x.NgaySinh == ngaysinh &&
                                                                                  x.MaHanhLy == item.adultBaggage
                                                                                  ).SingleOrDefault();
                    item.adultID = temp1.MaHanhKhach;
                    hkModel.adultList.Add(item);
                }
            }
            foreach (child item in childs)
            {
                if (item.childName != null)
                {
                    HanhLy childBaggage = new F_ThemHanhKhach().FindEntity(item.childBaggage);
                    item.childBaggageType = childBaggage.TenHanhLy;
                    ViewBag.tongtien     += childBaggage.GiaTien;
                    new F_ThemHanhKhach().ThemHanhKhach(item);
                    DateTime  ngaysinh = DateTime.ParseExact(item.childBirthday, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    HanhKhach temp1    = new AirLineDbContext().HanhKhaches.Where(x => x.GioiTinh == item.childSex &&
                                                                                  x.HoTen == item.childName &&
                                                                                  x.NgaySinh == ngaysinh &&
                                                                                  x.MaHanhLy == item.childBaggage
                                                                                  ).SingleOrDefault();
                    // lấy lại mã hành khách để sinh vé ở bước cuối cùng
                    item.childID = temp1.MaHanhKhach;
                    hkModel.childList.Add(item);
                }
            }
            foreach (infant item in infants)
            {
                if (item.infantName != null)
                {
                    new F_ThemHanhKhach().ThemHanhKhach(item);
                    DateTime  ngaysinh = DateTime.ParseExact(item.infantBirthday, "dd/MM/yyyy", CultureInfo.InvariantCulture);
                    HanhKhach temp1    = new AirLineDbContext().HanhKhaches.Where(x => x.GioiTinh == item.infantSex &&
                                                                                  x.HoTen == item.infantName &&
                                                                                  x.NgaySinh == ngaysinh &&
                                                                                  x.MaHanhLy == "1"
                                                                                  ).SingleOrDefault();
                    item.infantID = temp1.MaHanhKhach;
                    hkModel.infantList.Add(item);
                }
            }
            KhachHang model = new KhachHang();

            model.HoTenKhachHang = khmodel.fullname;
            model.KhuVuc         = khmodel.txtPax1_Ctry;
            model.DienThoai      = khmodel.phone;
            model.Email          = khmodel.email;
            model.Diachi         = khmodel.address;
            var temp = new AirLineDbContext().ThanhToans.Where(x => x.MaThanhToan == radiopayment).SingleOrDefault();

            //Khách Hàng(Người đặt vé) thì truyền qua ViewBag, hanh khach thi truyen qua view

            ViewBag.HinhThucThanhToan = temp.TenHinhThucThanhToan;
            ViewBag.khachhang         = model;
            ViewBag.tongtien         += khmodel.tongtien;
            var session1 = (UserLogin)Session[CommonSession.USER_SESSION];

            if (session1 != null)
            {
                TempData["layout"] = "logged in";
            }
            return(View(hkModel));
        }
示例#19
0
 public F_Login()
 {
     context = new AirLineDbContext();
 }
示例#20
0
 public F_GenerateCode()
 {
     context = new AirLineDbContext();
 }