Пример #1
0
        private void btnInapoi_Click(object sender, EventArgs e)
        {
            this.Hide();
            var MeniuPersonal = new MeniuPersonalRestaurant_Meniuri(ContPersonal);

            MeniuPersonal.ShowDialog();
            this.Close();
        }
Пример #2
0
        private void btn_meniuri_Click_1(object sender, EventArgs e)
        {
            this.Hide();
            var vizualizareMeniu = new MeniuPersonalRestaurant_Meniuri(cont);

            vizualizareMeniu.ShowDialog();
            this.Close();
        }
        private void btn_salveaza_Click_1(object sender, EventArgs e)
        {
            String numeMeniu = txtNume.Text;
            String pret      = txtPret.Text;

            lblErrorNume.Text = "";
            lblErrorPret.Text = "";



            if (numeMeniu == "")
            {
                lblErrorNume.Text = "Denumirea meniului este obligatorie!";
            }
            else if (pret == "")
            {
                lblErrorNume.Text = "Pretul meniului este obligatorie!";
            }
            else
            {
                // TO TO: Inregistrarea noului utilizator
                OleDbCommand cmdSelect, cmdInsert, cmdInsertDetalii;


                string          insert, insertDetalii;
                OleDbDataReader reader;

                insert = "INSERT INTO Meniu([NumeMeniu],[Pret]) VALUES ('" + txtNume.Text + "','" + txtPret.Text + "')";

                cmdInsert = new OleDbCommand(insert, conn);

                OleDbDataAdapter adapter = new OleDbDataAdapter();

                try
                {
                    // inserarea in meniu
                    conn.Open();
                    adapter.InsertCommand = new OleDbCommand(insert, conn);
                    adapter.InsertCommand.ExecuteNonQuery();
                    cmdInsert.Dispose();

                    // inserarea in meniuPreparat
                    cmdSelect = new OleDbCommand("SELECT idMeniu FROM Meniu where Meniu.idMeniu = @Meniu", conn);
                    cmdSelect.Parameters.AddWithValue("@Meniu", this.txtNume.Text);
                    reader = cmdSelect.ExecuteReader();

                    reader.Read();

                    /*
                     * var contMeniu = reader.GetValue(0);
                     *
                     * int numar = chLB_preparate.CheckedItems.Count;
                     * for(int i =0; i<=numar; i++)
                     * {
                     *  insertDetalii = "INSERT INTO MeniuPreparate([idMeniu],[idPreparat]) VALUES ('" + contMeniu + "' , '" + chLB_preparate.CheckedItems[i] + "')";
                     *  cmdInsertDetalii = new OleDbCommand(insertDetalii, conn);
                     *  adapter.InsertCommand = new OleDbCommand(insertDetalii, conn);
                     *  adapter.InsertCommand.ExecuteNonQuery();
                     *  cmdInsertDetalii.Dispose();
                     * }
                     */

                    MessageBox.Show("Meniul a fost adaugat!");
                    conn.Close();

                    //deschidere meniu

                    this.Hide();
                    var meniu = new MeniuPersonalRestaurant_Meniuri(ContPersonal);
                    meniu.ShowDialog();
                    this.Close();
                }
                catch (OleDbException ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }