Insérer les données dans la base de données en C#
Ndjoko
Messages postés
12
Date d'inscription
Statut
Membre
Dernière intervention
-
TDIA Messages postés 2 Date d'inscription Statut Membre Dernière intervention -
TDIA Messages postés 2 Date d'inscription Statut Membre Dernière intervention -
Bonjour à tous!, je n'ai pas suffisamment la connaissance pour le langage de programmation C# (C_sharp), je cherche le code qui pourras m'aider à insérer, recherche, modifier et supprimer les données dans une table, même afficher aussi,
merci pour la compréhension...
je vous aime tous !
merci pour la compréhension...
je vous aime tous !
A voir également:
- Insérer les données dans la base de données en C#
- Fuite données maif - Guide
- Supprimer les données de navigation - Guide
- Insérer une vidéo dans powerpoint - Guide
- Trier des données excel - Guide
- Base de registre - Guide
1 réponse
il y a des faults
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Globalization;
using Microsoft.VisualBasic;
namespace projet_b7al_contole
{
public partial class Form1 : Form
{
struct Personnel
{
public string Code;
public string Nom;
public string Prenom;
public string Poste;
}
Personnel[] Liste_personnel = new Personnel[1];
int i = 0;
int cd = 1;
int pos_encoure;
bool statut = false;
private void Afficher_Personnel(Personnel P)
{
this.TB_Code.Text = P.Code;
this.TB_Nom.Text = P.Nom;
this.TB_Prenom.Text = P.Prenom;
this.TB_Poste.Text = P.Poste;
}
private Personnel Remplir_Personnel(string cd ,string nm ,string pr ,string pt)
{
Personnel P = new Personnel();
P.Code = cd;
P.Nom = nm;
P.Prenom = pr;
P.Poste = pt;
return P;
}
private void Inintialiser_Personnel()
{
TB_Nom.Text = "";
TB_Prenom.Text = "";
TB_Poste.Text = "";
}
public Form1()
{
InitializeComponent();
}
private void BT_Ajouter_Click(object sender, EventArgs e)
{
if (!statut) cd++;
Liste_personnel[i] = Remplir_Personnel(TB_Code.Text, TB_Nom.Text, TB_Prenom.Text, TB_Poste.Text);
this.TB_Code.Text = cd.ToString("0000", CultureInfo.InvariantCulture);
if (!statut)
{
i++;
pos_encoure = i;
Array.Resize(ref Liste_personnel, i + 1);
}
statut = false;
Inintialiser_Personnel();
}
private void Form1_Load(object sender, EventArgs e)
{
this.TB_Code.Text = cd.ToString("0000", CultureInfo.InvariantCulture);
}
private void BT_Premier_Click(object sender, EventArgs e)
{
Afficher_Personnel(Liste_personnel[0]);
pos_encoure = 0;
statut = true;
}
private void BT_Dernier_Click(object sender, EventArgs e)
{
Afficher_Personnel(Liste_personnel[i-1]);
pos_encoure = i - 1;
statut = true;
}
private void BT_Precedent_Click(object sender, EventArgs e)
{
if (pos_encoure > 0)
{
pos_encoure--;
Afficher_Personnel(Liste_personnel[pos_encoure]);
statut = true;
}
else
{
MessageBox.Show("Debut Du Tableau", "Erreur");
pos_encoure = 0;
}
}
private void BT_Suivant_Click(object sender, EventArgs e)
{
if(pos_encoure < i)
{
pos_encoure++;
Afficher_Personnel(Liste_personnel[pos_encoure]);
statut = true;
}
else
{
MessageBox.Show("fin Du Tableau", "Erreur");
pos_encoure = i - 1;
}
}
private void BT_Supprimer_Click(object sender, EventArgs e)
{
for (int j = pos_encoure; j < i; j++)
{
Liste_personnel[j]= Liste_personnel[j + 1];
}
if (pos_encoure !=0)
pos_encoure--;
i--;
Array.Resize(ref Liste_personnel,i+1);
try { Afficher_Personnel(Liste_personnel[ pos_encoure ]); }
catch { Afficher_Personnel(Liste_personnel[pos_encoure+1]); }
}
private void BT_Modifier_Click(object sender, EventArgs e)
{
Liste_personnel[pos_encoure] = Remplir_Personnel(TB_Code.Text, TB_Nom.Text, TB_Prenom.Text, TB_Poste.Text);
}
private void BT_Recherche_Click(object sender, EventArgs e)
{
bool trouve = false;
int k=0;
int j=0;
string cod = Interaction.InputBox("Enter Le Code : ", "Recherche");
while ((j < i) && (!trouve))
{
if (Liste_personnel[j].Code == cod)
{
trouve = true;
k = j;
}
j++;
}
if (trouve)
{
Afficher_Personnel(Liste_personnel[k]);
pos_encoure = k;
}
else if (!trouve)
{
MessageBox.Show("Cette employé n'existe pas", "Erreur");
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Globalization;
using Microsoft.VisualBasic;
namespace projet_b7al_contole
{
public partial class Form1 : Form
{
struct Personnel
{
public string Code;
public string Nom;
public string Prenom;
public string Poste;
}
Personnel[] Liste_personnel = new Personnel[1];
int i = 0;
int cd = 1;
int pos_encoure;
bool statut = false;
private void Afficher_Personnel(Personnel P)
{
this.TB_Code.Text = P.Code;
this.TB_Nom.Text = P.Nom;
this.TB_Prenom.Text = P.Prenom;
this.TB_Poste.Text = P.Poste;
}
private Personnel Remplir_Personnel(string cd ,string nm ,string pr ,string pt)
{
Personnel P = new Personnel();
P.Code = cd;
P.Nom = nm;
P.Prenom = pr;
P.Poste = pt;
return P;
}
private void Inintialiser_Personnel()
{
TB_Nom.Text = "";
TB_Prenom.Text = "";
TB_Poste.Text = "";
}
public Form1()
{
InitializeComponent();
}
private void BT_Ajouter_Click(object sender, EventArgs e)
{
if (!statut) cd++;
Liste_personnel[i] = Remplir_Personnel(TB_Code.Text, TB_Nom.Text, TB_Prenom.Text, TB_Poste.Text);
this.TB_Code.Text = cd.ToString("0000", CultureInfo.InvariantCulture);
if (!statut)
{
i++;
pos_encoure = i;
Array.Resize(ref Liste_personnel, i + 1);
}
statut = false;
Inintialiser_Personnel();
}
private void Form1_Load(object sender, EventArgs e)
{
this.TB_Code.Text = cd.ToString("0000", CultureInfo.InvariantCulture);
}
private void BT_Premier_Click(object sender, EventArgs e)
{
Afficher_Personnel(Liste_personnel[0]);
pos_encoure = 0;
statut = true;
}
private void BT_Dernier_Click(object sender, EventArgs e)
{
Afficher_Personnel(Liste_personnel[i-1]);
pos_encoure = i - 1;
statut = true;
}
private void BT_Precedent_Click(object sender, EventArgs e)
{
if (pos_encoure > 0)
{
pos_encoure--;
Afficher_Personnel(Liste_personnel[pos_encoure]);
statut = true;
}
else
{
MessageBox.Show("Debut Du Tableau", "Erreur");
pos_encoure = 0;
}
}
private void BT_Suivant_Click(object sender, EventArgs e)
{
if(pos_encoure < i)
{
pos_encoure++;
Afficher_Personnel(Liste_personnel[pos_encoure]);
statut = true;
}
else
{
MessageBox.Show("fin Du Tableau", "Erreur");
pos_encoure = i - 1;
}
}
private void BT_Supprimer_Click(object sender, EventArgs e)
{
for (int j = pos_encoure; j < i; j++)
{
Liste_personnel[j]= Liste_personnel[j + 1];
}
if (pos_encoure !=0)
pos_encoure--;
i--;
Array.Resize(ref Liste_personnel,i+1);
try { Afficher_Personnel(Liste_personnel[ pos_encoure ]); }
catch { Afficher_Personnel(Liste_personnel[pos_encoure+1]); }
}
private void BT_Modifier_Click(object sender, EventArgs e)
{
Liste_personnel[pos_encoure] = Remplir_Personnel(TB_Code.Text, TB_Nom.Text, TB_Prenom.Text, TB_Poste.Text);
}
private void BT_Recherche_Click(object sender, EventArgs e)
{
bool trouve = false;
int k=0;
int j=0;
string cod = Interaction.InputBox("Enter Le Code : ", "Recherche");
while ((j < i) && (!trouve))
{
if (Liste_personnel[j].Code == cod)
{
trouve = true;
k = j;
}
j++;
}
if (trouve)
{
Afficher_Personnel(Liste_personnel[k]);
pos_encoure = k;
}
else if (!trouve)
{
MessageBox.Show("Cette employé n'existe pas", "Erreur");
}
}
}
}