private void picEmergeSave_Click(object sender, EventArgs e) { foreach (DataRow drStaff in dsBelfray.Tables["Staff"].Rows) { if (drStaff["staffID"].ToString().Equals(lblStaffNo.Text)) { MyStaff myStaff = new MyStaff(); bool ok = true; errP.Clear(); //Contact Name try { myStaff.ContactName = txtContactName.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtContactName, MyEx.toString()); } //Contact Tel No try { myStaff.ContactTelNo = txtContactTel.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtPhoneNo, MyEx.toString()); } //Try Adding try { if (ok) { drStaff.BeginEdit(); drStaff["staffEmergName"] = myStaff.ContactName; drStaff["staffEmergTel"] = myStaff.ContactTelNo; drStaff.EndEdit(); daStaff.Update(dsBelfray, "Staff"); MessageBox.Show("Emergency Contact Info Updated"); picEmergeCancel.Visible = false; picEmergeSave.Visible = false; picEmergeEdit.Visible = true; txtContactName.Enabled = false; txtContactTel.Enabled = false; } } catch (Exception ex) { MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); } } } }
private void picStaffSave_Click(object sender, EventArgs e) { foreach (DataRow drStaff in dsBelfray.Tables["Staff"].Rows) { if (drStaff["staffID"].ToString().Equals(lblStaffNo.Text)) { MyStaff myStaff = new MyStaff(); bool ok = true; errP.Clear(); //Forename try { myStaff.Forename = txtForename.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtForename, MyEx.toString()); } //Surname try { myStaff.Surname = txtSurname.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtSurname, MyEx.toString()); } //Street try { myStaff.Street = txtStreet.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtStreet, MyEx.toString()); } //City try { myStaff.City = txtCity.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtCity, MyEx.toString()); } //County try { myStaff.County = txtCounty.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtCounty, MyEx.toString()); } //Postcode try { myStaff.Postcode = txtPostcode.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtPostcode, MyEx.toString()); } //Tel No try { myStaff.TelNo = txtPhoneNo.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtPhoneNo, MyEx.toString()); } //Try Adding try { if (ok) { int length = txtSurname.Text.ToString().Length; string lastInitial = txtSurname.Text.ToString().Substring(0, 1); string lName = txtSurname.Text.ToString().Substring(1, length - 1); char[] fName = txtForename.Text.ToString().ToCharArray(); string initial = fName[0].ToString().ToUpper(); lblLogin.Text = lastInitial.ToUpper() + lName + initial; drStaff.BeginEdit(); drStaff["staffFName"] = myStaff.Forename; drStaff["staffLName"] = myStaff.Surname; drStaff["staffStreet"] = myStaff.Street; drStaff["staffCity"] = myStaff.City; drStaff["staffCounty"] = myStaff.County; drStaff["staffPcode"] = myStaff.Postcode; drStaff["staffTelNo"] = myStaff.TelNo; drStaff["staffLogin"] = lblLogin.Text.ToString(); drStaff.EndEdit(); daStaff.Update(dsBelfray, "Staff"); MessageBox.Show("User Info Updated"); picStaffCancel.Visible = false; picStaffSave.Visible = false; picStaffEdit.Visible = true; txtForename.Enabled = false; txtSurname.Enabled = false; txtStreet.Enabled = false; txtCity.Enabled = false; txtCounty.Enabled = false; txtPostcode.Enabled = false; txtPhoneNo.Enabled = false; } } catch (Exception ex) { MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); } } } }
private void picPassSave_Click(object sender, EventArgs e) { foreach (DataRow drStaff in dsBelfray.Tables["Staff"].Rows) { if (drStaff["staffID"].ToString().Equals(lblStaffNo.Text)) { MyStaff myStaff = new MyStaff(); bool ok = true; errP.Clear(); //Account Type try { switch (cmbAccountType.SelectedIndex) { case 0: myStaff.AccType = "ADM"; break; case 1: myStaff.AccType = "HTL"; break; case 2: myStaff.AccType = "RES"; break; } } catch (MyException MyEx) { ok = false; errP.SetError(cmbAccountType, MyEx.toString()); } //Staff Password try { myStaff.StaffPW = txtCurrent.Text.ToString(); } catch (MyException MyEx) { ok = false; errP.SetError(txtCurrent, MyEx.toString()); } //Try Adding try { if (ok) { drStaff.BeginEdit(); drStaff["staffPassword"] = myStaff.StaffPW; drStaff["accTypeID"] = myStaff.AccType; drStaff.EndEdit(); daStaff.Update(dsBelfray, "Staff"); MessageBox.Show("Account Info Updated"); picPassCancel.Visible = false; picPassSave.Visible = false; picPassEdit.Visible = true; txtCurrent.Enabled = false; cmbAccountType.Enabled = false; } } catch (Exception ex) { MessageBox.Show("" + ex.TargetSite + "", ex.Message + "Error!", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error); } } } }