Exemplo n.º 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            this.Hide();
            var MeniuClient = new MeniuClient(ContClient);

            MeniuClient.ShowDialog();
            this.Close();
        }
Exemplo n.º 2
0
        public void btnInregistrare_Click(object sender, EventArgs e)
        {
            conectare.ConectareBazDate();
            conn = conectare.ConectareBazDate();
            conn.Open();


            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;
            lblNull.Text            = "";
            lblTelErr.Text          = "";
            lblUserErr.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;



            if (validare.ValidareTelefon(TxtTelefon.Text, out string ErrorMessage) == false)
            {
                lblTelErr.Text = ErrorMessage.ToString();
                valid          = false;
            }

            if (validare.ValidareParola(txtParola.Text, out string ErrorMessagePass) == false)
            {
                if (ErrorMessagePass.ToString() == "0")
                {
                    lblNull.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)
            {
                lblUserErr.Text = ErrorMessageUser.ToString();
                valid           = false;
            }

            if (valid == true)
            {
                // TO DO: Inregistrarea noului utilizator
                OleDbCommand cmdSelect, cmdInsert, cmdInsertDetalii;


                string          insert, insertDetalii;
                OleDbDataReader reader;
                insert = "INSERT INTO Conturi([User],[Parola],[Rol]) VALUES ('" + txtUser.Text + "','" + txtParola.Text + "','Client')";

                cmdInsert = new OleDbCommand(insert, conn);

                OleDbDataAdapter adapter = new OleDbDataAdapter();

                try
                {
                    // inserarea in conturi

                    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],[idCont]) VALUES ('" + txtNume.Text + "','" + txtPrenume.Text + "','" + TxtTelefon.Text + "','" + txtEmail.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 MeniuClient(idCont);
                    meniu.ShowDialog();
                    this.Close();
                }

                catch (OleDbException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
        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();
            }
        }