//航次基本信息绑定 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; }
/// <summary> /// 增改船舶 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSaveShip_Click(object sender, EventArgs e) { try { string shipID = lbID2.Value; ShipInfo sInfo = new ShipInfo(); sInfo.Name = tbName.Text; sInfo.Code = tbCode.Text; sInfo.Captain = tbCaptain.Text; sInfo.ChiefEngineer = tbChiefEngineer.Text; sInfo.GeneralManager = tbGeneralManager.Text; sInfo.RentDate = (string.IsNullOrEmpty(cRentDate.Text.Trim())) ? DateTime.MaxValue : Convert.ToDateTime(cRentDate.Text); sInfo.LoadType = rblLoadType.SelectedValue; sInfo.OperationType = rblOperationType.SelectedValue; if (string.IsNullOrEmpty(shipID)) { new Ship().Add(sInfo); } else { sInfo.ID = shipID; new Ship().Update(sInfo); } ShowMsg("操作成功!"); BindShip(0); } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
/// <summary> /// 添加船舶 /// </summary> /// <param name="cInfo">实体</param> /// <returns>新增实体的主键</returns> public string Add(ShipInfo cInfo) { return dal.Add(cInfo); }
/// <summary> /// 更新船舶 /// </summary> /// <param name="cInfo">实体</param> public void Update(ShipInfo cInfo) { if (string.IsNullOrEmpty(cInfo.ID)) { throw new ArgumentNullException("参数ID不能为空。"); } dal.Update(cInfo); }
/// <summary> /// 添加船舶 /// </summary> /// <param name="ID">实体主键</param> /// <returns></returns> public void Delete(string ID) { ShipInfo cInfo = new ShipInfo(); cInfo.ID = ID; dal.Delete(cInfo); }