private void btn_Submit_Click(object sender, EventArgs e)
        {
            _f.Name = txtb_name.Text;

            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            //creer la synchro
            if (ssc.SetFamily(_f.Id, _f, IdSynchro) == 1)
            {
                MessageBox.Show("La famille " + _f.Name + " a été mise à jour avec succès.");
                FStockAdmin.combobox_families.Items.Clear();
                ServiceSynchro.Family[] AllFamilies = ssc.GetFamilies(true);
                foreach (ServiceSynchro.Family family in AllFamilies)
                {
                    FStockAdmin.combobox_families.Items.Add(family);
                }

                foreach (ServiceSynchro.Family family in FStockAdmin.combobox_families.Items)
                {
                    if (family.Id == _f.Id)
                    {
                        FStockAdmin.combobox_families.SelectedItem = family;
                    }
                }
            }
            else
            {
                MessageBox.Show("Une erreur est survenue.");
            }
            this.Close();
        }
Beispiel #2
0
        private void btn_add_article_Click(object sender, EventArgs e)
        {
            _a.Name         = txtBox_article_name.Text;
            _a.State        = true;
            _a.FamilyId     = ((ServiceSynchro.Family)comboBox_family_name.SelectedItem).Id;
            _a.Quantity     = (int)nud_quantity.Value;
            _a.LocationCode = maskedTextB_location_code.Text;

            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            if (ssc.SetArticle(-1, _a, IdSynchro) == 1)
            {
                MessageBox.Show("L'article a bien été créé");

                foreach (ServiceSynchro.Family family in FStockAdmin.combobox_families.Items)
                {
                    if (_a.FamilyId == family.Id)
                    {
                        FStockAdmin.combobox_families.SelectedItem = family;
                    }
                }

                FStockAdmin.dtgv_articles.DataSource = ssc.GetArticles(_a.FamilyId, true);
            }

            txtBox_article_name.Text       = string.Empty;
            comboBox_family_name.Text      = "";
            nud_quantity.Value             = 0;
            maskedTextB_location_code.Text = string.Empty;
        }
Beispiel #3
0
 private void btn_delete_Click(object sender, EventArgs e)
 {
     if (_u.Id == CurrentUser.Id)
     {
         MessageBox.Show("AVERTISSEMENT: Vous ne pouvez pas supprimer votre compte.");
     }
     else
     {
         DialogResult dialogR = MessageBox.Show("Êtes-vous sûr de vouloir supprimer " + _u.Login + " ?", "Supprimer Utilisateur", MessageBoxButtons.YesNo);
         if (dialogR == DialogResult.Yes)
         {
             ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
             if (ssc.DelUser(_u.Id, IdSynchro) == 1)
             {
                 MessageBox.Show("L'utilisateur a bien été supprimé");
                 FUsersManagement.dtgv_usersList.DataSource = ssc.GetUsers(true);
                 this.Close();
             }
             else
             {
                 MessageBox.Show("Une erreur est survenue");
                 this.Close();
             }
         }
         //else ? if (dialogR == DialogResult.Yes){}
     }
 }
        private void btn_delete_Click(object sender, EventArgs e)
        {
            DialogResult dialogR = MessageBox.Show("Êtes-vous sûr de vouloir supprimer " + _f.Name + " ?", "Supprimer Famille", MessageBoxButtons.YesNo);

            if (dialogR == DialogResult.Yes)
            {
                ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
                if (ssc.DelFamily(_f.Id, IdSynchro) == 1)
                {
                    MessageBox.Show("La famille a bien été supprimée");
                    FStockAdmin.combobox_families.Items.Clear();
                    ServiceSynchro.Family[] AllFamilies = ssc.GetFamilies(true);
                    foreach (ServiceSynchro.Family family in AllFamilies)
                    {
                        FStockAdmin.combobox_families.Items.Add(family);
                    }
                    FStockAdmin.dtgv_articles.DataSource = null;
                    FStockAdmin.combobox_families.Text   = "";
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Une erreur est survenue");
                    this.Close();
                }
            }
            //else ? if (dialogR == DialogResult.Yes){}
        }
Beispiel #5
0
 private void btn_AddUser_Click(object sender, EventArgs e)
 {
     if (txtBox_Password_1.Text == txtBox_Password_2.Text)
     {
         //txtBox_Name , txtBox_Password , cb_admin , btn_Add
         string uLogin = txtBox_Name.Text;
         string uPassw = txtBox_Password_1.Text;
         bool   uAdmin = cb_admin.Checked;
         ServiceSynchro.User newUser = new ServiceSynchro.User();
         newUser.Login    = uLogin;
         newUser.Password = md5.CalculateMD5Hash(uPassw).ToLower();
         newUser.Admin    = uAdmin;
         newUser.State    = true;
         newUser.Id       = -1;
         ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
         if (ssc.SetUser(-1, newUser, IdSynchro) == 1)
         {
             MessageBox.Show("L'utilisateur a bien été ajouté");
             FUsersManagement.dtgv_usersList.DataSource = ssc.GetUsers(true);
         }
         else
         {
             MessageBox.Show("Une erreur est survenue");
         }
         this.Close();
     }
     else
     {
         MessageBox.Show("Les deux mdp ne correspondent pas");
     }
     txtBox_Password_1.Text = txtBox_Password_2.Text = txtBox_Name.Text = string.Empty;
     cb_admin.Checked       = false;
 }
Beispiel #6
0
        ServiceSynchro.Article[] Articles = new ServiceSynchro.Article[] { }; //tous les articles (actifs)
        public Stock_user(int idUser)
        {
            //chargement du CurrentUser
            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            ServiceSynchro.User[] Allusers          = ssc.GetUsers(true);
            foreach (ServiceSynchro.User user in Allusers)
            {
                if (user.Id == idUser)
                {
                    CurrentUser = user;
                }
            }

            //téléchargement des données de la bdd au lancement
            Families = Synchro.DownloadFamilies();
            Articles = Synchro.DownloadArticles();

            InitializeComponent();

            //chargement des familles dans la combo
            foreach (ServiceSynchro.Family family in Families)
            {
                input_family.Items.Add(family);
            }
            input_family.DisplayMember = "name";
        }
Beispiel #7
0
        private void btn_add_family_Click(object sender, EventArgs e)
        {
            _f.Name  = txtBox_family_name.Text;
            _f.State = true;
            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            if (ssc.SetFamily(-1, _f, IdSynchro) == 1)
            {
                MessageBox.Show("La famille a bien été créée");

                FStockAdmin.combobox_families.Items.Clear();
                ServiceSynchro.Family[] AllFamilies = ssc.GetFamilies(true);
                foreach (ServiceSynchro.Family family in AllFamilies)
                {
                    FStockAdmin.combobox_families.Items.Add(family);
                }

                foreach (ServiceSynchro.Family family in FStockAdmin.combobox_families.Items)
                {
                    if (FStockAdmin.combobox_families.SelectedItem == null)
                    {
                        FStockAdmin.combobox_families.SelectedItem = family;
                    }
                    else
                    {
                        if (family.Id > ((ServiceSynchro.Family)FStockAdmin.combobox_families.SelectedItem).Id)
                        {
                            FStockAdmin.combobox_families.SelectedItem = family;
                        }
                    }
                }
            }
            txtBox_family_name.Text = string.Empty;
            this.Close();
        }
        public UpdateFamily(int idFamily, int idCurrentUser, int _IdSynchro, Stock_admin _FStockAdmin)
        {
            InitializeComponent();

            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            ServiceSynchro.User[]   Allusers        = ssc.GetUsers(false);
            ServiceSynchro.Family[] Allfamilies     = ssc.GetFamilies(false);
            foreach (ServiceSynchro.Family family in Allfamilies)
            {
                if (family.Id == idFamily)
                {
                    _f = family;
                }
            }

            foreach (ServiceSynchro.User user in Allusers)
            {
                if (user.Id == idCurrentUser)
                {
                    CurrentUser = user;
                }
            }


            IdSynchro = _IdSynchro;

            FStockAdmin = _FStockAdmin;

            lbl_titre.Text += " " + _f.Name;
        }
Beispiel #9
0
 private void btn_Submit_Click(object sender, EventArgs e)
 {
     _a.Name         = txtb_name.Text;
     _a.LocationCode = txtb_location.Text;
     _a.FamilyId     = ((ServiceSynchro.Family)comboBox_family.SelectedItem).Id;
     _a.Quantity     = (int)nud_quantity.Value;
     ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
     //creer la synchro
     if (ssc.SetArticle(_a.Id, _a, IdSynchro) == 1)
     {
         MessageBox.Show("L'article " + _a.Name + " a été mis à jour avec succès.");
         StockAdmin.dtgv_articles.DataSource = ssc.GetArticles(_a.FamilyId, true);
         foreach (ServiceSynchro.Family family in StockAdmin.combobox_families.Items)
         {
             if (family.Id == _a.FamilyId)
             {
                 StockAdmin.combobox_families.SelectedItem = family;
             }
         }
     }
     else
     {
         MessageBox.Show("Une erreur est survenue.");
     }
     this.Close();
 }
Beispiel #10
0
 private void combobox_families_SelectedIndexChanged(object sender, EventArgs e)
 {
     ServiceSynchro.Family selectedFamily         = (ServiceSynchro.Family)combobox_families.SelectedItem;
     ServiceSynchro.ServiceSynchroClient ssc      = new ServiceSynchro.ServiceSynchroClient();
     ServiceSynchro.Article[]            articles = ssc.GetArticles(selectedFamily.Id, true);
     dtgv_articles.DataSource         = articles;
     dtgv_articles.Columns[0].Visible = false;
     dtgv_articles.Columns[1].Visible = false;
     dtgv_articles.Columns[5].Visible = false;
     // WARNING les index partent de la dernière colonne de la BDD !
 }
Beispiel #11
0
 public MenuAdmin(int IdCurrentUser, int _IdSynchro)
 {
     InitializeComponent();
     ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
     ServiceSynchro.User[] allUser           = ssc.GetUsers(false);
     foreach (ServiceSynchro.User user in allUser)
     {
         if (user.Id == IdCurrentUser)
         {
             CurrentUser = user;
         }
     }
     IdSynchro = _IdSynchro;
 }
Beispiel #12
0
 public AddFamily(int idCurrentUser, int _IdSynchro, Stock_admin _FStockAdmin)
 {
     InitializeComponent();
     ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
     ServiceSynchro.User[] Allusers          = ssc.GetUsers(false);
     foreach (ServiceSynchro.User user in Allusers)
     {
         if (user.Id == idCurrentUser)
         {
             CurrentUser = user;
         }
     }
     IdSynchro   = _IdSynchro;
     FStockAdmin = _FStockAdmin;
 }
 public UsersManagement(int IdCurrentUser, int _IdSynchro)
 {
     InitializeComponent();
     ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
     dtgv_usersList.DataSource = ssc.GetUsers(true);
     ServiceSynchro.User[] allUser = ssc.GetUsers(false);
     foreach (ServiceSynchro.User user in allUser)
     {
         if (user.Id == IdCurrentUser)
         {
             CurrentUser = user;
         }
     }
     IdSynchro = _IdSynchro;
 }
Beispiel #14
0
        public UpdateArticle(int idArticle, int idCurrentUser, int _IdSynchro, int idFamily, Stock_admin _fStockAdmin)
        {
            InitializeComponent();
            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            ServiceSynchro.User[]    Allusers       = ssc.GetUsers(false);
            ServiceSynchro.Article[] Allarticles    = ssc.GetArticles(idFamily, false);
            foreach (ServiceSynchro.Article article in Allarticles)
            {
                if (article.Id == idArticle)
                {
                    _a = article;
                }
            }
            foreach (ServiceSynchro.User user in Allusers)
            {
                if (user.Id == idCurrentUser)
                {
                    CurrentUser = user;
                }
            }
            IdSynchro          = _IdSynchro;
            lbl_titre.Text    += " " + _a.Name;
            txtb_name.Text     = _a.Name;
            txtb_location.Text = _a.LocationCode;
            nud_quantity.Value = _a.Quantity;

            StockAdmin = _fStockAdmin;


            ServiceSynchro.Family[] Families = ssc.GetFamilies(true);

            //chargement des familles dans la combo
            int n             = 0;
            int indexToSelect = 0;

            foreach (ServiceSynchro.Family family in Families)
            {
                comboBox_family.Items.Add(family);
                if (family.Id == idFamily)
                {
                    indexToSelect = n;
                }
                n = n + 1;
            }
            comboBox_family.DisplayMember = "name";

            comboBox_family.SelectedItem = comboBox_family.Items[indexToSelect];
        }
Beispiel #15
0
        private void btn_delete_Click(object sender, EventArgs e)
        {
            DialogResult dialogR = MessageBox.Show("Êtes-vous sûr de vouloir supprimer " + _a.Name + " ?", "Supprimer Article", MessageBoxButtons.YesNo);

            if (dialogR == DialogResult.Yes)
            {
                ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
                if (ssc.DelArticle(_a.Id, IdSynchro) == 1)
                {
                    MessageBox.Show("L'article a bien été supprimé");
                    StockAdmin.dtgv_articles.DataSource = ssc.GetArticles(_a.FamilyId, true);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Une erreur est survenue");
                    this.Close();
                }
            }
        }
Beispiel #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="idUser"></param>
        /// <param name="idCurrentUser"></param>
        /// <param name="_IdSynchro"></param>
        /// <param name="_FUsersManagement">Récupère l'instance de la fenêtre 'gestion utilisateur' pour mettre à jour la dataGridView</param>
        public UpdateUser(int idUser, int idCurrentUser, int _IdSynchro, Gestinv.UsersManagement _FUsersManagement)
        {
            InitializeComponent();
            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            ServiceSynchro.User[] Allusers          = ssc.GetUsers(false);
            foreach (ServiceSynchro.User user in Allusers)
            {
                if (user.Id == idUser)
                {
                    _u = user;
                }
                if (user.Id == idCurrentUser)
                {
                    CurrentUser = user;
                }
            }
            IdSynchro        = _IdSynchro;
            FUsersManagement = _FUsersManagement;

            lbl_titre.Text += " " + _u.Login;
        }
Beispiel #17
0
        public Stock_admin(int idCurrentUser, int _IdSynchro)
        {
            InitializeComponent();
            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            ServiceSynchro.User[] allUser           = ssc.GetUsers(false);
            foreach (ServiceSynchro.User user in allUser)
            {
                if (user.Id == idCurrentUser)
                {
                    CurrentUser = user;
                }
            }
            IdSynchro = _IdSynchro;
            ServiceSynchro.Family[] Families = ssc.GetFamilies(true);

            //chargement des familles dans la combo
            foreach (ServiceSynchro.Family family in Families)
            {
                combobox_families.Items.Add(family);
            }
            combobox_families.DisplayMember = "name";
        }
Beispiel #18
0
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            _u.Login = txtb_Login.Text;
            if (txtb_password1.Text != "" && (txtb_password1.Text == txtb_password2.Text))
            {
                //Hasher la string md5.CalculateMD5Hash(uPassw).ToLower();
                _u.Password = md5.CalculateMD5Hash(txtb_password1.Text).ToLower();
            }
            else if (txtb_password1.Text != txtb_password2.Text)
            {
                MessageBox.Show("Veuillez renseigner deux mdp identiques");
            }
            else
            {
                MessageBox.Show("Le mot de passe n'a pas été modifié");
            }
            if (_u.Id == CurrentUser.Id)
            {
                _u.Admin = true;
                MessageBox.Show("AVERTISSEMENT: Vous ne pouvez pas rétrograder vos droits utilisateurs.");
            }
            else
            {
                _u.Admin = cb_admin.Checked;
            }

            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            //creer la synchro
            if (ssc.SetUser(_u.Id, _u, IdSynchro) == 1)
            {
                MessageBox.Show("L'utilisateur " + _u.Login + " a été mis à jour avec succès.");
                FUsersManagement.dtgv_usersList.DataSource = ssc.GetUsers(true);
            }
            else
            {
                MessageBox.Show("Une erreur est survenue.");
            }
            this.Close();
        }
Beispiel #19
0
        private void button1_Click(object sender, EventArgs e)
        {
            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            ServiceSynchro.User[] Allusers          = ssc.GetUsers(false);

            string inputLogin = login.Text;
            //SOURCE
            string inputPassword = password.Text;

            password.Text = "";
            //HASH
            string inputPasswordMd5 = md5.CalculateMD5Hash(inputPassword).ToLower();
            bool   authen_state     = false;
            var    AllusersLength   = Allusers.GetLength(0);

            for (int iRow = 0; iRow < AllusersLength; iRow++)
            {
                if ((Allusers[iRow].Login == inputLogin) && ((Allusers[iRow].Password == inputPasswordMd5)))
                {
                    if (Allusers[iRow].Admin)
                    {
                        authen_state = true;
                        MenuAdmin fMenuAdmin = new MenuAdmin(Allusers[iRow].Id, ssc.CreateSynchro(Allusers[iRow].Id));
                        fMenuAdmin.Show();
                    }
                    else
                    {
                        authen_state = true;
                        Stock_user fStockUser = new Stock_user(Allusers[iRow].Id);
                        fStockUser.Show();
                    }
                }
            }
            if (!authen_state)
            {
                MessageBox.Show("L'authentification a échouée !");
            }
        }
Beispiel #20
0
        public AddArticle(int idCurrentUser, int _IdSynchro, Stock_admin _FStockAdmin)
        {
            InitializeComponent();
            ServiceSynchro.ServiceSynchroClient ssc = new ServiceSynchro.ServiceSynchroClient();
            ServiceSynchro.User[]   Allusers        = ssc.GetUsers(false);
            ServiceSynchro.Family[] Families        = ssc.GetFamilies(true);
            foreach (ServiceSynchro.User user in Allusers)
            {
                if (user.Id == idCurrentUser)
                {
                    CurrentUser = user;
                }
            }
            IdSynchro   = _IdSynchro;
            FStockAdmin = _FStockAdmin;

            //chargement des familles dans la combo
            foreach (ServiceSynchro.Family family in Families)
            {
                comboBox_family_name.Items.Add(family);
            }
            comboBox_family_name.DisplayMember = "name";
        }
Beispiel #21
0
        public LogsView()
        {
            InitializeComponent();
            ServiceSynchro.ServiceSynchroClient ssc      = new ServiceSynchro.ServiceSynchroClient();
            ServiceSynchro.Synchronization[]    synchros = ssc.GetSynchronizations(20);
            int n = 0;

            foreach (ServiceSynchro.Synchronization synchro in synchros)
            {
                treeView1.Nodes.Add(synchro.Date.ToString() + " (" + synchro.UserLogin + ")");
                foreach (ServiceSynchro.Modification modif in synchro.Modifications)
                {
                    string chainedesc = "";
                    string detail     = "";


                    if (modif.Family != null)
                    {
                        chainedesc = "Family's ID: " + modif.Family.Id.ToString();
                        if (modif.OldValue != "0" && modif.NewValue != "0")
                        {
                            if (modif.OldValue != modif.NewValue)
                            {
                                detail = "Modification : " + modif.OldValue + " --> " + modif.NewValue;
                                if (modif.Family.Name != modif.NewValue)
                                {
                                    detail = detail + "     (Nom actuel de la famille concernée : " + modif.Family.Name + ")";
                                }
                            }
                            else
                            {
                                detail = "Modification sur : " + modif.Family.Name;
                            }
                        }
                        if (modif.OldValue == "0" && modif.NewValue != "0")
                        {
                            detail = "Ajout : " + modif.NewValue;
                        }
                        if (modif.OldValue == "0" && modif.NewValue == "0")
                        {
                            detail = "Suppresion de : " + modif.Family.Name;
                        }
                    }
                    if (modif.User != null)
                    {
                        chainedesc = "User's ID: " + modif.User.Id.ToString();
                        if (modif.OldValue != "0" && modif.NewValue != "0")
                        {
                            if (modif.OldValue != modif.NewValue)
                            {
                                detail = "Modification : " + modif.OldValue + " --> " + modif.NewValue;
                                if (modif.User.Login != modif.NewValue)
                                {
                                    detail = detail + "     (Login actuel de l'utilisateur concerné : " + modif.User.Login + ")";
                                }
                            }
                            else
                            {
                                detail = "Modification sur : " + modif.User.Login;
                            }
                        }
                        if (modif.OldValue == "0" && modif.NewValue != "0")
                        {
                            detail = "Ajout : " + modif.NewValue;
                        }
                        if (modif.OldValue == "0" && modif.NewValue == "0")
                        {
                            detail = "Suppresion de : " + modif.User.Login;
                        }
                    }
                    if (modif.Article != null)
                    {
                        chainedesc = "Article's ID: " + modif.Article.Id.ToString();
                        if (modif.OldValue != "0" && modif.NewValue != "0")
                        {
                            if (modif.OldValue != modif.NewValue)
                            {
                                detail = "Modification : " + modif.OldValue + " --> " + modif.NewValue;
                                if (modif.Article.Name != modif.NewValue)
                                {
                                    detail = detail + "     (Nom actuel de l'article concerné : " + modif.Article.Name + ")";
                                }
                            }
                            else
                            {
                                detail = "Modification sur : " + modif.Article.Name;
                            }
                        }
                        if (modif.OldValue == "0" && modif.NewValue != "0")
                        {
                            detail = "Ajout : " + modif.NewValue;
                        }
                        if (modif.OldValue == "0" && modif.NewValue == "0")
                        {
                            detail = "Suppresion de : " + modif.Article.Name;
                        }
                    }
                    treeView1.Nodes[n].Nodes.Add(modif.ModificationType + "     " + chainedesc + "     " + detail);
                }
                n = n + 1;
            }
        }