Пример #1
0
        protected void lvSummary_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                ListViewDataItem dataItem = (ListViewDataItem)e.Item;
                RouteOrder r = (RouteOrder)(dataItem.DataItem);

                Label lblRouteTotal = (Label)(dataItem.FindControl("lblRouteTotal"));
                lblRouteTotal.Text = r.RouteTotalAmount.ToString("c") + " USD";

                Label lblRouteName = (Label)(dataItem.FindControl("lblRouteName"));
                Route route = new Route().GetRouteBySchedule(r.ScheduleId.Value);
                lblRouteName.Text = route.DeparturePort.PortName + " - " + route.ArriavlPort.PortName;

                Schedule schedule = new Schedule().GetById(r.ScheduleId.Value, false);
                Label lblVesselName = (Label)(dataItem.FindControl("lblVesselName"));
                lblVesselName.Text = schedule.Vessel.VesselName;

                Vessel vessel = new Vessel().GetById(schedule.VesselId.Value, false);
                Label lblCompanyName = (Label)(dataItem.FindControl("lblCompanyName"));
                lblCompanyName.Text = vessel.Operator.CompanyName;

                Label lblDepartureDatetime = (Label)(dataItem.FindControl("lblDepartureDatetime"));
                lblDepartureDatetime.Text = schedule.SailingTime.HasValue ? schedule.SailingTime.Value.ToString() : string.Empty;

                Label lblArrivalDatetime = (Label)(dataItem.FindControl("lblArrivalDatetime"));
                lblArrivalDatetime.Text = schedule.ArrivalTime.HasValue ? schedule.ArrivalTime.Value.ToString() : string.Empty;

                Label lblPassenger = (Label)(dataItem.FindControl("lblPassenger"));
                Label lblTransport = (Label)(dataItem.FindControl("lblTransport"));
                Label lblAccommodation = (Label)(dataItem.FindControl("lblAccommodation"));

            }
        }
Пример #2
0
 public RouteDto(Route route)
 {
     _RoutesID = route.ID;
     _OperatorId = route.OperatorId;
     _DeparturePortId = route.DeparturePortId;
     _ArriavlPortId = route.ArriavlPortId;
     _IsActive = route.IsActive;
 }
Пример #3
0
 public void DoUpdate(int ID, int operatorId, string departurePortId, string arrivalPortId)
 {
     Route route = new Route().GetById(ID, true);
      route.OperatorId = operatorId;
      route.DeparturePortId = departurePortId;
      route.ArriavlPortId = arrivalPortId;
      route.Update();
 }
Пример #4
0
        public static Route GetRouteByPortId(string depPortId, string arrPortId, int operatorId)
        {
            OQL oql = new OQL(typeof(Route));
             if (string.IsNullOrEmpty(depPortId) || string.IsNullOrEmpty(arrPortId) || operatorId <= 0)
                 return null;

             oql.AddCondition(Condition.Eq(Route.Properties.OperatorId, operatorId));
             oql.AddCondition(Condition.Eq(Route.Properties.DeparturePortId, depPortId));
             oql.AddCondition(Condition.Eq(Route.Properties.ArriavlPortId, arrPortId));

             RouteList list = new Route().GetList(oql);
             if (list.Count == 1)
                 return list[0];
             else if (list.Count > 1)
                 throw new Exception("Duplicate route with same operator, departure port and arrival port found.");
             else
                 return null;
        }
Пример #5
0
        protected void lvAccommodation_ItemDataBound(object sender, ListViewItemEventArgs e)
        {
            if (e.Item.ItemType == ListViewItemType.DataItem)
            {
                ListViewDataItem dataItem = (ListViewDataItem)e.Item;
                RouteOrder r = (RouteOrder)(dataItem.DataItem);
                Label lblRoute = (Label)(dataItem.FindControl("lblRoute"));
                Route route = new Route().GetRouteBySchedule(r.ScheduleId.Value);
                lblRoute.Text = route.DeparturePort.PortName+ " - " + route.ArriavlPort.PortName;

                GridView gvAccommodation = (GridView)(dataItem.FindControl("gvAccommodation"));
                if (gvAccommodation != null)
                {
                    IList<FareType> ftList = new FareType().GetAccommodationTypeBySchedule(r.ScheduleId.Value);
                    gvAccommodation.DataSource = ftList;
                    gvAccommodation.DataBind();
                }
            }
        }
Пример #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!(Session[ByteCore.FerryBooking.Web.SessionVariable.Step1UserInput] is Step1UserInput))
            {
                Response.Redirect("Default.aspx");
            }
            Step1UserInput step1 = (Step1UserInput)Session[SessionVariable.Step1UserInput];
            if (!Page.IsPostBack)
            {
                RouteList routelist = new RouteList();
                Route r1 = new Route().GetById(step1.Route1Id,false);
                routelist.Add(r1);

                Hashtable htSchedulePreLoad = new Hashtable();
                htSchedulePreLoad.Add(r1.ID.ToString(),InitRouteSchedule(step1.Route1Id));

                if (step1.Route2Id>0)
                {
                    Route r2 = new Route().GetById(step1.Route2Id, false);
                    routelist.Add(r2);
                    htSchedulePreLoad.Add(r2.ID.ToString(), InitRouteSchedule(step1.Route2Id));
                }

                if (step1.Route3Id>0)
                {
                    Route r3 = new Route().GetById(step1.Route3Id, false);
                    routelist.Add(r3);
                    htSchedulePreLoad.Add(r3.ID.ToString(), InitRouteSchedule(step1.Route3Id));
                }

                if (step1.Route4Id > 0)
                {
                    Route r4 = new Route().GetById(step1.Route4Id, false);
                    routelist.Add(r4);
                    htSchedulePreLoad.Add(r4.ID.ToString(), InitRouteSchedule(step1.Route4Id));
                }

                Session[SessionVariable.RouteSchedules] = htSchedulePreLoad;

                this.lvSchedule.DataSource = routelist;
                lvSchedule.DataBind();
                RouteOrderPassengerDetailList passengerList = new RouteOrderPassengerDetailList();
                for (int i = 0; i < step1.PassengersCount; i++)
                {
                    passengerList.Add(new RouteOrderPassengerDetail());
                }

                lvPassenger.DataSource = passengerList;
                lvPassenger.DataBind();

                lvTravelMethod.DataSource = routelist;
                lvTravelMethod.DataBind();
            }
        }
Пример #7
0
        private void UpdateRoute(int id)
        {
            int operatorId;
            string departurePortId;
            string arrivalPortId;

            DropDownList ddlOperator = (DropDownList)this.FV_Route.FindControl("ddlOperator");
            DropDownList ddlDeparturePort = (DropDownList)this.FV_Route.FindControl("ddlDeparturePort");
            DropDownList ddlArrivalPort = (DropDownList)this.FV_Route.FindControl("ddlArrivalPort");

            operatorId = (ddlOperator == null) ? 0 : Convert.ToInt32(ddlOperator.SelectedValue);
            departurePortId = (ddlDeparturePort == null) ? "" : ddlDeparturePort.SelectedValue;
            arrivalPortId = (ddlArrivalPort == null) ? "" : ddlArrivalPort.SelectedValue;

            Route route = new Route();
            route.DoUpdate(id, operatorId, departurePortId, arrivalPortId);
            BindList();

            if (ddlOperator != null)
                ddlOperator.SelectedIndex = 0;
            if (ddlDeparturePort != null)
                ddlDeparturePort.SelectedIndex = 0;
            if (ddlArrivalPort != null)
                ddlArrivalPort.SelectedIndex = 0;

            this.lblMessage.Text = "Update successfully";
            this.lblMessage.ForeColor = Color.Green;
        }
Пример #8
0
        private void InsertRoute()
        {
            int operatorId;
            string departurePortId;
            string arrivalPortId;

            DropDownList ddlOperator = (DropDownList)this.FV_Route.FindControl("ddlOperator");
            DropDownList ddlDeparturePort = (DropDownList)this.FV_Route.FindControl("ddlDeparturePort");
            DropDownList ddlArrivalPort = (DropDownList)this.FV_Route.FindControl("ddlArrivalPort");

            operatorId = (ddlOperator == null) ? 0 : Convert.ToInt32(ddlOperator.SelectedValue);
            departurePortId = (ddlDeparturePort == null) ? "" : ddlDeparturePort.SelectedValue;
            arrivalPortId = (ddlArrivalPort == null) ? "" : ddlArrivalPort.SelectedValue;

            _route = new Route();
            _route.OperatorId = operatorId;
            _route.DeparturePortId = departurePortId;
            _route.ArriavlPortId = arrivalPortId;

            Route.DoInsert(_route);

            BindList();

            if (ddlOperator != null)
                ddlOperator.SelectedIndex = 0;
            if (ddlDeparturePort != null)
                ddlDeparturePort.SelectedIndex = 0;
            if (ddlArrivalPort != null)
                ddlArrivalPort.SelectedIndex = 0;

            this.lblMessage.Text = "Insert successfully";
            this.lblMessage.ForeColor = Color.Green;
        }
        public DataTable ImportFareDumpFile(string fileName)
        {
            DataTable dt = null;
            DataTable dtErrInfo = new DataTable();
            dtErrInfo.Columns.Add("RowNumber", typeof(int));
            dtErrInfo.Columns.Add("ErrColumnName", typeof(string));
            dtErrInfo.Columns.Add("ErrColumnData", typeof(string));
            dtErrInfo.Columns.Add("ErrDescription", typeof(string));

            dt = this.GetDataTableFromExcel(fileName);

            //Check Column in imported Excel file match the template, no missing column
            string columnNames;
            columnNames = ",Dep,Arr,Dreg,Areg,Category,Facility,Minlength,Maxlength,Amount,Byfootamt,Startdate,Enddate,Recid,Description,";
            int rowNumber = 0;
            foreach (DataColumn column in dt.Columns)
            {
                if (columnNames.IndexOf("," + column.ColumnName + ",") < 0)
                    dtErrInfo.Rows.Add(new object[] { rowNumber, column.ColumnName, "Template Error", "The column in XLS file does not match orinigal template" });
            }
            if (dtErrInfo.Rows.Count > 0)
                return dtErrInfo;

            //Check if column “Dep” and “Arr”(Port Code) exists in Port table.
            //If not then create port
            foreach (DataRow row in dt.Rows)
            {
                string depPortId = row["Dep"].ToString();
                string arrPortId = row["Arr"].ToString();
                if (string.IsNullOrEmpty(depPortId) || string.IsNullOrEmpty(arrPortId))
                    continue;
                Port dport = new Port().GetById(depPortId, false);
                if (dport == null)
                {
                    Port dp = new Port();
                    dp.DoInsert(depPortId, depPortId);
                }
                Port aport = new Port().GetById(arrPortId, false);
                if (aport == null)
                {
                    Port ap = new Port();
                    ap.DoInsert(arrPortId, arrPortId);
                }

                //Select distinct column “Dep” and “Arr” from Route table, if not exist, insert into Route table
                Company c = Company.GetCompanyByShortName("AMHS");
                int operatorId = c.ID;

                Route r = Route.GetRouteByPortId(depPortId, arrPortId, operatorId);
                int routeId;
                if (r == null)
                {
                    Route newRoute = new Route();
                    newRoute.OperatorId = operatorId;
                    newRoute.DeparturePortId = depPortId;
                    newRoute.ArriavlPortId = arrPortId;
                    newRoute.IsActive = true;
                    Route.DoInsert(newRoute);
                    routeId = newRoute.ID;
                }
                else
                {
                    routeId = r.ID;
                }

                //Create a record in Fare table (RouteID, StartDate, EndDate)
                string strStartDate = row["Startdate"].ToString();
                string strEndDate = row["Enddate"].ToString();
                DateTime startDate = DateTime.MaxValue;
                DateTime endDate = DateTime.MaxValue;
                if (string.IsNullOrEmpty(strStartDate) || string.IsNullOrEmpty(strEndDate))
                {
                    dtErrInfo.Rows.Add(new object[] { rowNumber, "StartDate/EndDate", "Null", " StartDate/EndDate is worng format or value" });
                    continue;
                }

                if (DateTime.TryParse(strStartDate, out startDate) && DateTime.TryParse(strEndDate, out endDate))
                {
                    int fareId;
                    Fare existingFare = Fare.GetFareByRouteAndDateRange(routeId, startDate, endDate);
                    if (existingFare == null)
                    {
                        Fare newFare = new Fare();
                        newFare.RoutesID = routeId;
                        newFare.StartDate = startDate;
                        newFare.EndDate = endDate;
                        Fare.DoInsert(newFare);
                        fareId = newFare.ID;
                    }
                    else
                    {
                        fareId = existingFare.ID;
                    }

                    string strCategory = row["Category"].ToString();
                    FareCategory fareCategory = FareCategory.GetCategoryByName(strCategory);
                    if (fareCategory == null)
                    {
                        dtErrInfo.Rows.Add(new object[] { rowNumber, "Fare Category", "Null", " Fare Category not found" });
                        continue;
                    }

                    int categoryId = fareCategory.ID;
                    string strFacility = row["Facility"].ToString();
                    string strDescription = row["Description"].ToString();
                    if (!string.IsNullOrEmpty(strFacility) && !string.IsNullOrEmpty(strDescription))
                    {
                        int fareTypeId = 0;
                        int minLength = 0;
                        int maxLength = 0;
                        decimal amount = 0.0m;
                        decimal byFootAmount = 0.0m;
                        string strMinLength = row["Minlength"].ToString();
                        string strMaxLength = row["Maxlength"].ToString();
                        string strAmount = row["Amount"].ToString();
                        string strByFootAmount = row["Byfootamt"].ToString();
                        decimal.TryParse(strByFootAmount, out byFootAmount);
                        FareType existingFareType = FareType.GetFareTypeByValue(operatorId, categoryId, strFacility, strDescription);
                        if (existingFareType == null)
                        {
                            if (decimal.TryParse(strAmount, out amount))
                            {
                                int.TryParse(strMinLength, out minLength);
                                int.TryParse(strMaxLength, out maxLength);
                                if (strCategory == EnumFareCategory.CARDECK.ToString())
                                {
                                    VehicleType newVehicleType = new VehicleType();
                                    newVehicleType.OperatorId = operatorId;
                                    newVehicleType.CategoryId = categoryId;
                                    newVehicleType.FareTypeName = strFacility;
                                    newVehicleType.FareTypeDescription = strDescription;
                                    newVehicleType.MinLegth = minLength;
                                    newVehicleType.MaxLegth = maxLength;
                                    newVehicleType.ByFootAmount = byFootAmount;
                                    VehicleType.DoInsert(newVehicleType);
                                    fareTypeId = newVehicleType.ID;
                                }
                                else if (strCategory == EnumFareCategory.PASSAGE.ToString())
                                {
                                    int defaultMinAge = 0;
                                    int defaultMaxAge = 0;
                                    switch (strFacility.ToUpper())
                                    {
                                        case "ADT":
                                            defaultMinAge = 12;
                                            defaultMaxAge = 65;
                                            break;
                                        case "CHD":
                                            defaultMinAge = 6;
                                            defaultMaxAge = 12;
                                            break;
                                        case "SRC":
                                            defaultMinAge = 65;
                                            defaultMaxAge = 99;
                                            break;
                                        case "UND":
                                            defaultMinAge = 0;
                                            defaultMaxAge = 6;
                                            break;
                                        default:
                                            break;
                                    }
                                    PassengerType newPassegerType = new PassengerType();
                                    newPassegerType.OperatorId = operatorId;
                                    newPassegerType.CategoryId = categoryId;
                                    newPassegerType.FareTypeName = strFacility;
                                    newPassegerType.FareTypeDescription = strDescription;
                                    if (minLength == 0)
                                    {
                                        minLength = defaultMinAge;
                                        newPassegerType.MinAge = defaultMinAge;
                                    }
                                    else
                                        newPassegerType.MinAge = minLength;
                                    if (maxLength == 0)
                                    {
                                        maxLength = defaultMaxAge;
                                        newPassegerType.MaxAge = defaultMaxAge;
                                    }
                                    else
                                        newPassegerType.MaxAge = maxLength;
                                    PassengerType.DoInsert(newPassegerType);
                                    fareTypeId = newPassegerType.ID;
                                }
                                else
                                {
                                    FareType newFareType = new FareType();
                                    newFareType.OperatorId = operatorId;
                                    newFareType.CategoryId = categoryId;
                                    newFareType.FareTypeName = strFacility;
                                    newFareType.FareTypeDescription = strDescription;
                                    FareType.DoInsert(newFareType);
                                    fareTypeId = newFareType.ID;
                                }
                            }
                            else
                            {
                                dtErrInfo.Rows.Add(new object[] { rowNumber, "Minlength/Maxlength/Amount", "Null", "Minlength/Maxlength/Amount is worng format or value" });
                                continue;
                            }
                        }
                        else
                        {
                            int.TryParse(strMinLength, out minLength);
                            int.TryParse(strMaxLength, out maxLength);
                            decimal.TryParse(strAmount, out amount);
                            fareTypeId = existingFareType.ID;
                        }

                        if (FareItem.GetFareItemByValues(fareTypeId, fareId, minLength, maxLength, amount) == null)
                        {
                            FareItem newFareItem = new FareItem();
                            newFareItem.FareTypeId = fareTypeId;
                            newFareItem.FareId = fareId;
                            newFareItem.RangeStart = minLength;
                            newFareItem.RangeEnd = maxLength;
                            newFareItem.Amount = amount;
                            newFareItem.ByFootAmount = byFootAmount;
                            FareItem.DoInsert(newFareItem);
                        }
                    }
                    else
                    {
                        dtErrInfo.Rows.Add(new object[] { rowNumber, "Facility/Description", "Null", " Facility/Description is worng format or value" });
                        continue;
                    }
                }
                else
                {
                    dtErrInfo.Rows.Add(new object[] { rowNumber, "StartDate/EndDate", "Null", " StartDate/EndDate is worng format or value" });
                    continue;
                }
            }

            return dtErrInfo;
        }
Пример #10
0
 private void BindRoute()
 {
     int operatorInd = Convert.ToInt32(this.ddlOperator.SelectedValue);
     Route r = new Route();
     RouteList rlist = r.GetRouteList(operatorInd);
     this.ddlRoute.DataSource = rlist;
     this.ddlRoute.DataTextField = "FullName";
     this.ddlRoute.DataValueField = "ID";
     this.ddlRoute.DataBind();
     this.ddlRoute.Items.Insert(0, new ListItem("-- Show All --", "0"));
 }
Пример #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                List<KeyValuePair<string, string>> routeList = new Route().GetKeyValueList();
                routeList.Insert(0, new KeyValuePair<string, string>("0", "(select outward route)"));
                ddlRoute1.DataSource = routeList;
                ddlRoute1.DataValueField = "Key";
                ddlRoute1.DataTextField = "Value";
                ddlRoute1.DataBind();
                ddlRoute1.SelectedIndex = 0;

                List<KeyValuePair<string, string>> routeEmptyList = new List<KeyValuePair<string,string>>();
                routeEmptyList.Insert(0, new KeyValuePair<string, string>("0", "(select return route)"));
                ddlRoute2.DataSource = routeEmptyList;
                ddlRoute2.DataValueField = "Key";
                ddlRoute2.DataTextField = "Value";
                ddlRoute2.DataBind();
                ddlRoute2.SelectedIndex = 0;

                ddlRoute3.DataSource = routeEmptyList;
                ddlRoute3.DataValueField = "Key";
                ddlRoute3.DataTextField = "Value";
                ddlRoute3.DataBind();
                ddlRoute3.SelectedIndex = 0;

                ddlRoute4.DataSource = routeEmptyList;
                ddlRoute4.DataValueField = "Key";
                ddlRoute4.DataTextField = "Value";
                ddlRoute4.DataBind();
                ddlRoute4.SelectedIndex = 0;

                List<KeyValuePair<int, string>> passengerList = new List<KeyValuePair<int,string>>();
                passengerList.Add(new KeyValuePair<int, string>(0, "Select total passengers"));
                for (int i = 1; i < 10; i++)
                {
                    passengerList.Add(new KeyValuePair<int, string>(i, i.ToString() + " passengers"));
                }

                List<KeyValuePair<int, string>> vehicleList = new List<KeyValuePair<int, string>>();
                vehicleList.Add(new KeyValuePair<int, string>(0, "Select total vehicles"));
                for (int i = 1; i < 10; i++)
                {
                    vehicleList.Add(new KeyValuePair<int, string>(i, i.ToString() + " vehicles"));
                }

                ddlPassengers.DataSource = passengerList;
                ddlPassengers.DataValueField = "Key";
                ddlPassengers.DataTextField = "Value";
                ddlPassengers.DataBind();
                ddlPassengers.SelectedIndex = 0;

                ddlVehicles.DataSource = vehicleList;
                ddlVehicles.DataValueField = "Key";
                ddlVehicles.DataTextField = "Value";
                ddlVehicles.DataBind();
                ddlVehicles.SelectedIndex = 0;

                string jscript;
                jscript = string.Format(
                    @"
                    var route1 = document.getElementById('{0}');
                    var route2 = document.getElementById('{1}');
                    var route3 = document.getElementById('{2}');
                    var route4 = document.getElementById('{3}');
                    var passengers = document.getElementById('{4}');
                    var vehicles = document.getElementById('{5}');
                    route3.style.display = 'none';
                    route4.style.display = 'none';
                    var singleRb = document.getElementById('{6}');
                    var returnRb = document.getElementById('{7}');
                    var multiRb = document.getElementById('{8}');
                    "
                    , this.ddlRoute1.ClientID
                    ,this.ddlRoute2.ClientID
                    ,this.ddlRoute3.ClientID
                    ,this.ddlRoute4.ClientID
                    ,this.ddlPassengers.ClientID
                    ,this.ddlVehicles.ClientID
                    ,this.rbSingle.ClientID
                    ,this.rbReturn.ClientID
                    ,this.rbMulti.ClientID
                    );

                jscript += "initRouteDataSource();";

                Page.ClientScript.RegisterStartupScript(this.GetType(), "StartUp", jscript, true);

                rbReturn.Attributes.Add("onChange", "javascript:return on_rbReturn();");
                rbSingle.Attributes.Add("onChange", "javascript:return on_rbSingle();");
                rbMulti.Attributes.Add("onChange", "javascript:return on_rbMulti();");
                ddlRoute1.Attributes.Add("onChange", "javascript:return on_route1_change();");
            }
        }
Пример #12
0
 public void DoDelete(int ID)
 {
     Route route = new Route().GetById(ID, false);
      route.Delete();
 }
Пример #13
0
 public static void DoInsert(Route route)
 {
     route.Create();
 }
Пример #14
0
 public Route GetRouteBySchedule(int scheduleId)
 {
     Schedule schedule = new Schedule().GetById(scheduleId, false);
      Fare fare = new Fare().GetById(schedule.FareId.Value, false);
      Route route = new Route().GetById(fare.RoutesID.Value, false);
      return route;
 }