//Adjust player funds. Can be passed a negative value. Safeguards against going under 0 public static void AddMoney(int value) { if (money + value > 0) { money += value; } else { money = 0; } //Update money text UpdateMoney moneyText = FindObjectOfType <UpdateMoney>(); moneyText.UpdateMoneyText(); if (value > 0) { moneyText.PlayGain(); } else { moneyText.PlayLoss(); } }
private void Awake()//Singleton { if (instance == null) { instance = this; } else if (instance != this) { Destroy(gameObject); } }
public void AddMoney(int value) { if (money + value > 0) { money += value; } else { money = 0; } //Update money text UpdateMoney moneyText = GameObject.FindObjectOfType <UpdateMoney>(); moneyText.UpdateMoneyText(); }
private void Awake() { Instance = this; }
private void metroButUpdateForControlForm_Click(object sender, EventArgs e) { try { if (metroTabControlCF2.SelectedTab.Text == "Организация") { if (metroGridOrganization.SelectedCells.Count != 0) { string ID_Org = manipulationDB.generationID("SELECT ИД FROM Организация " + "WHERE Наименование='" + metroGridOrganization.CurrentRow.Cells[1].Value + "'" + " AND [Дата регистрации]='" + metroGridOrganization.CurrentRow.Cells[2].Value + "' AND" + " [Юридический адрес]='" + metroGridOrganization.CurrentRow.Cells[3].Value + "' AND" + " [Фактический адрес]='" + metroGridOrganization.CurrentRow.Cells[4].Value + "'"); manipulationProgramm.ZapisIndex(ID_Org); UpdateOrganization updateOrganization = new UpdateOrganization(); updateOrganization.Show(); updateOrganization.metroTextBoxNamOrg.Text = Convert.ToString(metroGridOrganization.CurrentRow.Cells[1].Value); updateOrganization.metroTextBoxDateReg.Text = Convert.ToString(metroGridOrganization.CurrentRow.Cells[2].Value); updateOrganization.metroTextBoxUrAddress.Text = Convert.ToString(metroGridOrganization.CurrentRow.Cells[3].Value); updateOrganization.metroTextBoxFactAdress.Text = Convert.ToString(metroGridOrganization.CurrentRow.Cells[4].Value); } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } else if (metroTabControlCF2.SelectedTab.Text == "Валюты") { if (metroGridMoney.SelectedCells.Count != 0) { string ID_Val = manipulationDB.generationID("SELECT ИД FROM Валюта" + " WHERE Наименование='" + metroGridMoney.CurrentRow.Cells[1].Value + "' " + "AND [Сокращенное наименование]='" + metroGridMoney.CurrentRow.Cells[2].Value + "'"); manipulationProgramm.ZapisIndex(ID_Val); UpdateMoney updateMoney = new UpdateMoney(); updateMoney.Show(); updateMoney.metroTextBoxFullName.Text = Convert.ToString(metroGridMoney.CurrentRow.Cells[1].Value); updateMoney.metroTextBoxMiniName.Text = Convert.ToString(metroGridMoney.CurrentRow.Cells[2].Value); } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } else if (metroTabControlCF2.SelectedTab.Text == "Курсы валют") { if (metroGridMoneySize.SelectedCells.Count != 0) { string ID_Val1 = manipulationDB.generationID("SELECT ИД FROM Валюта WHERE [Сокращенное наименование]='" + metroGridMoneySize.CurrentRow.Cells[2].Value + "'"); string ID_Val12 = manipulationDB.generationID("SELECT ИД FROM Валюта WHERE [Сокращенное наименование]='" + metroGridMoneySize.CurrentRow.Cells[4].Value + "'"); string query_Curs = "SELECT ИД FROM [Курс валют] WHERE Единица1=@ed1 AND Валюта1=@val1 AND Единица2=@ed2 AND Валюта2=@val2"; string ID_Curs = ""; try { SqlCommand comm = new SqlCommand(query_Curs, connect); connect.Open(); comm.Parameters.AddWithValue("@ed1", metroGridMoneySize.CurrentRow.Cells[1].Value); comm.Parameters.AddWithValue("@val1", ID_Val1); comm.Parameters.AddWithValue("@ed2", metroGridMoneySize.CurrentRow.Cells[3].Value); comm.Parameters.AddWithValue("@val2", ID_Val12); if (comm.ExecuteScalar() != null) { ID_Curs = comm.ExecuteScalar().ToString(); } else { ID_Curs = ""; } connect.Close(); manipulationProgramm.ZapisIndex(ID_Curs); UpdateMoneySize updateMoneySize = new UpdateMoneySize(); updateMoneySize.Show(); manipulationDB.SelectComboBox("SELECT * FROM Валюта", updateMoneySize.metroComboBoxVal1, "Сокращенное наименование", "ИД"); manipulationDB.SelectComboBox("SELECT * FROM Валюта", updateMoneySize.metroComboBoxVal2, "Сокращенное наименование", "ИД"); updateMoneySize.metroTextBoxSizeMoney1.Text = Convert.ToString(metroGridMoneySize.CurrentRow.Cells[1].Value); updateMoneySize.metroComboBoxVal1.Text = Convert.ToString(metroGridMoneySize.CurrentRow.Cells[2].Value); updateMoneySize.metroTextBoxSizeMoney2.Text = Convert.ToString(metroGridMoneySize.CurrentRow.Cells[3].Value); updateMoneySize.metroComboBoxVal2.Text = Convert.ToString(metroGridMoneySize.CurrentRow.Cells[4].Value); } catch (SqlException exSQL) { MessageBox.Show(exSQL.Message, "Ошибка работы с базой данных:"); } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка работы с приложением:"); } finally { connect.Close(); } } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } else if (metroTabControlCF2.SelectedTab.Text == "Финансовые операции") { if (metroGridFinansedOperation.SelectedCells.Count != 0) { string ID_Oper = manipulationDB.generationID("SELECT * FROM Операция " + "WHERE Наименование='" + metroGridFinansedOperation.CurrentRow.Cells[1].Value + "'"); manipulationProgramm.ZapisIndex(ID_Oper); UpdateFinansedOperation updateFinansedOperation = new UpdateFinansedOperation(); updateFinansedOperation.Show(); updateFinansedOperation.metroTextBoxNamFinOperation.Text = Convert.ToString(metroGridFinansedOperation.CurrentRow.Cells[1].Value); } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } else if (metroTabControlCF2.SelectedTab.Text == "Паспорт") { if (metroGridPassport.SelectedCells.Count != 0) { string ID_Pass = manipulationDB.generationID("SELECT * FROM Паспорт " + "WHERE ФИО='" + metroGridPassport.CurrentRow.Cells[1].Value + "' AND СиН='" + metroGridPassport.CurrentRow.Cells[2].Value + "'"); manipulationProgramm.ZapisIndex(ID_Pass); UpdatePassport updatePass = new UpdatePassport(); updatePass.Show(); updatePass.metroTextBoxFio.Text = Convert.ToString(metroGridPassport.CurrentRow.Cells[1].Value); updatePass.metroTextBoxSin.Text = Convert.ToString(metroGridPassport.CurrentRow.Cells[2].Value); updatePass.metroTextBoxIdentifity.Text = Convert.ToString(metroGridPassport.CurrentRow.Cells[3].Value); } else { MessageBox.Show("Выберите строку, которую хотите изменить!!!", "Ошибка"); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Ошибка:"); } }
public static void CallUpdateMoney(int value) { UpdateMoney?.Invoke(value); }
// Use this for initialization void Awake() { instance = this; }