public List <String[]> changeRecord(int index, String column, String input)
        {
            if (v.validateIndex(index, records.Count))
            {
                String[] entryToChange = records[index];
                switch (column)
                {
                case "ID":
                    if (v.validateID(input))
                    {
                        if (v.IDisFree(int.Parse(input)))
                        {
                            entryToChange = updateID(entryToChange, input);
                        }
                    }
                    displaySuccess(column, index, input);
                    return(records);

                case "name":
                    entryToChange = updateName(entryToChange, input);
                    displaySuccess(column, index, input);
                    return(records);

                case "birthdate":
                    entryToChange = updateMaritalState(entryToChange, input);
                    displaySuccess(column, index, input);
                    return(records);

                case "maritalState":
                    if (v.maritialstateIsValid(input))
                    {
                        entryToChange = updateMaritalState(entryToChange, input);
                        displaySuccess(column, index, input);
                    }
                    return(records);

                case "salary":
                    if (v.validateSalary(input))
                    {
                        entryToChange = updateSalary(entryToChange, input);
                        displaySuccess(column, index, input);
                    }
                    return(records);

                case "address":
                    entryToChange = updateAddress(entryToChange, input);
                    records.RemoveAt(index);
                    records.Insert(index, entryToChange);
                    displaySuccess(column, index, input);
                    return(records);

                default:
                    MessageBox.Show("Invalid column flag");
                    return(records);
                }
            }
            return(records);
        }
Exemple #2
0
 public List <String[]> resgisterEmployee(int id, string name, string dateofbirth, string maritialstate, float salary, string address)
 {
     //run through and validate the input info before making the employee
     if (v.IDisFree(id))
     {
         if (nameIsFree(name))
         {
             if (v.maritialstateIsValid(maritialstate))
             {
                 MessageBox.Show("Employee Registered Successfully");
                 Employee e     = new Employee(id, name, dateofbirth, maritialstate, salary, address);
                 String   eInfo = e.ToString();
                 records.Add(eInfo.Split(','));
                 return(records);
             }
         }
     }
     return(records);
 }