I am trying to receive user input from a textbox and send it into an array that is in my class that is named Employee.
I am not sure if the code below is correct, but it seems like it is, because I have no compiling errors.
However, when I press the button the employee name and number are still in the textbox. What I would like for this application to do is the following:
- receive an employee's name and ID number;
- send them to my array that is in my " Employee" class, and as a name is sent to my array;
- I want the text box to clear in order for a new name to be entered.
Is this possible? Or am I asking for too much?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Company_Employees
{
class Employee
{
private const int NAME = 100;
private static string[] employee = new string[NAME];
private const int NUMBER = 100;
private static int[] iD = new int[NUMBER];
public Employee() n// This is a null Constructor
{
employee[NAME] = null;
iD[NUMBER] = 0;
}
public Employee(string name, int number) // This is my overloaded constructor that receive these arguments from my main form.
{
for (int index = 0; index < employee.Length; index++)
{
name = employee[index];
}
for (int index = 0; index < iD.Length; index++)
{
number = iD[index];
}
}
public static int getemployeeNumber ()
{
return iD[NUMBER];
}
public static string getemployeeName()
{
return employee[NAME];
}
}
}
This is my main Form that's has the button_click event handler.
I want the user to input the employee name and ID number. Every time the user clicks the button to send the information to my "EmployeeClass", the textbox is cleared in order for new input to be entered.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace Company_Employees
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string employeeNames;
int eNumbers;
employeeNames = eName.Text;
eNumbers = int.Parse( eNum.Text );
Employee chart = new Employee(employeeNames, eNumbers);
for ( int index = 0; index < 100; index++)
{
index = eNumbers;
}
}
}
}
eName.Clear();andeNum.Clear()after the arrays filling process.