/// <summary> /// 添加事件 /// </summary> /// <param name="rsEvent"></param> private void AddRunEvent(RsRunEvent rsEvent) { string sql = @"insert into TAB_Plan_RunEvent (strRunEventGUID,strTrainPlanGUID, nEventID,dtEventTime,strTrainNo,strTrainTypeName,strTrainNumber,nTMIS, nKeHuo,strGroupGUID,strTrainmanNumber1,strTrainmanNumber2,dtCreateTime,nResult,strResult,JiaoLuAndnStationNo) values (@strRunEventGUID,@strTrainPlanGUID,@nEventID,@dtEventTime,@strTrainNo, @strTrainTypeName,@strTrainNumber,@nTMIS,@nKeHuo,@strGroupGUID,@strTrainmanNumber1, @strTrainmanNumber2,getdate(),@nResult,@strResult,@JiaoLuAndnStationNo)"; SqlParameter[] sqlParams = { new SqlParameter("@strRunEventGUID", rsEvent.strRunEventGUID), new SqlParameter("@strTrainPlanGUID", rsEvent.strTrainPlanGUID), new SqlParameter("@nEventID", rsEvent.nEventID), new SqlParameter("@dtEventTime", rsEvent.dtEventTime), new SqlParameter("@strTrainNo", rsEvent.strTrainNo), new SqlParameter("@strTrainTypeName", rsEvent.strTrainTypeName), new SqlParameter("@strTrainNumber", rsEvent.strTrainNumber), new SqlParameter("@nTMIS", rsEvent.nTMIS), new SqlParameter("@nKeHuo", rsEvent.nKehuo), new SqlParameter("@strGroupGUID", rsEvent.strGroupGUID), new SqlParameter("@strTrainmanNumber1", rsEvent.strTrainmanNumber1), new SqlParameter("@strTrainmanNumber2", rsEvent.strTrainmanNumber2), new SqlParameter("@nResult", rsEvent.nEventID), new SqlParameter("@strResult", rsEvent.strResult), new SqlParameter("@JiaoLuAndnStationNo", rsEvent.JiaoLuAndnStationNo) }; SqlHelper.ExecuteNonQuery(SqlHelper.ConnString, CommandType.Text, sql, sqlParams); }
private Boolean AddRunEvent(RunEvent Rec, TrainmanPlan plan, string eventGUID, ref string ErrInfo, ref int ErrCode) { ErrCode = 0; ErrInfo = ""; RsRunEvent rsEvent = new RsRunEvent(); if (Rec.strRunEventGUID == string.Empty) { ErrCode = 1; return(false); } if (Rec.dtEventTime > plan.trainPlan.lastArriveTime) { ErrCode = 3; ErrInfo = "超时被丢弃"; return(false); } bool bHasEvent = GetRunEventOfPlan(plan.trainPlan.planID, Rec.nEventID, rsEvent); if ((bHasEvent) && (rsEvent.dtEventTime == Rec.dtEventTime)) { ErrCode = 4; ErrInfo = "记录重复"; return(false); } rsEvent.JiaoLuAndnStationNo = Rec.JiaoLuAndnStationNo; rsEvent.strRunEventGUID = eventGUID; rsEvent.nEventID = Rec.nEventID; rsEvent.strTrainPlanGUID = plan.trainPlan.planID; rsEvent.dtEventTime = Rec.dtEventTime; rsEvent.nTMIS = Rec.strStationName; rsEvent.strGroupGUID = plan.trainPlan.planID; rsEvent.strTrainmanNumber1 = Rec.strTrainmanNumber1; rsEvent.strTrainmanNumber2 = Rec.strTrainmanNumber2; rsEvent.nResultID = Rec.nResultID; rsEvent.strTrainNo = Rec.strTrainNo; rsEvent.strTrainNumber = Rec.strTrainNumber; rsEvent.strTrainTypeName = Rec.strTrainTypeName; rsEvent.strResult = Rec.strResult; AddRunEvent(rsEvent); return(true); }
private Boolean GetRunEventOfPlan(string planGUID, int EventID, RsRunEvent rsEvent) { string sql = "select top 1 * from TAB_Plan_RunEvent where strTrainPlanGUID = @planGUID and nEventID = @eventID order by dtEventTime desc "; SqlParameter[] sqlParams = { new SqlParameter("@planGUID", planGUID), new SqlParameter("@eventID", EventID) }; DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.ConnString, CommandType.Text, sql, sqlParams).Tables[0]; if (dt.Rows.Count == 0) { return(false); } else { DataRow dr = dt.Rows[0]; rsEvent.strRunEventGUID = dr["strRunEventGUID"].ToString(); rsEvent.strTrainPlanGUID = dr["strTrainPlanGUID"].ToString(); rsEvent.nEventID = Convert.ToInt32(dr["nEventID"]); rsEvent.dtEventTime = Convert.ToDateTime(dr["dtEventTime"]); rsEvent.strTrainNo = dr["strTrainNo"].ToString(); rsEvent.strTrainTypeName = dr["strTrainTypeName"].ToString(); rsEvent.strTrainNumber = dr["strTrainNumber"].ToString(); rsEvent.nTMIS = dr["nTMIS"].ToString();; rsEvent.strGroupGUID = dr["strGroupGUID"].ToString(); rsEvent.strTrainmanNumber1 = dr["strTrainmanNumber1"].ToString(); rsEvent.strTrainmanNumber2 = dr["strTrainmanNumber2"].ToString(); rsEvent.dtCreateTime = Convert.ToDateTime(dr["dtCreateTime"]); rsEvent.nResultID = Convert.ToInt32(dr["nResult"]); rsEvent.strResult = dr["strResult"].ToString(); return(true); } }