Exemplo n.º 1
0
 private void MeniuAdministrator_AdaugarePersoanl_Load(object sender, EventArgs e)
 {
     cboFunctie.SelectedIndex = 0;
     conn = conectare.ConectareBazDate();
     dataGridView1.Hide();
     btnStergerePersonal.Hide();
 }
        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();
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void MeniuResponsabilEvenimente_Load(object sender, EventArgs e)
        {
            conn = conectare.ConectareBazDate();
            conn.Open();
            OleDbCommand cmdSelectNume;

            OleDbDataReader readerNume;

            // verificarea existentei user-ului
            cmdSelectNume = new OleDbCommand("SELECT Nume FROM DetaliiCont where DetaliiCont.idCont = @idCont", conn);
            cmdSelectNume.Parameters.AddWithValue("@idCont", this.cont);
            readerNume = cmdSelectNume.ExecuteReader();

            readerNume.Read();
            lblNume.Text = Convert.ToString(readerNume.GetValue(0));



            int i = 0;

            dataGridView1.ColumnCount        = 7;
            dataGridView1.Columns[0].Name    = "Nr";
            dataGridView1.Columns[1].Name    = "Tip Eveniment";
            dataGridView1.Columns[2].Name    = "Locatie";
            dataGridView1.Columns[3].Name    = "Data-Ora";
            dataGridView1.Columns[4].Name    = "Perioada desfasurare";
            dataGridView1.Columns[5].Name    = "Aprobare";
            dataGridView1.Columns[6].Name    = "Id";
            dataGridView1.Columns[6].Visible = false;
            OleDbCommand    cmdSelect, cmdSelect2;
            OleDbDataReader reader, reader2;

            cmdSelect = new OleDbCommand("Select idSolicitare, idCont,idLocatie,TipEveniment, BeneficiiLimuzina, BeneficiiMuzica,BeneficiiAranjamentFloral, BeneficiiDansatori,BeneficiiAranjamentBaloane, BeneficiiAnimatori, Specificatii, Data, PerioadaDesfasurare,Aprobare, idMeniu FROM SolicitariEvenimente", conn);
            cmdSelect.Parameters.AddWithValue("@idCont", this.cont);
            reader = cmdSelect.ExecuteReader();

            while (reader.Read())
            {
                i++;
                cmdSelect2 = new OleDbCommand("Select idLocatie, Denumire from Locatii where idLocatie=@idLoc", conn);
                cmdSelect2.Parameters.AddWithValue("@idLoc", reader.GetValue(2));
                reader2 = cmdSelect2.ExecuteReader();
                reader2.Read();

                string[] row1 = new string[] { i.ToString(), reader.GetValue(3).ToString(), reader2.GetValue(1).ToString(), reader.GetValue(11).ToString(), reader.GetValue(12).ToString(), reader.GetValue(13).ToString(), reader.GetValue(0).ToString() };
                dataGridView1.Rows.Add(row1);
            }
            conn.Close();
        }
Exemplo n.º 4
0
        private void MeniuClient_RezervareCamera_Load(object sender, EventArgs e)
        {
            conn = conectarestr.ConectareBazDate();
            conn.Open();
            OleDbCommand    cmdSelect;
            OleDbDataReader reader;

            cmdSelect = new OleDbCommand("Select NrCamera, NrPaturi, Detalii, PretCamera from Camere", conn);
            reader    = cmdSelect.ExecuteReader();

            while (reader.Read())
            {
                cboCamera.Items.Add(reader.GetValue(0).ToString());
            }
            conn.Close();
        }
Exemplo n.º 5
0
        public bool ValidareUser(string user, out string ErrorMessage)
        {
            //TO DO: Verficarea existaentei aceluiasi user in momentul inregistrarii
            var input = user;

            ErrorMessage = string.Empty;
            OleDbCommand    cmdSelect;
            OleDbDataReader reader;
            ConectareBD     conectare = new ConectareBD();
            OleDbConnection conn      = conectare.ConectareBazDate();

            if (string.IsNullOrWhiteSpace(input))
            {
                ErrorMessage = "Trebuie sa adaugi un nume de utilizator";
                return(false);
            }
            else
            {
                conn.Open();
                cmdSelect = new OleDbCommand("SELECT User, Parola FROM Conturi where Conturi.User = '******'", conn);

                reader = cmdSelect.ExecuteReader();

                if (reader.HasRows)
                {
                    ErrorMessage = "User-ul este deja folosit";
                    return(false);
                }
            }

            return(true);
        }
        private void MeniuPersonalRestaurant_VizualizeazaPreparate_Load(object sender, EventArgs e)
        {
            conn = conectare.ConectareBazDate();
            conn.Open();

            int          i = 0;
            int          j = 0;
            OleDbCommand cmdSelect, cmdselect2;

            OleDbDataReader reader, reader2;

            cmdselect2 = new OleDbCommand("SELECT Distinct TipPreparat from Preparate", conn);
            reader2    = cmdselect2.ExecuteReader();

            while (reader2.Read())
            {
                this.treeView1.Nodes.Add("'" + reader2.GetValue(0).ToString());
                i++;

                cmdSelect = new OleDbCommand(" SELECT idPreparat,TipPreparat, NumePreparat, Pret FROM Preparate where Preparate.TipPreparat =@Preparat", conn);
                cmdSelect.Parameters.AddWithValue("@Preparat", reader2.GetValue(0));
                reader = cmdSelect.ExecuteReader();
                j      = 0;
                while (reader.Read())
                {
                    j++;
                    treeView1.Nodes[i - 1].Nodes.Add("'" + reader.GetValue(2).ToString() + "' - '" + reader.GetValue(3).ToString() + "' lei");
                    treeView1.Nodes[i - 1].NodeFont = new Font("Monotype Corsiva", 16);
                    treeView1.Nodes[i - 1].Nodes[j - 1].NodeFont = new Font("Monotype Corsiva", 14);
                }
            }
        }
Exemplo n.º 7
0
        private void VizualizareContClient_Load(object sender, EventArgs e)
        {
            conn = conectare.ConectareBazDate();

            OleDbCommand cmdSelect, cmdSelect2;

            OleDbDataReader reader;

            conn.Open();
            // verificarea existentei user-ului
            cmdSelect  = new OleDbCommand("SELECT Nume, Prenume, Email, Telefon FROM DetaliiCont where DetaliiCont.idCont = @idCont", conn);
            cmdSelect2 = new OleDbCommand("SELECT User, Parola  FROM Conturi where Conturi.idCont = @idCont", conn);

            cmdSelect.Parameters.AddWithValue("@idCont", this.ContClient);
            cmdSelect2.Parameters.AddWithValue("@idCont", this.ContClient);

            reader = cmdSelect.ExecuteReader();

            reader.Read();
            txtNume.Text    = Convert.ToString(reader.GetValue(0));
            txtPrenume.Text = Convert.ToString(reader.GetValue(1));
            txtEmail.Text   = Convert.ToString(reader.GetValue(2));
            TxtTelefon.Text = Convert.ToString(reader.GetValue(3));

            reader = cmdSelect2.ExecuteReader();

            reader.Read();
            txtUser.Text   = Convert.ToString(reader.GetValue(0));
            txtParola.Text = Convert.ToString(reader.GetValue(1));
            conn.Close();
        }
        private void MeniuPersonalHotelPrincipal_Load(object sender, EventArgs e)
        {
            conn = conectare.ConectareBazDate();
            conn = conectare.ConectareBazDate();

            OleDbCommand cmdSelect;

            OleDbDataReader reader;

            conn.Open();
            // verificarea existentei user-ului
            cmdSelect = new OleDbCommand("SELECT Nume FROM DetaliiCont where DetaliiCont.idCont = @idCont", conn);
            cmdSelect.Parameters.AddWithValue("@idClient", this.cont);
            reader = cmdSelect.ExecuteReader();

            reader.Read();
        }
Exemplo n.º 9
0
        private void MeniuAdministrator_Load(object sender, EventArgs e)
        {
            
            conectare.ConectareBazDate();
            conn = conectare.ConectareBazDate();

            OleDbCommand cmdSelect;

            OleDbDataReader reader;
            conn.Open();
            // verificarea existentei user-ului
            cmdSelect = new OleDbCommand("SELECT Nume FROM DetaliiCont where DetaliiCont.idCont = @idCont", conn);
            cmdSelect.Parameters.AddWithValue("@idClient", this.ContAdministrator);
            reader = cmdSelect.ExecuteReader();
            reader.Read();
            lblNume.Text = Convert.ToString(reader.GetValue(0));
        }
Exemplo n.º 10
0
        private void MeniuPersonalHotelVerificaDisponibilitatea_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSetCamere.Camere' table. You can move, or remove it, as needed.
            this.camereTableAdapter.Fill(this.dataSetCamere.Camere);

            conn = conectare.ConectareBazDate();
            conn = conectare.ConectareBazDate();

            OleDbCommand cmdSelect;

            OleDbDataReader reader;

            conn.Open();
            // verificarea existentei user-ului
            cmdSelect = new OleDbCommand("SELECT Nume FROM DetaliiCont where DetaliiCont.idCont = @idCont", conn);
            cmdSelect.Parameters.AddWithValue("@idClient", this.cont);
            reader = cmdSelect.ExecuteReader();

            reader.Read();
        }
Exemplo n.º 11
0
        private void button1_Click(object sender, EventArgs e)
        {
            conectare.ConectareBazDate();
            conn = conectare.ConectareBazDate();
            conn.Open();

            if (textBox1.Text == "")
            {
                MessageBox.Show("Introduceti mesaj");
            }

            else
            {
                if (comboBox1.Text == "")
                {
                    MessageBox.Show("Introduceti nota");
                }
                else
                {
                    string           insert = "INSERT INTO Feedback([Mesaj],[idCont],[NotaAcordataServicii]) VALUES ('" + textBox1.Text + "','" + ContClient + "','" + comboBox1.Text + "')";
                    OleDbCommand     cmdInsert;
                    OleDbDataAdapter adapter = new OleDbDataAdapter();

                    cmdInsert = new OleDbCommand(insert, conn);

                    try
                    {
                        // inserarea in conturi

                        adapter.InsertCommand = new OleDbCommand(insert, conn);
                        adapter.InsertCommand.ExecuteNonQuery();
                        cmdInsert.Dispose();
                        MessageBox.Show("Recenzia dumneavoastra a fost primita");
                    }
                    catch (OleDbException ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
        private void MeniuClient_Restaurant_Meniu_Load(object sender, EventArgs e)
        {
            conn = conectare.ConectareBazDate();
            conn.Open();

            int          i = 0;
            int          j = 0;
            OleDbCommand cmdSelect, cmdselect2, cmdSelect3;

            OleDbDataReader reader, reader2, reader3;

            cmdselect2 = new OleDbCommand("SELECT Distinct TipPreparat from Preparate", conn);
            reader2    = cmdselect2.ExecuteReader();

            while (reader2.Read())
            {
                this.treeView1.Nodes.Add("'" + reader2.GetValue(0).ToString());
                i++;

                cmdSelect = new OleDbCommand(" SELECT idPreparat,TipPreparat, NumePreparat, Pret FROM Preparate where Preparate.TipPreparat =@Preparat", conn);
                cmdSelect.Parameters.AddWithValue("@Preparat", reader2.GetValue(0));
                reader = cmdSelect.ExecuteReader();
                j      = 0;
                while (reader.Read())
                {
                    j++;
                    treeView1.Nodes[i - 1].Nodes.Add("'" + reader.GetValue(2).ToString() + "' - '" + reader.GetValue(3).ToString() + "' lei");
                    treeView1.Nodes[i - 1].NodeFont = new Font("Monotype Corsiva", 16);
                    treeView1.Nodes[i - 1].Nodes[j - 1].NodeFont = new Font("Monotype Corsiva", 14);

/*
 *                  cmdSelect3 = new OleDbCommand("SELECT  Ingrediente from Preparate where Preparate.idPreparat =@Preparat", conn);
 *                  cmdSelect3.Parameters.AddWithValue("@Preparat", reader.GetValue(0));
 *                  reader3 = cmdSelect3.ExecuteReader();
 *                  while (reader3.Read())
 *                  {
 *                      treeView1.Nodes[i - 1].Nodes[0].Nodes.Add("Ingrediente:" + reader3.GetValue(0));
 *
 *
 *                  }
 */
                }
            }
        }
        private void MeniuPersonalRestaurant_AdaugareMeniu_Load(object sender, EventArgs e)
        {
            conn = conectare.ConectareBazDate();
            conn.Open();

            OleDbCommand cmdSelect;

            OleDbDataReader reader;

            cmdSelect = new OleDbCommand("SELECT * from Preparate", conn);
            reader    = cmdSelect.ExecuteReader();


            while (reader.Read())
            {
                chLB_preparate.Items.Add(reader[1].ToString());
            }
            conn.Close();
        }
Exemplo n.º 14
0
        private void button1_Click(object sender, EventArgs e)
        {
            conectare.ConectareBazDate();
            conn = conectare.ConectareBazDate();
            conn.Open();

            var             q   = "SELECT DetaliiCont.[idDC], DetaliiCont.[Nume], DetaliiCont.[Prenume], DetaliiCont.[Telefon], DetaliiCont.[Email], DetaliiCont.[Adresa], DetaliiCont.[Functia] FROM DetaliiCont ";
            var             cmd = new OleDbCommand(q, conn);
            var             da  = new OleDbDataAdapter(q, conn);
            OleDbDataReader reader;

            reader = cmd.ExecuteReader();

            var ds = new DataSet();

            da.Fill(ds, "Detalii cont");
        }
Exemplo n.º 15
0
        private void MeniuClient_Evenimente_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'testareBDDataSet.Meniu' table. You can move, or remove it, as needed.
            dateTimePicker1.Format       = DateTimePickerFormat.Custom;
            dateTimePicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss";

            conectare.ConectareBazDate();
            conn = conectare.ConectareBazDate();
            int i = 0;

            OleDbCommand cmdSelect, cmdselect2;

            OleDbDataReader reader, reader2;

            conn.Open();
            // verificarea existentei user-ului
            cmdselect2 = new OleDbCommand("SELECT Meniu.idMeniu, Meniu.NumeMeniu, Meniu.Pret FROM Meniu", conn);
            reader2    = cmdselect2.ExecuteReader();

            while (reader2.Read())
            {
                cboMeniu.Items.Add(reader2.GetValue(1).ToString());
                this.treeView1.Nodes.Add("'" + reader2.GetValue(1).ToString() + "' - '" + reader2.GetValue(2).ToString() + "' lei");
                i++;

                cmdSelect = new OleDbCommand(" SELECT MeniuPreparat.idMeniu, MeniuPreparat.idPreparat, Preparate.idPreparat, Preparate.NumePreparat from MeniuPreparat INNER JOIN Preparate on MeniuPreparat.idPreparat = Preparate.idPreparat where MeniuPreparat.idMeniu = @idMeniu", conn);
                cmdSelect.Parameters.AddWithValue("@idMeniu", reader2.GetValue(0));
                reader = cmdSelect.ExecuteReader();

                while (reader.Read())
                {
                    treeView1.Nodes[i - 1].Nodes.Add("'" + reader.GetValue(3).ToString() + "'");
                }
            }
            OleDbDataReader readerLocatii;

            cmdSelect     = new OleDbCommand("Select idLocatie, Denumire, Capacitate from Locatii", conn);
            readerLocatii = cmdSelect.ExecuteReader();

            while (readerLocatii.Read())
            {
                cboLocatii.Items.Add(readerLocatii.GetValue(1));
            }
            conn.Close();
        }
Exemplo n.º 16
0
 private void MeniuPersonalRestaurant_Preparate_Load(object sender, EventArgs e)
 {
     conectare.ConectareBazDate();
     conn = conectare.ConectareBazDate();
 }
Exemplo n.º 17
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.º 18
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();
            }
        }
Exemplo n.º 19
0
        private void Rezerva_Click(object sender, EventArgs e)
        {
            conn = conectare.ConectareBazDate();
            conn.Open();
            dateTimePicker1.Format       = DateTimePickerFormat.Custom;
            dateTimePicker1.CustomFormat = "MM/dd/yyyy hh:mm:ss";

            if (DateTime.Compare(dateTimePicker1.Value, DateTime.Today) < 0)
            {
                MessageBox.Show("Data si ora introduse trebuie sa fie mai mari decat data si ora curente");
            }
            else
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("Introduceti numarul persoanelor");
                }
                else
                {
                    OleDbCommand    cmdSelect;
                    OleDbDataReader reader;
                    int             suma = 0;

                    cmdSelect = new OleDbCommand("select NrPersoane, Data from RezervariRestaurant where Data between @Start and @Stop", conn);
                    cmdSelect.Parameters.AddWithValue("@Start", dateTimePicker1.Value.ToString());
                    cmdSelect.Parameters.AddWithValue("@Stop", dateTimePicker1.Value.AddHours(1).ToString());
                    reader = cmdSelect.ExecuteReader();
                    while (reader.Read())
                    {
                        suma = suma + Convert.ToInt32(reader.GetValue(0));
                    }

                    if (suma >= 150)
                    {
                        MessageBox.Show("Nu mai avem locuri disponibile pentru acest interval orar");
                    }
                    else
                    {
                        string           insert = "Insert into RezervariRestaurant([idCont],[Data],[NrPersoane]) values ('" + ContClient.ToString() + "','" + dateTimePicker1.Value + "','" + textBox1.Text + "')";
                        OleDbCommand     cmdInsert;
                        OleDbDataAdapter adapter = new OleDbDataAdapter();

                        cmdInsert = new OleDbCommand(insert, conn);

                        try
                        {
                            // inserarea in conturi

                            adapter.InsertCommand = new OleDbCommand(insert, conn);
                            adapter.InsertCommand.ExecuteNonQuery();
                            cmdInsert.Dispose();
                            MessageBox.Show("Rezervarea dumneavoastra a fost inregistrata");
                        }
                        catch (OleDbException ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
            }
        }
Exemplo n.º 20
0
        private void cboTip_SelectedIndexChanged(object sender, EventArgs e)
        {
            conn = conectare.ConectareBazDate();
            conn.Open();
            OleDbCommand    cmdSelect, cmdSelect2;
            OleDbDataReader reader, reader2;

            dataGridView1.Columns.Clear();
            int i = 0;

            Beneficii.Visible = false;

            if (cboTip.SelectedItem.ToString() == "Hotel")
            {
                dataGridView1.ColumnCount     = 6;
                dataGridView1.Columns[0].Name = "Nr";
                dataGridView1.Columns[1].Name = "Nr Camera";
                dataGridView1.Columns[2].Name = "Check in";
                dataGridView1.Columns[3].Name = "CheckOut";
                dataGridView1.Columns[4].Name = "Specificatii";
                dataGridView1.Columns[5].Name = "Pret";
                cmdSelect = new OleDbCommand("Select idRezervareCamera, NrCamera,DataStart, DataStop, Specificatii,Pret, idCont FROM RezervariCamere where idCont=@idCont", conn);
                cmdSelect.Parameters.AddWithValue("@idCont", this.ContClient);
                reader = cmdSelect.ExecuteReader();

                while (reader.Read())
                {
                    i++;
                    string[] row1 = new string[] { i.ToString(), reader.GetValue(1).ToString(), reader.GetValue(2).ToString(), reader.GetValue(3).ToString(), reader.GetValue(4).ToString(), reader.GetValue(5).ToString() };
                    dataGridView1.Rows.Add(row1);
                }
            }
            else
            {
                if (cboTip.SelectedItem.ToString() == "Evenimente")
                {
                    dataGridView1.ColumnCount        = 7;
                    dataGridView1.Columns[0].Name    = "Nr";
                    dataGridView1.Columns[1].Name    = "Tip Eveniment";
                    dataGridView1.Columns[2].Name    = "Locatie";
                    dataGridView1.Columns[3].Name    = "Data-Ora";
                    dataGridView1.Columns[4].Name    = "Perioada desfasurare";
                    dataGridView1.Columns[5].Name    = "Aprobare";
                    dataGridView1.Columns[6].Name    = "Id";
                    dataGridView1.Columns[6].Visible = false;

                    cmdSelect = new OleDbCommand("Select idSolicitare, idCont,idLocatie,TipEveniment, BeneficiiLimuzina, BeneficiiMuzica,BeneficiiAranjamentFloral, BeneficiiDansatori,BeneficiiAranjamentBaloane, BeneficiiAnimatori, Specificatii, Data, PerioadaDesfasurare,Aprobare, idMeniu FROM SolicitariEvenimente where idCont=@idCont", conn);
                    cmdSelect.Parameters.AddWithValue("@idCont", this.ContClient);
                    reader = cmdSelect.ExecuteReader();

                    while (reader.Read())
                    {
                        i++;
                        cmdSelect2 = new OleDbCommand("Select idLocatie, Denumire from Locatii where idLocatie=@idLoc", conn);
                        cmdSelect2.Parameters.AddWithValue("@idLoc", reader.GetValue(2));
                        reader2 = cmdSelect2.ExecuteReader();
                        reader2.Read();

                        string[] row1 = new string[] { i.ToString(), reader.GetValue(3).ToString(), reader2.GetValue(1).ToString(), reader.GetValue(11).ToString(), reader.GetValue(12).ToString(), reader.GetValue(13).ToString(), reader.GetValue(0).ToString() };
                        dataGridView1.Rows.Add(row1);
                    }
                }
                else
                {
                    if (cboTip.SelectedItem.ToString() == "Restaurant")
                    {
                        dataGridView1.ColumnCount     = 3;
                        dataGridView1.Columns[0].Name = "Nr";
                        dataGridView1.Columns[1].Name = "Data";
                        dataGridView1.Columns[2].Name = "Numar persoane";

                        cmdSelect = new OleDbCommand("Select Data, NrPersoane, idCont from RezervariRestaurant where idCont=@idCont", conn);
                        cmdSelect.Parameters.AddWithValue("@idCont", this.ContClient);
                        reader = cmdSelect.ExecuteReader();

                        while (reader.Read())
                        {
                            i++;
                            string[] row1 = new string[] { i.ToString(), reader.GetValue(0).ToString(), reader.GetValue(1).ToString() };
                            dataGridView1.Rows.Add(row1);
                        }
                    }
                }
            }
            conn.Close();
        }