Exemple #1
0
    public string ValidateEngineerList(string filepath)
    {
        string output = "";

        try
        {
            if (File.Exists(filepath))
            {
                DataFile fileData = new DataFile();
                fileContent = df.readFile(filepath);
                int count;
                for (int i = 1; i < fileContent.Count; i++)
                {
                    count = i + 1;
                    string   fileLine = fileContent[i].ToString();
                    string[] fLine    = fileLine.Split(',');
                    if (fLine.Length == 2)
                    {
                        string EngineerName    = fLine[0].ToString();
                        string EngineerContact = fLine[1].ToString();
                        if (EngineerContact.Length.Equals(9))
                        {
                            EngineerContact = "0" + EngineerContact;
                        }
                        data_table = data_file.EngineerNumberExists(EngineerContact);
                        if (data_table.Rows.Count < 1)
                        {
                            if (EngineerName.Equals(""))
                            {
                                output = "The Engineer Name at Line " + count + " is Incorrect";
                                return(output);
                            }
                            else if (EngineerContact.Equals(""))
                            {
                                output = "The Engineer Contact can not be empty at Line " + count;
                                return(output);
                            }
                        }
                        else
                        {
                            output = "The Engineer Contact at Line " + count + " Already Exists";
                            return(output);
                        }
                    }
                    else
                    {
                        output = "Invalid Number of Columns on line count All the file line Should have 2 Columns";
                        return(output);
                    }
                }

                output = "NONE";
                return(output);
            }
            else
            {
                output = "The File Name Does Not Exist";
                return(output);
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }