private void btnAgAdd_Click(object sender, RoutedEventArgs e) { try { { RegisteredUser NewOne = new RegisteredUser(); Char G; String photo = @"\\openbox\WRR301\Team03\RISDB\Images\" + curUser.SysID.ToString() + ".jpg"; if (rbGenM.IsChecked == true) { G = '1'; } else { G = '0'; } String depcode = NewOne.getDcode(cmbxDep.Text); NewOne.AddUser(txtName.Text, cmbxTitle.Text, txtSname.Text, txtUN.Text, pBPass.Text, txtCNo.Text, depcode, photo, dpDoB.Text, txtEmail.Text, G, cmbxToU.Text); if (cmbxToU.Text == "Administrative Assistant") { AdministrativeAssistant AA = new AdministrativeAssistant(); String sysID = AA.getID(txtUN.Text); AA.AddUser(sysID, txtStID.Text); } else if (cmbxToU.Text == "Independent Researcher") { IndependentResearcher IR = new IndependentResearcher(); String sysID = IR.getID(txtUN.Text); IR.AddUser(sysID, txtStID.Text); } else if (cmbxToU.Text == "Lecturer") { Lecturer LT = new Lecturer(); String sysID = LT.getID(txtUN.Text); LT.AddUser(sysID, txtStID.Text); } else if (cmbxToU.Text == "Researcher") { Researcher RS = new Researcher(); String sysID = RS.getID(txtUN.Text); RS.AddUser(sysID, txtRID.Text); } else if (cmbxToU.Text == "Student") { Student SD = new Student(); String sysID = SD.getID(txtUN.Text); SD.AddUser(sysID, txtStID.Text); } else if (cmbxToU.Text == "Supervisor") { Supervisor SP = new Supervisor(); String sysID = SP.getID(txtUN.Text); SP.AddUser(sysID, txtStID.Text); } else if (cmbxToU.Text == "System Administrator") { SystemAdministrator SA = new SystemAdministrator(); String sysID = SA.getID(txtUN.Text); SA.AddUser(sysID, txtStID.Text, txtPos.Text); } MessageBox.Show("Registered User Added", "~Added~"); InitializeGrid(); txtUN.Text = ""; pBPass.Text = ""; pBConf.Text = ""; cmbxTitle.SelectedIndex = -1; cmbxDep.SelectedIndex = -1; //cmbxToU.SelectedIndex = -1; txtName.Text = ""; txtSname.Text = ""; txtCNo.Text = ""; txtEmail.Text = ""; txtStID.Text = ""; txtPos.Text = ""; txtRID.Text = ""; } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { if (!curUser.isExceptionFree()) throw new Exception("Cannot save to the database while there are errors on the form"); RegisteredUser NewOne = new RegisteredUser(); Char G; if (rbGenM.IsChecked == true) { G = '1'; } else { G = '0'; } String photo = @"\\openbox\WRR301\Team03\RISDB\Images\" + curUser.SysID.ToString() + ".jpg"; String depcode = NewOne.getDcode(cmbxDep.Text); NewOne.AddUser(txtName.Text, cmbxTitle.Text, txtSname.Text, txtUN.Text, pBPass.Text, txtCNo.Text, depcode, photo, dpDoB.Text, txtEmail.Text, G, cmbxToU.Text); setUserDataSource(); txtUN.Text = ""; pBPass.Text = ""; pBConf.Text = ""; txtName.Text = ""; txtSname.Text = ""; txtCNo.Text = ""; txtEmail.Text = ""; btnUpdate.Visibility = Visibility.Hidden; MessageBox.Show("Registered User Added", "~Added~"); }