private void buttonCreaMercato_Click(object sender, EventArgs e) { if (lega.ListaSvincolati == null) { MessageBox.Show("Caricare prima la lista svincolati"); } else { if (lega.MercatoAttivo == null) { ServerLegaSoapClient myGestioneAdminController = new ServerLegaSoapClient(); lega = myGestioneAdminController.creaMercato(lega); //List<Squadra> squadre = mercato.Squadre; if (lega.MercatoAttivo != null) { MessageBox.Show("Hai creato un mercato per la lega. Unisciti!"); } else { MessageBox.Show("Errore nella creazione del mercato! Riprova!"); } } else { MessageBox.Show("E' già presente un mercato attivo in questa lega. Unisciti!"); } } }
private void button1_Click(object sender, EventArgs e) { int offertaNum = 0; Giocatore selezionato = null; foreach (Giocatore g in lega.ListaSvincolati.Giocatori) { if (textBox3.Text.Equals(g.Nome)) { selezionato = g; break; } } try { offertaNum = Int32.Parse(textBox1.Text); } catch (Exception exc) { MessageBox.Show("Hai sbagliato a scrivere l'offerta, deve essere un intero!"); return; } if ((ValidaOfferta(offertaNum, selezionato))) { ServerLega.ServerLegaSoapClient myGestioneAsta = new ServerLegaSoapClient(); Lega legaPass = myGestioneAsta.Offri(offertaNum, squadra, lega); lega = legaPass; this.Hide(); new HomeMercatoAdmin(lega, squadra).Show(); } else { MessageBox.Show("Offerta non valida, reinserire i dati!"); } }
private void buttonOffri_Click(object sender, EventArgs e) { int offertaNum = 0; try { offertaNum = Int32.Parse(textBoxOfferta.Text); } catch (Exception) { MessageBox.Show("Hai sbagliato a scrivere l'offerta, deve essere un intero!"); return; } Giocatore selezionato = TrovaGiocatore(comboBoxSvincolati.SelectedItem.ToString()); if ((ValidaOfferta(offertaNum, selezionato)) && (comboBoxSvincolati.SelectedItem != null) && selezionato != null) { ServerLega.ServerLegaSoapClient myGestioneAsta = new ServerLegaSoapClient(); Lega legaPass = myGestioneAsta.CreaAsta(selezionato, offertaNum, squadra, lega); lega = legaPass; this.Hide(); new HomeMercatoAdmin(lega, squadra).Show(); } else { MessageBox.Show("Offerta non valida o giocatore selezionato non valido, reinserire i dati!"); } }
public Lega CreaAsta(Giocatore giocatore, int offerta, Squadra squadra, Lega lega) { Asta asta = new Asta(1, lega.MercatoAttivo.Squadre, giocatore); lega.MercatoAttivo.AstaAttiva = asta; ICreazioneAstaController myCreaAsta = new CreazioneAstaController(); myCreaAsta.ChiamaGiocatore(giocatore, asta); myCreaAsta.OffriCrediti(offerta, asta, squadra); int count = lega.MercatoAttivo.AstaAttiva.Squadre.Count; for (int i = 0; i < count && lega.MercatoAttivo.AstaAttiva != null; i++) { if (!lega.MercatoAttivo.AstaAttiva.Squadre[i].Nome.Equals(squadra.Nome)) { int result; Random r = new Random(); result = r.Next(2); if (result == 0) { lega = AbbandonaMock(lega.MercatoAttivo.AstaAttiva.Squadre[i], lega); } else { lega = RialzaMock(lega.MercatoAttivo.AstaAttiva.Squadre[i], lega); } if (lega.MercatoAttivo.AstaAttiva != null) { count = lega.MercatoAttivo.AstaAttiva.Squadre.Count; } } } return(lega); }
private Lega AzioniMock(Lega lega, Squadra squadra) { int count; String ruolo; ruolo = lega.MercatoAttivo.AstaAttiva.Giocatore.Ruolo; if (squadra.VerificaReparto(ruolo, lega)) { ruolo = "ALTRI"; count = lega.MercatoAttivo.AstaAttiva.Squadre.Count; for (int i = 0; i < count && lega.MercatoAttivo.AstaAttiva != null; i++) { if (!lega.MercatoAttivo.AstaAttiva.Squadre[i].Nome.Equals(squadra.Nome)) { int result; Random r = new Random(); result = r.Next(2); if (result == 0) { lega = AbbandonaMock(lega.MercatoAttivo.AstaAttiva.Squadre[i], lega); } else { lega = RialzaMock(lega.MercatoAttivo.AstaAttiva.Squadre[i], lega); } if (lega.MercatoAttivo.AstaAttiva != null) { count = lega.MercatoAttivo.AstaAttiva.Squadre.Count; } } } } else { count = lega.MercatoAttivo.AstaAttiva.Squadre.Count; for (int i = 0; i < count && lega.MercatoAttivo.AstaAttiva != null; i++) { if (!lega.MercatoAttivo.AstaAttiva.Squadre[i].Nome.Equals(squadra.Nome)) { int result; Random r = new Random(); result = r.Next(2); if (result == 0) { lega = AbbandonaMock(lega.MercatoAttivo.AstaAttiva.Squadre[i], lega); } else { lega = RialzaMock(lega.MercatoAttivo.AstaAttiva.Squadre[i], lega); } if (lega.MercatoAttivo.AstaAttiva != null) { count = lega.MercatoAttivo.AstaAttiva.Squadre.Count; } } } } return(lega); }
public HomeMercatoAdmin(Lega legaPass, Squadra squadra) { InitializeComponent(); this.lega = legaPass; this.squadra = squadra; this.mercato = lega.MercatoAttivo; textBoxCrediti.Text = "" + lega.SquadraAdmin.CreditiResidui; buttonCrea.Enabled = false; buttonPartecipa.Enabled = false; textBoxGiocatore.Enabled = false; textBoxCrediti.Enabled = false; textBoxOfferta.Enabled = false; if (lega.SquadraAdmin.Giocatori.Count != 0) { foreach (Giocatore g in lega.SquadraAdmin.Giocatori) { listBoxAcquisti.Items.Add(g.Nome.ToString()); } } if (lega.MercatoAttivo.AstaAttiva != null) { textBoxGiocatore.Text = lega.MercatoAttivo.AstaAttiva.Giocatore.Nome; textBoxOfferta.Text = "" + lega.MercatoAttivo.AstaAttiva.UltimaOfferta; } ServerLegaSoapClient myGestioneAdminController = new ServerLegaSoapClient(); Turno result = new Turno(); result = myGestioneAdminController.GestisciAsta(lega, squadra); if (result == null) { MessageBox.Show("Errore durante la gestione dell'asta."); } if (result.Ruolo == "FINITO") { MessageBox.Show("Il mercato è stato completato."); new HomeLegaAdmin(lega).Show(); } if (result.Ruolo == "ALTRI") { MessageBox.Show("Altri utenti devono finire di fare l'asta."); Thread.Sleep(3000); result = myGestioneAdminController.GestisciAsta(lega, squadra); } if (result.Tipo == true) { labelAttesa.Visible = false; MessageBox.Show("E' il tuo turno devi creare una asta."); buttonCrea.Enabled = true; } else { labelAttesa.Visible = false; MessageBox.Show("E' il tuo turno devi partecipare ad una asta."); buttonPartecipa.Enabled = true; } }
public void LegaSetUp() { _utente = new Utente("mailtestLega.com"); _utente.IsAdmin = true; _lega = new Lega("FantacalcioClub", 10); _squadraAdmin = new Squadra("SquareFC", _lega, _utente); _lega.AggiungiSquadra(_squadraAdmin); _lega.SquadraAdmin = _squadraAdmin; }
public List <Lega> GetLeghe(Utente utente) { List <Lega> leghe = new List <Lega>(); SqlConnection conn = null; try { //CAMBIARE IL PATH A SECONDA DEL DB USATO!! ///JACOPO //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Jacopo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaJacopo.mdf;Integrated Security=True"); //LORENZO conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Lorenzo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaLori.mdf;Integrated Security=True"); //ALAN //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Alan\Documents\universita\terzo anno\secondo semestre\progetto\MyFantalega\ServerLega\App_Data\DBMyFantalega.mdf;Integrated Security=True"); conn.Open(); //QUERY CHE RESTITUISCE LE LEGHE SqlCommand select = new SqlCommand("SELECT * FROM Lega WHERE nome IN (SELECT S.lega FROM Squadra S JOIN Utente U ON U.username = S.utente WHERE U.[e-mail]='" + utente.Email + "')", conn); SqlDataReader reader = select.ExecuteReader(); while (reader.Read()) { Lega lega = new Lega(reader["nome"].ToString(), (int)reader.GetValue(1)); lega.CreditiInizialiSquadra = reader.GetInt32(2); lega.NumeroPor = reader.GetInt32(3); lega.NumeroDif = reader.GetInt32(4); lega.NumeroCen = reader.GetInt32(5); lega.NumeroAtt = reader.GetInt32(6); Squadra squadraAdmin = new Squadra(); squadraAdmin.Nome = reader.GetString(7); ListaSvincolati lista = null; if (reader.GetValue(8).GetType() != typeof(DBNull)) { lista = new ListaSvincolati(); lista.IdLista = reader.GetInt32(8); } lega.ListaSvincolati = lista; //squadraAdmin.Lega = lega; squadraAdmin.Utente = utente; lega.SquadraAdmin = squadraAdmin; leghe.Add(lega); } reader.Close(); return(leghe); } catch (Exception e) { Console.WriteLine(e.Message); return(null); } finally { conn.Close(); } }
private void button2_Click(object sender, EventArgs e) { ServerLega.ServerLegaSoapClient myGestioneAsta = new ServerLegaSoapClient(); Lega legaPass = myGestioneAsta.Rialza(squadra, lega); lega = legaPass; this.Hide(); new HomeMercatoAdmin(lega, squadra).Show(); }
public CreaAsta(Lega lega, Squadra squadra) { InitializeComponent(); this.lega = lega; this.squadra = squadra; foreach (Giocatore g in lega.ListaSvincolati.Giocatori) { comboBoxSvincolati.Items.Add(g.Ruolo + "-" + g.Nome + "-" + g.QuotazioneIniziale); } }
public Lega Abbandona(Squadra squadra, Lega lega) { IPartecipaAstaController myPartecipaAsta = new PartecipaAstaController(); myPartecipaAsta.AbbandonaGiocatore(lega.MercatoAttivo.AstaAttiva, squadra); lega = AssegnaGiocatore(lega.MercatoAttivo.AstaAttiva.Giocatore, lega.MercatoAttivo.AstaAttiva.UltimoOfferente, lega.MercatoAttivo.AstaAttiva.UltimaOfferta, lega); if (lega != null) { lega.MercatoAttivo.AstaAttiva = null; } return(lega); }
public void SetUp() { Utente _utente = new Utente(); _utente.Email = "*****@*****.**"; _utente.IsAdmin = true; //INVOCAZIONE DEL METODO REMOTO ServerLegaSoapClient myGestioneUtenteController = new ServerLegaSoapClient(); _lega = myGestioneUtenteController.CreaLega("TestCreaLega", 4, "SquareFC", _utente); myGestioneUtenteController.Close(); }
private void buttonChiudiMercato_Click(object sender, EventArgs e) { /*Boolean benFormate = true; * for (int i = 0; i < mercato.Squadre.Count(); i++) * { * if (!mercato.Squadre.ElementAt(i).VerificaCompletezza()) * { * benFormate = false; * break; * } * } * if (!benFormate) * { * if (MessageBox.Show("Sei sicuro di chiudere un mercato non concluso?", "Mercato", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) * { * ServerLegaSoapClient myGestioneAdminController = new ServerLegaSoapClient(); * Boolean result; * result = myGestioneAdminController.ChiudiMercato(mercato); * if (result == true) * { * MessageBox.Show("Mercato chiuso anche se non completo"); * new HomeLegaAdmin(mercato.Lega).Show(); * } * else * { * MessageBox.Show("Errore nella chiusura del mercato"); * } * } * else * { * MessageBox.Show("Mercato ancora attivo"); * } * } * else * {*/ ServerLegaSoapClient myGestioneAdminController = new ServerLegaSoapClient(); Lega result; result = myGestioneAdminController.ChiudiMercato(mercato, lega); if (result != null) { MessageBox.Show("Mercato chiuso correttamente"); lega = result; this.Hide(); new HomeLegaAdmin(lega).Show(); } else { MessageBox.Show("Errore nella chiusura del mercato"); } /*}*/ }
/*private void textBoxPor_TextChanged(object sender, EventArgs e) * { * //Se il numero di portieri è valido passo controllare tutti gli altri campi * if (ValidaPor()) * AbilitaButtonConferma(); * } * * * private void textBoxDif_TextChanged(object sender, EventArgs e) * { * //Se il numero di difensori è valido passo controllare tutti gli altri campi * if (ValidaDif()) * AbilitaButtonConferma(); * } * * private void textBoxCen_TextChanged(object sender, EventArgs e) * { * //Se il numero di centrocampisti è valido passo controllare tutti gli altri campi * if (ValidaCen()) * AbilitaButtonConferma(); * } * * private void textBoxAtt_TextChanged(object sender, EventArgs e) * { * //Se il numero di attaccanti è valido passo controllare tutti gli altri campi * if (ValidaAtt()) * AbilitaButtonConferma(); * } * * private void textBoxCreditiIniz_TextChanged(object sender, EventArgs e) * { * //Se il numero di crediti iniziali è valido passo controllare tutti gli altri campi * if (ValidaCrediti()) * AbilitaButtonConferma(); * }*/ private void buttonCaricaLista_Click(object sender, EventArgs e) { ServerLega.ServerLegaSoapClient myLegaController = new ServerLega.ServerLegaSoapClient(); lega.ListaSvincolati = null; lega = myLegaController.CaricaLista("file", lega); if (lega.ListaSvincolati != null) { MessageBox.Show("Lista caricata correttamente!"); } else { MessageBox.Show("Errore nel caricamento lista!"); } }
private Lega RialzaMock(Squadra squadra, Lega lega) { IPartecipaAstaController myPartecipaAsta = new PartecipaAstaController(); myPartecipaAsta.RialzaOfferta(lega.MercatoAttivo.AstaAttiva, squadra); if (lega != null) { return(lega); } else { lega.MercatoAttivo.AstaAttiva = null; return(lega); } }
public PartecipaAsta(Lega lega, Squadra squadra) { InitializeComponent(); this.lega = lega; this.squadra = squadra; foreach (Squadra s in lega.MercatoAttivo.AstaAttiva.Squadre) { comboBox1.Items.Add(s.Nome); } textBox2.Text = lega.MercatoAttivo.AstaAttiva.UltimoOfferente.Nome; textBox5.Text = Convert.ToString(lega.MercatoAttivo.AstaAttiva.UltimaOfferta); textBox3.Text = lega.MercatoAttivo.AstaAttiva.Giocatore.Nome; textBox2.Enabled = false; textBox3.Enabled = false; textBox5.Enabled = false; }
public Lega Rialza(Squadra squadra, Lega lega) { Lega result; IPartecipaAstaController myPartecipaAsta = new PartecipaAstaController(); myPartecipaAsta.RialzaOfferta(lega.MercatoAttivo.AstaAttiva, squadra); result = AzioniMock(lega, lega.SquadraAdmin); if (result != null) { return(result); } else { result.MercatoAttivo.AstaAttiva = null; return(result); } }
public GestioneLega(Lega legaPass) { lega = legaPass; InitializeComponent(); buttonGestioneGiocatori.Enabled = false; buttonGestionePartecipanti.Enabled = false; buttonVisualizzaLog.Enabled = false; buttonEliminaLega.Enabled = false; //Setto l'output alle impostazioni attuali textBoxPor.Text = lega.NumeroPor.ToString(); textBoxDif.Text = lega.NumeroDif.ToString(); textBoxCen.Text = lega.NumeroCen.ToString(); textBoxAtt.Text = lega.NumeroAtt.ToString(); textBoxCreditiIniz.Text = lega.CreditiInizialiSquadra.ToString(); trackBarNumPartecipanti.Value = lega.NumeroSquadreTotali; }
private void CreaButton_Click(object sender, EventArgs e) { //sul numero di partecipanti non viene fatto nessun controllo perche la track bar lascia inserire solo valori dal 4 al 12 Client.ServerLega.ServerLegaSoapClient myGestioneUtenteController = new Client.ServerLega.ServerLegaSoapClient(); Lega lega = myGestioneUtenteController.CreaLega(NomeDellaLegatextBox.Text, NPartTrackBar.Value, NomeDellaSquadratextBox.Text, _utenteNav); if (lega == null) { MessageBox.Show("Creazione andata male. Probabilmente esiste già una lega con quel nome!"); } else { this.Close(); HomeLegaAdmin homeLegaAdmin = new HomeLegaAdmin(lega); homeLegaAdmin.Show(); } }
public Lega CaricaLista(String source, Lega lega) { Lega result = null; if (lega == null || source.Equals(null)) { return(null); } if (source.Equals("file")) { ICaricaListaController listaController = new CaricaListaFileController(); result = listaController.CaricaLista(lega); } else if (source.Equals("url")) { //PREDISPOSIZIONE FUTURA: lettura della lista da url } return(result); }
public Lega SetImpostazioni(int sqTot, int creIni, int numPor, int numDif, int numCen, int numAtt, Lega lega) { Lega aggiornata = lega; if (sqTot.Equals(null) || creIni.Equals(null) || numPor.Equals(null) || numDif.Equals(null) || numCen.Equals(null) || numAtt.Equals(null) || lega == null) { return(null); } //AGGIORNO PRIMA IL DB SqlConnection conn = null; try { //JACOPO //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Jacopo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaJacopo.mdf;Integrated Security=True"); //LORENZO conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Lorenzo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaLori.mdf;Integrated Security=True"); //ALAN //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Alan\Documents\universita\terzo anno\secondo semestre\progetto\MyFantalega\ServerLega\App_Data\DBMyFantalega.mdf;Integrated Security=True"); conn.Open(); SqlCommand update = new SqlCommand("UPDATE Lega SET numSquadreTot=" + sqTot + ", creditiIniziali=" + creIni + ", numPor=" + numPor + ", numDif=" + numDif + ", numCen=" + numCen + ", numAtt=" + numAtt + " WHERE nome='" + lega.NomeLega + "'", conn); update.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e.Message); return(null); } finally { conn.Close(); } //SE IL DB E' STATO AGGIORNATO CORRETTAMENTE, AGGIORNO E RITORNO LA LEGA AGGIORNATA aggiornata.NumeroSquadreTotali = sqTot; aggiornata.CreditiInizialiSquadra = creIni; aggiornata.NumeroAtt = numAtt; aggiornata.NumeroCen = numCen; aggiornata.NumeroDif = numDif; aggiornata.NumeroPor = numPor; return(aggiornata); }
private void buttonConferma_Click(object sender, EventArgs e) { if (ValidaRichiesta()) { //richiesta al ServerLega mediante il proxy Client ServerLega.ServerLegaSoapClient myLegaController = new ServerLega.ServerLegaSoapClient(); Lega aggiornata; aggiornata = myLegaController.SetImpostazioni(trackBarNumPartecipanti.Value, int.Parse(textBoxCreditiIniz.Text), int.Parse(textBoxPor.Text), int.Parse(textBoxDif.Text), int.Parse(textBoxCen.Text), int.Parse(textBoxAtt.Text), lega); if (aggiornata == null) { MessageBox.Show("Errore della modifica lato server!"); } else { lega = aggiornata; MessageBox.Show("Impostazioni modificate correttamente!"); } } }
public GestioneMercato(Lega legaPass, Squadra squadra) { InitializeComponent(); this.lega = legaPass; mercato = lega.MercatoAttivo; this.squadra = squadra; buttonVisualizzaReport.Enabled = false; buttonCreaPausa.Enabled = false; textBox1.Enabled = false; textBox2.Enabled = false; textBox3.Enabled = false; textBox4.Enabled = false; textBox5.Enabled = false; textBox6.Enabled = false; textBox7.Enabled = false; foreach (Squadra s in mercato.Squadre) { comboBox1.Items.Add(s.Nome); } }
public SvincolaGiocatore(Squadra squadraPass, Lega legaPass) { InitializeComponent(); lega = legaPass; utente = null; giocatore = null; squadra = squadraPass; textBox1.Enabled = false; svincolaButton.Enabled = false; button2.Enabled = true; List <Giocatore> giocatori = squadra.Giocatori; if (giocatori == null) { comboBoxGiocatori.Text = "Nessun giocatore disponibile"; } foreach (Giocatore giocatore in giocatori) { comboBoxGiocatori.Items.Add(giocatore.Nome.ToString()); } }
private void svincolaButton_Click(object sender, EventArgs e) { if (MessageBox.Show("Sei sicuro di voler svincolare il giocatore?", giocatore.Nome, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Client.ServerLega.ServerLegaSoapClient mySvincoloController = new Client.ServerLega.ServerLegaSoapClient(); Lega result = mySvincoloController.SvincolaGiocatore(giocatore, squadra, lega); if (result != null) { MessageBox.Show("Giocatore svincolato"); lega = result; } else { MessageBox.Show("Errore nello svincolo del giocatore"); } } else { MessageBox.Show("Giocatore non svincolato scegli un altro giocatore"); } }
public void SetUp() { Utente _utente = new Utente(); _utente.Email = "mailtestLega.com"; _utente.IsAdmin = true; _lega = new Lega(); _lega.NumeroSquadreTotali = 10; _lega.NomeLega = "LigaCspt"; _lega.Squadre = new List <Squadra>(); Squadra _squadraAdmin = new Squadra(); _squadraAdmin.Utente = _utente; _squadraAdmin.Nome = "SquareFC"; _lega.Squadre.Add(_squadraAdmin); _lega.SquadraAdmin = _squadraAdmin; ServerLegaSoapClient myGestioneAdminController = new ServerLegaSoapClient(); _lega = myGestioneAdminController.SetImpostazioni(8, 100, 2, 6, 6, 4, _lega); myGestioneAdminController.Close(); }
private void buttonAccedi_Click(object sender, EventArgs e) { foreach (Lega l in mieLeghe) { if (l.NomeLega.Equals(comboBoxLeghe.SelectedItem)) { legaScelta = l; break; } } if (legaScelta.SquadraAdmin.Utente.Email.Equals(_utenteNav.Email)) //Sta entrando l'admin della lega { this.Hide(); HomeLegaAdmin homeLegaAdmin = new HomeLegaAdmin(legaScelta); homeLegaAdmin.BringToFront(); homeLegaAdmin.Show(); } else { //entra un utente } }
public Lega SvincolaGiocatore(Giocatore g, Squadra s, Lega lega) { if (!s.Giocatori.Contains(g) || g == null || s == null) { return(null); } s.RimuoviGiocatore(g); g.NomeSquadra = "ListaSvincolati"; s.CreditiResidui = s.CreditiResidui + (g.PrezzoAcquisto / 2); //g.PrezzoAcquisto = 0; lega.ListaSvincolati.AggiungiGiocatore(g); SqlConnection conn = null; try { ///JACOPO //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Jacopo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaJacopo.mdf;Integrated Security=True"); //LORENZO conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Lorenzo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaLori.mdf;Integrated Security=True"); //ALAN //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Alan\Documents\universita\terzo anno\secondo semestre\progetto\MyFantalega\ServerLega\App_Data\DBMyFantalega.mdf;Integrated Security=True"); conn.Open(); SqlCommand update = new SqlCommand("update Giocatore set lista=" + lega.ListaSvincolati.IdLista + ", legaSquadra=NULL, nomeSquadra=NULL, prezzoAcquisto= " + g.PrezzoAcquisto + " where nome='" + g.Nome + "'", conn); update.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e.Message); return(null); } finally { conn.Close(); } return(lega); }
public Lega CreaMercato(Lega lega) { SqlConnection conn = null; try { //JACOPO //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Jacopo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaJacopo.mdf;Integrated Security=True"); //LORENZO conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Lorenzo\Source\Repos\progettoIngegneriaDelSoftware\MyFantalega\ServerLega\App_Data\DBMyFantalegaLori.mdf;Integrated Security=True"); //ALAN //conn = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Alan\Documents\universita\terzo anno\secondo semestre\progetto\MyFantalega\ServerLega\App_Data\DBMyFantalega.mdf;Integrated Security=True"); conn.Open(); Random random = new Random(); int id = random.Next(0, 1000); Mercato m = new Mercato(); m.IdMercato = id; //aggiungiamo squadre per l'esposizione del progetto //ATTENZIONE: AGGIUNGERE A MANO AL DB NELLA TABELLA UTENTE 3 Utenti con username rispettivamente userMock1, userMock2, userMock3 m.addSquadra(lega.SquadraAdmin); Utente a1 = new Utente(); Squadra s1 = new Squadra(); int codice = random.Next(0, 9999); s1.Nome = "SquadraMock" + codice; s1.Utente = a1; String userMock = "UserMock" + codice; SqlCommand insertUtente = new SqlCommand("INSERT INTO Utente (username, [e-mail] ) VALUES ( '" + userMock + "', '*****@*****.**')", conn); insertUtente.ExecuteNonQuery(); SqlCommand insert = new SqlCommand("INSERT INTO Squadra(nome, creditiResidui, lega, utente) VALUES('" + s1.Nome + "' ," + lega.CreditiInizialiSquadra + ", '" + lega.NomeLega + "' , '" + userMock + "')", conn); insert.ExecuteNonQuery(); m.addSquadra(s1); lega.AggiungiSquadra(s1); Utente a2 = new Utente(); Squadra s2 = new Squadra(); codice = random.Next(0, 9999); s2.Nome = "SquadraMock" + codice; s2.Utente = a2; userMock = "UserMock" + codice; insertUtente = new SqlCommand("INSERT INTO Utente (username, [e-mail] ) VALUES ( '" + userMock + "', '*****@*****.**')", conn); insertUtente.ExecuteNonQuery(); insert = new SqlCommand("INSERT INTO Squadra(nome, creditiResidui, lega, utente) VALUES('" + s2.Nome + "' ," + lega.CreditiInizialiSquadra + ", '" + lega.NomeLega + "' , '" + userMock + "')", conn); insert.ExecuteNonQuery(); m.addSquadra(s2); lega.AggiungiSquadra(s2); Utente a3 = new Utente(); Squadra s3 = new Squadra(); codice = random.Next(0, 9999); s3.Nome = "SquadraMock" + codice; s3.Utente = a3; userMock = "UserMock" + codice; insertUtente = new SqlCommand("INSERT INTO Utente (username, [e-mail] ) VALUES ( '" + userMock + "', '*****@*****.**')", conn); insertUtente.ExecuteNonQuery(); insert = new SqlCommand("INSERT INTO Squadra(nome, creditiResidui, lega, utente) VALUES('" + s3.Nome + "' ," + lega.CreditiInizialiSquadra + ", '" + lega.NomeLega + "' , '" + userMock + "')", conn); insert.ExecuteNonQuery(); m.addSquadra(s3); lega.AggiungiSquadra(s3); /* * m.addSquadra( new Squadra("Foizasteam", lega, new Utente())); * m.addSquadra( new Squadra("TagliesterUnited", lega, new Utente())); * m.addSquadra( new Squadra("TaglionsporKulubu", lega, new Utente())); * m.addSquadra( new Squadra("Stefanese1997", lega, new Utente())); * m.addSquadra( new Squadra("DeportivoAperitivo", lega, new Utente())); * m.addSquadra( new Squadra("CRFantasia7", lega, new Utente())); * m.addSquadra( new Squadra("MercedesAMG", lega, new Utente())); * m.addSquadra( new Squadra("SanGallo", lega, new Utente())); */ lega.MercatoAttivo = m; return(lega); } catch (Exception e) { Console.WriteLine(e.Message); lega.MercatoAttivo = null; return(lega); } finally { conn.Close(); } }
public HomeLegaAdmin(Lega lega) { InitializeComponent(); this.lega = lega; squadra = lega.SquadraAdmin; }