private void materialRaisedButton1_Click(object sender, EventArgs e) { string gender = "Male"; if (maleGenderCheckBox.Checked != true) { gender = "Female"; } String query = "INSERT INTO student_database(first_name, last_name, gender, address, phone, birth_date, email, parent_name, relation, parent_phone, nationality, religion, roll, photo, admisson_date, class, previous_school) VALUES ('" + firstNameTextBox.Text + "', '" + lastNameTextBox.Text + "', '" + gender + "', '" + addressTextBox.Text + "', '" + phoneTextBox.Text + "', '" + birthDateTimePicker.Text + "', '" + emainTextBox.Text + "', '" + parentNameTextBox.Text + "', '" + relationParentTextBox.Text + "', '" + parentPhoneTextBox.Text + "', '" + nationalityTextBox.Text + "', '" + religionTextBox.Text + "', '" + studentRollTextBox.Text + "', '" + img + "', '" + DateTime.Now.ToString("yyyy-MM-dd") + "', '" + classTextBox.Text + "', '" + previoudSchoolTextBox.Text + "' ); "; MySqlConnection databaseConnection = new MySqlConnection(conString); MySqlConnection databaseConnection2 = new MySqlConnection(conString); databaseConnection.Open(); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); MySqlDataReader myReader = commandDatabase.ExecuteReader(); databaseConnection2.Open(); Login_Form f1 = new Login_Form(); string pass = f1.getMD5(studentPassTextBox.Text); String query2 = "INSERT INTO user_data(username, pass, access_lvl, id_number) VALUES ('" + userNameTextBox.Text + "', '" + pass + "', '" + "Student" + "', '" + studentRollTextBox.Text + "');"; MySqlCommand commandDatabase2 = new MySqlCommand(query2, databaseConnection2); MySqlDataReader myReader2 = commandDatabase2.ExecuteReader(); databaseConnection.Close(); databaseConnection2.Close(); MessageBox.Show("Successfully Completed!"); }
private void AddEmployee_Click(object sender, EventArgs e) { string gender = "Male"; if (genderCheckBox1.Checked != true) { gender = "Female"; } String query = "INSERT INTO employee_database(first_name, last_name, gender, address, phone, birthday, email, religion, employee_id, photo, join_date, designation, qualification) VALUES ('" + employeeFirstNameTextBox.Text + "', '" + employeeLastNameTextBox.Text + "', '" + gender + "', '" + addressTextField.Text + "', '" + phoneTextField1.Text + "', '" + birthDateTextField.Text + "', '" + emailTextField1.Text + "', '" + employeeReligionTextField1.Text + "', '" + employeeIdTextField.Text + "', '" + img + "', '" + joinDateTextField.Text + "', '" + designationTextField.Text + "', '" + QualificationTextField.Text + "' ); "; MySqlConnection databaseConnection = new MySqlConnection(conString); MySqlConnection databaseConnection2 = new MySqlConnection(conString); databaseConnection.Open(); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); MySqlDataReader myReader = commandDatabase.ExecuteReader(); databaseConnection2.Open(); Login_Form f1 = new Login_Form(); string pass = f1.getMD5(employeePassTextField.Text); string access_lvl = designationTextField.Text == "Staff" ? "Staff" : "Teacher"; String query2 = "INSERT INTO user_data(username, pass, access_lvl, id_number) VALUES ('" + employeeUserNameTextField.Text + "', '" + pass + "', '" + access_lvl + "', '" + employeeIdTextField.Text + "');"; MySqlCommand commandDatabase2 = new MySqlCommand(query2, databaseConnection2); MySqlDataReader myReader2 = commandDatabase2.ExecuteReader(); databaseConnection.Close(); databaseConnection2.Close(); MessageBox.Show("Successfully Completed!"); }
private void materialRaisedButton1_Click(object sender, EventArgs e) { Login_Form f1 = new Login_Form(); string pass = f1.getMD5(user_pass.Text); String query = "INSERT INTO user_data(username, pass, access_lvl, id_number) VALUES ('" + user_name.Text + "', '" + pass + "', '" + accessTypeComboBox.Text + "', '" + user_id.Text + "');"; MySqlConnection databaseConnection = new MySqlConnection(conString); databaseConnection.Open(); MySqlCommand commandDatabase = new MySqlCommand(query, databaseConnection); MySqlDataReader myReader = commandDatabase.ExecuteReader(); MessageBox.Show("Successfully Completed!"); }