public int SavePrev(string strXml) { RSConnection cnn; SqlCommand cmd; SqlParameter prm; int retVal = 0; LoadVals(strXml); cnn = new RSConnection("CR"); cmd = new SqlCommand("spUnitOfMeasure_Update", cnn.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; prm = cmd.Parameters.Add("@ID", SqlDbType.Int); prm.Value = oVar.ID; prm = cmd.Parameters.Add("@UseCode", SqlDbType.VarChar, 2); prm.Value = oVar.UseCode; prm = cmd.Parameters.Add("@Code", SqlDbType.VarChar, 10); prm.Value = oVar.Code; prm = cmd.Parameters.Add("@Description", SqlDbType.VarChar, 100); prm.Value = oVar.Description; prm = cmd.Parameters.Add("@Ordinal", SqlDbType.Int); prm.Value = oVar.Ordinal; cmd.ExecuteNonQuery(); retVal = Convert.ToInt32(cmd.Parameters["@ID"].Value); prm = null; cmd = null; cnn.CloseConnection(); cnn = null; return(retVal); }
public bool Delete(int iID) { bool retVal = false; RSConnection cnn; SqlCommand cmd; SqlParameter prm; cnn = new RSConnection("CR"); cmd = new SqlCommand("spUnitOfMeasure_Delete", cnn.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; prm = cmd.Parameters.Add("@ID", SqlDbType.Int); prm.Value = iID; try { cmd.ExecuteNonQuery(); retVal = true; } catch { retVal = false; } prm = null; cmd = null; cnn.CloseConnection(); cnn = null; return(retVal); }
public void MakePointConnection(RSConnection otherCar) { OtherPoint = otherCar.CouplerPointLeft; SetCouplerObjectToLookAt(OtherPoint); IsAbleToConnect = false; CouplerCollider.enabled = false; otherCar.CouplerPointLeft.CouplerCollider.enabled = false; }
private void Awake() { engine = GetComponent <Engine> (); rSConnection = GetComponent <RSConnection> (); rsComposition = GetComponent <RSComposition> (); engineT = GetComponent <Transform> (); car = GetComponent <RollingStock> (); }
private void OnTriggerEnter(Collider other) { if (IsAbleToConnect) { OtherPoint = other.GetComponent <CouplerPoint> (); OtherRSConnection = OtherPoint.RSConnection; RSConnection.MakeConnection(OtherRSConnection); } }
public void RemoveConnection() { IsConnectedRight = false; TempCar = RightCar.RollingStock; RightCar.LeftCar = null; RightCar = null; CouplerRight.DestroyCouplerConnection(); CouplerPointRight.DestroyPointConnection(); }
public void InitConnection(RSConnection otherCar) { IsConnectedRight = true; RightCar = otherCar; RightCar.LeftCar = this; // this coupler is in connection CouplerRight.MakeCouplerConnection(); CouplerPointRight.MakePointConnection(otherCar); }
public void DestroyConnection() { CompositionManager.Instance.UpdateCompositionsAfterUncoupling(RightCar.RollingStock); IsConnectedRight = false; JustUncoupled = true; TempCar = RightCar.RollingStock; tempDist = TempCar.OwnRun - RollingStock.OwnRun; RightCar.LeftCar = null; RightCar = null; CouplerRight.DestroyCouplerConnection(); CouplerPointRight.DestroyPointConnection(); }
public void MakeConnection(RSConnection otherCar) { IsConnectedRight = true; RightCar = otherCar; RightCar.LeftCar = this; // this coupler is in connection CouplerRight.MakeCouplerConnection(); CouplerPointRight.MakePointConnection(otherCar); // make new comp from two CompositionManager.Instance.UpdateCompositionsAfterCoupling(RollingStock, RightCar.RollingStock); //for coupler indication EventManager.CarsCoupled(); }
public void FormCompositionsAfterSettingCars(RollingStock [] _cars, RollingStock activeEngine) { for (int i = 0; i < _cars.Length; i++) { // we take only cars from left if (_cars [i].RSConnection.LeftCar == null) // it means that it is still Maincar { RollingStock car = _cars [i]; Composition thisCarComposition = car.RSComposition.CarComposition; // set engine if (activeEngine != null) { thisCarComposition.CompEngine = activeEngine.Engine; thisCarComposition.CompEngine.IsActive = true; } else { thisCarComposition.CompEngine = null; } //it is in first position now car.RSComposition.NumInComposition = 0; int count = 1; //it is next car now rightConnection = car.RSConnection.RightCar; while (rightConnection != null) { // define num in comp rightConnection.RSComposition.NumInComposition = count; // comp of connected cars is not active rightConnection.RSComposition.CarComposition.IsActive = false; // set cars comp to each next car rightConnection.RSComposition.CarComposition = thisCarComposition; // place of each next car in comp thisCarComposition.Cars [count] = rightConnection.RollingStock; // each next car is not main now rightConnection.RSComposition.IsMainCar = false; // take next car rightConnection = rightConnection.RightCar; count++; } thisCarComposition.Quantity = count; thisCarComposition.LeftCar = car; thisCarComposition.RightCar = thisCarComposition.Cars [count - 1]; thisCarComposition.IsOutside = false; TrackPath.Instance.GetTrackPath(thisCarComposition.MainCar); } } }
public SqlDataReader GetList() { SqlDataReader dr; RSConnection cnn; SqlCommand cmd; cnn = new RSConnection("CR"); cmd = new SqlCommand("spUnitOfMeasure_ListAll", cnn.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); cmd = null; return(dr); }
public void Init() { OwnTransform = GetComponent <Transform>(); Engine = GetComponent <Engine> (); Model = GetComponentInChildren <RSModel> (); RSConnection = GetComponent <RSConnection> (); RSComposition = GetComponent <RSComposition> (); CarProperties = GetComponent <CarProperties> (); if (Engine) { OwnEngine = Engine; IsEngine = true; } RSConnection.Init(); RSComposition.Init(); // set bogeys to RS SetBogeys(); }
public string GetByID(int iID) { SqlDataReader dr; RSConnection cnn; SqlCommand cmd; SqlParameter prm; string tmpStr = ""; cnn = new RSConnection("CR"); cmd = new SqlCommand("spUnitOfMeasure_ByID", cnn.GetConnection()); cmd.CommandType = CommandType.StoredProcedure; prm = cmd.Parameters.Add("@ID", SqlDbType.Int); prm.Value = iID; dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); while (dr.Read()) { oVar = new COUnitOfMeasure(); oVar.ID = Convert.ToInt32(dr["ID"]); oVar.UseCode = dr["UseCode"].ToString(); oVar.Code = dr["Code"].ToString(); oVar.Description = dr["Description"].ToString(); oVar.Ordinal = Convert.ToInt32(dr["Ordinal"]); tmpStr = GetDataString(); } dr.Close(); dr = null; prm = null; cmd = null; cnn.CloseConnection(); cnn = null; return(tmpStr); }
private void Awake() { engine = GetComponent <Engine> (); connection = engine.GetComponent <RollingStock> ().GetComponent <RSConnection> (); Enable = true; }
private void Awake() { RSConnection = GetComponentInParent <RSConnection> (); }