예제 #1
0
        private void btnAddRecord_Click(object sender, EventArgs e)
        {
            AddNewRec newform = new AddNewRec();

            if (newform.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    IpayableStaff newEmployee = newform.GetEmployee();
                    employeeList.Add(newEmployee);
                    lstEmployees.Items.Clear();

                    foreach (IpayableStaff empo in employeeList)
                    {
                        lstEmployees.Items.Add(empo.ToString());
                    }
                    SaveData();
                }
                catch (exception_blank_field c)
                {
                    MessageBox.Show(c.Message, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (exception_select_dept t)
                {
                    MessageBox.Show(t.Message, "Selection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                catch (FormatException d)
                {
                    MessageBox.Show(d.Message, "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
예제 #2
0
        private void lstEmployees_SelectedIndexChanged(object sender, EventArgs e)
        {
            int IndexName = lstEmployees.SelectedIndex;

            if (IndexName > -1)
            {
                IpayableStaff employeeDetails = employeeList[IndexName];
                lblStatement.Text = employeeDetails.ShowDetails();
            }
        }
예제 #3
0
        private void display(List <IpayableStaff> displ)
        {
            lstEmployees.Items.Clear();

            for (int i = 0; i < displ.Count; i++)
            {
                IpayableStaff dis = (IpayableStaff)displ[i];

                lstEmployees.Items.Add(dis);
            }
        }
예제 #4
0
        private void LoadData()
        {
            lstEmployees.Items.Clear();

            FileStream      inFile;
            BinaryFormatter bformatter = new BinaryFormatter();

            if (File.Exists(filename))
            {
                inFile = new FileStream(filename, FileMode.Open, FileAccess.Read);

                while (inFile.Position < inFile.Length)
                {
                    IpayableStaff load = (IpayableStaff)bformatter.Deserialize(inFile);
                    employeeList.Add(load);
                    lstEmployees.Items.Add(load);
                }
                inFile.Close();
            }
        }