예제 #1
0
        private void Btn_AjandekTorlese_Click(object sender, EventArgs e)
        {
            Ajandek ajandek = (Ajandek)ajandekListBox.SelectedItem;

            try
            {
                string          sql = "DELETE FROM ajandek WHERE id = '" + ajandek.Id + "';";
                MySqlDataReader reader;
                reader = new MySqlCommand(sql, conn).ExecuteReader();
                while (reader.Read())
                {
                }
                reader.Close();
                ajandekListBox.Items.Clear();
                AdatBetoltes();
                ajandekListBox.SelectedIndex  = -1;
                TxtBox_AjandekNev.Text        = "Ajándék neve";
                TxtBox_AjandekNev.ForeColor   = Color.Gray;
                TxtBox_AjandekUzlet.Text      = "Üzlet neve";
                TxtBox_AjandekUzlet.ForeColor = Color.Gray;

                LBL_AjandekID.Text    = "ID: ";
                LBL_AjandekNev.Text   = "Név: ";
                LBL_AjandekUzlet.Text = "Üzlet neve: ";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
        void AdatBetoltes()
        {
            string sql  = @"SELECT id, nev, uzlet FROM ajandek ORDER BY nev";
            var    comm = this.conn.CreateCommand();

            comm.CommandText = sql;
            using (var reader = comm.ExecuteReader())
            {
                while (reader.Read())
                {
                    int    id  = reader.GetInt32("id");
                    string nev = reader.GetString("nev");

                    string uzlet;
                    try
                    {
                        uzlet = reader.GetString("uzlet");
                    }
                    catch (SqlNullValueException ex)
                    {
                        uzlet = null;
                    }
                    var ajandek = new Ajandek(id, nev, uzlet);
                    ajandekListBox.Items.Add(ajandek);
                }
            }
        }
예제 #3
0
        private void ajandekListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            Ajandek ajandek = (Ajandek)ajandekListBox.SelectedItem;

            TxtBox_AjandekNev.Text      = ajandek.Nev;
            TxtBox_AjandekNev.ForeColor = Color.Black;
            if (ajandek.Uzlet == "")
            {
                TxtBox_AjandekUzlet.Text      = "Saját készítésű";
                TxtBox_AjandekUzlet.ForeColor = Color.Gray;
            }
            else
            {
                TxtBox_AjandekUzlet.Text      = ajandek.Uzlet;
                TxtBox_AjandekUzlet.ForeColor = Color.Black;
            }

            LBL_AjandekID.Text    = "ID: ";
            LBL_AjandekNev.Text   = "Név: ";
            LBL_AjandekUzlet.Text = "Üzlet neve: ";
            LBL_AjandekID.Text   += ajandek.Id.ToString();
            LBL_AjandekNev.Text  += ajandek.Nev;
            if (ajandek.Uzlet == "")
            {
                LBL_AjandekUzlet.Text += "Saját készítésű";
            }
            else
            {
                LBL_AjandekUzlet.Text += ajandek.Uzlet;
            }
            Btn_AjandekHozzaadas.Text = "Ajándék módosítása";

            if (ajandekListBox.SelectedIndex != -1)
            {
                Btn_AjandekTorlese.Enabled = true;
            }
        }