private int ExecuteSQL(string SQLD)
        {
            string m_GetID    = "SELECT LAST_INSERT_ID()";  // Grab the ID of last instered row
            int    m_ObjectID = 0;

            // Connect to Database and update
            MySqlConnection m_Connection   = new MySqlConnection(DB.GetLoginStr());
            MySqlCommand    m_CommandAdd   = new MySqlCommand(SQLD, m_Connection);
            MySqlCommand    m_CommandGetID = new MySqlCommand(m_GetID, m_Connection);

            m_Connection.Open();

            try
            {
                // Execute Command
                m_CommandAdd.ExecuteNonQuery();
                MySqlDataReader m_Reader = m_CommandGetID.ExecuteReader();  // Get ID
                m_Reader.Read();                                            // Read in data
                m_ObjectID = m_Reader.GetInt32(0);
            }
            catch (Exception Error)
            {
                MessageBox.Show("SQL Error: " + Error.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(-1);
            }

            return(m_ObjectID);
        }
        private MySqlDataReader ExcuteSQLQuery(string SQLD)
        {
            // Populate the Starbase Combox
            MySqlConnection m_Connection = new MySqlConnection(DB.GetLoginStr());
            MySqlCommand    m_Command    = new MySqlCommand(SQLD, m_Connection);

            m_Connection.Open();

            return(m_Command.ExecuteReader());
        }
Exemple #3
0
        private MySqlDataReader ExcuteSQLQuery(string SQLD)
        {
            // Populate the Starbase Combox
            MySqlConnection m_Connection = new MySqlConnection(DB.GetLoginStr());
            MySqlCommand    m_Command    = new MySqlCommand(SQLD, m_Connection);
            MySqlDataReader data         = (null);

            m_Connection.Open();

            try
            {
                data = m_Command.ExecuteReader();
            }
            catch (Exception e)
            {
                MessageBox.Show("Error executing mysql: " + SQLD, e.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return(data);
        }
Exemple #4
0
        private void LoadEffects()
        {
            // Pull down data
            DataTable        dataTable        = new DataTable();
            MySqlConnection  m_conn           = new MySqlConnection(DB.GetLoginStr());
            String           query            = "SELECT Description,Tooltip,Constant1Value,Constant2Value,EffectID FROM item_effect_base";
            MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, m_conn);

            mySqlDataAdapter.Fill(dataTable);

            foreach (DataRow r in dataTable.Rows)
            {
                EffectList EffectAdd = new EffectList();

                EffectAdd.EffectDescList = r["Description"].ToString();
                EffectAdd.EffectID       = (int)r["EffectID"];
                EffectAdd.EffectToolList = r["Tooltip"].ToString();

                // Add to the list
                m_EffectList.Add(EffectAdd);
            }
        }
Exemple #5
0
        private void LoadItemData()
        {
            // Load in item name
            MySqlDataReader ItemQuery = ExcuteSQLQuery("SELECT name FROM item_base WHERE id = '" + m_CurrentItem + "'");

            // See if we found data
            if (ItemQuery.HasRows)
            {
                ItemQuery.Read();
                ItemName.Text = ItemQuery.GetString(0);
            }

            // remove all data
            m_EffectIDNum.Clear();

            // Set it all to 0
            for (int y = 0; y < 5; y++)
            {
                m_BoxList[y].EffectBox.SelectedIndex = 0;
            }

            // Find all Effects on this item
            DataTable        dataTable        = new DataTable();
            MySqlConnection  conn             = new MySqlConnection(DB.GetLoginStr());
            String           query            = "SELECT ItemEffectID, item_effect_base_id, Var1Data, Var2Data, Var3Data FROM item_effects WHERE ItemID = '" + m_CurrentItem + "'";
            MySqlDataAdapter mySqlDataAdapter = new MySqlDataAdapter(query, conn);

            mySqlDataAdapter.Fill(dataTable);

            int x = 0;

            foreach (DataRow r in dataTable.Rows)
            {
                m_BoxList[x].EffectBox.Enabled = true;

                m_EffectIDNum.Add((int)r["ItemEffectID"]);
                int EffID = (int)r["item_effect_base_id"];
                m_BoxList[x].EffectBox.SelectedIndex = FindEffectID(EffID);
                m_BoxList[x].Var1.Text = r["Var1Data"].ToString();
                m_BoxList[x].Var2.Text = r["Var2Data"].ToString();
                m_BoxList[x].Var3.Text = r["Var3Data"].ToString();
                x++;
                // Make sure we dont go over the count #
                if (x >= m_BoxList.Count)
                {
                    break;
                }
            }
            // Fill rest with 0's
            for (; x < 5; x++)
            {
                m_BoxList[x].EffectBox.Enabled = true;
                m_EffectIDNum.Add(0);
            }

            // Zero this out, if we cant find a container when we save
            // we will create a new one
            m_CurrentContainer = 0;

            // Find containers for Activateable Only
            DataTable        ContainerDataTable        = new DataTable();
            MySqlConnection  ContainConn               = new MySqlConnection(DB.GetLoginStr());
            String           ContainerQuery            = "SELECT EffectContainerID,RechargeTime,Unknown2,_Range,Unknown4, EnergyUse FROM Item_effect_container WHERE EquipEffect = '1' AND ItemID = '" + m_CurrentItem + "'";
            MySqlDataAdapter ContainermySqlDataAdapter = new MySqlDataAdapter(ContainerQuery, ContainConn);

            ContainermySqlDataAdapter.Fill(ContainerDataTable);

            if (ContainerDataTable.Rows.Count > 0)
            {
                // Read in the data (will only have 1 row)
                DataRow r = ContainerDataTable.Rows[0];

                m_CurrentContainer = (int)r["EffectContainerID"];
                Range.Text         = r["_Range"].ToString();
                CoolDown.Text      = r["RechargeTime"].ToString();
                EnergyUse.Text     = r["EnergyUse"].ToString();
            }
            else
            {
                Range.Text     = "0";
                CoolDown.Text  = "0";
                EnergyUse.Text = "0";
            }


            // Enable effects to be changed
            //EnableEffects(true);
        }