private void btnInapoi_Click(object sender, EventArgs e) { conectare.ConectareBazDate(); conn = conectare.ConectareBazDate(); OleDbCommand cmdSelect; OleDbDataReader reader; conn.Open(); cmdSelect = new OleDbCommand("SELECT Rol FROM Conturi where Conturi.idCont = @idCont", conn); cmdSelect.Parameters.AddWithValue("@idCont", Cont); reader = cmdSelect.ExecuteReader(); reader.Read(); if (reader.GetValue(0).ToString() == "Administrator") { this.Hide(); var meniu = new MeniuAdministrator(Cont); meniu.ShowDialog(); this.Close(); } else { if (reader.GetValue(0).ToString() == "Personal Hotel") { this.Hide(); var meniu = new MeniuPersonalHotel(Cont); meniu.ShowDialog(); this.Close(); } else { if (reader.GetValue(0).ToString() == "Personal Restaurant") { this.Hide(); var meniu = new MeniuPersonalRestaurant(Cont); meniu.ShowDialog(); this.Close(); } else { if (reader.GetValue(0).ToString() == "ResponsabilEvenimente") { this.Hide(); var meniu = new MeniuResponsabilEvenimente(Cont); meniu.ShowDialog(); this.Close(); } } } } }
private void button2_Click(object sender, EventArgs e) { this.Hide(); var Start = new MeniuAdministrator(contAdministrator); Start.ShowDialog(); this.Close(); }
private void button1_Click_1(object sender, EventArgs e) { Boolean valid = true; lblDimensiune.ForeColor = System.Drawing.Color.Black; lblLiteraMare.ForeColor = System.Drawing.Color.Black; lblLiteraMica.ForeColor = System.Drawing.Color.Black; lblCifra.ForeColor = System.Drawing.Color.Black; LblCaracter.ForeColor = System.Drawing.Color.Black; lblErrorNume.Text = ""; lblErrorParola.Text = ""; lblErrorUser.Text = ""; String user = txtUser.Text; String parola = txtParola.Text; String Email = txtEmail.Text; String Telefon = TxtTelefon.Text; String Nume = txtNume.Text; String Prenume = txtPrenume.Text; String Adresa = txtAdresa.Text; String Functia = cboFunctie.Text; if (validare.ValidareNume(txtNume.Text, out string ErrorMessage) == false) { lblErrorNume.Text = ErrorMessage.ToString(); valid = false; } if (validare.ValidareParola(txtParola.Text, out string ErrorMessagePass) == false) { if (ErrorMessagePass.ToString() == "0") { lblErrorParola.Text = "Trebuie sa introduci o parola"; } else { // label-urile se coloreaza in rosu in functie de validarile nerespectate for (int i = 0; i <= ErrorMessagePass.ToString().Length - 1; i++) { if (ErrorMessagePass.Substring(i, 1) == "1") { lblDimensiune.ForeColor = System.Drawing.Color.Red; } if (ErrorMessagePass.Substring(i, 1) == "2") { lblLiteraMare.ForeColor = System.Drawing.Color.Red; } if (ErrorMessagePass.Substring(i, 1) == "3") { lblLiteraMica.ForeColor = System.Drawing.Color.Red; } if (ErrorMessagePass.Substring(i, 1) == "4") { lblCifra.ForeColor = System.Drawing.Color.Red; } if (ErrorMessagePass.Substring(i, 1) == "5") { LblCaracter.ForeColor = System.Drawing.Color.Red; } } } valid = false; } if (validare.ValidareUser(txtUser.Text, out string ErrorMessageUser) == false) { lblErrorUser.Text = ErrorMessageUser.ToString(); valid = false; } if (valid == true) { // TO TO: Inregistrarea noului utilizator OleDbCommand cmdSelect, cmdInsert, cmdInsertDetalii; string insert, insertDetalii; OleDbDataReader reader; insert = "INSERT INTO Conturi([User],[Parola],[Rol]) VALUES ('" + txtUser.Text + "','" + txtParola.Text + "','" + cboFunctie.Text + "')"; cmdInsert = new OleDbCommand(insert, conn); OleDbDataAdapter adapter = new OleDbDataAdapter(); try { // inserarea in conturi conn.Open(); adapter.InsertCommand = new OleDbCommand(insert, conn); adapter.InsertCommand.ExecuteNonQuery(); cmdInsert.Dispose(); // inserarea in detaliicont cmdSelect = new OleDbCommand("SELECT idCont FROM Conturi where Conturi.User = @User", conn); cmdSelect.Parameters.AddWithValue("@User", this.txtUser.Text); reader = cmdSelect.ExecuteReader(); reader.Read(); idCont = reader.GetValue(0); insertDetalii = "INSERT INTO DetaliiCont([Nume],[Prenume],[Telefon],[Email],[Adresa],[Functia],[idCont]) VALUES ('" + txtNume.Text + "','" + txtPrenume.Text + "','" + TxtTelefon.Text + "','" + txtEmail.Text + "', '" + txtAdresa.Text + "','" + cboFunctie.Text + "','" + idCont + "')"; cmdInsertDetalii = new OleDbCommand(insertDetalii, conn); adapter.InsertCommand = new OleDbCommand(insertDetalii, conn); adapter.InsertCommand.ExecuteNonQuery(); cmdInsertDetalii.Dispose(); MessageBox.Show("Utilizatorul a fost adaugat!"); conn.Close(); //deschidere meniu this.Hide(); var meniu = new MeniuAdministrator(idCont); meniu.ShowDialog(); this.Close(); } catch (OleDbException ex) { MessageBox.Show(ex.Message); } } }
public void btnConectare_Click(object sender, EventArgs e) { conectare.ConectareBazDate(); conn = conectare.ConectareBazDate(); OleDbCommand cmdSelect, cmdSelect2; OleDbDataReader reader, reader2; conn.Open(); // verificarea existentei user-ului cmdSelect = new OleDbCommand("SELECT User, Parola, Rol FROM Conturi where Conturi.User = @User AND Conturi.Parola = @Parola", conn); cmdSelect.Parameters.AddWithValue("@User", this.txtUser.Text); cmdSelect.Parameters.AddWithValue("@Parola", this.txtParola.Text); reader = cmdSelect.ExecuteReader(); if (reader.HasRows) { reader.Read(); cmdSelect2 = new OleDbCommand("SELECT idCont FROM Conturi where Conturi.User = @User", conn); cmdSelect2.Parameters.AddWithValue("@User", this.txtUser.Text); reader2 = cmdSelect2.ExecuteReader(); reader2.Read(); idCont = reader2.GetValue(0); if (reader.GetValue(2).ToString() == "Client") { this.Hide(); var meniu = new MeniuClient(idCont); meniu.ShowDialog(); this.Close(); } else { if (reader.GetValue(2).ToString() == "Administrator") { this.Hide(); var meniu = new MeniuAdministrator(idCont); meniu.ShowDialog(); this.Close(); } else { if (reader.GetValue(2).ToString() == "Personal Hotel") { this.Hide(); var meniu = new MeniuPersonalHotelPrincipal(idCont); meniu.ShowDialog(); this.Close(); } else { if (reader.GetValue(2).ToString() == "Personal Restaurant") { this.Hide(); var meniu = new MeniuPersonalRestaurant(idCont); meniu.ShowDialog(); this.Close(); } else { if (reader.GetValue(2).ToString() == "ResponsabilEvenimente") { this.Hide(); var meniu = new MeniuResponsabilEvenimente(idCont); meniu.ShowDialog(); this.Close(); } } } } } } else { MessageBox.Show("User-ul sau parola au fost introduse gresit!"); conn.Close(); } }