//method to delete data fromthe hms database using staff id private void Deletetoolstrip_Click(object sender, EventArgs e) { if (staffidtext.Text == "") { MessageBox.Show("Please Insert Staff ID"); } else { int staffid = Convert.ToInt32(staffidtext.Text); var staffbiz = new StaffRegistrationsBiz(); if (MessageBox.Show("Are you Sure you want to delete", "Confirm Deltion", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { var result = staffbiz.Delete(staffid); if (result.Status) { MessageBox.Show("Successfuly Deleted"); clear(); } else { MessageBox.Show("Not Deleted Successfuly." + result.Message); } } } }
// method save data to the database private void toolStripButton23_Click(object sender, EventArgs e) { var staffdal = new Staffregistration() { Name = staffnametext.Text, MiddleName = staffmiddlenamettext.Text, LastName = stafflastnametext.Text, Sex = seccomboboxtext.Text, Possition = Positiontext.Text, Department = Departmenttext.Text, Branch = Branchtext.Text, Remarks = Remarkstext.Text }; var staffbiz = new StaffRegistrationsBiz(); var result = staffbiz.Add(staffdal); if (result.Status) { XtraMessageBox.Show("Saved Succsessfully"); clear(); } else { XtraMessageBox.Show("Note Saved Successfully." + result.Message); } }
//method that edit data from the database private void Edittoolstrip_Click(object sender, EventArgs e) { if (staffidtext.Text == "") { MessageBox.Show("Please Insert Staff ID "); } else { var staffdata = new Staffregistration() { staffID = Convert.ToInt32(staffidtext.Text), Name = staffnametext.Text, MiddleName = staffmiddlenamettext.Text, LastName = stafflastnametext.Text, Sex = seccomboboxtext.Text, Possition = Positiontext.Text, Department = Departmenttext.Text, Branch = Branchtext.Text, Remarks = Remarkstext.Text }; var editstaffBiz = new StaffRegistrationsBiz(); if (MessageBox.Show("are you sure you want to Edit this file ?", "Confirm Updating", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK) { var result = editstaffBiz.Update(staffdata); if (result.Status) { MessageBox.Show("Successfuly Updated"); clear(); } else { MessageBox.Show("Update faild." + result.Message); } } } }