Esempio n. 1
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 change_flight_ServerClick(object sender, EventArgs e)
        {
            //FlightService fs = new FlightService();
            ManagerService ms = new ManagerService();
            FlightService fs = new FlightService();
            flight f = (flight)Session["flight"];
            if (f == null) return;
            String actual_departure_str = this.actual_departure.Value;
            DateTime actual_departure_dt = DateTime.Parse(actual_departure_str);
            f.actual_departure = actual_departure_dt;

            String actual_arrival_str= this.actual_arrival.Value;
            DateTime actual_arrival_dt= DateTime.Parse(actual_arrival_str);
            f.actual_arrival = actual_arrival_dt;

               //actual arrival, actual departure是日期加上时刻么?
            int plane_no = int.Parse(this.plane_no.Value);
            int plane_id = 2; //通过飞机编号得到id
            f.plane_id = plane_id;
            f.econmy_fee = decimal.Parse(this.economy_fee.Value);
            f.business_fee = decimal.Parse(this.business_fee.Value);
            f.deluxe_fee = decimal.Parse(this.deluxe_fee.Value);

               String res= ms.updateFlight(f);
               if (res == "success")
               {
               Server.Transfer("check-flight.aspx");
               }
            //fail呢?
        }
        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");
        }
        protected void next_ServerClick(object sender, EventArgs e)
        {
            user u = new user();
            u.user_id = (int)Session["id"];
            u = os.getUserById(u);
            int seat_num = (int)Session["seat_num"];

            o.SSR = this.SSR.Value ;
            o.type = type;

            FlightService fs = new FlightService();
            String plane_type_name = searchF.plane.plane_type.name;
            BitArray seat = new BitArray(20);
            seat.SetAll(false);
            seat.Set(seat_num,true);
            o.seat = OrderService.BitArrayToByteArray(seat);

            if ( (o = os.generate(u, searchF, o, seat_num)) != null)
            {
                Session["new_order"] = o;
                Server.Transfer("payment.aspx");
            }
            else
            {
                ShowPopUpMsg("Seat is book by others!");
            }
        }
Esempio n. 5
0
        public String getWhileData()
        {
            FlightService fs = new FlightService();
            List<flight> flight_list = fs.getTodayFlight();
            String table = "";
            foreach (flight f in flight_list)
            {
                table += "<tr>";

                table += "<td>" + f.flight_name + "</td>";
                table += "<td>" + f.air_line.city_from + "</td>";
                table += "<td class=\"hidden-480\">" + f.air_line.city_to + "</td>";
                table += "<td>" + f.air_line.schedule_departure + "</td>";
                table += "<td class=\"hidden-480\">" + f.air_line.schedule_arrival + "</td>";
                table += "<td>正常</td>";
                table += "<td>" + f.air_line.schedule_departure + "</td>";
                table += "<td>" + f.air_line.schedule_arrival + "</td>";

                table += "</tr>";
            }
            return table;
        }
        protected void input_flight_ServerClick(object sender, EventArgs e)
        {
            FlightService fs = new FlightService();
            air_line al = new air_line();
            al.air_line_name = this.flight_name.Value;
            String[] time_leave = (this.time_depart.Value).Split(':');
            String[] time_arr= this.time_arrive.Value.Split(':');
            al.city_from = this.city_from.Value;
            al.city_to = this.city_to.Value;

            int t_1 = int.Parse(time_leave[0]);
            int t_2 = int.Parse(time_leave[1]);
            TimeSpan ts_l = new TimeSpan(t_1,t_2,0);
            t_1 = int.Parse(time_arr[0]);
            t_2 = int.Parse(time_arr[1]);
            TimeSpan ts_a = new TimeSpan(t_1,t_2,0);
            al.schedule_departure = ts_l;
            al.schedule_arrival = ts_a;
            al.mile = 100;
            al.air_line_status = "available";
            fs.insertAirLine(al);
        }
        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);
        }