public frmStudentskaSluzbaProfesor(string user, string vrsta) { InitializeComponent(); FillComboboxGrupa(); FillCombobox profesori = new FillCombobox(FillComboboxProfesor); profesori.Invoke(); FillCombobox studenti = new FillCombobox(FillComboboxStudent); studenti.Invoke(); FillComboboxProfesor(); FillComboboxStudent(); FillComboboxSmer(); lblProfesorPrikazLogin.Text = user; lblVrstaKorisnikaSistema.Text = vrsta; LoadTable(lblVrstaKorisnikaSistema.Text); if (vrsta.Equals("PROFESOR")) { grpBoxStudent.DataBindings.Control.Enabled = false; } if (vrsta.Equals("STUDENT")) { grpBoxProfesor.DataBindings.Control.Enabled = false; } }
private void btnProfesorUnos_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtProfesorUsername.Text) || String.IsNullOrWhiteSpace(txtProfesorUsername.Text) || txtProfesorUsername.Text.Length == 0 || String.IsNullOrEmpty(txtProfesorIme.Text) || String.IsNullOrWhiteSpace(txtProfesorIme.Text) || txtProfesorIme.Text.Length == 0 || String.IsNullOrEmpty(txtProfesorPrezime.Text) || String.IsNullOrWhiteSpace(txtProfesorPrezime.Text) || txtProfesorPrezime.Text.Length == 0 || String.IsNullOrEmpty(txtProfesorEmail.Text) || String.IsNullOrWhiteSpace(txtProfesorEmail.Text) || txtProfesorEmail.Text.Length == 0) { MessageBox.Show("Niste popunili sva polja"); } else { string myConnection = "datasource=localhost;port=3306;username=root;password=Fil2105ozof!"; string Query = "START TRANSACTION; INSERT INTO studentskasluzba.korisnici (username,password,grupa_id)VALUES('" + this.txtProfesorUsername.Text + "','" + this.txtProfesorPassword.Text + "','" + grupaId + "');INSERT INTO studentskasluzba.profesor (profesor_ime,profesor_prezime,profesor_zvanje,profesor_email,profesor_korisnik_id) VALUES ('" + this.txtProfesorIme.Text.ToUpper() + "','" + this.txtProfesorPrezime.Text.ToUpper() + "','" + this.txtProfesorZvanje.Text.ToUpper() + "','" + this.txtProfesorEmail.Text + "',last_insert_id()); COMMIT;"; MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand SelectCommand = new MySqlCommand(Query, myConn); MySqlDataReader myReader; try { myConn.Open(); myReader = SelectCommand.ExecuteReader(); MessageBox.Show("Slog je upisan u bazu"); txtProfesorUsername.Text = ""; txtProfesorPassword.Text = ""; cmbProfesorVrstaKorisnika.Text = ""; txtProfesorIme.Text = ""; txtProfesorPrezime.Text = ""; txtProfesorZvanje.Text = ""; txtProfesorEmail.Text = ""; txtProfesorUsername.Focus(); while (myReader.Read()) { } myConn.Close(); myReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); txtProfesorUsername.Text = ""; txtProfesorPassword.Text = ""; cmbProfesorVrstaKorisnika.Text = ""; txtProfesorIme.Text = ""; txtProfesorPrezime.Text = ""; txtProfesorZvanje.Text = ""; txtProfesorEmail.Text = ""; txtProfesorUsername.Focus(); myConn.Close(); } } LoadTable(lblVrstaKorisnikaSistema.Text); FillCombobox profesori = new FillCombobox(FillComboboxProfesor); profesori.Invoke(); }
private void btnStudentUpis_Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(txtProfesorUsername.Text) || String.IsNullOrWhiteSpace(txtProfesorUsername.Text) || txtProfesorUsername.Text.Length == 0 || String.IsNullOrEmpty(txtStudentIme.Text) || String.IsNullOrWhiteSpace(txtStudentIme.Text) || txtStudentIme.Text.Length == 0 || String.IsNullOrEmpty(txtStudentPrezime.Text) || String.IsNullOrWhiteSpace(txtStudentPrezime.Text) || txtStudentPrezime.Text.Length == 0 || String.IsNullOrEmpty(txtStudentEmail.Text) || String.IsNullOrWhiteSpace(txtStudentEmail.Text) || txtStudentEmail.Text.Length == 0 || String.IsNullOrEmpty(txtStudentJMBG.Text) || String.IsNullOrWhiteSpace(txtStudentJMBG.Text) || txtStudentJMBG.Text.Length == 0) { MessageBox.Show("Niste popunili sva polja"); } else if (txtStudentJMBG.Text.Length < 13 || txtStudentJMBG.Text.Length > 13) { MessageBox.Show("JMBG nije ispravan"); } else if (!isValidEmail(txtStudentEmail.Text)) { MessageBox.Show("Email adresa nije validna"); } else { string myConnection = "datasource=localhost;port=3306;username=root;password=Fil2105ozof!"; string Query = "START TRANSACTION; INSERT INTO studentskasluzba.korisnici (username,password,grupa_id)VALUES('" + this.txtProfesorUsername.Text + "','" + this.txtProfesorPassword.Text + "','" + grupaId + "');INSERT INTO studentskasluzba.student (student_ime,student_prezime,student_jmbg,student_datumrodjenja,student_telefon,student_smer_id,student_broj_indeksa,student_godina_upisa,student_email,student_korisnik_id) VALUES ('" + this.txtStudentIme.Text.ToUpper() + "','" + this.txtStudentPrezime.Text.ToUpper() + "','" + this.txtStudentJMBG.Text + "','" + dateTimePickerDatumRodjenja.Value.ToString("yyyy-MM-dd") + "','" + txtStudentTelefon.Text + "','" + studentSmerId + "','" + txtStudentBrIndeksa.Text + "','" + txtStudentGodinaUpisa.Text + "','" + this.txtStudentEmail.Text + "',last_insert_id()); COMMIT;"; MySqlConnection myConn = new MySqlConnection(myConnection); MySqlCommand SelectCommand = new MySqlCommand(Query, myConn); MySqlDataReader myReader; try { myConn.Open(); myReader = SelectCommand.ExecuteReader(); MessageBox.Show("Slog je upisan u bazu"); txtProfesorUsername.Text = ""; txtProfesorPassword.Text = ""; cmbProfesorVrstaKorisnika.Text = ""; txtStudentIme.Text = ""; txtStudentPrezime.Text = ""; txtStudentJMBG.Text = ""; dateTimePickerDatumRodjenja.Text = ""; txtStudentTelefon.Text = ""; txtStudentBrIndeksa.Text = ""; txtStudentGodinaUpisa.Text = ""; txtProfesorEmail.Text = ""; txtProfesorUsername.Focus(); while (myReader.Read()) { } myConn.Close(); myReader.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); txtProfesorUsername.Text = ""; txtProfesorPassword.Text = ""; cmbProfesorVrstaKorisnika.Text = ""; txtStudentIme.Text = ""; txtStudentPrezime.Text = ""; txtStudentJMBG.Text = ""; dateTimePickerDatumRodjenja.Text = ""; txtStudentTelefon.Text = ""; txtStudentBrIndeksa.Text = ""; txtStudentGodinaUpisa.Text = ""; cmbStudentSmer.Text = ""; txtStudentEmail.Text = ""; txtProfesorUsername.Focus(); myConn.Close(); } } LoadTable(lblVrstaKorisnikaSistema.Text); FillCombobox studenti = new FillCombobox(FillComboboxStudent); studenti.Invoke(); }