Пример #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 ScheduleDto(Schedule schedule)
 {
     _ScheduleId = schedule.ID;
     _VesselId = schedule.VesselId;
     _FareId = schedule.FareId;
     _SailingTime = schedule.SailingTime;
     _ArrivalTime = schedule.ArrivalTime;
 }
Пример #3
0
 public IList<FareType> GetAccommodationTypeBySchedule(int scheduleId)
 {
     IList<FareType> ftList = new List<FareType>();
      Schedule schedule = new Schedule().GetById(scheduleId, false);
      Vessel vessel = new Vessel().GetById(schedule.VesselId.Value, false);
      ftList = vessel.FareTypes;
      return ftList;
 }
Пример #4
0
 public void DoUpdate(int ID, int vesselId, int fareId, DateTime sailingTime, DateTime arrivalTime)
 {
     Schedule schedule = new Schedule().GetById(ID, true);
      schedule.VesselId = vesselId;
      schedule.FareId = fareId;
      schedule.SailingTime = sailingTime;
      schedule.ArrivalTime = arrivalTime;
      schedule.Update();
 }
Пример #5
0
        public static Schedule GetScheduleByValues(int vesselId, int fareId, DateTime sailingTime, DateTime arrivalTime)
        {
            OQL oql = new OQL(typeof(Schedule));
             oql.AddCondition(Condition.Eq(Schedule.Properties.VesselId, vesselId));
             oql.AddCondition(Condition.Eq(Schedule.Properties.FareId, fareId));
             oql.AddCondition(Condition.Eq(Schedule.Properties.SailingTime, sailingTime));
             oql.AddCondition(Condition.Eq(Schedule.Properties.ArrivalTime, arrivalTime));

             ScheduleList list = new Schedule().GetList(oql);
             if (list.Count == 1)
                 return list[0];
             else if (list.Count > 1)
                 throw new Exception("Duplicate Schedule Found");
             else
                 return null;
        }
Пример #6
0
        private Dictionary<string, object> InitRouteSchedule(int routeId)
        {
            DateTime dtNow = new DateTime(2008, 6, 1);
            ScheduleList routeScheduleList;
            routeScheduleList = new Schedule().GetScheduleListForRoute(routeId, dtNow);
            Dictionary<string,object> routeSchedules = new Dictionary<string,object>();
            foreach (Schedule s in routeScheduleList)
            {
                if (!routeSchedules.ContainsKey(s.SailingTime.Value.Year.ToString()))
                    routeSchedules.Add(s.SailingTime.Value.Year.ToString(), null);
                if (routeSchedules[s.SailingTime.Value.Year.ToString()] == null)
                    routeSchedules[s.SailingTime.Value.Year.ToString()] = new Dictionary<string, object>();

                Dictionary<string, object> monthList = (Dictionary<string, object>)routeSchedules[s.SailingTime.Value.Year.ToString()];
                if (!monthList.ContainsKey(s.SailingTime.Value.ToString("MMMM")))
                    monthList.Add(s.SailingTime.Value.ToString("MMMM"), null);
                if (monthList[s.SailingTime.Value.ToString("MMMM")] == null)
                    monthList[s.SailingTime.Value.ToString("MMMM")] = new Dictionary<string, object>();

                Dictionary<string, object> dayList = (Dictionary<string, object>)monthList[s.SailingTime.Value.ToString("MMMM")];
                if (!dayList.ContainsKey(s.SailingTime.Value.ToString("ddd dd")))
                    dayList.Add(s.SailingTime.Value.ToString("ddd dd"), null);
                if (dayList[s.SailingTime.Value.ToString("ddd dd")] == null)
                    dayList[s.SailingTime.Value.ToString("ddd dd")] = new Dictionary<string, object>();

                Dictionary<string, object> timeList = (Dictionary<string, object>)dayList[s.SailingTime.Value.ToString("ddd dd")];
                if (!timeList.ContainsKey(s.SailingTime.Value.ToString("HH:mm")))
                    timeList.Add(s.SailingTime.Value.ToString("HH:mm"), s.ID);
            }

            return routeSchedules;
        }
Пример #7
0
        protected void ddlTime_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList ddlTime =(DropDownList)sender;
            Label labArrivalDate = (Label)(ddlTime.Parent.FindControl("labArrivalDate"));
            Label labRouteNo = (Label)(ddlTime.Parent.FindControl("labRouteNo"));
            int rowIdx = Convert.ToInt32(labRouteNo.Text) - 1;
            ListView lvVehicle = (ListView)(this.lvTravelMethod.Items[rowIdx].FindControl("lvVehicle"));
            UpdatePanel upnlVehicle = (UpdatePanel)(this.lvTravelMethod.Items[rowIdx].FindControl("upnlVehicle"));
            if (ddlTime.SelectedIndex > 0)
            {
                int scheduleId = Convert.ToInt32(ddlTime.SelectedValue);
                Schedule schedule = new Schedule().GetById(scheduleId, false);

                labArrivalDate.Text = "Arrival date:" + schedule.ArrivalTime.Value.ToString("ddd dd MMMM yyyy, HH:mm");
                lvVehicle.Enabled = true;
                SortedList<string,string> types = new SortedList<string,string>();
                types.Add("", "--select--");
                foreach (FareItem fi in schedule.Fare.FareItems)
                {
                    if (fi.FareType is VehicleType &&
                        ((VehicleType)fi.FareType).MinLegth.HasValue &&
                        ((VehicleType)fi.FareType).MinLegth.Value>0)
                        if (!types.ContainsKey(fi.FareType.FareTypeName))
                            types.Add(fi.FareType.FareTypeName, fi.FareType.FareTypeName);
                }

                foreach (ListViewDataItem item in lvVehicle.Items)
                {
                    DropDownList ddlType = (DropDownList)(item.FindControl("ddlType"));
                    ddlType.DataSource = types;
                    ddlType.DataValueField = "Key";
                    ddlType.DataTextField = "Value";
                    ddlType.DataBind();
                }
            }
            else
            {
                labArrivalDate.Text = "";

                foreach (ListViewDataItem item in lvVehicle.Items)
                {
                    DropDownList ddlType = (DropDownList)(item.FindControl("ddlType"));
                    ddlType.SelectedIndex = 0;
                    DropDownList ddlHeight = (DropDownList)(item.FindControl("ddlHeight"));
                    ddlHeight.SelectedIndex = 0;
                    DropDownList ddlWidth = (DropDownList)(item.FindControl("ddlWidth"));
                    ddlWidth.SelectedIndex = 0;
                    TextBox txtLength = (TextBox)(item.FindControl("txtLength"));
                    txtLength.Text = "";

                }

                lvVehicle.Enabled = false;
            }
            upnlVehicle.Update();
        }
Пример #8
0
        private void UpdateSchedule(int id)
        {
            int vesselId;
            int fareId;
            DateTime sailingTime;
            DateTime arrivalTime;

            DropDownList ddlVessel = (DropDownList)this.FV_Schedule.FindControl("ddlVessel");
            DropDownList ddlFare = (DropDownList)this.FV_Schedule.FindControl("ddlFare");
            TextBox txtSailingTime = (TextBox)this.FV_Schedule.FindControl("txtSailingTime");
            TextBox txtArrivalTime = (TextBox)this.FV_Schedule.FindControl("txtArrivalTime");

            vesselId = (ddlVessel == null) ? 0 : Convert.ToInt32(ddlVessel.SelectedValue);
            fareId = (ddlFare == null) ? 0 : Convert.ToInt32(ddlFare.SelectedValue);

            if (DateTime.TryParse(txtSailingTime.Text.Trim(), out sailingTime)
                && DateTime.TryParse(txtArrivalTime.Text.Trim(), out arrivalTime)
                && vesselId != 0 && fareId != 0)
            {
                Schedule schedule = new Schedule();
                schedule.DoUpdate(id, vesselId, fareId, sailingTime, arrivalTime);
                BindList();

                if (ddlVessel != null)
                    ddlVessel.SelectedIndex = 0;
                if (ddlFare != null)
                    ddlFare.SelectedIndex = 0;

                this.lblMessage.Text = "Update successfully";
                this.lblMessage.ForeColor = Color.Green;
            }
            else
            {
                this.lblMessage.Text = "Update failed";
                this.lblMessage.ForeColor = Color.Red;
            }
        }
Пример #9
0
 private void BindList()
 {
     Schedule schedule = new Schedule();
     int vesselId = 0;
     int fareId = 0; ;
     if (this.ddlVessel.SelectedIndex != -1)
         int.TryParse(this.ddlVessel.SelectedValue, out vesselId);
     if (this.ddlFare.SelectedIndex != -1)
         int.TryParse(this.ddlFare.SelectedValue, out fareId);
     DateTime startTime = new DateTime(1900, 1, 1);
     DateTime endTime = DateTime.MaxValue;
     DateTime.TryParse(this.txtStartDate.Text, out startTime);
     DateTime.TryParse(this.txtEndDate.Text, out endTime);
     if (startTime == DateTime.MinValue)
         startTime = new DateTime(1900, 1, 1);
     if (endTime == DateTime.MinValue)
         endTime = DateTime.MaxValue;
     if (endTime != DateTime.MaxValue)
         endTime = endTime.AddDays(1.0);
     ScheduleList list = schedule.GetScheduleList(vesselId, fareId, startTime, endTime);
     this.GV_ScheduleList.DataSource = list;
     this.GV_ScheduleList.DataBind();
     this.lblMessage.Text = "";
 }
Пример #10
0
 public void DoDelete(int ID)
 {
     Schedule schedule = new Schedule().GetById(ID, true);
      schedule.Delete();
 }
Пример #11
0
 public static void DoInsert(Schedule schedule)
 {
     schedule.Create();
 }
        private DataTable ImportScheduleDumpFile(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 = ",Sailing,Vessel,Depschid,Dep,Departs,Arrschid,Arr,Arrives,";
            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 strVessel = row["Vessel"].ToString();
                if (!string.IsNullOrEmpty(strVessel))
                {
                    Vessel vessel = Vessel.GetVesselByCode(strVessel.Trim());
                    if (vessel != null)
                    {
                        string depPortId = row["Dep"].ToString().Trim();
                        string arrPortId = row["Arr"].ToString().Trim();
                        Port dport = new Port().GetById(depPortId, false);
                        Port aport = new Port().GetById(arrPortId, false);
                        if (dport != null && aport != null)
                        {
                            Company c = Company.GetCompanyByShortName("AMHS");
                            int operatorId = c.ID;

                            Route r = Route.GetRouteByPortId(depPortId, arrPortId, operatorId);
                            if (r != null)
                            {
                                int routeId = r.ID;
                                string strDepDatetime = row["Departs"].ToString();
                                string strArrDatetime = row["Arrives"].ToString();
                                DateTime depDatetime = DateTime.MinValue;
                                DateTime arrDatetime = DateTime.MinValue;
                                if (DateTime.TryParse(strDepDatetime, out depDatetime)
                                    && DateTime.TryParse(strArrDatetime, out arrDatetime))
                                {
                                    Fare availableFare = Fare.GetFareForSchedule(routeId, depDatetime);
                                    if (availableFare != null)
                                    {
                                        if (Schedule.GetScheduleByValues(vessel.ID, availableFare.ID, depDatetime, arrDatetime) == null)
                                        {
                                            Schedule newSchedule = new Schedule();
                                            newSchedule.VesselId = vessel.ID;
                                            newSchedule.FareId = availableFare.ID;
                                            newSchedule.SailingTime = depDatetime;
                                            newSchedule.ArrivalTime = arrDatetime;
                                            Schedule.DoInsert(newSchedule);
                                        }
                                    }
                                    else
                                    {
                                        dtErrInfo.Rows.Add(new object[] { rowNumber, "Fare", "Null", "Fare is worng format or value" });
                                        continue;
                                    }
                                }
                                else
                                {
                                    dtErrInfo.Rows.Add(new object[] { rowNumber, "Dep/Arr DateTime", "Null", "Dep/Arr DateTime is worng format or value" });
                                    continue;
                                }
                            }
                            else
                            {
                                dtErrInfo.Rows.Add(new object[] { rowNumber, "Route", "Null", "Route is worng format or value" });
                                continue;
                            }
                        }
                        else
                        {
                            dtErrInfo.Rows.Add(new object[] { rowNumber, "Dep/Arr Port", "Null", "Dep/Arr Port is worng format or value" });
                            continue;
                        }
                    }
                    else
                    {
                        dtErrInfo.Rows.Add(new object[] { rowNumber, "Vessel", "Null", "Vessel is worng format or value" });
                        continue;
                    }
                }
                else
                {
                    dtErrInfo.Rows.Add(new object[] { rowNumber, "Vessel", "Null", "Vessel is worng format or value" });
                    continue;
                }
            }
            return dtErrInfo;
        }
Пример #13
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;
 }