protected void gv_List_RowDataBound(object sender, GridViewRowEventArgs e) { if (MCSTabControl1.SelectedIndex == 1 && e.Row.RowType == DataControlRowType.DataRow) { HyperLink hy_DispatchRide = (HyperLink)e.Row.FindControl("hy_DispatchRide"); if (hy_DispatchRide != null) { int carid = (int)gv_List.DataKeys[e.Row.RowIndex][0]; IList <Car_DispatchRide> lists = Car_DispatchRideBLL.GetModelList("Car_DispatchRide.State = 2 AND Car_DispatchRide.CarID=" + carid.ToString()); if (lists.Count > 0) { Car_DispatchRide m = lists[lists.Count - 1]; hy_DispatchRide.Text = m.Destination; hy_DispatchRide.NavigateUrl = "Car_DispatchRideDetail.aspx?ID=" + m.ID.ToString(); } } } }
protected void bt_Save_Click(object sender, EventArgs e) { FNA_EvectionRouteBLL bll; Car_DispatchRideBLL car_ridebll = null; if ((int)ViewState["ID"] == 0) { bll = new FNA_EvectionRouteBLL(); } else { bll = new FNA_EvectionRouteBLL((int)ViewState["ID"]); } pn_detail.GetData(bll.Model); #region 保存车辆使用信息 if (bll.Model.Transport == "4") { //自驾车时,关联派车单 if (string.IsNullOrEmpty(bll.Model["RelateCarDispatch"])) { car_ridebll = new Car_DispatchRideBLL(); pn_detail.GetData(car_ridebll.Model); if (car_ridebll.Model.KilometresEnd < car_ridebll.Model.KilometresStart) { MessageBox.Show(this, "对不起,还车公里数不能小于发车公里数!"); return; } car_ridebll.Model.Destination = bll.Model.EvectionLine; car_ridebll.Model.Matters = "差旅行程"; car_ridebll.Model.State = 3; //已交车 car_ridebll.Model.OrganizeCity = new Org_StaffBLL((int)Session["UserID"]).Model.OrganizeCity; car_ridebll.Model.ActGoBackTime = DateTime.Now; car_ridebll.Model.ApproveFlag = 2; car_ridebll.Model.ApplyStaff = bll.Model.RelateStaff; car_ridebll.Model.InsertStaff = (int)Session["UserID"]; bll.Model["RelateCarDispatch"] = car_ridebll.Add().ToString(); } else { car_ridebll = new Car_DispatchRideBLL(int.Parse(bll.Model["RelateCarDispatch"])); pn_detail.GetData(car_ridebll.Model); if (car_ridebll.Model.KilometresEnd < car_ridebll.Model.KilometresStart) { MessageBox.Show(this, "对不起,还车公里数不能小于发车公里数!"); return; } car_ridebll.Model.Destination = bll.Model.EvectionLine; car_ridebll.Model.UpdateStaff = (int)Session["UserID"]; car_ridebll.Update(); } //更新车辆最后的公里数 Car_CarListBLL CarBll = new Car_CarListBLL(car_ridebll.Model.CarID); if (CarBll.Model != null) { if (Car_DispatchRideBLL.GetModelList("CarID=" + car_ridebll.Model.CarID.ToString() + " AND ID > " + car_ridebll.Model.ID.ToString()).Count == 0) { //如果当前用车信息是该车辆最后一次用车记录,则更新车辆最后公里数 CarBll.Model.Kilometres = car_ridebll.Model.KilometresEnd; CarBll.Update(); } } } #endregion if ((int)ViewState["ID"] == 0) { bll.Model.ApproveFlag = 2; bll.Model.InsertStaff = (int)Session["UserID"]; ViewState["ID"] = bll.Add(); } else { bll.Model.UpdateStaff = (int)Session["UserID"]; bll.Update(); } if (car_ridebll != null && car_ridebll.Model["RelateEvectionRoute"] == "") { car_ridebll.Model["RelateEvectionRoute"] = ViewState["ID"].ToString(); car_ridebll.Update(); } if (sender != null) { MessageBox.ShowAndClose(this, "保存成功!"); } }