public static void ElaboraPilotiAlianti(dbInteraction DBI, JSONObject coop) { bool[] trainiEff = new bool[coop.trainiEff.Count]; foreach (Pilota p in coop.pilsAli) { int idPilot = DBI.AddPilotAliante(p); if (idPilot != -1) { for (int i = 0; i < coop.trainiEff.Count; i++) { if (!trainiEff[i] && p.id == coop.trainiEff[i].IDPilota) { Traini tr = coop.trainiEff[i]; tr.IDPilota = idPilot; coop.trainiEff[i] = tr; trainiEff[i] = true; } } } } }
protected void btnAdd_Click(object sender, EventArgs e) { dbInteraction DBI = new dbInteraction(); if (txtPara1.Text != "" && txtpara2.Text != "") { switch (c) { case 0: Session["result"] = DBI.AddPilot(new Pilota(txtPara1.Text, txtpara2.Text)); break; case 1: Session["result"] = DBI.AddPilotAliante(new Pilota(txtPara1.Text, txtpara2.Text)); break; case 2: Session["result"] = DBI.AddInstructor(new Pilota(txtPara1.Text, txtpara2.Text)); break; case 3: Session["result"] = DBI.AddModTrainatore(new ModelloAereo(txtPara1.Text, txtpara2.Text)); break; case 4: Session["result"] = DBI.AddModAliante(new ModelloAereo(txtPara1.Text, txtpara2.Text)); break; default: break; } } Response.Redirect("~/aggiungiElemento.aspx"); }