private void btnGenerateList_Click(object sender, EventArgs e) { if ( cbSelectedList.Text == string.Empty ) return; try { using ( SqlConnection sqlCon = GenerateSqlConnection() ) { sqlCon.Open(); SqlCommand cmd = new SqlCommand( GetSqlQuery( cbSelectedList.Text ), sqlCon ); SqlDataReader dr = cmd.ExecuteReader(); List<SFM.ListInterface> pNewList = new List<SFM.ListInterface>(); while ( dr.Read() ) { string[] val = { dr["id"].ToString(), dr["value"].ToString() }; SFM.ListInterface pInterface = new SFM.ListInterface( val ); pNewList.Add( pInterface ); } sqlCon.Close(); switch ( cbSelectedList.Text ) { case "Itemlist": wndGlobalUI.pListItems = pNewList; SFM.SafeFile( pNewList, "items.txt" ); SFM.UpdateDataGridView( wndGlobalUI.dgvItems, pNewList ); break; case "BuffList": wndGlobalUI.pListBuffs = pNewList; SFM.SafeFile( pNewList, "buffs.txt" ); SFM.UpdateDataGridView( wndGlobalUI.dgvBuffs, pNewList ); break; case "Monsterlist": wndGlobalUI.pListMonster = pNewList; SFM.SafeFile( pNewList, "monster.txt" ); SFM.UpdateDataGridView( wndGlobalUI.dgvMonster, pNewList ); break; case "Petlist": wndGlobalUI.pListPets = pNewList; SFM.SafeFile( pNewList, "pets.txt" ); SFM.UpdateDataGridView( wndGlobalUI.dgvPets, pNewList ); break; case "Skilllist": wndGlobalUI.pListSkills = pNewList; SFM.SafeFile( pNewList, "skills.txt" ); SFM.UpdateDataGridView( wndGlobalUI.dgvSkills, pNewList ); break; default: break; } } } catch ( Exception ex ) { MessageBox.Show( ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error ); } Properties.Settings.Default.dbAddress = tbDbAddress.Text; Properties.Settings.Default.dbDatabase = tbDbDatabase.Text; Properties.Settings.Default.dbUsername = tbDbUsername.Text; if ( cbSavePassword.Checked ) { Properties.Settings.Default.dbPassword = tbDbPassword.Text; } Properties.Settings.Default.Save(); this.Close(); }
private void btnGenerateList_Click(object sender, EventArgs e) { if (cbSelectedList.Text == string.Empty) { return; } try { using (SqlConnection sqlCon = GenerateSqlConnection()) { sqlCon.Open(); SqlCommand cmd = new SqlCommand(GetSqlQuery(cbSelectedList.Text), sqlCon); SqlDataReader dr = cmd.ExecuteReader(); List <SFM.ListInterface> pNewList = new List <SFM.ListInterface>(); while (dr.Read()) { string[] val = { dr["id"].ToString(), dr["value"].ToString() }; SFM.ListInterface pInterface = new SFM.ListInterface(val); pNewList.Add(pInterface); } sqlCon.Close(); switch (cbSelectedList.Text) { case "Itemlist": wndGlobalUI.pListItems = pNewList; SFM.SafeFile(pNewList, "items.txt"); SFM.UpdateDataGridView(wndGlobalUI.dgvItems, pNewList); break; case "BuffList": wndGlobalUI.pListBuffs = pNewList; SFM.SafeFile(pNewList, "buffs.txt"); SFM.UpdateDataGridView(wndGlobalUI.dgvBuffs, pNewList); break; case "Monsterlist": wndGlobalUI.pListMonster = pNewList; SFM.SafeFile(pNewList, "monster.txt"); SFM.UpdateDataGridView(wndGlobalUI.dgvMonster, pNewList); break; case "Petlist": wndGlobalUI.pListPets = pNewList; SFM.SafeFile(pNewList, "pets.txt"); SFM.UpdateDataGridView(wndGlobalUI.dgvPets, pNewList); break; case "Skilllist": wndGlobalUI.pListSkills = pNewList; SFM.SafeFile(pNewList, "skills.txt"); SFM.UpdateDataGridView(wndGlobalUI.dgvSkills, pNewList); break; default: break; } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } Properties.Settings.Default.dbAddress = tbDbAddress.Text; Properties.Settings.Default.dbDatabase = tbDbDatabase.Text; Properties.Settings.Default.dbUsername = tbDbUsername.Text; if (cbSavePassword.Checked) { Properties.Settings.Default.dbPassword = tbDbPassword.Text; } Properties.Settings.Default.Save(); this.Close(); }