public void AddEmployee() { Employee nemployee = new Employee(); nemployee.Employeeid = Convert.ToInt32(flatTextBoxempid.Text); nemployee.Username = flatTextBoxempname.Text; nemployee.Lastname = flatTextBoxemplast.Text; nemployee.Jobtitle = flatComboBoxempjobtitle.Text; nemployee.Address = flatTextBoxempaddress.Text; nemployee.Phone = Convert.ToInt64(flatTextBoxempphone.Text); nemployee.Email = flatTextBoxempemail.Text; nemployee.Status = (EnumStatus)flatComboBoxempstatus.SelectedIndex; nemployee.Pictureprofile = pictureBoxemp.Image; listofemployee.Add(nemployee); EmployeeDA.Binarywriter(listofemployee); MessageBox.Show("a new user has been added"); }
private void flatButtonedit_Click(object sender, EventArgs e) { if (MessageBox.Show("Are you sure you want to edit the employee ", "" , MessageBoxButtons.YesNo) == DialogResult.Yes) { foreach (Employee element in listofemployee) { listofemployee[index].Employeeid = Convert.ToInt32(flatTextBoxempid.Text); listofemployee[index].Username = flatTextBoxempname.Text; listofemployee[index].Lastname = flatTextBoxemplast.Text; listofemployee[index].Jobtitle = flatComboBoxempjobtitle.Text; listofemployee[index].Phone = Convert.ToInt64(flatTextBoxempphone.Text); listofemployee[index].Email = flatTextBoxempemail.Text; listofemployee[index].Pictureprofile = pictureBoxemp.Image; listofemployee[index].Status = (EnumStatus)flatComboBoxempstatus.SelectedIndex; EmployeeDA.Binarywriter(listofemployee); } Cleanfields(); } }