private void SelectEmploy_onItemSelected(object sender, EventArgs e) { List <Employe> em = new List <Employe>(); using (Gestion_CaisseEntities db = new Gestion_CaisseEntities()){ // em = db.Employes.Select<> // SelectEmploy.Items } }
private void Form1_Load(object sender, EventArgs e) { db = new Gestion_CaisseEntities(); dmD = new List <DemandeDecaissement>(); emp = new Employe(); employeBindingSource.DataSource = db.Employes.ToList(); clear(); typD = new List <TypeDemande>(); using (Gestion_CaisseEntities dbs = new Gestion_CaisseEntities()) { typD = db.TypeDemandes.ToList(); dmD = db.DemandeDecaissements.ToList(); } //foreach (TypeDemande ty in typD) // comboBox1.Items.Add(ty.type); comboBox1.DataSource = typD; comboBox1.ValueMember = "idTypeDemande"; comboBox1.DisplayMember = "type"; demandeDecaissementBindingSource.DataSource = dmD; var req = from typ in db.TypeDemandes.DefaultIfEmpty() join ddc in db.DemandeDecaissements on typ.idTypeDemande equals ddc.idTypeDemande join v in db.Employes on ddc.idEmploye equals v.idEmploye join ps in db.PieceJointes on ddc.idDemandeDecaissement equals ps.idDemandeDecaissement //where ddc.idEmploye == idEmploy select new { Nom_Prenom = v.nomEmploye + " " + v.prenomEmploye, Type_Demande = typ.type, Motif = ddc.motif, Montant_Demande = ddc.montantDemande, Date_Demande = ddc.dateDemande, Statut_Demande = ddc.statutDemande, Piece_Jointe = ps.cheminFichier }; datagridListeDmd.DataSource = req.ToList(); //datagridListeDmd.Columns[1].HeaderText = "Nom et prenom"; datagridListeDmd.ColumnHeadersVisible = true; }
void modification() { emp = new Employe(); if (listeEmp.CurrentRow.Index != -1) { materieldesign.SelectTab("EnregistreEm"); this.Refresh(); emp.idEmploye = Convert.ToInt32(listeEmp.CurrentRow.Cells["idEmployeDataGridViewTextBoxColumn"].Value); using (Gestion_CaisseEntities db = new Gestion_CaisseEntities()) { emp = db.Employes.Where(x => x.idEmploye == emp.idEmploye).FirstOrDefault(); nomE.Text = emp.nomEmploye; prenomE.Text = emp.prenomEmploye; typeProfil.Text = emp.statut; numPhone.Text = emp.numeroTelephone != null?emp.numeroTelephone.Value.ToString() : ""; } } }
private void listeDemande_Load(object sender, EventArgs e) { idE = Form1.idEmploy; ld = new List <DemandeDecaissement>(); d = new Gestion_CaisseEntities(); //demandeDecaissementBindingSource.DataSource = d.DemandeDecaissements.Where(x => x.idEmploye == idE).ToList(); var req = from typ in d.TypeDemandes join ddc in d.DemandeDecaissements on typ.idTypeDemande equals ddc.idTypeDemande where ddc.idEmploye == idE select new { type = typ.type, motif = ddc.motif, montantDemande = ddc.montantDemande, dateDemande = ddc.dateDemande, statutDemande = ddc.statutDemande, }; datagridListDemande.DataSource = req.ToList(); }
private void btnEnvoiDmd_Click(object sender, EventArgs e) { // allocation de la memoire des instances PieceJointe pc = new PieceJointe(); DemandeDecaissement dmdD = new DemandeDecaissement(); TypeDemande tD = new TypeDemande(); byte[] imge = null; FileStream stream = new FileStream(imgeLocation, FileMode.Open, FileAccess.Read); BinaryReader brd = new BinaryReader(stream); DateTime dte = DateTime.Today; // remplissage de valeur dans les instance imge = brd.ReadBytes((int)stream.Length); dmdD.dateDemande = dte; dmdD.montantDemande = Convert.ToInt32(mtn.Text.Trim()); dmdD.motif = motif.Text.Trim(); //authentification(); dmdD.idEmploye = idEmploy;//ec.idEmploye; pc.cheminFichier = imge; pc.idDemandeDecaissement = dmdD.idDemandeDecaissement; tD.type = typdP; dmdD.idTypeDemande = idtypD; dmdD.statutDemande = pstat; // Ouverture et enregistrement dans la BD using (Gestion_CaisseEntities db = new Gestion_CaisseEntities()) { db.DemandeDecaissements.Add(dmdD); db.PieceJointes.Add(pc); //db.TypeDemandes.Add(tD); db.SaveChanges(); MessageBox.Show("Votre demande a été bien envoyé"); } clearFrmDD(); }
void save() { // Profil profilUser = Worker.SystemProfiles.FirstOrDefault( p => p.nomProfil == emp.statut); if (emp.idEmploye == 0) { emp = new Employe(); emp.mot_de_passe = psw.Text.Trim(); emp.nomEmploye = nomE.Text.Trim(); emp.prenomEmploye = prenomE.Text.Trim(); emp.statut = typeProfil.selectedValue.Trim(); emp.sexe = Masculin.Checked ? "M" : "F"; emp.numeroTelephone = Convert.ToInt32(numPhone.Text.Trim()); using (Gestion_CaisseEntities db = new Gestion_CaisseEntities()) { db.Employes.Add(emp); db.SaveChanges(); } } else { emp.nomEmploye = nomE.Text.Trim(); emp.prenomEmploye = prenomE.Text.Trim(); emp.statut = typeProfil.Text.Trim(); emp.numeroTelephone = Convert.ToInt32(numPhone.Text.Trim()); using (Gestion_CaisseEntities db = new Gestion_CaisseEntities()) { //db.Employes.Attach(emp); db.Entry(emp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } } MessageBox.Show("L'enregistrement a été bien effectué"); clear(); nomE.Focus(); }
void authentification() { Employe empc = new Employe(); using (Gestion_CaisseEntities db = new Gestion_CaisseEntities()) { var req = from empr in db.Employes where empr.nomEmploye == idUser.Text.Trim() select empr; empc = req.FirstOrDefault(); if (empc.nomEmploye == idUser.Text.Trim() && empc.mot_de_passe == mdp.Text.Trim()) { idEmploy = empc.idEmploye; if (empc.statut == "Administrateur") { panel1.Show(); Balance.Hide(); RedigerDemande.Hide(); validerDemande.Hide(); materieldesign.SelectTab("listEmp1"); this.Refresh(); } if (empc.statut == "Caissier") { panel1.Show(); approvisionnement.Show(); Balance.Hide(); RedigerDemande.Hide(); validerDemande.Hide(); EnreEmploy.Hide(); btnListEmploye.Hide(); } if (empc.statut == "Chef_service") { panel1.Show(); Balance.Show(); validerDemande.Show(); approvisionnement.Hide(); RedigerDemande.Hide(); EnreEmploy.Hide(); btnListEmploye.Hide(); materieldesign.SelectTab("validDemd"); //materieldesign.SelectTab("validDemd"); } if (empc.statut == "Simple_employe") { panel1.Show(); RedigerDemande.Show(); materieldesign.SelectTab("redigerDmd"); Balance.Hide(); approvisionnement.Hide(); validerDemande.Hide(); EnreEmploy.Hide(); btnListEmploye.Hide(); } } else { panel1.Hide(); MessageBox.Show("mot de passe ou id invalide"); } } }