protected void Unnamed_Click(object sender, EventArgs e) { int rowIndex = gvwStudents.SelectedIndex; usernumber = userNumbersList[rowIndex]; User u = new User(); string firstName = FirstName.Text; string surname = Surname.Text; string email = MCEmail.Text; string contactNumber = ContactNumber.Text; string address = PhysicalAddress.Text; string date = default_datetimepickerss.Text; if (String.IsNullOrEmpty(date)) { date = "10/10/2010"; } string[] words = date.Split('/'); words[2] = words[2].Substring(0, 4); DateTime birthday = new DateTime(Convert.ToInt32(words[2]), Convert.ToInt32(words[0]), Convert.ToInt32(words[1])); int cityNumber = Convert.ToInt32(CityDDL.SelectedIndex) + 1; string gender = GenderDDL.Text; Boolean active = true; //Automatically assign as Client because a Dealer/Employee is added by a manager int securityRoleNumber = 1; foreach (Client c in ClientBindingList.MyClientList) { if (usernumber == c.UserNumber) { //Update Client & Dealer normal details User updateUser = new User(usernumber, firstName, surname, email, contactNumber, address, password, securityRoleNumber, cityNumber, birthday, gender, active); //When Client is changed into a Dealer if (c.ClientType == "Client" && CheckBox1.Checked == true) { updateUser.SecurityRoleNumber = 4; updateUser.UpdateUser(updateUser); Dealer d = new Dealer(); bool found = false; //If a Client used to be a dealer foreach (Dealer inD in DealerBindingList.DealerList) { if (c.UserNumber == inD.UserNumber) { d.UpdateDealer(inD.UserNumber, Convert.ToInt32(TextBox8.Text), true); c.UpdateClient(c.UserNumber, "Dealer", true); found = true; } } //If the client has never been a dealer if (found == false) { updateUser.UpdateUser(updateUser); d.InsertNewDealer(c.UserNumber, Convert.ToInt32(TextBox8.Text), true); c.UpdateClient(c.UserNumber, "Dealer", true); } } //When a dealer is changed back into a client else if (c.ClientType == "Dealer" && CheckBox1.Checked == false) { Dealer d = new Dealer(); updateUser.UpdateUser(updateUser); d.UpdateDealer(c.UserNumber, 0, false); c.UpdateClient(c.UserNumber, "Client", true); } //changing the details associated with an existing dealer else if (c.ClientType == "Dealer" && CheckBox1.Checked == true) { Dealer d = new Dealer(); updateUser.SecurityRoleNumber = 4; updateUser.UpdateUser(updateUser); d.UpdateDealer(c.UserNumber, Convert.ToInt32(TextBox8.Text), true); } //Changing the details of an existing client that has never been a dealer else if (c.ClientType == "Client" && CheckBox1.Checked == false) { updateUser.UpdateUser(updateUser); } } } List<Cli> myLi = new List<Cli>(); foreach (Client inC in ClientBindingList.MyClientList) { userNumbersList.Add(inC.UserNumber); Cli me = new Cli(); me.FirstName = inC.FirstName; me.Surname = inC.Surname; me.ContactNumber = inC.ContactNumber; myLi.Add(me); } gvwStudents.DataSource = myLi; gvwStudents.DataBind(); }