public bool Delete(employerBLL u) { bool isSucces = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "delete FROM Employer where Matricule=@Matricule"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Matricule", u.Matricule); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSucces = true; } else { isSucces = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSucces); }
public bool Modifier(employerBLL u) { bool isSucces = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "UPDATE Employer set Nom=@Nom,Prenom=@Prenom,Cfi=@Cfi,Fonction=@Fonction,Batiment=@Batiment where Matricule=@Matricule"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Nom", u.Nom); cmd.Parameters.AddWithValue("@Prenom", u.Prenom); cmd.Parameters.AddWithValue("@Matricule", u.Matricule); cmd.Parameters.AddWithValue("@Cfi", u.Cfi); cmd.Parameters.AddWithValue("@Fonction", u.Fonction); cmd.Parameters.AddWithValue("@Batiment", u.Batiment); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSucces = true; } else { isSucces = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSucces); }
public bool Insert(employerBLL u) { bool isSucces = false; SqlConnection conn = new SqlConnection(myconnstring); try { string sql = "INSERT INTO EMPLOYER (Nom,Prenom,Matricule,Cfi,Fonction,Batiment) VALUES (@Nom,@Prenom,@Matricule,@Cfi,@Fonction,@Batiment) "; SqlCommand cmd = new SqlCommand(sql, conn); cmd.Parameters.AddWithValue("@Nom", u.Nom); cmd.Parameters.AddWithValue("@Prenom", u.Prenom); cmd.Parameters.AddWithValue("@Matricule", u.Matricule); cmd.Parameters.AddWithValue("@Cfi", u.Cfi); cmd.Parameters.AddWithValue("@Fonction", u.Fonction); cmd.Parameters.AddWithValue("@Batiment", u.Batiment); conn.Open(); int rows = cmd.ExecuteNonQuery(); if (rows > 0) { isSucces = true; } else { isSucces = false; } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { conn.Close(); } return(isSucces); }