private void suppremer_Click(object sender, RoutedEventArgs e) { gestion_stockEntities td1 = new gestion_stockEntities(); int ids = int.Parse(id.Text); emplyee emp = td1.emplyees.Where(a => a.id_emp == ids).First(); td1.emplyees.Remove(emp); td1.SaveChanges(); }
private void ajouter_Click(object sender, RoutedEventArgs e) { UserControluser usercont = new UserControluser(); byte[] image = null; if (source == "") { MessageBox.Show("add picture of emplyee"); } else { FileStream stream = new FileStream(source, FileMode.Open, FileAccess.Read); BinaryReader brs = new BinaryReader(stream); image = brs.ReadBytes((int)stream.Length); } emplyee ls = new emplyee(); gestion_stockEntities td1 = new gestion_stockEntities(); int ids = int.Parse(id.Text); var emp = td1.emplyees.Where(a => a.id_emp == ids).Count(); if (emp == 0) { ls.id_emp = int.Parse(id.Text); ls.login_emp = usernime.Text; ls.password_emp = password.Password; ls.nom = nime.Text; ls.Ntele = int.Parse(telephone.Text); ls.type_emp = ((ComboBoxItem)catigo.SelectedItem).Content.ToString(); ls.image_emp = image; ls.note = note.Text; ls.prenom = second.Text; td1.emplyees.Add(ls); td1.SaveChanges(); accpet lm = new accpet(); lm.Show(); this.Hide(); usercont.dataemp.Items.Refresh(); } else { accpet lm = new accpet(); lm.Show(); lm.acp.Visibility = Visibility.Hidden; lm.bacp.Visibility = Visibility.Hidden; lm.textp.Text = ""; lm.textp.Text = "emplyee n'est pas accepte"; [email protected] = Visibility.Visible; lm.bref.Visibility = Visibility.Visible; } }
private void ajouter_Click(object sender, RoutedEventArgs e) { UserControluser usercont = new UserControluser(); byte[] image = null; FileStream stream = new FileStream(source, FileMode.Open, FileAccess.Read); BinaryReader brs = new BinaryReader(stream); image = brs.ReadBytes((int)stream.Length); fornisuer ls = new fornisuer(); gestion_stockEntities td1 = new gestion_stockEntities(); int ids = int.Parse(id.Text); var forni = td1.fornisuers.Where(a => a.id_fornisuer == ids).Count(); if (forni == 0) { ls.id_fornisuer = ids; ls.nom_fourniseur = nime.Text; ls.tele_forniseur = telephone.Text; ls.address_forniseur = adress.Text; ls.image = image; ls.note_forniseur = note.Text; td1.fornisuers.Add(ls); td1.SaveChanges(); accpet lm = new accpet(); lm.Show(); this.Hide(); } else { accpet lm = new accpet(); lm.Show(); lm.acp.Visibility = Visibility.Hidden; lm.bacp.Visibility = Visibility.Hidden; lm.textp.Text = ""; lm.textp.Text = "fourniseur n'est pas accepte"; [email protected] = Visibility.Visible; lm.bref.Visibility = Visibility.Visible; } }