/// <summary> /// 添加费用类别 /// </summary> /// <param name="cInfo">实体</param> /// <returns>新增实体的主键</returns> public string Add(Relation_RoutePortInfo cInfo) { // 如果是始运港,排序为0,如果是目的港,排序为99,其他类型排序号不变 if (cInfo.PortTypeID == 2) { cInfo.OrderNum = "0"; } else if (cInfo.PortTypeID == 4) { cInfo.OrderNum = "99"; } else { int order = int.Parse(cInfo.OrderNum); if (order < 1 || order > 98) { throw new ArgumentException("排序号必须为1-98之间的数字。"); } } return dal.Add(cInfo); }
//航次基本信息绑定 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 btnSaveRoute_Click(object sender, EventArgs e) { try { RouteInfo ri = new RouteInfo(); ri.Distance = float.Parse(tbDistance.Text); ri.Name = tbRouteName.Text; Relation_RoutePortInfo rrpis = new Relation_RoutePortInfo(); rrpis.PortID = Convert.ToInt32(ddlStartPort.SelectedValue); rrpis.PortTypeID = 2; rrpis.OrderNum = "0"; Relation_RoutePortInfo rrpie = new Relation_RoutePortInfo(); rrpie.PortID = Convert.ToInt32(ddlEndPort.SelectedValue); rrpie.PortTypeID = 4; rrpie.OrderNum = "0"; //新增 if (string.IsNullOrEmpty(lbID.Value)) { int routeId = Convert.ToInt32(new Route().Add(ri)); //始发港 rrpis.RouteID = routeId; new Relation_RoutePort().Add(rrpis); //目的港 rrpie.RouteID = routeId; new Relation_RoutePort().Add(rrpie); } //编辑 else { int routeId = Convert.ToInt32(lbID.Value); ri.ID = routeId.ToString(); new Route().Update(ri); //始发港 rrpis.RouteID = routeId; IList<PortInfo> pList = new Port().GetList(routeId.ToString(), "2"); rrpis.ID = new Port().GetPortListByRoute(routeId.ToString(), "2").Tables[0].Rows[0]["relateId"].ToString(); new Relation_RoutePort().Update(rrpis); //目的港 rrpie.RouteID = routeId; rrpie.ID = new Port().GetPortListByRoute(routeId.ToString(), "4").Tables[0].Rows[0]["relateId"].ToString(); new Relation_RoutePort().Update(rrpie); string id = lbID.Value; RouteInfo rInfo = new Route().GetByID(id); lbTotalRoute.Text = rInfo.TotalRoute; } BindRoute(0, pGrid.PageSize); BindPassPortList(lbID.Value); ShowMsg("操作成功!"); } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
/// <summary> /// 经停港按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void gvPassedPorts_RowCommand(object sender, GridViewCommandEventArgs e) { try { int routeId = Convert.ToInt32(lbID.Value); if (e.CommandName == "btnDel") { string relateId = e.CommandArgument.ToString(); new Relation_RoutePort().Delete(relateId); } else { #region 控件 int index = Convert.ToInt32(e.CommandArgument.ToString()); GridViewRow gvr = (GridViewRow)gvPassedPorts.Rows[index]; HiddenField hfRelateId = (HiddenField)gvr.FindControl("hidRelateId"); string relateId = hfRelateId.Value.ToString(); DropDownList drp = (DropDownList)gvr.FindControl("ddlPassPort"); TextBox tbOrderNum = (TextBox)gvr.FindControl("tbOrderNum"); #endregion Relation_RoutePortInfo info = new Relation_RoutePortInfo(); info.OrderNum = tbOrderNum.Text; info.PortID = Convert.ToInt32(drp.SelectedValue); info.PortTypeID = 5; info.RouteID = routeId; if (e.CommandName == "btnEdit") { info.ID = relateId; new Relation_RoutePort().Update(info); } if (e.CommandName == "btnAdd") { new Relation_RoutePort().Add(info); } } string id = lbID.Value; RouteInfo rInfo = new Route().GetByID(id); lbTotalRoute.Text = rInfo.TotalRoute; BindPassPortList(id); ShowMsg("操作成功!"); } catch (ArgumentNullException aex) { ShowMsg(aex.Message); } catch (Exception ex) { ShowMsg(ex.Message); Log(ex); } }
/// <summary> /// 添加费用类别 /// </summary> /// <param name="ID">实体主键</param> /// <returns></returns> public void Delete(string ID) { Relation_RoutePortInfo cInfo = new Relation_RoutePortInfo(); cInfo.ID = ID; dal.Delete(cInfo); }
/// <summary> /// 更新费用类别 /// </summary> /// <param name="cInfo">实体</param> public void Update(Relation_RoutePortInfo cInfo) { if (string.IsNullOrEmpty(cInfo.ID)) { throw new ArgumentNullException("参数ID不能为空。"); } // 如果是始运港,排序为0,如果是目的港,排序为99,其他类型排序号不变 if (cInfo.PortTypeID == 2) { cInfo.OrderNum = "0"; } else if (cInfo.PortTypeID == 4) { cInfo.OrderNum = "99"; } else { int order = int.Parse(cInfo.OrderNum); if (order < 1 || order > 98) { throw new ArgumentException("排序号必须为1-98之间的数字。"); } } dal.Update(cInfo); }