Exemplo n.º 1
0
        private void NewEmployeeButton_Click(object sender, EventArgs e)
        {
            char[]   separator  = new char[] { ',' };
            string[] attributes = NewEmployeeTextBox1.Text.Split(separator);
            Employee emp;


            if (String.IsNullOrEmpty(NewEmployeeTextBox1.Text))
            {
                NewEmployeeFlagLabel.Text = "Tekstikenttä on tyhjä!";
                NewEmployeeFlagLabel.Show();
            }
            else if (!verifyEmpolyeeName(attributes[0]))
            {
                NewEmployeeFlagLabel.Text = "Nimi on jo listassa!";
                NewEmployeeFlagLabel.Show();
            }
            else
            {
                emp = new Employee(Convert.ToString(attributes[0]),
                                   Convert.ToInt16(attributes[1]),
                                   Convert.ToDouble(attributes[2]));

                empolyees.Add(emp);
                employeesLength.Text     = empolyees.Count.ToString();
                NewEmployeeTextBox1.Text = "";
                NewEmployeeFlagLabel.Hide();
                EmployeesComboBox.DataSource    = null;
                EmployeesComboBox.DataSource    = empolyees;
                EmployeesComboBox.DisplayMember = "name";
                emp = null;
            }
        }
Exemplo n.º 2
0
        private void NewEmployeeButton_Click(object sender, EventArgs e)
        {
            string newEmployee = NewEmployeeTextBox1.Text;

            if (String.IsNullOrEmpty(newEmployee))
            {
                NewEmployeeFlagLabel.Text = "Tekstikenttä on tyhjä!";
                NewEmployeeFlagLabel.Show();
            }
            else if (empolyees.Contains(newEmployee))
            {
                NewEmployeeFlagLabel.Text = "Nimi on jo listassa!";
                NewEmployeeFlagLabel.Show();
            }
            else
            {
                empolyees.Add(newEmployee);
                EmployeesListBox.DataSource = null;
                EmployeesListBox.DataSource = empolyees;
            }
        }