public static void ElaboraIstruttori(dbInteraction DBI, JSONObject coop) { bool[] trainiEff = new bool[coop.trainiEff.Count]; foreach (Pilota p in coop.instructors) { int idPilot = DBI.AddInstructor(p); if (idPilot != -1) { for (int i = 0; i < coop.trainiEff.Count; i++) { if (!trainiEff[i] && p.id == coop.trainiEff[i].IDIstruttore) { Traini tr = coop.trainiEff[i]; tr.IDIstruttore = 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"); }