Beispiel #1
0
 private void buttonAdaugaAngajat_Click(object sender, EventArgs e)
 {
     try
     {
         if (checkNullOrEmpty())
         {
             return;
         }
         Persoana prs = new Persoana(textBoxCNP.Text, textBoxNume.Text, textBoxPrenume.Text, dateTimePickerDataAng.Value, int.Parse(textBoxExperienta.Text), int.Parse(textBoxSalariu.Text), textBoxDepartamemt.Text, textBoxStudii.Text);
         this.meniu.adaugaAngajat(prs);
         MessageBox.Show("Angajatul a fost adaugat");
         this.Close();
         meniu.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Ceva nu a functionat corect!");
     }
     finally
     {
         textBoxCNP.Clear();
         textBoxNume.Clear();
         textBoxPrenume.Clear();
         textBoxExperienta.Clear();
         textBoxSalariu.Clear();
         textBoxDepartamemt.Clear();
         textBoxStudii.Clear();
     }
 }
Beispiel #2
0
 public static string AsCsv(Persoana persoana)
 {
     return(string.Format(
                "{0},{1},{2},{3},{4},{5},{6},{7}",
                persoana.Cnp,
                persoana.Nume,
                persoana.prenume,
                persoana.dataAngajare.ToString(),
                persoana.experienta.ToString(),
                persoana.salariu.ToString(),
                persoana.departament,
                persoana.studii));
 }
Beispiel #3
0
        private void salvareDateInFisierToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            if (saveFileDialog.ShowDialog() == DialogResult.OK)
            {
                string[] arrayPersoane = new string[this.meniu.ListaAngajati.Count];
                for (int i = 0; i < this.meniu.ListaAngajati.Count; i++)
                {
                    arrayPersoane[i] = Persoana.AsCsv(this.meniu.ListaAngajati.ElementAt(i));
                }
                File.WriteAllText(saveFileDialog.FileName,
                                  string.Join(Environment.NewLine, arrayPersoane));
            }
        }
Beispiel #4
0
        public static Persoana FromCsv(string csvLine)
        {
            string[] values   = csvLine.Split(',');
            Persoana persoana = new Persoana();

            persoana.Cnp          = values[0];
            persoana.nume         = values[1];
            persoana.prenume      = values[2];
            persoana.dataAngajare = DateTime.Parse(values[3]);
            persoana.experienta   = int.Parse(values[4]);
            persoana.salariu      = int.Parse(values[5]);
            persoana.departament  = values[6];
            persoana.studii       = values[7];
            return(persoana);
        }
Beispiel #5
0
        public int CompareTo(object obj)
        {
            Persoana p = (Persoana)obj;

            if (this.salariu < p.salariu)
            {
                return(-1);
            }
            else if (this.salariu > p.salariu)
            {
                return(1);
            }
            else
            {
                return(string.Compare(this.nume, p.nume));
            }
        }
Beispiel #6
0
        public Meniu()
        {
            Persoana test   = new Persoana("2990829480070", "Dragomirescu", "Oana", DateTime.Parse("1/10/2020 1:04:22"), 3, 20000, "IT", "Superioare");
            Persoana test1  = new Persoana("1770423460079", "Popescu", "Viorel", DateTime.Parse("1/10/2020 1:04:22"), 3, 50000, "IT", "Superioare");
            Persoana test2  = new Persoana("5590829480070", "Mihai", "Ion", DateTime.Parse("1/10/2020 1:04:22"), 3, 2000, "Marketing", "Superioare");
            Persoana test3  = new Persoana("6990829480070", "Vasile", "Mihaela", DateTime.Parse("1/10/2020 1:04:22"), 3, 8400, "HR", "Superioare");
            Persoana test4  = new Persoana("1990829480070", "Ion", "Andrei", DateTime.Parse("1/10/2020 1:04:22"), 3, 2000, "IT", "Superioare");
            Persoana test5  = new Persoana("2990829480070", "Ionescu", "Gerorgiana", DateTime.Parse("1/10/2020 1:04:22"), 3, 45000, "HR", "Superioare");
            Persoana test6  = new Persoana("2990829480070", "Florea", "Laura", DateTime.Parse("1/10/2020 1:04:22"), 3, 10000, "IT", "Superioare");
            Persoana test7  = new Persoana("2990829480070", "Gheorge", "Lavinia", DateTime.Parse("1/10/2020 1:04:22"), 3, 1000, "HR", "Superioare");
            Persoana test8  = new Persoana("2990829480070", "Dumitru", "Alexandra", DateTime.Parse("1/10/2020 1:04:22"), 3, 5000, "HR", "Liceale");
            Curs     testC  = new Curs(110, "Java", "IT", 4);
            Curs     testC2 = new Curs(111, "Time Management", "HR", 2);
            Curs     testC3 = new Curs(112, "C#", "IT", 12);
            Curs     testC4 = new Curs(113, "Dezvoltare persoanala", "HR", 4);
            Job      testJ  = new Job("Web Developer", 5, 20000, 10000);
            Job      testJ2 = new Job("Java Developer", 5, 200000, 100000);
            Job      testJ3 = new Job("Programator Ajutor", 1, 1000, 2500);
            Job      testJ4 = new Job("HR Manager", 4, 7000, 9000);

            listaAngajati = new List <Persoana>();
            listaAngajati.Add(test);
            listaAngajati.Add(test1);
            listaAngajati.Add(test2);
            listaAngajati.Add(test3);
            listaAngajati.Add(test4);
            listaAngajati.Add(test5);
            listaAngajati.Add(test6);
            listaAngajati.Add(test7);
            listaAngajati.Add(test8);
            listaJoburi = new List <Job>();
            listaJoburi.Add(testJ);
            listaJoburi.Add(testJ2);
            listaJoburi.Add(testJ3);
            listaJoburi.Add(testJ4);
            listaCursuri = new List <Curs>();
            listaCursuri.Add(testC);
            listaCursuri.Add(testC2);
            listaCursuri.Add(testC3);
            listaCursuri.Add(testC4);
            InitializeComponent();
        }
Beispiel #7
0
        private void citireDateDinFisierToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            OpenFileDialog folderBrowserDialog = new OpenFileDialog();

            if (folderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                List <Persoana> values = File.ReadAllLines(folderBrowserDialog.FileName).Skip(0).Select(v => Persoana.FromCsv(v)).ToList();
                this.meniu.ListaAngajati = values;
                reload();
            }
        }
Beispiel #8
0
        public void adaugaAngajat(object persoana)
        {
            Persoana prs = (Persoana)persoana;

            listaAngajati.Add(prs);
        }