protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Length == 0)
            {
                lblError.Text = "Flight Name Can't be Empty";
                txtName.Focus();
            }
            else
            {
                string flightName  = txtName.Text;
                int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                string airlinename = ddlAirLine.SelectedItem.Text;
                flightid = Request.QueryString["flightid"].ToString();
                Flight _flight = new Flight()
                {
                    ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                    {
                        Id = airlineid, Name = airlinename
                    }
                };
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                flightManager.UpdateFlight(_flight);

                lblError.Text = "Flight Updated";
            }
        }
        private void ItemsGet()
        {
            // Read sample item info from XML document into a DataSet
            try
            {
                // Populate the repeater control with the Items DataSet
                IFlightManager  flightManger = (IFlightManager)AirTravelManagerFactory.Create("Flight");
                PagedDataSource objPds       = new PagedDataSource();
                objPds.DataSource  = flightManger.GetFlights();
                objPds.AllowPaging = true;
                objPds.PageSize    = 3;

                objPds.CurrentPageIndex = CurrentPage;

                lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of "
                                      + objPds.PageCount.ToString();

                // Disable Prev or Next buttons if necessary
                commandPrevious.Enabled = !objPds.IsFirstPage;
                commandNext.Enabled     = !objPds.IsLastPage;

                dlFlight.DataSource = objPds;
                dlFlight.DataBind();
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
        public void BindData()
        {
            try
            {
                ddlAirLine.DataSource     = new AirLineManager().GetAirLines();
                ddlAirLine.DataTextField  = "Name";
                ddlAirLine.DataValueField = "Id";
                ddlAirLine.DataBind();

                flightid = Request.QueryString["flightid"].ToString();

                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                flight = flightManager.GetFlight(int.Parse(flightid));

                FlightClass flightclass = new FlightClass();


                txtName.Text             = flight.Name;
                ddlAirLine.SelectedValue = flight.AirlineForFlight.Id.ToString();
                GridView1.DataSource     = flight.GetClasses();
                GridView1.DataBind();
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
            catch (AirlineManagerException exc2)
            {
                throw exc2;
            }
        }
        protected void btnCancel_Click1(object sender, EventArgs e)
        {
            clear();
            txtDuration.Enabled = false;

            scheduleid = Request.QueryString["scheduleid"].ToString();

            try
            {
                IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");
                schedule = scheduleManager.GetSchedule(int.Parse(scheduleid));

                dpFromCity.SelectedValue = schedule.RouteInfo.FromCity.CityId.ToString();
                dpToCity.SelectedValue   = schedule.RouteInfo.ToCity.CityId.ToString();
                txtDuration.Text         = schedule.DurationInMins.ToString();
                TimeSpan dptime = schedule.DepartureTime;
                DropDownList1.SelectedValue = dptime.Hours.ToString();
                DropDownList2.SelectedValue = dptime.Minutes.ToString();
                TimeSpan dpMinutes = schedule.ArrivalTime;
                DropDownList4.SelectedValue = dpMinutes.Hours.ToString();
                DropDownList5.SelectedValue = dpMinutes.Hours.ToString();

                dpAirlineName.SelectedValue = schedule.FlightInfo.AirlineForFlight.Id.ToString();
                ListItem item = new ListItem(schedule.FlightInfo.Name.ToString(), schedule.FlightInfo.ID.ToString());
                dpFlightName.Items.Add(item);
                chkStatus.Checked = schedule.IsActive;
            }
            catch (ScheduleManagerException ex)
            {
                throw ex;
            }
        }
        private void ItemsGet()
        {
            // Read sample item info from XML document into a DataSet
            try
            {
                // Populate the repeater control with the Items DataSet
                IFlightManager  flightManger = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                PagedDataSource objPds       = new PagedDataSource();
                List <Flight>   flights      = flightManger.GetFlights();
                if (flights.Count > 0)
                {
                    objPds.DataSource  = flights;
                    objPds.AllowPaging = true;
                    objPds.PageSize    = 3;

                    ctlAdminMaster.BuildPager(objPds);

                    dlFlight.DataSource = objPds;
                    dlFlight.DataBind();
                }
                else
                {
                    dlFlight.Visible = false;
                }
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
示例#6
0
        //public int CurrentPage
        //{
        //    get
        //    {
        //        // look for current page in ViewState
        //        object o = this.ViewState["_CurrentPage"];
        //        if (o == null)
        //            return 0;   // default to showing the first page
        //        else
        //            return (int)o;
        //    }

        //    set
        //    {
        //        this.ViewState["_CurrentPage"] = value;
        //    }
        //}

        private void ItemsGet()
        {
            // Read sample item info from XML document into a DataSet

            try
            {
                // Populate the repeater control with the Items DataSet
                IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");
                PagedDataSource  objPds          = new PagedDataSource();
                List <Schedule>  schedules       = scheduleManager.GetSchedules();
                if (schedules.Count > 0)
                {
                    objPds.DataSource  = schedules;
                    objPds.AllowPaging = true;
                    objPds.PageSize    = 5;

                    ctlAdminMaster.BuildPager(objPds);
                    //objPds.CurrentPageIndex = CurrentPage;
                    //lblCurrentPage.Text = "Page: " + (CurrentPage + 1).ToString() + " of " + objPds.PageCount.ToString();
                    //commandPrevious.Enabled = !objPds.IsFirstPage;
                    //commandNext.Enabled = !objPds.IsLastPage;

                    Repeater1.DataSource = objPds;
                    Repeater1.DataBind();
                }
                else
                {
                    Repeater1.Visible = false;
                }
            }
            catch (ScheduleManagerException ex)
            {
                throw ex;
            }
        }
示例#7
0
        protected void dpFlightName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (dpFlightName.Text.Equals("None") == false)
            {
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                try
                {
                    Flight             flight        = flightManager.GetFlight(int.Parse(dpFlightName.SelectedValue));
                    List <TravelClass> flightClasses = new List <TravelClass>();

                    foreach (FlightClass fc in flight.GetClasses())
                    {
                        flightClasses.Add(fc.ClassInfo);
                    }

                    Repeater1.DataSource = flightClasses;
                    Repeater1.DataBind();
                }
                catch (FlightManagerException ex)
                {
                    ctlAdminMaster.ErrorMessage = ex.Message;
                }
            }
            else
            {
                ShowDefaultClasses();
            }
        }
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row          = GridView1.Rows[e.RowIndex];
                TextBox     txtNoOfSeats = (TextBox)row.FindControl("txtNoOfSeats");
                int         intNoOfSeats = Convert.ToInt32((txtNoOfSeats.Text.ToString()));

                if ((!int.TryParse(txtNoOfSeats.Text, out intNoOfSeats)) || (intNoOfSeats <= 0))
                {
                    ctlAdminMaster.ErrorMessage = "Seat count should be a positive number";
                    txtNoOfSeats.Focus();
                }
                else
                {
                    string txtClass = ((TextBox)row.FindControl("txtClass")).Text;

                    FlightClass _class = new FlightClass();
                    switch (txtClass)
                    {
                    case "Economy": _class.ClassInfo = TravelClass.Economy; break;

                    case "Business": _class.ClassInfo = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.NoOfSeats = intNoOfSeats;

                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };

                    flightManager.UpdateFlightClass(_flight, _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    ctlAdminMaster.ErrorMessage = "Flight Seats Updated";
                }
            }
            catch (FlightManagerException ex)
            {
                ctlAdminMaster.ErrorMessage = ex.Message;
            }
        }
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row = GridView1.Rows[e.RowIndex];

                if (((TextBox)row.FindControl("txtNoOfSeats")).Text.Length == 0)
                {
                    lblError.Text = "Seats Cannot be Empty";
                    ((TextBox)row.FindControl("txtNoOfSeats")).Focus();
                }
                else
                {
                    string txtClass     = ((TextBox)row.FindControl("txtClass")).Text;
                    int    txtNoOfSeats = Convert.ToInt32((((TextBox)row.FindControl("txtNoOfSeats")).Text.ToString()));

                    FlightClass _class = new FlightClass();
                    switch (txtClass)
                    {
                    case "Economy": _class.ClassInfo = TravelClass.Economy; break;

                    case "Business": _class.ClassInfo = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.NoOfSeats = txtNoOfSeats;

                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };

                    flightManager.UpdateFlightClass(_flight, _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    lblError.Text = "Flight Seats Updated";
                }
            }
            catch (FlightManagerException ex)
            {
                throw ex;
            }
        }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                Route            route           = new Route();
                IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");

                Schedule schedule = new Schedule();

                City fromcity = new City();
                fromcity.CityId = long.Parse(dpFromCity.SelectedItem.Value);
                fromcity.Name   = dpFromCity.SelectedItem.Text;
                route.FromCity  = fromcity;

                City tocity = new City();
                tocity.CityId = long.Parse(dpToCity.SelectedItem.Value);
                tocity.Name   = dpToCity.SelectedItem.Text;
                route.ToCity  = tocity;

                schedule.RouteInfo = route;
                if (scheduleManager.GetRouteID(schedule) == 0)
                {
                    lblError.Text = "Select the Existing Route";
                    dpFromCity.Focus();
                }
                else
                {
                    TimeSpan t1 = TimeSpan.Parse(DropDownList4.SelectedItem.ToString() + ":" + DropDownList5.SelectedItem.ToString());
                    TimeSpan t2 = TimeSpan.Parse(DropDownList1.SelectedItem.ToString() + ":" + DropDownList2.SelectedItem.ToString());
                    total            = int.Parse((t1 - t2).TotalMinutes.ToString());
                    txtDuration.Text = total.ToString();


                    Flight flight = new Flight();
                    flight.ID   = long.Parse(dpFlightName.SelectedItem.Value);
                    flight.Name = dpFlightName.SelectedItem.Text;

                    scheduleid              = Request.QueryString["scheduleid"].ToString();
                    schedule.ID             = long.Parse(scheduleid);
                    schedule.RouteInfo      = route;
                    schedule.FlightInfo     = flight;
                    schedule.DepartureTime  = TimeSpan.Parse(DropDownList1.SelectedItem.ToString() + ":" + DropDownList2.SelectedItem.ToString());
                    schedule.ArrivalTime    = TimeSpan.Parse(DropDownList4.SelectedItem.ToString() + ":" + DropDownList5.SelectedItem.ToString());
                    schedule.DurationInMins = total;
                    schedule.IsActive       = chkStatus.Checked;

                    scheduleManager.UpdateSchedule(schedule);
                    Response.Redirect("~/Admin/Home.aspx");
                }
            }
            catch (ScheduleManagerException ex)
            {
                lblError.Text = ex.Message;
            }
        }
示例#11
0
        public static IAirTravelManager GetRouteManager()
        {
            HttpContext   context = HttpContext.Current;
            IRouteManager rm      = (IRouteManager)context.Session["ROUTEMANAGER"];

            if (rm == null)
            {
                rm = (IRouteManager)AirTravelManagerFactory.Create("RouteManager");
                context.Session["ROUTEMANAGER"] = rm;
            }
            return(rm);
        }
示例#12
0
        // Updated Version
        public static IAirTravelManager GetCityManager()
        {
            HttpContext  context = HttpContext.Current;
            ICityManager cm      = (ICityManager)context.Session["CITYMANAGER"];

            if (cm == null)
            {
                cm = (ICityManager)AirTravelManagerFactory.Create("CityManager");
                context.Session["CITYMANAGER"] = cm;
            }
            return(cm);
        }
示例#13
0
        public void BindData()
        {
            scheduleid = Request.QueryString["scheduleid"].ToString();

            IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");

            schedule = scheduleManager.GetSchedule(int.Parse(scheduleid));

            FlightCost flightclass = new FlightCost();

            GridView1.DataSource = schedule.GetFlightCosts();
            GridView1.DataBind();
        }
示例#14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            lblErrorMessageLocal.InnerText = "";

            if (!IsPostBack)
            {
                clear();
                txtDuration.Enabled = false;

                try
                {
                    scheduleid = Request.QueryString["scheduleid"].ToString();
                    IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");
                    schedule = scheduleManager.GetSchedule(int.Parse(scheduleid));

                    if (schedule == null)
                    {
                        Response.Redirect("~/Error.aspx");
                    }


                    //dpFromCity.SelectedValue = schedule.RouteInfo.FromCity.CityId.ToString();
                    //dpToCity.SelectedValue = schedule.RouteInfo.ToCity.CityId.ToString();

                    dpRoute.SelectedValue = schedule.RouteInfo.ID.ToString();
                    txtDuration.Text      = schedule.DurationInMins.ToString();
                    TimeSpan dptime = schedule.DepartureTime;
                    dpDepartHours.SelectedValue = dptime.Hours.ToString();
                    dpDepartMins.SelectedValue  = dptime.Minutes.ToString();
                    TimeSpan dpMinutes = schedule.ArrivalTime;
                    dpArrivalHours.SelectedValue = dpMinutes.Hours.ToString();
                    dpArrivalMins.SelectedValue  = dpMinutes.Minutes.ToString();

                    dpAirlineName.SelectedValue = schedule.FlightInfo.AirlineForFlight.Id.ToString();
                    ListItem item = new ListItem(schedule.FlightInfo.Name.ToString(), schedule.FlightInfo.ID.ToString());
                    dpFlightName.Items.Add(item);
                    chkStatus.Checked = schedule.IsActive;

                    BindData();
                }
                catch (ScheduleManagerException ex)
                {
                    ctlAdminMaster.ErrorMessage = ex.Message;
                }
                catch (NullReferenceException ex)
                {
                    Response.Redirect("~/Error.aspx");
                }
            }
        }
示例#15
0
 public void BindData()
 {
     try
     {
         ICityManager cityManger = (ICityManager)AirTravelManagerFactory.Create("City");
         List <City>  cities     = cityManger.GetCities();
         grdCity.DataSource = cities;
         grdCity.DataBind();
     }
     catch (CityManagerException ex)
     {
         throw ex;
     }
 }
示例#16
0
        protected void grdCity_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            GridViewRow row = grdCity.Rows[e.RowIndex];

            TextBox txtState    = (TextBox)row.FindControl("txtState");
            TextBox txtCityName = (TextBox)row.FindControl("txtCityName");

            if (txtCityName.Text.Length == 0)
            {
                lblError.Text = "City Name Can't be Empty";
                txtCityName.Focus();
            }
            else
            {
                int cityId = Int32.Parse(grdCity.DataKeys[e.RowIndex].Value.ToString());

                string CityName  = txtCityName.Text;
                string StateName = txtState.Text;

                City _city = new City()
                {
                    CityId    = cityId,
                    Name      = CityName,
                    StateInfo = new State()
                    {
                        Name = StateName
                    }
                };

                try
                {
                    ICityManager cityManger = (ICityManager)AirTravelManagerFactory.Create("City");

                    if (cityManger.UpdateCity(_city))
                    {
                        lblError.Text = "City Updated Successfully";
                    }
                    else
                    {
                        lblError.Text = "City already exists";
                    }
                    grdCity.EditIndex = -1;
                    BindData();
                }
                catch (CityManagerException ex)
                {
                    throw ex;
                }
            }
        }
示例#17
0
        protected void dpAirlineName_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                dpFlightName.Items.Clear();
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                List <Flight>  flightlist    = flightManager.GetFlightsForAirLine(int.Parse(dpAirlineName.SelectedValue));

                foreach (Flight c in flightlist)
                {
                    ListItem item = new ListItem(c.Name, c.ID.ToString());
                    dpFlightName.Items.Add(item);
                }
                dpFlightName.DataBind();
            }
            catch (FlightManagerException exc)
            {
                ctlAdminMaster.ErrorMessage = exc.Message;
            }
        }
示例#18
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtName.Text))
            {
                ctlAdminMaster.ErrorMessage = "Flight Name Can't be Empty";
                txtName.Focus();
            }
            else
            {
                if (!hdnName.Value.Equals(txtName.Text))
                {
                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    flightid = Request.QueryString["flightid"].ToString();
                    Flight _flight = new Flight()
                    {
                        ID = int.Parse(flightid), Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };
                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");

                    if (flightManager.UpdateFlight(_flight) > 0)
                    {
                        ctlAdminMaster.ErrorMessage = "Flight with the same name already exists in the target Airline";
                    }
                    else
                    {
                        ctlAdminMaster.ErrorMessage = "Flight Updated";
                        Response.Redirect("~/Admin/ManageFlights.aspx");
                    }
                }
                else
                {
                    ctlAdminMaster.ErrorMessage = "No changes made to the flight";
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            ctlAdminMaster.ErrorMessage = "";
            if (!IsPostBack)
            {
                try
                {
                    IScheduleManager scm  = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");
                    DataSet          dsTI = scm.GetTravelInventory();
                    gridTravelInventory.DataSource = dsTI.Tables[0];
                    gridTravelInventory.DataBind();

                    if (dsTI.Tables[0].Rows.Count > 0)
                    {
                        for (int i = 3; i < dsTI.Tables.Count; ++i)
                        {
                            GridView gridClass = (GridView)gridTravelInventory.Rows[i - 3].FindControl("gridClassDetails");
                            gridClass.DataSource = dsTI.Tables[i];
                            gridClass.DataBind();
                            gridClass.Visible = true;
                        }
                    }
                    else
                    {
                        //ctlAdminMaster.ErrorMessage = "Sorry !!! No Bookings Done For The Day";
                    }
                }
                catch (ScheduleManagerException ex)
                {
                    ctlAdminMaster.ErrorMessage = ex.Message;
                }
                catch (Exception)
                {
                    ctlAdminMaster.ErrorMessage = "Sorry !!! Unable to get travel inventory";
                }
            }
        }
示例#20
0
        protected void dpAirlineName_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (dpAirlineName.Text.Equals("None") == false)
            {
                dpFlightName.Items.Clear();
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("Flight");
                try
                {
                    List <Flight> flightlist = flightManager.GetFlightsForAirLine(int.Parse(dpAirlineName.SelectedValue));

                    dpFlightName.Items.Add("None");
                    foreach (Flight c in flightlist)
                    {
                        ListItem item = new ListItem(c.Name, c.ID.ToString());
                        dpFlightName.Items.Add(item);
                    }
                    dpFlightName.DataBind();
                }
                catch (FlightManagerException ex)
                {
                    lblError.Text = ex.Message;
                }
            }
        }
示例#21
0
        private void clear()
        {
            dpFromCity.Items.Clear();
            dpToCity.Items.Clear();
            dpAirlineName.Items.Clear();
            dpFlightName.Items.Clear();
            DropDownList1.Items.Clear();
            DropDownList2.Items.Clear();
            DropDownList4.Items.Clear();
            DropDownList5.Items.Clear();

            DropDownList1.Items.Add("None");
            DropDownList4.Items.Add("None");
            for (int i = 1; i <= 24; i++)
            {
                DropDownList1.Items.Add(i.ToString());
                DropDownList4.Items.Add(i.ToString());
            }
            DropDownList1.DataBind();
            DropDownList4.DataBind();

            DropDownList2.Items.Add("None");
            DropDownList5.Items.Add("None");
            for (int i = 0; i <= 59; i++)
            {
                DropDownList2.Items.Add(i.ToString());
                DropDownList5.Items.Add(i.ToString());
            }
            DropDownList2.DataBind();
            DropDownList5.DataBind();

            txtDuration.Enabled = false;

            txtDuration.Text  = "";
            chkStatus.Checked = false;
            ICityManager cityManager = (ICityManager)AirTravelManagerFactory.Create("City");

            try
            {
                List <City> cities = cityManager.GetCities();

                dpFromCity.Items.Add("None");
                foreach (City c in cities)
                {
                    ListItem item = new ListItem(c.Name, c.CityId.ToString());
                    dpFromCity.Items.Add(item);
                }
                dpFromCity.DataBind();

                dpToCity.Items.Add("None");
                foreach (City c in cities)
                {
                    ListItem item = new ListItem(c.Name, c.CityId.ToString());
                    dpToCity.Items.Add(item);
                }
                dpToCity.DataBind();
            }
            catch (CityManagerException e)
            {
                lblError.Text = e.Message;
            }


            IAirLineManager airlineManager = (IAirLineManager)AirTravelManagerFactory.Create("Airline");

            try
            {
                List <Airline> airlines = airlineManager.GetAirLines();

                dpAirlineName.Items.Add("None");
                foreach (Airline c in airlines)
                {
                    ListItem item = new ListItem(c.Name, c.Id.ToString());
                    dpAirlineName.Items.Add(item);
                }
                dpAirlineName.DataBind();
            }
            catch (AirlineManagerException e)
            {
                lblError.Text = e.Message;
            }

            var travelClassvalues = Enum.GetValues(typeof(TravelClass)).Cast <TravelClass>();

            Repeater1.DataSource = travelClassvalues;
            Repeater1.DataBind();
        }
示例#22
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("Schedule");

            Schedule schedule = new Schedule();

            Route route = new Route();

            if (dpFromCity.Text.Equals("None") == true)
            {
                lblError.Text = "Select From City";
                dpFromCity.Focus();
            }
            else if (dpToCity.Text.Equals("None") == true)
            {
                lblError.Text = "Select To City";
                dpToCity.Focus();
            }
            else if (dpAirlineName.Text.Equals("None") == true)
            {
                lblError.Text = "Select Airline Name";
                dpAirlineName.Focus();
            }
            else if (dpFlightName.Text.Equals("None") == true)
            {
                lblError.Text = "Select Flight Name";
                dpFlightName.Focus();
            }
            else if (DropDownList1.Text.Equals("None") == true)
            {
                lblError.Text = "Select Departure Hours";
                DropDownList1.Focus();
            }
            else if (DropDownList2.Text.Equals("None") == true)
            {
                lblError.Text = "Select Departure Minutes";
                DropDownList2.Focus();
            }
            else if (DropDownList4.Text.Equals("None") == true)
            {
                lblError.Text = "Select Arrival Hours";
                DropDownList4.Focus();
            }
            else if (DropDownList5.Text.Equals("None") == true)
            {
                lblError.Text = "Select Arrival Minutes";
                DropDownList5.Focus();
            }
            else
            {
                City fromcity = new City();
                fromcity.CityId = long.Parse(dpFromCity.SelectedItem.Value);
                fromcity.Name   = dpFromCity.SelectedItem.Text;
                route.FromCity  = fromcity;

                City tocity = new City();
                tocity.CityId = long.Parse(dpToCity.SelectedItem.Value);
                tocity.Name   = dpToCity.SelectedItem.Text;
                route.ToCity  = tocity;

                schedule.RouteInfo = route;
                int routeID = scheduleManager.GetRouteID(schedule);
                schedule.RouteInfo.ID = routeID;
                if (routeID == 0)
                {
                    lblError.Text = "Select the Existing Route";
                    dpFromCity.Focus();
                }
                else
                {
                    TimeSpan t1 = TimeSpan.Parse(DropDownList4.SelectedItem.ToString() + ":" + DropDownList5.SelectedItem.ToString());
                    TimeSpan t2 = TimeSpan.Parse(DropDownList1.SelectedItem.ToString() + ":" + DropDownList2.SelectedItem.ToString());
                    total            = int.Parse((t1 - t2).TotalMinutes.ToString());
                    txtDuration.Text = total.ToString();

                    Flight flight = new Flight();
                    flight.ID   = long.Parse(dpFlightName.SelectedItem.Value);
                    flight.Name = dpFlightName.SelectedItem.Text;

                    schedule.RouteInfo      = route;
                    schedule.FlightInfo     = flight;
                    schedule.DepartureTime  = TimeSpan.Parse(DropDownList1.SelectedItem.ToString() + ":" + DropDownList2.SelectedItem.ToString());
                    schedule.ArrivalTime    = TimeSpan.Parse(DropDownList4.SelectedItem.ToString() + ":" + DropDownList5.SelectedItem.ToString());
                    schedule.DurationInMins = total;
                    schedule.IsActive       = chkStatus.Checked;

                    foreach (RepeaterItem item in Repeater1.Items)
                    {
                        Label   lblclassname = (Label)item.FindControl("ClassName");
                        TextBox txtcost      = (TextBox)item.FindControl("txtCostPerTicket");

                        if (txtcost.Text.Length == 0)
                        {
                            lblError.Text = "Flight Cost Can't be Empty";
                            txtcost.Focus();
                            break;
                        }
                        else
                        {
                            if (txtcost != null || lblclassname != null)
                            {
                                string classname = lblclassname.Text;
                                string val       = txtcost.Text;

                                FlightCost fc = new FlightCost();
                                fc.Class         = (TravelClass)Enum.Parse(typeof(TravelClass), classname);
                                fc.CostPerTicket = decimal.Parse(txtcost.Text);

                                schedule.AddFlightCost(fc);
                            }
                        }
                    }

                    try
                    {
                        scheduleManager.AddSchedule(schedule);
                        lblError.Text = "Schedule Added Successfully";
                    }
                    catch (ScheduleManagerException ex)
                    {
                        lblError.Text = ex.Message;
                    }
                }
            }
        }
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row = GridView1.Rows[e.RowIndex];

                if (((TextBox)row.FindControl("txtCost")).Text.Length == 0)
                {
                    lblError.Text = "Cost Cannot be Empty";
                    ((TextBox)row.FindControl("txtCost")).Focus();
                }
                else
                {
                    string     txtClass = ((TextBox)row.FindControl("txtClass")).Text;
                    int        txtCost  = Convert.ToInt32((((TextBox)row.FindControl("txtCost")).Text.ToString()));
                    FlightCost _class   = new FlightCost();
                    switch (txtClass)
                    {
                    case "Economy": _class.Class = TravelClass.Economy; break;

                    case "Business": _class.Class = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.CostPerTicket = txtCost;

                    IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");
                    Schedule         schedule        = new Schedule();
                    Route            route           = new Route();
                    City             fromcity        = new City();

                    fromcity.CityId = long.Parse(dpFromCity.SelectedItem.Value);
                    fromcity.Name   = dpFromCity.SelectedItem.Text;
                    route.FromCity  = fromcity;

                    City tocity = new City();
                    tocity.CityId = long.Parse(dpToCity.SelectedItem.Value);
                    tocity.Name   = dpToCity.SelectedItem.Text;
                    route.ToCity  = tocity;

                    Flight flight = new Flight();
                    flight.ID   = long.Parse(dpFlightName.SelectedItem.Value);
                    flight.Name = dpFlightName.SelectedItem.Text;

                    scheduleid          = Request.QueryString["scheduleid"].ToString();
                    schedule.ID         = long.Parse(scheduleid);
                    schedule.RouteInfo  = route;
                    schedule.FlightInfo = flight;

                    scheduleManager.UpdateScheduleFlightCost(schedule, _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    lblError.Text = "Flight Cost Updated";
                }
            }
            catch (ScheduleManagerException ex)
            {
                throw ex;
            }
        }
示例#24
0
 public static ICityManager GetCityManager()
 {
     return((ICityManager)AirTravelManagerFactory.Create("City"));
 }
示例#25
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (txtName.Text.Length == 0)
            {
                lblError.Text = "Flight Name Can't be Empty";
                txtName.Focus();
            }
            else if (ddlAirLine.Text.Equals("None") == true)
            {
                lblError.Text = "Select Airline Name";
                ddlAirLine.Focus();
            }
            else
            {
                string flightName  = txtName.Text;
                int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                string airlinename = ddlAirLine.SelectedItem.Text;
                Flight _flight     = new Flight()
                {
                    Name = flightName, AirlineForFlight = new Airline()
                    {
                        Id = airlineid, Name = airlinename
                    }
                };
                IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("Flight");

                try
                {
                    foreach (RepeaterItem item in dlClass.Items)
                    {
                        TextBox txtNoOfSeats = (TextBox)item.FindControl("txtNoOfSeats");
                        Label   lblClass     = (Label)item.FindControl("lblClass");

                        if (txtNoOfSeats.Text.Length == 0)
                        {
                            txtNoOfSeats.Focus();
                            lblError.Text = "No of Seats Cannot be Empty";
                            break;
                        }
                        else
                        {
                            if (txtNoOfSeats != null)
                            {
                                TravelClass travelClass = (TravelClass)Enum.Parse(typeof(TravelClass), lblClass.Text.Trim());
                                int         NoOfSeats   = int.Parse(txtNoOfSeats.Text);
                                FlightClass _class      = new FlightClass()
                                {
                                    ClassInfo = travelClass, NoOfSeats = NoOfSeats
                                };
                                _flight.AddClass(_class);
                            }
                        }
                    }
                    if (flightManager.AddFlight(_flight) == false)
                    {
                        lblError.Text = "Flight Name already exists";
                    }
                    else
                    {
                        lblError.Text = "Flight Added Successfully";
                    }
                }
                catch (FlightManagerException exc)
                {
                    throw exc;
                }
            }
        }
示例#26
0
 public static IRouteManager GetRouteManager()
 {
     return((IRouteManager)AirTravelManagerFactory.Create("Route"));
 }
示例#27
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            if (IsValid)
            {
                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    ctlAdminMaster.ErrorMessage = "Flight Name Can't be Empty";
                    txtName.Focus();
                }
                else if (ddlAirLine.Text.Equals("None") == true)
                {
                    ctlAdminMaster.ErrorMessage = "Select Airline Name";
                    ddlAirLine.Focus();
                }
                else
                {
                    string flightName  = txtName.Text;
                    int    airlineid   = int.Parse(ddlAirLine.SelectedItem.Value);
                    string airlinename = ddlAirLine.SelectedItem.Text;
                    Flight _flight     = new Flight()
                    {
                        Name = flightName, AirlineForFlight = new Airline()
                        {
                            Id = airlineid, Name = airlinename
                        }
                    };
                    IFlightManager flightManager = (IFlightManager)AirTravelManagerFactory.Create("FlightManager");
                    bool           blnSeatsValid = true;

                    try
                    {
                        foreach (RepeaterItem item in dlClass.Items)
                        {
                            TextBox txtNoOfSeats     = (TextBox)item.FindControl("txtNoOfSeats");
                            Label   lblClass         = (Label)item.FindControl("lblClass");
                            int     intNumberOfSeats = 0;

                            if ((!int.TryParse(txtNoOfSeats.Text, out intNumberOfSeats)) || (intNumberOfSeats <= 0))
                            {
                                txtNoOfSeats.Focus();
                                ctlAdminMaster.ErrorMessage = "Seat count should be a positive number";
                                blnSeatsValid = false;
                                break;
                            }
                            else
                            {
                                if (txtNoOfSeats != null)
                                {
                                    TravelClass travelClass = (TravelClass)Enum.Parse(typeof(TravelClass), lblClass.Text.Trim());
                                    FlightClass _class      = new FlightClass()
                                    {
                                        ClassInfo = travelClass, NoOfSeats = intNumberOfSeats
                                    };
                                    _flight.AddClass(_class);
                                }
                            }
                        }
                        if (blnSeatsValid)
                        {
                            if (flightManager.AddFlight(_flight) == false)
                            {
                                ctlAdminMaster.ErrorMessage = "Flight Name already exists";
                            }
                            else
                            {
                                ctlAdminMaster.ErrorMessage = "Flight Added Successfully";
                            }
                        }
                    }
                    catch (FlightManagerException exc)
                    {
                        ctlAdminMaster.ErrorMessage = exc.Message;
                    }
                }
            }
        }
        private void clear()
        {
            dpFromCity.Items.Clear();
            dpToCity.Items.Clear();
            dpAirlineName.Items.Clear();
            dpFlightName.Items.Clear();
            DropDownList1.Items.Clear();
            DropDownList2.Items.Clear();
            DropDownList4.Items.Clear();
            DropDownList5.Items.Clear();

            for (int i = 1; i <= 24; i++)
            {
                DropDownList1.Items.Add(i.ToString());
                DropDownList4.Items.Add(i.ToString());
            }
            DropDownList1.DataBind();
            DropDownList4.DataBind();

            for (int i = 0; i <= 59; i++)
            {
                DropDownList2.Items.Add(i.ToString());
                DropDownList5.Items.Add(i.ToString());
            }
            DropDownList2.DataBind();
            DropDownList5.DataBind();

            txtDuration.Enabled = false;

            txtDuration.Text  = "";
            chkStatus.Checked = false;

            try
            {
                ICityManager cityManager = (ICityManager)AirTravelManagerFactory.Create("City");
                List <City>  cities      = cityManager.GetCities();

                foreach (City c in cities)
                {
                    ListItem item = new ListItem(c.Name.Trim(), c.CityId.ToString());
                    dpFromCity.Items.Add(item);
                }
                dpFromCity.DataBind();


                foreach (City c in cities)
                {
                    ListItem item = new ListItem(c.Name, c.CityId.ToString());
                    dpToCity.Items.Add(item);
                }
                dpToCity.DataBind();

                AirLineManager objairline = new AirLineManager();
                List <Airline> airlines   = objairline.GetAirLines();

                foreach (Airline c in airlines)
                {
                    ListItem item = new ListItem(c.Name, c.Id.ToString());
                    dpAirlineName.Items.Add(item);
                }
                dpAirlineName.DataBind();
            }
            catch (CityManagerException ex)
            {
                lblError.Text = ex.Message;
            }
            catch (AirlineManagerException exc)
            {
                lblError.Text = exc.Message;
            }
        }
示例#29
0
        protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                GridViewRow row     = GridView1.Rows[e.RowIndex];
                TextBox     txtCost = (TextBox)row.FindControl("txtCost");
                decimal     decCost = 0;

                if (!decimal.TryParse(txtCost.Text, out decCost))
                {
                    lblErrorMessageLocal.InnerText = "Cost should be a positive currency value";
                    txtCost.Focus();
                }
                else if (decCost <= 0)
                {
                    lblErrorMessageLocal.InnerText = "Cost should be a positive currency value";
                    txtCost.Focus();
                }
                else
                {
                    string     txtClass = ((TextBox)row.FindControl("txtClass")).Text;
                    FlightCost _class   = new FlightCost();

                    switch (txtClass)
                    {
                    case "Economy": _class.Class = TravelClass.Economy; break;

                    case "Business": _class.Class = TravelClass.Business; break;

                    default:
                        break;
                    }
                    _class.CostPerTicket = decCost;

                    IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");
                    //Schedule schedule = new Schedule();
                    //Route route = null;

                    //string rid = dpRoute.SelectedValue;
                    //IRouteManager routeManager = (IRouteManager)BusinessObjectManager.GetRouteManager();
                    //try
                    //{
                    //    List<Route> routes = routeManager.GetRoutes();
                    //    foreach (Route r in routes)
                    //    {
                    //        if (r.ID == Convert.ToInt32(rid))
                    //        {
                    //            route = r;
                    //            break;
                    //        }
                    //    }

                    //}
                    //catch (RouteManagerException ex)
                    //{
                    //    ctlAdminMaster.ErrorMessage = ex.Message;
                    //}

                    //Flight flight = new Flight();
                    //flight.ID = long.Parse(dpFlightName.SelectedItem.Value);
                    //flight.Name = dpFlightName.SelectedItem.Text;

                    scheduleid = Request.QueryString["scheduleid"].ToString();
                    //schedule.ID = long.Parse(scheduleid);
                    //schedule.RouteInfo = route;
                    //schedule.FlightInfo = flight;

                    scheduleManager.UpdateScheduleFlightCost(long.Parse(scheduleid), _class);

                    e.Cancel            = true;
                    GridView1.EditIndex = -1;
                    BindData();

                    //lblErrorMessageLocal.InnerText = "Flight Cost Updated";
                }
            }
            catch (ScheduleManagerException ex)
            {
                lblErrorMessageLocal.InnerText = ex.Message;
            }
        }
示例#30
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                Route            route           = null;
                IScheduleManager scheduleManager = (IScheduleManager)AirTravelManagerFactory.Create("ScheduleManager");

                Schedule schedule = new Schedule();

                string        rid          = dpRoute.SelectedValue;
                IRouteManager routeManager = (IRouteManager)BusinessObjectManager.GetRouteManager();
                try
                {
                    List <Route> routes = routeManager.GetRoutes();
                    foreach (Route r in routes)
                    {
                        if (r.ID == Convert.ToInt32(rid))
                        {
                            route = r;
                            break;
                        }
                    }
                }
                catch (RouteManagerException ex)
                {
                    ctlAdminMaster.ErrorMessage = ex.Message;
                }

                schedule.RouteInfo = route;
                if (scheduleManager.GetRouteID(schedule) == 0)
                {
                    ctlAdminMaster.ErrorMessage = "Select the Existing Route";
                }
                else if (dpFlightName.SelectedItem == null)
                {
                    ctlAdminMaster.ErrorMessage = "Please select a Flight name";
                }
                else
                {
                    TimeSpan t1 = TimeSpan.Parse(dpArrivalHours.SelectedItem.ToString() + ":" + dpArrivalMins.SelectedItem.ToString());
                    TimeSpan t2 = TimeSpan.Parse(dpDepartHours.SelectedItem.ToString() + ":" + dpDepartMins.SelectedItem.ToString());
                    total = int.Parse((t1 - t2).TotalMinutes.ToString());
                    if (total == 0)
                    {
                        ctlAdminMaster.ErrorMessage = "The departure time and the arrival time cannot be same";
                        return;
                    }

                    if (total < 0)
                    {
                        total = (24 * 60) + total;
                    }
                    txtDuration.Text = total.ToString();


                    Flight flight = new Flight();
                    flight.ID   = long.Parse(dpFlightName.SelectedItem.Value);
                    flight.Name = dpFlightName.SelectedItem.Text;

                    scheduleid              = Request.QueryString["scheduleid"].ToString();
                    schedule.ID             = long.Parse(scheduleid);
                    schedule.RouteInfo      = route;
                    schedule.FlightInfo     = flight;
                    schedule.DepartureTime  = TimeSpan.Parse(dpDepartHours.SelectedItem.ToString() + ":" + dpDepartMins.SelectedItem.ToString());
                    schedule.ArrivalTime    = TimeSpan.Parse(dpArrivalHours.SelectedItem.ToString() + ":" + dpArrivalMins.SelectedItem.ToString());
                    schedule.DurationInMins = total;
                    schedule.IsActive       = chkStatus.Checked;

                    scheduleManager.UpdateSchedule(schedule);
                    Response.Redirect("~/Admin/Schedule_Flight.aspx");
                }
            }
            catch (ScheduleManagerException ex)
            {
                ctlAdminMaster.ErrorMessage = ex.Message;
            }
        }