private void submitBtn_Click(object sender, EventArgs e) { AllUsers a = new AllUsers(); AllUsersRepository aRepo = new AllUsersRepository(); a.UserFullName = this.textBox1.Text; a.UserName = textBox2.Text; a.UserType = "Passenger"; a.UserQuestion = textBox10.Text; if (this.textBox5.Text == this.textBox4.Text) { a.UserPassword = this.textBox5.Text; PassengerRepository pRepo = new PassengerRepository(); Passenger p = new Passenger(); int x = pRepo.PassengerCount(); x++; p.PassengerId = x; p.Pname = this.textBox1.Text; p.Pusername = this.textBox2.Text; p.Pemail = this.textBox3.Text; p.Ppassword = this.textBox5.Text; p.Pgender = this.textBox6.Text; p.Page = Convert.ToInt32(this.textBox7.Text); p.Paddress = this.textBox9.Text; p.Pquestion = this.textBox10.Text; if (pRepo.Insert(p) && aRepo.Insert(a)) { MessageBox.Show("New User Added"); } else { MessageBox.Show("New User not Added. \nCould not connect to database", "Insert Error"); } this.textBox1.Text = ""; this.textBox2.Text = ""; this.textBox3.Text = ""; this.textBox4.Text = ""; this.textBox5.Text = ""; this.textBox6.Text = ""; this.textBox7.Text = ""; this.textBox9.Text = ""; this.textBox10.Text = ""; //this.textBox11.Text = ""; } else { wrongPasslabel.Text = "Password Don't match"; this.textBox4.Text = ""; this.textBox5.Text = ""; } }
private void addEmpBtn_Click(object sender, EventArgs e) { //add emp btn AllUsersRepository userRepo = new AllUsersRepository(); AllUsers user = new AllUsers(); user.UserFullName = textBox71.Text; user.UserType = "Employee"; user.UserName = textBox72.Text; user.UserPassword = textBox74.Text; user.UserQuestion = textBox79.Text; EmployeeRepository empRepo = new EmployeeRepository(); Employee emp = new Employee(); int x = empRepo.EmployeeCount(); x = x + 1; Console.WriteLine("emp count : " + x); emp.EmployeeID = x; emp.Name = textBox71.Text; emp.Username = textBox72.Text; emp.Email = textBox73.Text; emp.Password = textBox74.Text; emp.Gender = textBox75.Text; emp.Age = Convert.ToInt32(textBox76.Text); emp.Address = textBox78.Text; emp.Question = textBox79.Text; if (empRepo.Insert(emp) && userRepo.Insert(user)) { MessageBox.Show("New User Added"); textBox71.Text = ""; textBox72.Text = ""; textBox73.Text = ""; textBox74.Text = ""; textBox75.Text = ""; textBox76.Text = ""; textBox78.Text = ""; textBox79.Text = ""; } else { MessageBox.Show("User not Added. Error adding employee to database."); } }
private void button12_Click(object sender, EventArgs e) { //add admin btn AllUsersRepository userRepo = new AllUsersRepository(); AllUsers user = new AllUsers(); user.UserFullName = textBox81.Text; user.UserType = "Admin"; user.UserName = textBox82.Text; user.UserPassword = textBox84.Text; user.UserQuestion = textBox89.Text; AdminRepository adminRepo = new AdminRepository(); Admin a = new Admin(); int x = adminRepo.AdminCount(); x = x + 1; a.AdminId = x; a.Name = textBox81.Text; a.Username = textBox82.Text; a.Email = textBox83.Text; a.Password = textBox84.Text; a.Gender = textBox85.Text; a.Age = Convert.ToInt32(textBox86.Text); a.Address = textBox88.Text; a.Question = textBox89.Text; if (adminRepo.Insert(a) && userRepo.Insert(user)) { MessageBox.Show("New User Added"); textBox81.Text = ""; textBox82.Text = ""; textBox83.Text = ""; textBox84.Text = ""; textBox85.Text = ""; textBox86.Text = ""; textBox88.Text = ""; textBox89.Text = ""; } else { MessageBox.Show("New User did not Added. Error adding admin to database."); } }
private void button12_Click(object sender, EventArgs e) { //add admin btn AdminRepository adminRepo = new AdminRepository(); Admin a = new Admin(); a.AdminId = textBox70.Text; a.Name = textBox71.Text; a.Username = textBox72.Text; a.Email = textBox73.Text; a.Password = textBox74.Text; a.Gender = textBox75.Text; a.Age = Convert.ToInt32(textBox76.Text); a.Address = textBox78.Text; a.Question = textBox79.Text; if (adminRepo.Insert(a)) { AllUsersRepository userRepo = new AllUsersRepository(); AllUsers user = new AllUsers(); user.UserId = a.AdminId; user.UserType = "Admin"; user.UserName = a.Username; if (userRepo.Insert(user)) { MessageBox.Show("New User Added"); } else { MessageBox.Show("New User did not Added"); } } else { MessageBox.Show("Error adding admin to database."); } }
private void addEmpBtn_Click(object sender, EventArgs e) { EmployeeRepository empRepo = new EmployeeRepository(); Employee emp = new Employee(); emp.EmployeeID = textBox70.Text; emp.Name = textBox71.Text; emp.Username = textBox72.Text; emp.Email = textBox73.Text; emp.Password = textBox74.Text; emp.Gender = textBox75.Text; emp.Age = Convert.ToInt32(textBox76.Text); emp.Address = textBox78.Text; emp.Question = textBox79.Text; if (empRepo.Insert(emp)) { AllUsersRepository userRepo = new AllUsersRepository(); AllUsers user = new AllUsers(); user.UserId = emp.EmployeeID; user.UserType = "Employee"; user.UserName = emp.Username; if (userRepo.Insert(user)) { MessageBox.Show("New User Added"); } else { MessageBox.Show("New User did not Added"); } } else { MessageBox.Show("Error adding employee to database."); } }