private void Button_Click(object sender, RoutedEventArgs e)
        {
            gestion_stockEntities td1 = new gestion_stockEntities();

            if (user.Text != string.Empty && pass.Password != string.Empty)
            {
                var users = td1.emplyees.FirstOrDefault(a => a.login_emp.Equals(user.Text));
                if (users != null)
                {
                    if (users.password_emp.Equals(pass.Password))
                    {
                        Window1 ls = new Window1();
                        ls.Show();
                        ls.nime.Text = "";
                        ls.nime.Text = users.nom + " " + users.prenom;
                        this.Hide();
                    }
                    else
                    {
                        eror.Text        = "";
                        eror.Text        = "password and usernime not correct !";
                        eror.Visibility  = Visibility.Visible;
                        error.Visibility = Visibility.Visible;
                    }
                }
            }
            else
            {
                eror.Text        = "";
                eror.Text        = "entrer le mod pass et nom";
                eror.Visibility  = Visibility.Visible;
                error.Visibility = Visibility.Visible;
            }
        }
        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 modifier_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();

            usernime.Text     = emp.login_emp;
            password.Password = emp.password_emp;
            nime.Text         = emp.nom;
            telephone.Text    = emp.Ntele.ToString();
            note.Text         = emp.note;
            second.Text       = emp.prenom;
        }
        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 reshersher_Click(object sender, RoutedEventArgs e)
        {
            gestion_stockEntities td1 = new gestion_stockEntities();
            int       ids             = int.Parse(id.Text);
            fornisuer fors            = td1.fornisuers.Where(a => a.id_fornisuer == ids).First();

            nime.Visibility       = Visibility.Visible;
            adress.Visibility     = Visibility.Visible;
            note.Visibility       = Visibility.Visible;
            telephone.Visibility  = Visibility.Visible;
            usericon.Visibility   = Visibility.Visible;
            adressicon.Visibility = Visibility.Visible;
            noteicon.Visibility   = Visibility.Visible;
            phoneicon.Visibility  = Visibility.Visible;
            reshersher.Visibility = Visibility.Hidden;
            modifier.Visibility   = Visibility.Visible;
            nime.Text             = fors.nom_fourniseur;
            telephone.Text        = fors.tele_forniseur;
            note.Text             = fors.note_forniseur;
        }
        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;
            }
        }
Beispiel #7
0
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            gestion_stockEntities td1 = new gestion_stockEntities();

            dataemp.ItemsSource = td1.emplyees.ToList();
        }