protected void search_click(object sender, EventArgs e)
        {
            switch(this.level.Value){
                case "1": type ="deluxe"; break;
                case "2": type ="business"; break;
                case "3": type = "economy"; break;
            }
            searchF = new flight();
            searchF.departure_date = Convert.ToDateTime(this.datepicker.Value);
            airLine = new air_line();
            airLine.city_from = this.city_from.Value;
            airLine.city_to = this.city_to.Value;
            FlightService fs = new FlightService();
            searchF = fs.searchFlight(searchF, type ,airLine);
            if (searchF == null)
            {
                ShowPopUpMsg("No flight are found!");
                return;
            }

            Session["SearchFlight"] = searchF;
            Session["type"] = type;
            var response = base.Response;
            response.Redirect("list-flights.aspx");
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] == null)
            {
                var response = base.Response;
                response.Redirect("login.aspx");
            }

            searchF = (flight)Session["searchFlight"];
            type = (String)Session["type"];
            seat_num = (int)Session["seat_num"];
            oInDb = (order)Session["new_order"];

            if (oInDb == null) return;

            user u = new user();
            u.user_id = (int)Session["id"];
            u = os.getUserById(u);
            oInDb.user = u;
            flight f = new flight();
            f.flight_id = oInDb.flight_id;
            f= new FlightService().getFlightById(f);
            oInDb.flight = f;
            this.flight_date.Value = oInDb.flight.arrival_date.ToString("d");
            this.flight_name.Value = oInDb.flight.flight_name;
            this.city_from.Value = searchF.air_line.city_from;
            this.city_to.Value = searchF.air_line.city_to;
            this.user_name.Value = oInDb.user.user_name;
            this.price.Value = oInDb.payment.ToString();
            this.user_balance.Value = oInDb.user.balance.ToString();
            Session["new_order"] = oInDb;
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["id"] == null)
            {
                var response = base.Response;
                response.Redirect("login.aspx");
            }

            //页面跳转传值.
            searchF = (flight)Session["searchFlight"];
            type = (String)Session["type"];
            if (searchF == null) return ;

            flight_name.Value = searchF.flight_name;
            city_from.Value = searchF.air_line.city_from;
            cit_to.Value = searchF.air_line.city_to;
            d_time.Value = searchF.air_line.schedule_departure.ToString("c");
            a_time.Value = searchF.air_line.schedule_arrival.ToString("c");
            decimal fee;
            switch(type) {
                case "deluxe": fee = searchF.deluxe_fee * searchF.discount; break;
                case "business": fee = searchF.business_fee * searchF.discount; break;
                case "economy": fee = searchF.econmy_fee * searchF.discount; break;
                default: fee = 0; break;
            }
            this.fee.Value = fee.ToString() ;
        }
Esempio n. 4
0
 public void deleteFlight(int flightid)
 {
     int[] flight = new int[1];
     flight[0] = flightid;
     flight flig = new flight();
     flig = flightDAO.Find(flight);
     flightDAO.Delete(flig);
 }
Esempio n. 5
0
 public void getData()
 {
     FlightSysDataTableAdapters.flightTableAdapter flightAdapter = new FlightSysDataTableAdapters.flightTableAdapter();
     FlightSysData.flightDataTable flights = flightAdapter.GetData();
     foreach (FlightSysData.flightRow row in flights)
     {
         Console.WriteLine(row.flight_name);
     }
     flight flightEntity = new flight();
 }
Esempio n. 6
0
 public flight getFlightById(flight f)
 {
     var ls = from a in flightDAO.FindAll()
              where a.flight_id == f.flight_id
              select a;
     IEnumerable<flight> fInDbList = ls;
     if (fInDbList.ToList().Count > 0)
         return fInDbList.First();
     return null;
 }
        protected void assure_Btin_ServerClick(object sender, EventArgs e)
        {
            AirLineService als = new AirLineService();
            flight f = new flight();
            air_line al = als.findByName(this.air_line.Value);
            if (al == null)
            {
                ShowPopUpMsg("can't find air line" + this.air_line.Value);
                return;
            }
            plane pl = als.findByNO(int.Parse(this.plane_type_name.Value));
            f.flight_name = this.flight_name.Value;
            f.air_line_id = al.air_line_id;
            f.plane_id = pl.plane_id;
            f.status = "avail";
            f.discount = decimal.Parse(this.discount.Value);
            f.deluxe_fee = decimal.Parse(this.deluxe.Value);
            f.business_fee = decimal.Parse(this.business.Value);
            f.econmy_fee = decimal.Parse(this.economy.Value);
            BitArray deluxe_BA = getSeatBit(pl.plane_type.name,"deluxe");
            BitArray business_BA = getSeatBit(pl.plane_type.name, "business");
            BitArray economy_BA = getSeatBit(pl.plane_type.name, "economy");
            deluxe_BA.SetAll(true);
            business_BA.SetAll(true);
            economy_BA.SetAll(true);
            f.available_deluxe_seats = BitArrayToByteArray(deluxe_BA);
            f.available_business_seats = BitArrayToByteArray(business_BA);
            f.available_economy_seats = BitArrayToByteArray(economy_BA);
            String arrS = this.date_from.Value.Replace('-','/');
            f.arrival_date = DateTime.ParseExact(arrS ,"dd/mm/yyyy",CultureInfo.InvariantCulture);
            f.departure_date = f.arrival_date;
            f.actual_departure = DateTime.Now.AddHours(-3);
            f.actual_arrival = DateTime.Now.AddHours(2);

            FlightService FS = new FlightService();
            FS.insertFlight(f);
        }
Esempio n. 8
0
 //peizhi zhekou
 public String updateDiscont(decimal discount,int flightid)
 {
     int[] flight=new int[1];
     flight[0] = flightid;
     flight flig=new flight();
     flig = flightDAO.Find(flight);
     flig.discount = discount;
     if (flightDAO.Update(flig) != null)
         return "success";
     else return "fail";
 }
Esempio n. 9
0
 public String createFlight(flight flight)
 {
     if (flightDAO.Insert(flight) != null)
         return "success";
     else return "fail";
 }
Esempio n. 10
0
 public String updateFlight(flight flight)
 {
     if (flightDAO.Update(flight) != null)
         return "success";
     else return "fail";
 }
Esempio n. 11
0
        private static flight setSeat(flight f, order o, int seat_num , bool value)
        {
            BitArray deluxe = new BitArray(f.available_deluxe_seats);
            BitArray business = new BitArray(f.available_business_seats);
            BitArray economy = new BitArray(f.available_economy_seats);
            switch (o.type)
            {
                case "deluxe":
                    //seat with seatNum is set to 1 if it is available
                    deluxe.Set(seat_num, value);
                    f.available_deluxe_seats = BitArrayToByteArray(deluxe);
                    o.payment = f.deluxe_fee * f.discount;
                    break;
                case "business":
                    business.Set(seat_num, value);
                    f.available_business_seats = BitArrayToByteArray(business);
                    o.payment = f.business_fee * f.discount;
                    break;
                case "economy":
                    economy.Set(seat_num, value);
                    f.available_economy_seats = BitArrayToByteArray(economy);
                    o.payment = f.econmy_fee * f.discount;
                    break;
            }

            return f;
        }
Esempio n. 12
0
 private static bool hasSeat(flight f, order o , int seat_num)
 {
     BitArray deluxe = new BitArray(f.available_deluxe_seats);
     BitArray business = new BitArray(f.available_business_seats);
     BitArray economy = new BitArray(f.available_economy_seats);
     BitArray order_seat = new BitArray(o.seat);
     bool hasSeat = false;
     switch (o.type)
     {
         case "deluxe":
             //seat with seatNum is set to 1 if it is available
             if (deluxe.Get(seat_num) == true) hasSeat = true;
             break;
         case "business":
             if (business.Get(seat_num) == true) hasSeat = true;
             break;
         case "economy":
             if (economy.Get(seat_num) == true) hasSeat = true;
             break;
     }
     return hasSeat;
 }
Esempio n. 13
0
        public order generate(user u, flight f, order o ,int seat_num)
        {
            o.flight_id = f.flight_id;
            u = this.getUserById(u);
            //o.user = u;
            o.user_id = u.user_id;
            o.status = "paid";

            o.PNR = CalculateMD5Hash(u.user_name + seat_num + f.flight_id + DateTime.Now.Date) ;
            mutex.WaitOne();
            if (hasSeat(f, o))
            {
                using (var context = orderDAO.getContext())
                {
                    using (var dbContextTransaction = context.Database.BeginTransaction())
                    {
                        try
                        {
                            flight fInDB = getFlightById(f.flight_id);
                            //o.flight = fInDB;

                            if (fInDB == null) throw new Exception() ;

                            bool buy = true;
                            flight newF = setSeat(fInDB,o,seat_num,buy);
                            flightDAO.Update(newF);
                            if (u.user_level == 1) o.payment = o.payment * (decimal)0.95;
                            o = orderDAO.Insert(o);
                            context.SaveChanges();
                            dbContextTransaction.Commit();
                        }
                        catch (Exception)
                        {
                            dbContextTransaction.Rollback();
                        }
                    }
                }
            }
            mutex.ReleaseMutex();

            //
            return o;
        }
Esempio n. 14
0
        //该接口用于符合查询航班信息
        public flight searchFlight(flight f , String seat_type ,air_line air)
        {
            var select = from a in flightDAO.FindAll() select a;
            /*
            var select = from a in flightDAO.FindAll()
                         where a.departure_date.Date.CompareTo(f.departure_date.Date) <= 0
                             && a.arrival_date.Date.CompareTo(f.departure_date.AddDays(1).Date) >= 0
                         select a;
            */
            if (air.city_from != null)
            {
                select = select.Where(p => p.air_line.city_from == air.city_from);
            }

            if (air.city_to != null)
            {
                select = select.Where(p => p.air_line.city_to == air.city_to);
            }
            /*
            switch(seat_type) {
                case "deluxe":
                    SqlBinary avalD = new SqlBinary(f.available_deluxe_seats);
                    SqlBinary fullD = new SqlBinary(f.plane.plane_type.deluxe_seats);
                    //seat is set to 1 if it is available
                    //plane_type seat is set to 0
                    if(avalD.CompareTo(fullD) <= 0)
                        select = null;
                    break;
                case "business":
                    SqlBinary avalB = new SqlBinary(f.available_business_seats);
                    SqlBinary fullB = new SqlBinary(f.plane.plane_type.business_seats);
                    if(avalB.CompareTo(fullB) <= 0)
                        select = null;
                    break;
                case "economy":
                    SqlBinary avalE = new SqlBinary(f.available_economy_seats);
                    SqlBinary fullE = new SqlBinary(f.plane.plane_type.economy_seats);
                    if(avalE.CompareTo(fullE) <= 0)
                        select = null;
                    break;
                default: break;
            }
            */
            if (select.ToList<flight>().Count == 0) return null;
            return select.First<flight>();
        }
Esempio n. 15
0
 public flight insertFlight(flight f)
 {
     return flightDAO.Insert(f);
 }