static void TesterCollection()
        {
            Salaries salaries = new Salaries();

            salaries.Add(new Salarie()
            {
                Matricule = "01tre12", Nom = "bost", Prenom = "Vincent", DateNaissance = new DateTime(1962, 01, 13)
            });
            salaries.Add(new Salarie()
            {
                Matricule     = "01tre13",
                Nom           = "bosti",
                Prenom        = "Vincente",
                DateNaissance = new DateTime(1962, 01, 14)
            });
            Salarie sal3 = new Salarie()
            {
                Matricule     = "01tre13",
                Nom           = "bosti",
                Prenom        = "Vincente",
                DateNaissance = new DateTime(1962, 01, 14)
            };

            salaries.Add(sal3);



            Console.ReadLine();
        }
Example #2
0
        static void Main(string[] args)
        {
            Salaries listeSalaries = new Salaries();

            listeSalaries.Add(new Salarie()
            {
                Matricule = "12XXX12", Nom = "Bost", Prenom = "Vincent"
            });
            listeSalaries.Add(new Salarie()
            {
                Matricule = "12XXX13", Nom = "Tartempion", Prenom = "Gilbert"
            });
            listeSalaries.Add(new Salarie()
            {
                Matricule = "12XXX12", Nom = "Bost", Prenom = "Vincent"
            });
            Console.WriteLine("attendu true {0}", 2 == listeSalaries.Count);
            Salarie salASupprimer = listeSalaries.Extraire("12XXX13");

            listeSalaries.Remove(salASupprimer);
            Console.WriteLine("attendu true {0}", 1 == listeSalaries.Count);
            Salarie salASupprimer2 = listeSalaries.Extraire("12XXX12");

            listeSalaries.Remove(salASupprimer2);
            listeSalaries.Remove()
            Console.WriteLine("attendu true {0}", 0 == listeSalaries.Count);
            Console.ReadLine();
        }
Example #3
0
    private void PopulateSalaries(AttestableItems items)
    {
        Salaries salaries           = Salaries.ForOrganization(Organization.PPSE);
        Salaries unattestedSalaries = new Salaries();

        // LINQ would be nice here. "Where Attested=0".

        foreach (Salary salary in salaries)
        {
            if (!salary.Attested)
            {
                if (attestationRights.ContainsKey(salary.PayrollItem.BudgetId) && salary.PayrollItem.PersonId != _currentUser.Identity)
                {
                    unattestedSalaries.Add(salary);
                }
                else if (salary.PayrollItem.ReportsToPersonId == _currentUser.Identity)
                {
                    unattestedSalaries.Add(salary);
                }
            }
        }

        foreach (Salary salary in unattestedSalaries)
        {
            AddAttestableItem(items, salary);
        }
    }
Example #4
0
        private void ModifierSalarie()
        {
            if (IsValidChamps())
            {
                try
                {
                    salaries.Remove(salarie);
                    if (chkCommercial.Checked)
                    {
                        salarie = new Commercial();
                        ((Commercial)salarie).ChiffreAffaire = decimal.Parse(txtCA.Text);
                        ((Commercial)salarie).Commission     = decimal.Parse(txtComm.Text);
                    }
                    else
                    {
                        salarie = new Salarie();
                    }

                    salarie.Matricule     = txtMatricule.Text;
                    salarie.Nom           = txtNom.Text;
                    salarie.Prenom        = txtPrenom.Text;
                    salarie.DateNaissance = DateTime.Parse(txtBDay.Text);
                    salarie.SalaireBrut   = decimal.Parse(txtSalaireBrut.Text);
                    salarie.TauxCS        = decimal.Parse(txtTauxCS.Text);
                    salaries.Add(salarie);

                    salaries.Save(MonApplication.DispositifSauvegarde, Properties.Settings.Default.AppData);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
        private void btnValider_Click(object sender, EventArgs e)
        {
            DialogResult validation = MessageBox.Show
                                          ("Etes-vous sûr.e de vouloir valider ces modifications ?", "Validation des modifications", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            switch (validation)
            {
            case DialogResult.Yes:
            {
                if (ChampsValides())
                {
                    if (isNew == true)
                    {
                        if (cbChoix.SelectedIndex == 0)
                        {
                            salaries.Add(salarie);
                        }
                        else if (cbChoix.SelectedIndex == 1)
                        {
                            salaries.Add(commercial);
                        }
                        cbSalarie.Items.Add(salarie.Matricule);
                        cbSalarie.SelectedItem = salarie.Matricule;
                    }

                    ChargerValeursSalaries();
                    SauvegarderSalarie();
                    MessageBox.Show("Les modifications ont bien été effectuées !");
                    GestionnaireContextes(Contextes.AjoutValider);
                }

                else
                {
                    if (isNew == true)
                    {
                        txtMatricule.Focus();
                    }
                    else
                    {
                        txtNom.Focus();
                    }
                }

                GestionnaireContextes(Contextes.ModificationIssue);

                break;
            }

            case DialogResult.No:
            {
                MessageBox.Show("Les modifications n'ont pas été effectuées. Retour à la modification du salarié.");
                break;
            }
            }
        }
Example #6
0
        static void Main(string[] args)
        {
            Salaries team = new Salaries();

            team.Add(new Salarie("Bachelet", "Damien", "00xxx00"));
            team.Add(new Salarie("Bacheleta", "Damiena", "01xxx01"));
            team.Add(new Salarie("Bacheleta", "Damiena", "01xxx01")); // Ne sera pas ajouté : même matricul
            Console.WriteLine("Non ajout avec même matricule : {0}", team.Count == 2);


            team.Add(new Salarie("Bacheletb", "Damienb", "02xxx02"));
            Salarie test = new Salarie("Bacheletc", "Damienc", "03xxx03");

            team.Add(test);

            Console.WriteLine("List :");
            afficherSalaries(team);

            team.supprimerSalarie("01xxx01");

            afficherSalaries(team);

            team.supprimerSalarie(test);

            afficherSalaries(team);

            Console.ReadLine();
            Console.Clear();

            SalariesH team2 = new SalariesH();

            team2.Add(new Salarie("Bachelet", "Damien", "00xxx00"));
            team2.Add(new Salarie("Bacheleta", "Damiena", "01xxx01"));
            team2.Add(new Salarie("Bacheletb", "Damienb", "01xxx01"));
            team2.Add(test);

            Console.WriteLine("HashSet :");
            afficherSalariesH(team2);

            team2.supprimerSalarie("01xxx01");

            afficherSalariesH(team2);

            team2.supprimerSalarie(test);

            afficherSalariesH(team2);

            Console.ReadLine();
        }
        public MainWindow()
        {
            InitializeComponent();
            this.WindowState = WindowState.Maximized;

            //Initialisation Roles//
            Role admin = new Role()
            {
                Identifiant = "administrateur", Description = "Accès total à l'applicaton"
            };
            Role limitedUser = new Role()
            {
                Identifiant = "utilisateur", Description = "Accès interdit au panneau utilisateur"
            };

            listRoles.Add(admin);
            listRoles.Add(limitedUser);

            //Initialisation Users//
            Utilisateur ran = new Utilisateur("aa111bb", "Ranchon", "00000");

            listUsers.Add(ran);
            listUsers.Add(new Utilisateur("bb0000bb", "Machin", "11111"));
            ran.Role = admin;

            Salarie tri = new Salarie("Ranchon", "Michel", "11aaa22");

            tri.Poste = "Salarie";
            listSalaries.Add(tri);
        }
Example #8
0
        private void OnSalaryAdded(SalaryAddedMessage message)
        {
            EditableSalaryViewModel salaryViewModel = new EditableSalaryViewModel(salaryValidator);

            salaryViewModel.LoadEntity(message.Content);
            Salaries.Add(salaryViewModel);
            exportCommand.RaiseCanExecuteChanged();
        }
Example #9
0
        public static void Serialisationv1()
        {
            #region Initialisation
            Salaries listesal = new Salaries();
            listesal.Add(new Salarie(new DateTime(1993, 11, 10), "12gty93", "CHESNE", "Sarah", 25000, 0.2));
            listesal.Add(new Salarie(new DateTime(1998, 08, 27), "12gty98", "CHESNE", "Emilie", 23000, 0.2));
            #endregion

            #region Exercice 2.1 CSV
            listesal.SaveText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.csv");
            Salaries listesal2 = new Salaries();


            listesal2.LoadText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.csv");
            foreach (Salarie sal in listesal2)
            {
                Console.WriteLine(sal.ToString());
            }
            #endregion

            #region XML
            listesal.SaveXML(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.xml");
            Salaries listesal3 = new Salaries();

            listesal3.LoadXML(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.xml");
            foreach (Salarie sal2 in listesal3)
            {
                Console.WriteLine(sal2.ToString());
            }
            #endregion

            #region Binaire

            listesal.SaveBinary(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.dat");
            Salaries listesal4 = new Salaries();
            listesal4.LoadBinary(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\PersitanceObjet\Salarie.dat");
            foreach (Salarie sal3 in listesal4)
            {
                Console.WriteLine(sal3.ToString());
            }
            #endregion

            

        }
Example #10
0
        private void modificationSalarie()
        {
            ErrorProvider ep = new ErrorProvider();

            try
            {
                salaries.Remove(salarie);
                if (IsValidChamps())
                {
                    ajouteNewSalarie();
                    salaries.Add(salarie);
                }
            }
            catch (Exception ex)
            {
                ep.SetError(btnValider, ex.Message);
            }
        }
Example #11
0
 private static void GenererCollection()
 {
     salaries.Add(new Salarie()
     {
         Matricule = "01ABC12", Nom = "Artemiche", Prenom = "Marcel", SalaireBrut = 1200.35M, TauxCS = 0.20M, DateNaissance = new DateTime(1980, 10, 25)
     });
     salaries.Add(new Salarie()
     {
         Matricule = "02ABC12", Nom = "Bernard", Prenom = "Antoine", TauxCS = 0.20M, DateNaissance = new DateTime(1981, 09, 25)
     });
     salaries.Add(new Commercial()
     {
         Matricule = "03ABC12", Nom = "Commerce", Prenom = "Philippe", Commission = 0.2M, ChiffreAffaire = 2500, TauxCS = 0.20M, DateNaissance = new DateTime(1979, 09, 25)
     });
     salaries.Add(new Commercial()
     {
         Matricule = "04ABC12", Nom = "CommerceVIP", Prenom = "Jean", Commission = 0.2M, TauxCS = 0.20M, DateNaissance = new DateTime(1990, 09, 25)
     });
 }
Example #12
0
        private void AddSalaries(IEnumerable <Salary> importedCollection)
        {
            foreach (var item in importedCollection)
            {
                EditableSalaryViewModel itemViewModel = new EditableSalaryViewModel(salaryValidator);
                itemViewModel.LoadEntity(item);
                Salaries.Add(itemViewModel);
            }

            exportCommand.RaiseCanExecuteChanged();
        }
Example #13
0
        static void choix()
        {
            bool loop = true;

            do
            {
                Console.Clear();
                Console.WriteLine("C : Création | M : Modification | X : Suppression | L : Load | S : Save | Q : quit");
                char reponse = char.Parse(Console.ReadLine());
                switch (reponse)
                {
                case 'L':
                    Load("Txt");
                    //Load("Bin");
                    //Load("Xml");
                    //Load("Json");
                    break;

                case 'S':
                    Save("Txt");
                    //Save("Bin");
                    //Save("Xml");
                    //Save("Json");
                    break;

                case 'C': team.Add(creationSalarie()); break;

                case 'M': modificationSalarie(); break;

                case 'X': suppressionSalarie(); break;

                case 'Q': loop = false; break;
                }
            } while (loop);
        }
Example #14
0
        static void TesterSalariesCVS()
        {
            Salaries ListeSalaries = new Salaries();

            ListeSalaries.Add(new Salarie()
            {
                Matricule     = "12XXX34",
                Nom           = "Hemar",
                Prenom        = "Mylene",
                DateNaissance = new DateTime(1988, 02, 20),
                SalaireBrut   = 2000,
                TxCS          = 0.20
            });
            ListeSalaries.Add(new Salarie("12XXX35", "Groot", "JeSAppelle", new DateTime(2000, 03, 19), 2500, 0.30));
            ListeSalaries.SaveText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\Persistance");
            ListeSalaries.LoadText(@"C:\Users\CDI\Documents\Visual Studio 2015\Projects\Persistance");
            foreach (Salarie item in ListeSalaries)
            {
                Console.WriteLine(item.ToString());
            }
            Console.ReadLine();
        }
Example #15
0
 public Form1()
 {
     InitializeComponent();
     try
     {
         Salaries _team = new Salaries();
         Salarie  sal1  = new Salarie()
         {
             Nom = "Bachelet", Prenom = "Damien", Matricule = "00XXX00", DateNaissance = new DateTime(1986, 10, 13), SalaireBrut = 1200, TauxCS = 0.1m
         };
         Salarie sal2 = new Salarie()
         {
             Nom = "Bachelet1", Prenom = "Bob", Matricule = "00AXX00", DateNaissance = new DateTime(1986, 10, 13), SalaireBrut = 1200, TauxCS = 0.1m
         };
         _team.Add(sal1);
         _team.Add(sal2);
     }
     catch (Exception e)
     {
         textBox1.Text = e.Message;
         textBox2.Text = e.StackTrace;
     }
 }
        //Ajout des salariés
        private void AjouterSal()
        {
            try
            {
                salarie = new Salarie();

                salarie.Matricule = tbID.Text;
                salarie.Prenom    = tbMDP.Text;
                salarie.Nom       = tbNom.Text;


                salarie.DateNaissance = dtDate.Value;
                decimal.TryParse(tbSalBrut.Text, out decimal salBrut);
                salarie.SalaireBrut = salBrut;

                salarie.CompteBloque = cbCompteBloque.Checked;
                salaries.Add(salarie);
            }
            catch (ApplicationException aE)
            {
                epSal.SetError(btnValider, aE.Message);
            }
        }
Example #17
0
        private void LoadDependencies()
        {
            DependentExpenseClaims = new ExpenseClaims();
            DependentInvoices = new InboundInvoices();
            DependentSalariesNet = new Salaries();
            DependentSalariesTax = new Salaries();
            DependentCashAdvancesPayout = new CashAdvances();
            DependentCashAdvancesPayback = new CashAdvances();

            BasicFinancialDependency[] dependencies = SwarmDb.GetDatabaseForReading().GetPayoutDependencies(this.Identity);

            foreach (BasicFinancialDependency dependency in dependencies)
            {
                switch (dependency.DependencyType)
                {
                    case FinancialDependencyType.ExpenseClaim:
                        DependentExpenseClaims.Add(ExpenseClaim.FromIdentity(dependency.ForeignId));
                        break;
                    case FinancialDependencyType.InboundInvoice:
                        DependentInvoices.Add(InboundInvoice.FromIdentity(dependency.ForeignId));
                        break;
                    case FinancialDependencyType.Salary:
                        Salary salary = Salary.FromIdentity(dependency.ForeignId);
                        if (salary.NetSalaryCents == this.AmountCents)  // HACK: Assumes that tax total is not identical
                        {
                            DependentSalariesNet.Add(salary);
                        }
                        else
                        {
                            DependentSalariesTax.Add(salary);
                        }
                        break;

                    case FinancialDependencyType.CashAdvance:
                        DependentCashAdvancesPayout.Add(CashAdvance.FromIdentity(dependency.ForeignId));
                        break;

                    case FinancialDependencyType.CashAdvancePayback:
                        DependentCashAdvancesPayback.Add(CashAdvance.FromIdentity(dependency.ForeignId));
                        break;

                    default:
                        throw new NotImplementedException("Unknown financial dependency type in Payout.LoadDependencies(): " + dependency.ToString());
                }
            }
        }
Example #18
0
        private void AjouterSalarie()
        {
            Salarie SalarieNouveau = new Salarie();

            SalarieNouveau.Matricule     = txtMatricule.Text.Trim();
            SalarieNouveau.Nom           = txtNom.Text.Trim();
            SalarieNouveau.Prenom        = txtPrenom.Text.Trim();
            SalarieNouveau.DateNaissance = Convert.ToDateTime(txtDateNaissance.Text);
            SalarieNouveau.SalaireBrut   = Convert.ToDecimal(txtSalaireBrut.Text);
            SalarieNouveau.TauxCS        = Convert.ToDecimal(txtTaux.Text);

            if (gbTypeSalarie.Visible == true && ckbCommercial.Checked)
            {
                ((Commercial)salarie).ChiffreAffaire = Convert.ToDecimal(txtChiffreAffaire.Text);
                ((Commercial)salarie).Commission     = Convert.ToDecimal(txtComission.Text);
            }
            salaries.Add(SalarieNouveau);
        }
Example #19
0
        public async void Query()
        {
            if (string.IsNullOrWhiteSpace(StudentID))
            {
                Services.NotityService.Notify("请输入学号");
                return;
            }
            if (string.IsNullOrWhiteSpace(Name))
            {
                Services.NotityService.Notify("请输入姓名");
                return;
            }
            IsLoading = true;
            try
            {
                var re = await Services.MyBjutService.QuerySalaries(_httpService, StudentID, Name);

                if (re == null || re.Count == 0)
                {
                    Services.NotityService.Notify("没有查询到相关的信息");
                    Salaries.Clear();

                    Total = $"没有相关的信息";
                    return;
                }
                Salaries.Clear();
                foreach (var item in re)
                {
                    Salaries.Add(item);
                }

                var salary = Salaries.Aggregate(0d, (sum, m) => { return(sum + m.Salary); });
                Total = $"参与零工 {Salaries.Count} 次,共收入 {salary } 元";
            }
            catch (Exception e)
            {
                Services.NotityService.Notify(e.Message);
                return;
            }
            finally
            {
                IsLoading = false;
            }
        }
Example #20
0
 private void NouveauSalarie()
 {
     salarie = new Salarie()
     {
         Matricule     = txtB_Matricule.Text,
         Nom           = txtB_Nom.Text,
         Prenom        = txtB_Prenom.Text,
         DateNaissance = Convert.ToDateTime(mTxtB_DateDeNaissance.Text),
         SalaireBrut   = Convert.ToDecimal(txtB_SalaireBrut.Text),
         TauxCS        = Convert.ToDecimal(mTxtB_TauxCS.Text)
     };
     if (Pn_commercial.Visible == true)
     {
         ((Commercial)salarie).Commission     = Convert.ToDecimal(txtB_TauxCom_Commercial.Text);
         ((Commercial)salarie).ChiffreAffaire = Convert.ToDecimal(txtB_CA__commercial.Text);
     }
     salaries.Add(salarie);
     ChargerSalaries();
 }
Example #21
0
        /// <summary>
        /// sauvegarde ou modifie le salarié
        /// </summary>
        private void SauvegardeSalarie()
        {
            if (IsVerifChamp())
            {
                Salaries listeSal = new Salaries();

                StringBuilder sB = new StringBuilder(Paramètres.Default.path);
                sB.Append($@"\{listeSal.GetType().FullName}.Xml");

                Salarie s = new Salarie(TextBoxNom.Text.Trim(), TextBoxPrenom.Text.Trim(), TextBoxMatricule.Text.Trim())
                {
                    DateNaissance = (DateTime)(DatePickerDateDeNaissance.SelectedDate),
                    SalaireBrut   = decimal.Parse(TextBoxSalaireBrut.Text.Trim()),
                    TauxCS        = decimal.Parse(TextBoxTauxCotisationSociale.Text.Trim()),
                };
                s = (bool)CheckBoxCommercial.IsChecked ? new Commercial(s) : s;

                if (s is Commercial c)
                {
                    c.ChiffreAffaire = decimal.Parse(TextBoxChiffreDAffaire.Text.Trim());
                    c.Commission     = decimal.Parse(TextBoxCommission.Text.Trim());
                    s = c;
                }

                if (File.Exists(sB.ToString()))
                {
                    listeSal.Load(new SauvegardeXML(), Paramètres.Default.path);
                }

                if (listeSal.Contains(s)) // modification
                {
                    listeSal.Remove(s);
                }
                listeSal.Add(s);

                listeSal.Save(new SauvegardeXML(), Paramètres.Default.path);
                Clear();
                InitListBoxSalarie(string.Empty);
            }
        }
Example #22
0
        public async Task <IActionResult> OnGetAsync(string returnUrl = null)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(LocalRedirect("/"));
            }

            MDMSUserServiceModel user = _userService.GetAllUsers()
                                        .Include(x => x.Salaries)
                                        .Include(x => x.ExternalRepairs)
                                        .Include(x => x.InternalRepairs)
                                        .SingleOrDefault(x => x.Id == _userManager.GetUserId(User)).To <MDMSUserServiceModel>();
            var user1 = await Task.Run((() => _userManager.GetUserAsync(User).Result.To <MDMSUserServiceModel>()));

            FirstName  = user.FirstName;
            LastName   = user.LastName;
            BaseSalary = user.BaseSalary;
            AdditionalOnHourPayment = user.AdditionalOnHourPayment;
            IsAuthorized            = user.IsAuthorized;

            foreach (var salary in user.Salaries)
            {
                Salaries.Add(salary.To <MonthlySalaryViewModel>());
            }
            foreach (var intRep in user.InternalRepairs)
            {
                InternalRepairs.Add(intRep.To <InternalRepairViewModel>());
            }
            foreach (var extRep in user.ExternalRepairs)
            {
                ExternalRepairs.Add(extRep.To <ExternalRepairViewModel>());
            }


            returnUrl = returnUrl ?? Url.Content("~/");

            ReturnUrl = returnUrl;

            return(Page());
        }
        private static void TestExceptionV2(Salarie sal)
        {
            bool ok = false;

            try
            {
                if (sal.Matricule == null | sal.Prenom == null | sal.Nom == null)
                {
                    throw new SalarieException();
                    ok = false;
                }
                else
                {
                    salaries.Add(sal);
                    ok = true;
                }
            }
            //catch (ArgumentNullException aNE)
            //{
            //    Debug.WriteLine($"{aNE.Message} \n {aNE.Source} \n {aNE.StackTrace}");
            //    Console.WriteLine("prout");
            //    ok = false;
            //}
            catch (SalarieException ex2)
            {
                Console.WriteLine(Resource1.Salarie_002);
                ok = false;
            }
            catch (Exception)
            {
                Console.WriteLine("Autre Exception");
                ok = false;
            }
            finally
            {
                Console.WriteLine(ok);
            }
        }
Example #24
0
        private void AjouterSalarie()

        {
            salarie = new Salarie();

            salarie.Matricule     = textBoxMatricule.Text;
            salarie.Nom           = textBoxNom.Text;
            salarie.Prenom        = textBoxPrenom.Text;
            salarie.DateNaissance = DateTime.Parse(textBoxDatedeNaissance.Text);
            salarie.SalaireBrut   = decimal.Parse(textBoxSalaireBrut.Text);
            salarie.TauxCS        = decimal.Parse(textBoxTauxCS.Text.Replace(".", ","));

            Commercial commercial = salarie as Commercial;

            if (commercial != null)
            {
                commercial.ChiffreAffaire = Decimal.Parse(textBoxChiffreAffaire.Text);
                commercial.Commission     = Decimal.Parse(textBoxCommission.Text);
            }

            salaries.Add(salarie);
            salaries.Save(MonApplication.DispositifSauvegarde, Settings.Default.AppData);
        }
Example #25
0
 public void Change_Salary(double sal)
 {
     Salaries.Add(sal);
     Date_Salary_Changed.Add(DateTime.Now);
 }
Example #26
0
        static void Main(string[] args)
        {
            Salaries salaries = new Salaries();

            salaries.Add(new Salarie()
            {
                Matricule     = "23ABC56",
                Nom           = "Bost",
                Prenom        = "Vincent",
                DateNaissance = new DateTime(1962, 01, 13),
                SalaireBrut   = 3500,
                TauxCS        = 0.25M
            });
            salaries.Add(new Salarie()
            {
                Matricule     = "23ABC50",
                Nom           = "Morillon",
                Prenom        = "Jean",
                DateNaissance = new DateTime(1959, 10, 13),
                SalaireBrut   = 3500,
                TauxCS        = 0.25M
            });
            salaries.Add(new Commercial()
            {
                Matricule      = "79ABC50",
                Nom            = "Grotte",
                Prenom         = "Pascal",
                DateNaissance  = new DateTime(1963, 6, 05),
                SalaireBrut    = 3500,
                TauxCS         = 0.25M,
                ChiffreAffaire = 1500,
                Commission     = 10
            });
            ISauvegarde sauvegarde = new SauvegardeXML();

            salaries.Save(sauvegarde, Settings.Default.AppData);

            Roles roles = new Roles();

            roles.Add(new Role()
            {
                Identifiant = "Utilisateur", Description = "Utilisateur Application"
            });
            roles.Add(new Role()
            {
                Identifiant = "Administrateur", Description = "Administrateur Application"
            });
            roles.Save(sauvegarde, Settings.Default.AppData);
            Utilisateur utilisateur = new Utilisateur()
            {
                Identifiant = "C6GB011", MotDePasse = "Vince1962", Nom = "Bost", CompteBloque = false, Role = roles.ElementAt(1)
            };

            Utilisateurs utilisateurs = new Utilisateurs();

            utilisateurs.Add(utilisateur);
            utilisateur = new Utilisateur()
            {
                Identifiant = "A7DC011", MotDePasse = "Jean1959", Nom = "Morillon", CompteBloque = false, Role = roles.ElementAt(0)
            };
            utilisateurs.Add(utilisateur);
            utilisateurs.Save(sauvegarde, Settings.Default.AppData);
            Console.WriteLine(roles.RechercherRole("Administrateur").ToString());
            Console.ReadLine();
        }
Example #27
0
        static void Main(string[] args)
        {
            Salaries salaries = new Salaries();

            salaries.Add(new Salarie()
            {
                Matricule     = "23ABC56",
                Nom           = "Bost",
                Prenom        = "Vincent",
                DateNaissance = new DateTime(1962, 01, 13),
                SalaireBrut   = 3500,
                TauxCS        = 0.25M
            });
            salaries.Add(new Salarie()
            {
                Matricule     = "23ABC50",
                Nom           = "Morillon",
                Prenom        = "Jean",
                DateNaissance = new DateTime(1959, 10, 13),
                SalaireBrut   = 3500,
                TauxCS        = 0.25M
            });
            //salaries.Add(new Salarie()
            //{
            //    Matricule = "AAAA22",
            //    Nom = "Iguetoulene",
            //    Prenom = "Fazia",
            //    DateNaissance = new DateTime(1970, 2, 17),
            //    SalaireBrut = 700,
            //    TauxCS = 0.25M

            //});
            ISauvegarde sauvegarde = new SauvegardeXML();

            salaries.Save(sauvegarde, Settings.Default.AppData);

            Roles roles = new Roles();

            roles.Add(new Role()
            {
                Identifiant = "Utilisateur", Description = "Utilisateur Application"
            });
            roles.Add(new Role()
            {
                Identifiant = "Administrateur", Description = "Administrateur Application"
            });
            Utilisateur utilisateur = new Utilisateur()
            {
                Identifiant = "C6GB011", MotDePasse = "Vince1962", Nom = "Bost", CompteBloque = false, Role = roles.ElementAt(1)
            };

            Utilisateurs utilisateurs = new Utilisateurs();

            utilisateurs.Add(utilisateur);
            utilisateur = new Utilisateur()
            {
                Identifiant = "AAAA22", MotDePasse = "123456", Nom = "Iguetoulene", CompteBloque = false, Role = roles.ElementAt(0)
            };
            utilisateurs.Add(utilisateur);
            utilisateurs.Save(sauvegarde, Settings.Default.AppData);
            Console.WriteLine(roles.RechercherRole("Administrateur").ToString());
            roles.Save(sauvegarde, Settings.Default.AppData);
            Console.ReadLine();
        }
Example #28
0
        public void AjouterSalaries()
        {
            if (!(checkBoxCommercial.Checked))
            {
                Salarie salarie = new Salarie();
                if (Salarie.IsNomPrenomValide(textBoxNom.Text))
                {
                    salarie.Nom = textBoxNom.Text;
                    erreurCb.SetError(textBoxNom, "");
                }
                else
                {
                    erreurCb.SetError(textBoxNom, "Nom non valide");
                }
                if (Salarie.IsNomPrenomValide(textBoxPrenom.Text))
                {
                    salarie.Prenom = textBoxPrenom.Text;
                    erreurCb.SetError(textBoxPrenom, "");
                }
                else
                {
                    erreurCb.SetError(textBoxPrenom, "Prenom non valide");
                }


                bool ConvertionDate = DateTime.TryParse(textBoxDateDeNaissance.Text, out DateTime DateNaissanceConvertie);
                if (ConvertionDate == true && Salarie.IsDateNaissanceValide(DateNaissanceConvertie))
                {
                    salarie.DateNaissance = DateNaissanceConvertie;
                    erreurCb.SetError(textBoxDateDeNaissance, "");
                }
                else
                {
                    erreurCb.SetError(textBoxDateDeNaissance, "Date de naissance non valide");
                }
                if (Salarie.IsMatriculeValide(textBoxMatricule.Text))
                {
                    salarie.Matricule = textBoxMatricule.Text;
                    erreurCb.SetError(textBoxNom, "");
                }

                bool ConvertionSalaire = decimal.TryParse(textBoxSalaireBrut.Text, out decimal SalaireBrutConverti);
                if (ConvertionSalaire == true)
                {
                    salarie.SalaireBrut = SalaireBrutConverti;
                    erreurCb.SetError(textBoxSalaireBrut, "");
                }
                else
                {
                    erreurCb.SetError(textBoxSalaireBrut, "Format Salaire non valide");
                }
                bool ConvertionTauxCS = decimal.TryParse(textBoxTauxCS.Text, out decimal TauxCSConverti);
                if (ConvertionTauxCS == true && Salarie.IsTauxCSValid(TauxCSConverti))
                {
                    salarie.TauxCS = TauxCSConverti;
                    erreurCb.SetError(textBoxTauxCS, "");
                }
                else
                {
                    erreurCb.SetError(textBoxTauxCS, "TauxCS non valide");
                }

                if (!VerifValiditeSalarie())
                {
                    MessageBox.Show("Certains champs ne sont pas valides", "Erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("Salarié crée avec succée", "Ajout", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                }

                salaries.Add(salarie);
                cbChoixSalarie.Items.Add(salarie.Matricule);
                salaries.Save(MonApplication.DispositifSauvegarde, Properties.Settings.Default.AppData);
            }
            else if (checkBoxCommercial.Checked)
            {
                Commercial commercial = new Commercial();


                textBoxChiffreAffaire.ReadOnly = false;
                textBoxCommission.ReadOnly     = false;
                bool converstionCA = decimal.TryParse(textBoxChiffreAffaire.Text, out decimal ChiffreAfConverti);
                if (!converstionCA)
                {
                    MessageBox.Show("Entrer un decimal", "Message d'erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                }
                commercial.ChiffreAffaire = ChiffreAfConverti;
                bool convertionCom = decimal.TryParse(textBoxCommission.Text, out decimal ComConvertie);
                if (!convertionCom)
                {
                    MessageBox.Show("Entrer un decimal entre 0 et 0.6", "Message d'erreur", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                }
                commercial.Commission = ComConvertie;

                if (Salarie.IsNomPrenomValide(textBoxNom.Text))
                {
                    commercial.Nom = textBoxNom.Text;
                    erreurCb.SetError(textBoxNom, "");
                }
                else
                {
                    erreurCb.SetError(textBoxNom, "Nom non valide");
                }
                if (Salarie.IsNomPrenomValide(textBoxPrenom.Text))
                {
                    commercial.Prenom = textBoxPrenom.Text;
                    erreurCb.SetError(textBoxPrenom, "");
                }
                else
                {
                    erreurCb.SetError(textBoxPrenom, "Prenom non valide");
                }


                bool ConvertionDateCom = DateTime.TryParse(textBoxDateDeNaissance.Text, out DateTime DateNaissanceConvertieCom);
                if (ConvertionDateCom == true && Salarie.IsDateNaissanceValide(DateNaissanceConvertieCom))
                {
                    commercial.DateNaissance = DateNaissanceConvertieCom;
                    erreurCb.SetError(textBoxDateDeNaissance, "");
                }
                else
                {
                    erreurCb.SetError(textBoxDateDeNaissance, "Date de naissance non valide");
                }
                if (Salarie.IsMatriculeValide(textBoxMatricule.Text))
                {
                    commercial.Matricule = textBoxMatricule.Text;
                    erreurCb.SetError(textBoxNom, "");
                }

                bool ConvertionSalaireCom = decimal.TryParse(textBoxSalaireBrut.Text, out decimal SalaireBrutConvertiCom);
                if (ConvertionSalaireCom == true)
                {
                    commercial.SalaireBrut = SalaireBrutConvertiCom;
                    erreurCb.SetError(textBoxSalaireBrut, "");
                }
                else
                {
                    erreurCb.SetError(textBoxSalaireBrut, "Format Salaire non valide");
                }
                bool ConvertionTauxCSCom = decimal.TryParse(textBoxTauxCS.Text, out decimal TauxCSConvertiCom);
                if (ConvertionTauxCSCom == true && Salarie.IsTauxCSValid(TauxCSConvertiCom))
                {
                    commercial.TauxCS = TauxCSConvertiCom;
                    erreurCb.SetError(textBoxTauxCS, "");
                }
                else
                {
                    erreurCb.SetError(textBoxTauxCS, "TauxCS non valide");
                }
                salaries.Add(commercial);
                cbChoixSalarie.Items.Add(commercial.Matricule);
                salaries.Save(MonApplication.DispositifSauvegarde, Properties.Settings.Default.AppData);
                checkBoxCommercial.Checked = false;
                textBoxChiffreAffaire.Clear();
                textBoxCommission.Clear();
            }

            textBoxDateDeNaissance.Clear();
            textBoxTauxCS.Clear();
            textBoxMatricule.Clear();
            textBoxNom.Clear();
            textBoxPrenom.Clear();
            textBoxSalaireBrut.Clear();
        }