Hi, I have a Console app, in which I input Users and Customers (that is stored in a array) and is then allowd to create a note from a user to a customer. At the end I want to show all the notes in the notes array that has been created but using the user and the customers fullname as in the users and customers array. Can anyone please help?
Hi, sorry I didnt meen to give all the code just thought it would be more clearer that way, I am having trouble with the last foreach satement to show all the notes. In the notes input I am only asking for user and customer ID's, I then what to check in the User and Customers arrays if that user and customer do extist and then display their fullname as it is in the user and customer arrays and not just their ID's. Thanks in advance. Here is my code:
class Program
{
static void UserInput(User U)
{
Console.WriteLine("Add your User");
Console.WriteLine("");
Console.WriteLine("Please Enter a User:");
Console.WriteLine("User ID:");
U.ID = int.Parse(Console.ReadLine());
Console.WriteLine("Titel:");
U.Titel = (Console.ReadLine());
Console.WriteLine("Name:");
U.Name = (Console.ReadLine());
Console.WriteLine("Surname:");
U.Surname = (Console.ReadLine());
Console.WriteLine("Telephone Number:");
U.Telephone = int.Parse(Console.ReadLine());
Console.WriteLine("");
}
static void CustomerInput(Customer C)
{
Console.WriteLine("Add your Customer");
Console.WriteLine("");
Console.WriteLine("Please Enter a Customer:");
Console.WriteLine("Customer ID:");
C.ID = int.Parse(Console.ReadLine());
Console.WriteLine("Titel:");
C.Titel = (Console.ReadLine());
Console.WriteLine("Name:");
C.Name = (Console.ReadLine());
Console.WriteLine("Surname:");
C.Surname = (Console.ReadLine());
Console.WriteLine("Address:");
C.Address = (Console.ReadLine());
Console.WriteLine("");
}
static void NotesInput(Notes N)
{
Console.WriteLine("Create your Note");
Console.WriteLine("");
Console.WriteLine("Please enter User ID:");
N.FromUserID = int.Parse(Console.ReadLine());
Console.WriteLine("Please enter Customer ID:");
N.ToCustomerID = int.Parse(Console.ReadLine());
Console.WriteLine("Note Information:");
N.Info = (Console.ReadLine());
N.DateTime = DateTime.Now;
Console.WriteLine("");
}
static void Main(string[] args)
{
//User Array
int UserAmount;
Console.WriteLine("How many Users do you want to input?");
UserAmount = int.Parse(Console.ReadLine());
User[] users = new User[UserAmount];
for (int user = 0; user < users.Length; user++)
{
users[user] = new User();
UserInput(users[user]);
}
//Customer Array
int CustomerAmount;
Console.WriteLine("How many Customers do you want to input?");
CustomerAmount = int.Parse(Console.ReadLine());
Customer[] customer = new Customer[CustomerAmount];
for (int customers = 0; customers < customer.Length; customers++)
{
customer[customers] = new Customer();
CustomerInput(customer[customers]);
}
Console.WriteLine("All Users");
Console.WriteLine("");
//Show All Users
foreach (User user in users)
{
Console.WriteLine("User ID:" + " " + user.ID);
Console.WriteLine("User Name:" + " " + user.FullName);
Console.WriteLine("User Telephone number:" + " " + user.Telephone);
Console.WriteLine("");
}
Console.WriteLine("All Customers");
Console.WriteLine("");
//Show All Cutomers
foreach (Customer customers in customer)
{
Console.WriteLine("Customer ID:" + " " + customers.ID);
Console.WriteLine("Customer Name:" + " " + customers.FullName);
Console.WriteLine("Customer Address:" + " " + customers.Address);
Console.WriteLine("");
}
//Notes Array
int NoteAmount;
Console.WriteLine("How many Notes do you want to input?");
NoteAmount = int.Parse(Console.ReadLine());
Notes[] note = new Notes[NoteAmount];
for (int Note = 0; Note < note.Length; Note++)
{
note[Note] = new Notes();
NotesInput(note[Note]);
}
//Show All Notes
foreach (Notes Note in note)
{
User User;
Customer Customer;
string UserFullname;
if (users.Contains(Note.FromUserID))
{
UserFullname = User.FullName;
}
string CustomerFullName;
if (customer.Contains(Note.ToCustomerID))
{
CustomerFullName = Customer.FullName;
}
Console.WriteLine("From User:" + " " + + Note.FromUserID);
Console.WriteLine("To Customer:" + " " + Note.ToCustomerID);
Console.WriteLine("Info:" + " " + Note.Info);
Console.WriteLine("Date Time:" + " " + Note.DateTime);
Console.WriteLine("");
}
}
}