void Add() { //create an instance of the Inventory Collenction clsStaffCollection AllStaffs = new clsStaffCollection(); //validate the data on the web form string Error = AllStaffs.ThisStaff.Valid(txtName.Text, txtPhonenum.Text, txtSalary.Text, txtDateJoined.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user AllStaffs.ThisStaff.Name = txtName.Text; AllStaffs.ThisStaff.Phonenum = Convert.ToString(txtPhonenum.Text); AllStaffs.ThisStaff.Salary = Convert.ToDecimal(txtSalary.Text); AllStaffs.ThisStaff.DateJoined = Convert.ToDateTime(txtDateJoined.Text); AllStaffs.ThisStaff.Active = chkActive.Checked; //add the record AllStaffs.Add(); //all done so redirect back to the main page StaffManageForm SM = new StaffManageForm(); this.Hide(); SM.ShowDialog(); this.Close(); } else { //report an error lblError.Text = "There were problems with the data entered : " + Error; } }
public void Update() { //create an instance of the Inventory Collection clsStaffCollection AllStaffs = new clsStaffCollection(); //validate the data on the Windows Form string Error = AllStaffs.ThisStaff.Valid(txtName.Text, txtPhonenum.Text, txtSalary.Text, txtDateJoined.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to UPDATE AllStaffs.ThisStaff.Find(mStaffId); //get the data entered by the user AllStaffs.ThisStaff.Name = txtName.Text; AllStaffs.ThisStaff.Phonenum = Convert.ToString(txtPhonenum.Text); AllStaffs.ThisStaff.Salary = Convert.ToDecimal(txtSalary.Text); AllStaffs.ThisStaff.DateJoined = Convert.ToDateTime(txtDateJoined.Text); AllStaffs.ThisStaff.Active = chkActive.Checked; AllStaffs.ThisStaff.AccountNo = Convert.ToInt32(txtAccountNo.Text); //UPDATE the record AllStaffs.Update(); //All Done so Redirect to the previous Form StaffManageForm SM = new StaffManageForm(); this.Hide(); SM.ShowDialog(); this.Close(); } else { lblError.Text = "There were problems with the data entered: " + Error; } }
private void btnManageStaff_Click(object sender, EventArgs e) { StaffManageForm SM = new StaffManageForm(); this.Hide(); SM.ShowDialog(); this.Close(); }
private void btnCancel_Click(object sender, EventArgs e) { //all done so redirect back to the main page StaffManageForm SM = new StaffManageForm(); this.Hide(); SM.ShowDialog(); this.Close(); }
private void btnYes_Click(object sender, EventArgs e) { string message = "The Staff has been deleted successfully."; string caption = "Deletion Confirmation"; DialogResult result; MessageBoxButtons button = MessageBoxButtons.OK; result = MessageBox.Show(message, caption, button); if (result == DialogResult.OK) { //delete the record DeleteStaff(); //redirect to the main form StaffManageForm SM = new StaffManageForm(); this.Hide(); SM.ShowDialog(); this.Close(); } }
private void btnOK_Click(object sender, EventArgs e) { clsStaffCollection AllStaffs = new clsStaffCollection(); string Error = AllStaffs.ThisStaff.Valid(txtName.Text, txtPhonenum.Text, txtSalary.Text, txtDateJoined.Text); string message = "Are you sure to Add the new Staff to the Database?"; string caption = "User Confirmation!"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; //Displays the MessageBox //if there are no Errors returned if (Error == "") { //show the Message box result = MessageBox.Show(message, caption, buttons); //if "Yes" is pressed if (result == DialogResult.Yes) { //execute the Update method Add(); //all done so redirect back to the main page StaffManageForm SM = new StaffManageForm(); this.Hide(); SM.ShowDialog(); this.Close(); } } else { //report an error lblError.Text = "There were problems with the data entered : " + Error; } }