public async Task Maj_SerreAsync() { int i, a; String[][] response = await PackageHost.CreateMessageProxy("MySQL").Select_DB <System.String[][]>("plante,serre WHERE plante.Id = serre.Id" as System.String, "nom,url,seuil_lum,temp,besoin_eau,humidite,maturation,position_x,position_y,effectif" as System.String); a = await PackageHost.CreateMessageProxy("MySQL").Count_DB <System.Int32>("plante" as System.String); Serre so = new Serre(response[0].Length, a); init_tab(so.tab_url, PackageHost.GetSettingValue <String>("default_picture")); for (i = 0; i < response[0].Length; i++) //Contient les infos sur toutes les plantes planté dans la serre { so.Plante[i] = new Plante(); so.Plante[i].nom = response[0][i]; so.Plante[i].url = response[1][i]; so.Plante[i].seuil_lum = response[2][i]; so.Plante[i].temp = response[3][i]; so.Plante[i].besoin_eau = response[4][i]; so.Plante[i].humidite = response[5][i]; so.Plante[i].maturation = response[6][i]; so.Plante[i].position_x = response[7][i]; so.Plante[i].position_y = response[8][i]; so.Plante[i].effectif = response[9][i]; so.tab_url[(int.Parse(so.Plante[i].position_x) - 1) + (int.Parse(so.Plante[i].position_y) - 1) * PackageHost.GetSettingValue <Int32>("max_y")] = so.Plante[i].url; } so.LastId = a + 1; //Nouvel Id utilisable pendantl'ajout d'une plante response = await PackageHost.CreateMessageProxy("MySQL").Select_DB <System.String[][]>("plante" as System.String, "Id,nom,url,seuil_lum,temp,besoin_eau,humidite,maturation" as System.String); for (i = 0; i < response[0].Length; i++) //Contient toute les infos de la table plante { so.data[i] = new Database(); so.data[i].Id = response[0][i]; so.data[i].nom = response[1][i]; so.data[i].url = response[2][i]; so.data[i].seuil_lum = response[3][i]; so.data[i].temp = response[4][i]; so.data[i].besoin_eau = response[5][i]; so.data[i].humidite = response[6][i]; so.data[i].maturation = response[7][i]; } PackageHost.PushStateObject("Serre", so); }
private void btnDelete_Click(object sender, EventArgs e) { int codeSer = Convert.ToInt32(textCodeSerre.Text.Trim()); int cap = Convert.ToInt32(textCapacite.Text.Trim()); int sup = Convert.ToInt32(textSuperficie.Text.Trim()); string lib = comboBoxLibelle.Text.Trim(); if (MessageBox.Show("Etes-vous sûr de vouloir supprimer cette Serre?", "Supprimer?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Serre s = db.Serres.ToList <DAL.Serre>().Where(w => w.CodeSerre == codeSer).FirstOrDefault(); GenericRepository <Serre> ser = new GenericRepository <Serre>(db); ser.Delete(s); db.SaveChanges(); Clear(); datagridserre(); MessageBox.Show("utilisateur supprimé"); } }