//航次基本信息绑定 private void bindVoyageInfo(string voyageid) { VoyageInfo vi = new VoyageInfo(); Voyage v = new Voyage(); vi = v.GetByID(voyageid); string voyageName = vi.Name; string beginDate = vi.BeginDate.ToString(); string endDate = vi.EndDate.ToString(); string routeId = vi.RouteID.ToString(); Route r = new Route(); RouteInfo ri = new RouteInfo(); ri = r.GetByID(routeId); float distance = ri.Distance; Ship ship = new Ship(); ShipInfo si = new ShipInfo(); si = ship.GetByID(vi.ShipID.ToString()); string shipName = si.Name; string chiefEngineer = si.ChiefEngineer; string captain = si.Captain; string generalManager = si.GeneralManager; Relation_RoutePort rrp = new Relation_RoutePort(); Relation_RoutePortInfo rrpi = new Relation_RoutePortInfo(); int startPortId = 0; int endPortId = 0; rrpi = rrp.GetListByRouteID(routeId)[0]; int portType = rrpi.PortTypeID; //出发港 if (portType == 2) { startPortId = rrpi.PortID; } //到达港 if (portType == 4) { endPortId = rrpi.PortID; } rrpi = rrp.GetListByRouteID(routeId)[1]; portType = rrpi.PortTypeID; //出发港 if (portType == 2) { startPortId = rrpi.PortID; } //到达港 if (portType == 4) { endPortId = rrpi.PortID; } Port p = new Port(); PortInfo pi = new PortInfo(); pi = p.GetByID(startPortId.ToString()); string startPortName = pi.Name; pi = p.GetByID(endPortId.ToString()); string endPortName = pi.Name; lblShipName.Text = shipName; lblDistance.Text = distance.ToString(); if (beginDate.Split(' ')[0].ToString().Equals("1900/1/1")) { lblStartTime.Text = ""; } else { lblStartTime.Text = beginDate; } if (endDate.Split(' ')[0].ToString().Equals("1900/1/1")) { lblStartTime.Text = ""; } else { lblEndTime.Text = endDate; } lblStartPort.Text = startPortName; lblEndPort.Text = endPortName; lblChiefEngineer.Text = chiefEngineer; lblCaptain.Text = captain; lblGeneralManager.Text = generalManager; }
protected void Page_Load(object sender, EventArgs e) { try { if (!IsPostBack) { TitleInitial("船舶装箱情况", "维护航次信息,可以同时编辑船只载货情况。载货情况根据船只的“装箱类型”填写:“集装箱”船填写箱量相关信息,“散货”船填写散货载货量信息。"); BindDDL(); #region 航次 string voyageId = GetRequest("voyageId"); VoyageInfo vInfo = new VoyageInfo(); if (string.IsNullOrEmpty(voyageId) == false) { this.VoyageId = voyageId; vInfo = new Voyage().GetByID(this.VoyageId); tbVoyageName.Text = vInfo.Name; ddlRouteName.SelectedValue = vInfo.RouteID.ToString(); ddlManagerType.SelectedValue = vInfo.ManagerTypeID; RouteInfo rInfo = new Route().GetByID(vInfo.RouteID.ToString()); lbRoute.Text = rInfo.TotalRoute; string stime = vInfo.BeginDate.Date.ToString("yyyy-MM-dd"); if (stime.Equals("1900-01-01")) { tbStartTime.Text = ""; ddlStartHour.SelectedValue = "0"; ddlStartMin.SelectedValue = "0"; } else { tbStartTime.Text = stime; ddlStartHour.SelectedValue = vInfo.BeginDate.Hour.ToString(); ddlStartMin.SelectedValue = vInfo.BeginDate.Minute.ToString(); } string etime = vInfo.EndDate.Date.ToString("yyyy-MM-dd"); if (etime.Equals("1900-01-01")) { tbEndTime.Text = ""; ddlEndHour.SelectedValue = "0"; ddlEndMin.SelectedValue = "0"; } else { tbEndTime.Text = etime; ddlEndHour.SelectedValue = vInfo.EndDate.Hour.ToString(); ddlEndMin.SelectedValue = vInfo.EndDate.Minute.ToString(); } ddlShipName.SelectedValue = vInfo.ShipID.ToString(); tbOrder.Text = vInfo.OrderNum.ToString(); ShipTypeInitial(); } #endregion // 装箱情况 VoyageLoadInitial(vInfo); } } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
private void BindData(string reportID) { try { double diffHrs = 0; string voyageName = ""; // 距离(海里) string distance = ""; // 经停港 string totalRoute = string.Empty; double sumDistance = 0; string shipName = ""; string sTime = ""; string eTime = ""; string sPort = ""; string ePort = ""; string captain = ""; string chiefEngineer = ""; string generalManager = ""; DateTime temp = new DateTime(); IList<VoyageInfo> vList = new Voyage().GetVoyageListByReportID(reportID); string voyageIds = string.Empty; for (int i = 0; i < vList.Count; i++) { VoyageInfo vInfo = vList[i]; voyageIds += "," + vInfo.ID; RouteInfo rInfo = new Route().GetByID(vInfo.RouteID.ToString()); if (i == 0) { shipName = vInfo.ShipName; sTime = vInfo.BeginDate.ToString("yyyy-MM-dd hh:mm"); sPort = vInfo.sName; captain = vInfo.Captain; chiefEngineer = vInfo.ChiefEngineer; generalManager = vInfo.GeneralManager; } voyageName += " + " + vInfo.Name; distance += " + " + vInfo.Distance; totalRoute += " + " + rInfo.TotalRoute; sumDistance += vInfo.Distance; ; eTime = vInfo.EndDate.ToString("yyyy-MM-dd hh:mm"); diffHrs += vInfo.DiffHours; if (Convert.ToDateTime(eTime) > temp) { temp = Convert.ToDateTime(eTime); ePort = vInfo.eName; } } this.VoyageIds = voyageIds.Substring(1); voyageName = string.IsNullOrEmpty(voyageName) ? string.Empty : voyageName.Substring(3); distance = string.IsNullOrEmpty(distance) ? string.Empty : distance.Substring(3); totalRoute = string.IsNullOrEmpty(totalRoute) ? string.Empty : totalRoute.Substring(3); // 显示总里程 if (vList.Count > 1) { distance += " = " + sumDistance.ToString(); } lblVoyage.Text = voyageName; lblDistance.Text = distance + " " + totalRoute; lblShipName.Text = shipName; lblStartTime.Text = sTime; lblStartPort.Text = sPort; lblEndTime.Text = eTime; lblEndPort.Text = ePort; ViewState["diffHrs"] = diffHrs.ToString(); HangciBaseInputInfo ii = new HangciBaseInput().GetByID(reportID); cCaptainDate.Text = ii.ShipInputDate.ToString("yyyy-MM-dd"); cGeneralDate.Text = ii.GeneralManagerDate.ToString("yyyy-MM-dd"); lblChiefEngineer.Text = chiefEngineer; lblCaptain.Text = captain; lblGeneralManager.Text = generalManager; bindConsumeInfo(reportID); bindOilBalanceInfo(reportID); } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
protected void ddlShipName_SelectedIndexChanged(object sender, EventArgs e) { try { VoyageInfo vInfo = new VoyageInfo(); string voyageId = this.VoyageId; if (string.IsNullOrEmpty(voyageId) == false) { vInfo = new Voyage().GetByID(voyageId); VoyageLoadInitial(vInfo); } ShipTypeInitial(); } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
protected void btnSaveVoyage_Click(object sender, EventArgs e) { try { VoyageInfo vi = new VoyageInfo(); if (string.IsNullOrEmpty(this.VoyageId) == false) { vi = new Voyage().GetByID(this.VoyageId); } vi.Name = tbVoyageName.Text; vi.ShipID = Convert.ToInt32(ddlShipName.SelectedValue); vi.RouteID = Convert.ToInt32(ddlRouteName.SelectedValue); vi.OrderNum = Convert.ToInt32(tbOrder.Text); vi.ManagerTypeID = ddlManagerType.SelectedValue; string stime = tbStartTime.Text; string sHour = ddlStartHour.SelectedValue; string sMin = ddlStartMin.SelectedValue; string etime = tbEndTime.Text; string eHour = ddlEndHour.SelectedValue; string eMin = ddlEndMin.SelectedValue; if (!stime.Equals("")) { string beginDate = string.Format("{0} {1}:{2}", stime, sHour, sMin); vi.BeginDate = DateTime.Parse(beginDate); } else { vi.BeginDate = Convert.ToDateTime("1900-01-01"); } if (!etime.Equals("")) { string endDate = string.Format("{0} {1}:{2}", etime, eHour, eMin); vi.EndDate = DateTime.Parse(endDate); } else { vi.EndDate = Convert.ToDateTime("1900-01-01"); } if (string.IsNullOrEmpty(this.VoyageId)) { this.VoyageId = new Voyage().Add(vi); } else { new Voyage().Update(vi); } ShowMsg("航次保存成功!"); } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
/// <summary> /// 初始化航次信息 /// </summary> /// <param name="voyageID"></param> private string VoyageInitial(string voyageIds) { //根据航次或者船舶绑定数据 string[] voyageIdArray = voyageIds.Split(','); IList<VoyageInfo> vList = new Voyage().GetList(voyageIdArray); ddlVoyage.DataSource = vList; ddlVoyage.DataBind(); string voyageID = voyageIdArray[0]; VoyageInfo vInfo = new Voyage().GetByID(voyageID); ddlVoyage.SelectedValue = voyageID; string shipID = vInfo.ShipID.ToString(); ShipInfo sInfo = new Ship().GetByID(shipID); lbShip.Text = sInfo.Name; string routeID = vInfo.RouteID.ToString(); RouteInfo rInfo = new Route().GetByID(routeID); lbRoute.Text = rInfo.Name; lbMile.Text = rInfo.Distance.ToString(); IList<PortInfo> pList = new Port().GetList(routeID, "2"); lbBegin.Text = pList[0].Name; pList = new Port().GetList(routeID, "4"); lbEnd.Text = pList[0].Name; return voyageID; }
/// <summary> /// 根据页面实体设置页面值 /// </summary> /// <param name="wInfo"></param> private void SetPageValue(InsuranceOfFreightTransportInfo wInfo) { tbUserName.Text = this.UserCacheInfo.Name; tbCreateTime.Text = wInfo.CreateTime.ToShortDateString(); tbYear.Text = wInfo.CreateTime.Year.ToString(); tbMonth.Text = wInfo.CreateTime.Month.ToString(); if (string.IsNullOrEmpty(wInfo.ID)) { return; } DimTimeInfo dInfo = new DimTime().GetDimTimeInfo(wInfo.DimTimeID); tbMonth.Text = dInfo.MonthNumOfYear.ToString(); tbYear.Text = dInfo.Year.ToString(); ddlVoyage.SelectedValue = wInfo.VoyageID; VoyageInfo vInfo = new Voyage().GetByID(wInfo.VoyageID); ddlShip.SelectedValue = vInfo.ShipID.ToString(); ddlCurrency.SelectedValue = wInfo.CurrencyID; ddlYear.SelectedValue = dInfo.Year.ToString(); ddlMonth.SelectedValue = dInfo.MonthNumOfYear.ToString(); tb20英尺.Text = wInfo.Amount50kilo20feet; tb40英尺.Text = wInfo.Amount50kilo40feet; BindList(this.ID); tb总保费.Text = wInfo.总保费; lb总重柜量.Text = wInfo.总重柜量; tb备注.Text = wInfo.备注; }
private void BindVoyage(string shipID) { IList<VoyageInfo> sList = new Voyage().GetListByShipID(shipID); if (null == sList || sList.Count == 0) { sList = new List<VoyageInfo>(); VoyageInfo vInfo = new VoyageInfo(); vInfo.Name = "未关联到任何航次"; sList.Add(vInfo); } ddlVoyage.DataSource = sList; ddlVoyage.DataBind(); }
/// <summary> /// 绑定航次报表 /// </summary> private void BindVoyage(int pageIndex) { string shipID = MonthAndShipNavigate1.ShipID; string dateID = MonthAndShipNavigate1.DateID; DataSet ds = new Voyage().GetBaseList(true, dateID, shipID, pGridV.PageSize, pageIndex); gvVoyageList.DataSource = ds; gvVoyageList.DataBind(); CustomDataSet cDS = ds as CustomDataSet; if (cDS == null) { pGridV.TotalAmout = 0; return; } pGridV.TotalAmout = cDS.TotalAmout; }
/// <summary> /// 航次编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvVoyageList_RowCommand(object sender, GridViewCommandEventArgs e) { try { string voyageId = e.CommandArgument.ToString(); if (e.CommandName == "btnDelVoyage") { //是否报送 判断是否要删除 VoyageInfo vi = new Voyage().GetByID(voyageId); if (string.IsNullOrEmpty(vi.HangciBaseID) == false) { ShowMsg("请先删除这个航次对应的燃润料报表!"); return; } else { new Voyage().Delete(voyageId); ShowMsg("航次删除成功!"); BindVoyage(0); return; } } else if (e.CommandName == "btnEditVoyage") { string url = @"../Hangy/VoyageInput.aspx?voyageId=" + voyageId; Response.Redirect(url, false); } } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }