Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

LOGIN/

namespace Mini_projet_test
{
public partial class Login : Form
{
public Login()
{
InitializeComponent();
Connexion.Connect();
}

private void bntLogin_Click(object sender, EventArgs e)


{
SqlConnection conn = new SqlConnection("Data Source=DESKTOP-4F71V6C;Initial
Catalog=ENSAT;Integrated Security=True");

string query = "SELECT COUNT(*) FROM Profs WHERE username ='" +


this.txtUsername.Text + "' AND password = '" + this.txtPassword.Text + "'";
SqlCommand command = new SqlCommand(query,conn);

conn.Open();
int result = (int)command.ExecuteScalar();

if (result == 1)
{
Acceuil form = new Acceuil();
form.Show();
}
else
{
MessageBox.Show("Nom d'utilisateur ou mot de passe incorrect. Réessayez.");
}

private void txtPassword_TextChanged(object sender, EventArgs e)


{
txtPassword.PasswordChar = '*';
txtPassword.UseSystemPasswordChar = true;

}
}
}

using System;
Form

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
using Projet;
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Button;

namespace Mini_projet_test
{
public partial class GestionDesEtudiant : Form
{

public GestionDesEtudiant()
{
InitializeComponent();

}
private void dataGridView1_CellContentClick(object sender,
DataGridViewCellEventArgs e)
{
if (e.RowIndex >= 0)
{
DataGridViewRow row = this.dataGridView1.Rows[e.RowIndex];

// Set the values of the textboxes


this.txtCode.Text = row.Cells[0].Value.ToString();
this.txtName.Text = row.Cells[1].Value.ToString();
this.txtPrenom.Text = row.Cells[2].Value.ToString();
this.txtFiliere.Text = row.Cells[3].Value.ToString();
this.txtNiveau.Text = row.Cells[4].Value.ToString();
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{

private void Form2_Load(object sender, EventArgs e)


{
dataGridView1.DataSource = Eleve.all<Eleve>();
}
private void vider()
{
txtCode.Text = "";
txtName.Text = "";
txtPrenom.Text = "";
txtFiliere.Text = "";
txtNiveau.Text = "";
}
private void btnGestion_Click(object sender, EventArgs e)
{
GestionDesEtudiant form = new GestionDesEtudiant();
form.Show();
}

private void btnAjouter_Click(object sender, EventArgs e)


{
dataGridView1.Visible = true;
Eleve el = new Eleve(int.Parse(txtCode.Text), txtName.Text, txtPrenom.Text,
txtFiliere.Text, txtNiveau.Text);

el.save();

string dbConnection = DotEnv.GetDotEnvFilePath();

if (string.IsNullOrEmpty(dbConnection))
{
MessageBox.Show("The DB_CONNECTION environment variable is not set.");
}
else
{
MessageBox.Show("The value of the DB_CONNECTION environment variable is:
" + dbConnection);
MessageBox.Show("Ajout réussit");

dataGridView1.DataSource = Eleve.all<Eleve>();
}

private void checkBoxNiv_CheckedChanged(object sender, EventArgs e)


{

private void btnModifier_Click(object sender, EventArgs e)


{
dataGridView1.Visible = true;

Eleve el = Eleve.findByCode<Eleve>(txtCode.Text);
if (checkBoxNom.Checked == true) el.Nom = txtName.Text;
if (checkBoxPrenom.Checked == true) el.Prenom = txtPrenom.Text;
if (checkBoxNiv.Checked == true) el.Niveau = txtNiveau.Text;
if (checkBoxFil.Checked == true) el.Code_fil = txtFiliere.Text;
el.save();
dataGridView1.DataSource = Eleve.all<Eleve>();
}

private void btnSupprimer_Click(object sender, EventArgs e)


{
dataGridView1.Visible = true;
Eleve el = Eleve.findByCode<Eleve>(txtCode.Text);
DialogResult res = MessageBox.Show("vous voules vraiment supprimer cette
ligne?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

if (res == DialogResult.OK)
{
el.delete();

}
dataGridView1.DataSource = Eleve.all<Eleve>();

private void btnRechercher_Click(object sender, EventArgs e)


{
dataGridView1.Visible = true;

Dictionary<string, object> d = new Dictionary<string, object>();


if (checkBoxCode.Checked == false)
{

if (checkBoxNom.Checked == true) d.Add("nom", txtName.Text);


if (checkBoxPrenom.Checked == true) d.Add("prenom", txtPrenom.Text);
if (checkBoxNiv.Checked == true) d.Add("niveau", txtNiveau.Text);
if (checkBoxFil.Checked == true) d.Add("code_fil", txtFiliere.Text);
dataGridView1.DataSource = Eleve.select<Eleve>(d);
}
else
{
d.Add("code", txtCode.Text);
dataGridView1.DataSource = Eleve.select<Eleve>(d);

}
}

private void btnNouveau_Click(object sender, EventArgs e)


{
vider();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
Acceuil form = new Acceuil();
form.Show();
}
}
}

You might also like