public bool ArabaGuncelle(Araba araba)
        {
            bool sonuc;

            try
            {
                mysqlbaglan.Open();

                string sorgu = "UPDATE `tbl_araba` SET `Araba_Marka`='" + araba.Araba_Marka + "', `Araba_Model`='" + araba.Araba_Model + "',  `Araba_VitesTuruID`='" + araba.Araba_VitesTuruID + "', `Araba_YakitTuruID`='" + araba.Araba_YakitTuruID + "', `Araba_RenkID`='" + araba.Araba_RenkID + "' WHERE  `ArabaID`='" + araba.ArabaID + "'";

                MySqlCommand komut = new MySqlCommand(sorgu, mysqlbaglan);

                int islemSonucu = komut.ExecuteNonQuery();
                if (islemSonucu == 1)
                {
                    sonuc = true;
                }
                else
                {
                    sonuc = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("HATA: " + ex.Message);
                sonuc = false;
            }
            finally
            {
                mysqlbaglan.Close();
            }

            return(sonuc);
        }
        public bool ArabaSil(Araba araba)
        {
            bool sonuc;

            try
            {
                mysqlbaglan.Open();

                string sorgu = "DELETE FROM `tbl_araba` WHERE `tbl_araba`.`ArabaID` =" + araba.ArabaID;

                MySqlCommand komut = new MySqlCommand(sorgu, mysqlbaglan);

                int islemSonucu = komut.ExecuteNonQuery();
                if (islemSonucu == 1)
                {
                    sonuc = true;
                }
                else
                {
                    sonuc = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("HATA: " + ex.Message);
                sonuc = false;
            }
            finally
            {
                mysqlbaglan.Close();
            }

            return(sonuc);
        }
        private void button_araba_sil_Click(object sender, EventArgs e)
        {
            Araba nesne = new Araba()
            {
                ArabaID = (comboBox_araba_ID.SelectedIndex != -1) ? Convert.ToInt32(comboBox_araba_ID.Text) : 1,
            };

            DB_Sil dbIslem = new DB_Sil();
            bool   result  = dbIslem.ArabaSil(nesne);

            SonucGoster(result);
        }
        private void button_araba_getir_Click(object sender, EventArgs e)
        {
            int arabaSirasi = comboBox_araba_ID.SelectedIndex;

            Araba secilen = arabalar[arabaSirasi];

            textBox_araba_marka.Text  = secilen.Araba_Marka;
            textBox_araba_model.Text  = secilen.Araba_Model;
            textBox_araba_renkID.Text = secilen.Araba_RenkID + "";
            textBox_araba_vtID.Text   = secilen.Araba_VitesTuruID + "";
            textBox_araba_ytID.Text   = secilen.Araba_YakitTuruID + "";
        }
        private void button_araba_guncelle_Click(object sender, EventArgs e)
        {
            Araba nesne = new Araba()
            {
                ArabaID           = (comboBox_araba_ID.SelectedIndex != -1) ? Convert.ToInt32(comboBox_araba_ID.Text) : 1,
                Araba_Marka       = textBox_araba_marka.Text,
                Araba_Model       = textBox_araba_model.Text,
                Araba_RenkID      = Convert.ToInt32(textBox_araba_renkID.Text),
                Araba_VitesTuruID = Convert.ToInt32(textBox_araba_vtID.Text),
                Araba_YakitTuruID = Convert.ToInt32(textBox_araba_ytID.Text),
            };

            DB_Guncelle dbIslem = new DB_Guncelle();
            bool        result  = dbIslem.ArabaGuncelle(nesne);

            SonucGoster(result);
        }
        public List <Araba> ArabaListele()
        {
            List <Araba> liste = null;

            try
            {
                mysqlbaglan.Open();

                string sorgu = "SELECT * FROM `tbl_araba`";

                MySqlCommand    komut = new MySqlCommand(sorgu, mysqlbaglan);
                MySqlDataReader oku   = komut.ExecuteReader();

                liste = new List <Araba>();
                while (oku.Read())
                {
                    Araba nesne = new Araba()
                    {
                        ArabaID           = oku.GetInt32("ArabaID"),
                        Araba_Marka       = oku.GetString("Araba_Marka"),
                        Araba_Model       = oku.GetString("Araba_Model"),
                        Araba_RenkID      = oku.GetInt32("Araba_RenkID"),
                        Araba_VitesTuruID = oku.GetInt32("Araba_VitesTuruID"),
                        Araba_YakitTuruID = oku.GetInt32("Araba_YakitTuruID")
                    };

                    liste.Add(nesne);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("HATA: " + ex.Message);
            }
            finally
            {
                mysqlbaglan.Close();
            }

            return(liste);
        }
Exemple #7
0
        public bool ArabaEkle(Araba araba)
        {
            bool sonuc;

            try
            {
                mysqlbaglan.Open();


                string sorgu = "INSERT INTO `tbl_araba` (`ArabaID`, `Araba_Marka`, `Araba_Model`, `Araba_VitesTuruID`, `Araba_YakitTuruID`, `Araba_RenkID`)"
                               + " VALUES (NULL, '" + araba.Araba_Marka + "', '" + araba.Araba_Model + "', '" + araba.Araba_VitesTuruID + "', '" + araba.Araba_YakitTuruID + "', '" + araba.Araba_RenkID + "')";


                MySqlCommand komut = new MySqlCommand(sorgu, mysqlbaglan);

                int islemSonucu = komut.ExecuteNonQuery();
                if (islemSonucu == 1)
                {
                    sonuc = true;
                }
                else
                {
                    sonuc = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("HATA: " + ex.Message);
                sonuc = false;
            }
            finally
            {
                mysqlbaglan.Close();
            }

            return(sonuc);
        }