//------------------------------------------------// private void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene //DontDestroyOnLoad(gameObject); _dealer = GameObject.Find("Dealer").GetComponent <Dealer>(); _dealer.DealerUIInstance = this; p1Score.text = "0"; p2Score.text = "0"; manager = Manager.instance; }
public int SaveDealer(DealerUI objUI, System.Data.SqlClient.SqlTransaction objTrans) { int DealerID = 0; bool flagTransation = true; DealerDB objDB = new DealerDB(); objDB.Code = objUI.Code; objDB.Dealer = objUI.Dealer; objDB.RegionID = objUI.RegionID; objDB.IsActive = objUI.IsActive; objDB.Id = objUI.Id; objDB.CheckID = objUI.CheckID; objDB.City = objUI.City; objDB.InstallerName = objUI.InstallerName; objDB.IsOperatingDealer = objUI.IsOperatingDealer; DataAccessLayer objDataAccess = new DataAccessLayer(); try { if (objTrans == null) { flagTransation = false; objDataAccess.GetConnection.Open(); SqlTransaction objTransaction = objDataAccess.GetConnection.BeginTransaction(); objTrans = objTransaction; } DealerManager objManager = new DealerManager(); DealerID = objManager.SaveDealer(objDB, objTrans); if (!flagTransation) objTrans.Commit(); return DealerID; } catch (Exception ex) { if (!flagTransation) objTrans.Rollback(); throw ex; } finally { objDataAccess.GetConnection.Close(); } }