Example #1
0
 //*******************************************************
 // Load of the form plus database loading
 //*******************************************************
 private void LoginForm_Load(object sender, EventArgs e)
 {
     Validator.Validation.frm = this;
     attempt = 0;
     GeneralDataManipulation.listOfEmployee = new List <Employee>();
     GeneralDataManipulation.listOfEmployee = EmployeeDA.ReadUsers();
 }
Example #2
0
 public HRManagement()
 {
     InitializeComponent();
     comboBoxModeSelection.SelectedItem = "Users";
     myEmployeeList = EmployeeDA.GetEmployees();
     myUserList     = EmployeeDA.GetUsers();
     RefreshList();
 }
Example #3
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     if (comboBoxModeSelection.Text == "Employees")
     {
         EmployeeDA.DeleteEmployee(ConvertTextEmployee());
     }
     if (comboBoxModeSelection.Text == "Users")
     {
         EmployeeDA.DeleteUser(ConvertTextUser());
     }
     RefreshList();
 }
Example #4
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (comboBoxModeSelection.Text == "Employees")
     {
         EmployeeDA.SetEmployee(ConvertTextEmployee());
     }
     if (comboBoxModeSelection.Text == "Users")
     {
         User aUser = ConvertTextUser();
         aUser.EmpId = EmployeeDA.GetNextUID();
         EmployeeDA.SetUser(aUser);
     }
     RefreshList();
 }
Example #5
0
        //Methods
        public void RefreshList()
        {
            listViewEmployee.Items.Clear();
            listViewUser.Items.Clear();
            myEmployeeList = EmployeeDA.GetEmployees();
            myUserList     = EmployeeDA.GetUsers();
            foreach (User element in myUserList)
            {
                listViewUser.Items.Add(EmployeeDA.ConvertToListViewItemUser(element));
            }

            foreach (Employee element in myEmployeeList)
            {
                listViewEmployee.Items.Add(EmployeeDA.ConvertToListViewItemEmployee(element));
            }
        }
Example #6
0
        public static void DeleteEmployee(Employee employee)
        {
            List <Employee> myEmployeeList = EmployeeDA.GetEmployees();

            using (StreamWriter sw = new StreamWriter(filePathTemp))
            {
                foreach (Employee element in myEmployeeList)
                {
                    if (element.EmpId != employee.EmpId)
                    {
                        sw.WriteLine(element.GetEmployeeInfo());
                    }
                }
            }
            File.Replace(filePathTemp, filePathEmp, filePathBackup);
        }
Example #7
0
        public static void DeleteUser(User user)
        {
            List <User> myUserList = EmployeeDA.GetUsers();

            using (StreamWriter sw = new StreamWriter(filePathTemp))
            {
                foreach (User element in myUserList)
                {
                    if (element.EmpId != user.EmpId)
                    {
                        sw.WriteLine(element.GetUserInfo());
                    }
                }
            }

            File.Replace(filePathTemp, filePathUser, filePathBackup);
        }
Example #8
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            bool access = false;

            myUserList = EmployeeDA.GetUsers();
            foreach (User element in myUserList)
            {
                if ((textBoxUserName.Text == element.Username) && (textBoxPassword.Text == element.Password))
                {
                    access   = true;
                    LoggedIn = element;
                    FormMain formMain = new FormMain();
                    formMain.ShowDialog();
                    break;
                }
            }
            if (access == false)
            {
                MessageBox.Show("Error! Invalid User Name and/or Password entered.\nPlease try again.");
            }
        }