I can't access the variable in the structure from within the class
-
While I can read/write the 'mSepetler' variable from the three methods I marked in the picture, why can't I read/write from the method I marked in red?

@mamoo said in I can't access the variable in the structure from within the class:
why can't I read/write from the method I marked in red?
What happens if you try? How is that method implemented?
-
@mamoo said in I can't access the variable in the structure from within the class:
why can't I read/write from the method I marked in red?
What happens if you try? How is that method implemented?
-
@mamoo Please post code as text, not screen shots!
You also did not say what happens! So, again: what happens (any error messages?)?@jsulm I translate from google translate because my english is almost non-existent. I am sorry. it doesn't give any error message. it just reads my array variable 'mSepetler' as empty. However, I can read/write in 3 methods that I marked in the first picture I took.
void SepetYonetimi::sepetiSat(const int pSepetIndex, const int pKullaniciID, const int pSatilanCariID, const double pOdenenTutar) { QString FaturaNo = yeniFaturaNo(); //yeni fatura bilgisi girme başlangıcı sorgu.prepare("INSERT INTO faturalar (id, fatura_no, cari, tipi, tarih, kullanici, toplamtutar, odenentutar, kalantutar, odemetipi) " "VALUES (nextval('faturalar_sequence'), ?, ?, ?, ?, ?, ?, ?, ?, ?)"); sorgu.bindValue(0, FaturaNo); sorgu.bindValue(1, pSatilanCariID); sorgu.bindValue(2, 2);// 2 = satış faturası (veritabanında faturatipleri.tip) sorgu.bindValue(3, QDateTime::currentDateTime()); sorgu.bindValue(4, pKullaniciID); sorgu.bindValue(5, mSepetler[pSepetIndex].toplamTutar); // sepet toplam tutarı qDebug() << mSepetler[pSepetIndex].toplamTutar; if(pOdenenTutar > mSepetler[pSepetIndex].toplamTutar){// ödenen tutar sepet toplamından büyükse sorgu.bindValue(6, mSepetler[pSepetIndex].toplamTutar);// sepet toplam tutarı mSepetler[pSepetIndex].kalanTutar = 0; } else if(pOdenenTutar <= mSepetler[pSepetIndex].toplamTutar){// ödenen tutar sepet toplam tutarından küçükse sorgu.bindValue(6, pOdenenTutar);// ödenen tutar mSepetler[pSepetIndex].kalanTutar += mSepetler[pSepetIndex].toplamTutar - pOdenenTutar; // kalan tutarı hesaplama } sorgu.bindValue(7, mSepetler[pSepetIndex].kalanTutar);// kalan tutar sorgu.bindValue(8, 1);//nakit ödeme tipinde satış sorgu.exec(); if(sorgu.lastError().isValid()){ qDebug() << qPrintable(sorgu.lastError().text()); } //kasa hareketi girme ve kasaya ödenen para kadar giriş if(pOdenenTutar > 0){// kasanın tutması için. cariye veresiye kaydedecekse odenen tutar 0 dan büyükse // odenen para büyük veya eşitse sepettoplamtutarina sepetin tamamı ödendi demek. if(pOdenenTutar >= mSepetler[pSepetIndex].toplamTutar){ kasaHareketiEkle(pKullaniciID, KasaHareketi::Giris, mSepetler[pSepetIndex].toplamTutar, "SATIŞ FAT.NO:" + FaturaNo, mSepetler[pSepetIndex].kazanc); // if(satilacakSepet.getFazlaTutarAlacaklandir()){ // //yeni alış fatura bilgisi girme başlangıcı cariYonetimi classını bu sayfaya ekleyemediğim için böyle geçici çözdüm. // double fazlaTutar = satilacakSepet.getOdenenTutar() - satilacakSepet.sepetToplamTutari(); // sorgu.prepare("INSERT INTO faturalar(id, fatura_no, cari, tipi, tarih, kullanici, toplamtutar, odenentutar, kalantutar, evrakno, aciklama, odemetipi) " // "VALUES (nextval('faturalar_sequence'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); // sorgu.bindValue(0, yeniFaturaNo()); // sorgu.bindValue(1, satisYapilanCariID); // sorgu.bindValue(2, 1); // sorgu.bindValue(3, QDateTime::currentDateTime()); // sorgu.bindValue(4, satisYapanKullanici.getUserID()); // sorgu.bindValue(5, fazlaTutar); // sorgu.bindValue(6, 0); // sorgu.bindValue(7, fazlaTutar); // sorgu.bindValue(8, ""); // sorgu.bindValue(9, FaturaNo + "'lu işlemde fazla ödenen tutar alacaklandirildi"); // sorgu.bindValue(10, 1); // sorgu.exec(); // if(sorgu.lastError().isValid()){ // qDebug() << qPrintable(sorgu.lastError().text()); // } // } //******************************************************** } // odenen para küçükse sepettoplamtutarindan sepet eksik veya veresiye ödendi. if(pOdenenTutar < mSepetler[pSepetIndex].toplamTutar){ kasaHareketiEkle(pKullaniciID, KasaHareketi::Giris, pOdenenTutar, "SATIŞ FAT.NO:" + FaturaNo, mSepetler[pSepetIndex].kazanc);// veresiye veya eksik ödediği için kar olarak eklemiyorum. } }
-
@jsulm I translate from google translate because my english is almost non-existent. I am sorry. it doesn't give any error message. it just reads my array variable 'mSepetler' as empty. However, I can read/write in 3 methods that I marked in the first picture I took.
void SepetYonetimi::sepetiSat(const int pSepetIndex, const int pKullaniciID, const int pSatilanCariID, const double pOdenenTutar) { QString FaturaNo = yeniFaturaNo(); //yeni fatura bilgisi girme başlangıcı sorgu.prepare("INSERT INTO faturalar (id, fatura_no, cari, tipi, tarih, kullanici, toplamtutar, odenentutar, kalantutar, odemetipi) " "VALUES (nextval('faturalar_sequence'), ?, ?, ?, ?, ?, ?, ?, ?, ?)"); sorgu.bindValue(0, FaturaNo); sorgu.bindValue(1, pSatilanCariID); sorgu.bindValue(2, 2);// 2 = satış faturası (veritabanında faturatipleri.tip) sorgu.bindValue(3, QDateTime::currentDateTime()); sorgu.bindValue(4, pKullaniciID); sorgu.bindValue(5, mSepetler[pSepetIndex].toplamTutar); // sepet toplam tutarı qDebug() << mSepetler[pSepetIndex].toplamTutar; if(pOdenenTutar > mSepetler[pSepetIndex].toplamTutar){// ödenen tutar sepet toplamından büyükse sorgu.bindValue(6, mSepetler[pSepetIndex].toplamTutar);// sepet toplam tutarı mSepetler[pSepetIndex].kalanTutar = 0; } else if(pOdenenTutar <= mSepetler[pSepetIndex].toplamTutar){// ödenen tutar sepet toplam tutarından küçükse sorgu.bindValue(6, pOdenenTutar);// ödenen tutar mSepetler[pSepetIndex].kalanTutar += mSepetler[pSepetIndex].toplamTutar - pOdenenTutar; // kalan tutarı hesaplama } sorgu.bindValue(7, mSepetler[pSepetIndex].kalanTutar);// kalan tutar sorgu.bindValue(8, 1);//nakit ödeme tipinde satış sorgu.exec(); if(sorgu.lastError().isValid()){ qDebug() << qPrintable(sorgu.lastError().text()); } //kasa hareketi girme ve kasaya ödenen para kadar giriş if(pOdenenTutar > 0){// kasanın tutması için. cariye veresiye kaydedecekse odenen tutar 0 dan büyükse // odenen para büyük veya eşitse sepettoplamtutarina sepetin tamamı ödendi demek. if(pOdenenTutar >= mSepetler[pSepetIndex].toplamTutar){ kasaHareketiEkle(pKullaniciID, KasaHareketi::Giris, mSepetler[pSepetIndex].toplamTutar, "SATIŞ FAT.NO:" + FaturaNo, mSepetler[pSepetIndex].kazanc); // if(satilacakSepet.getFazlaTutarAlacaklandir()){ // //yeni alış fatura bilgisi girme başlangıcı cariYonetimi classını bu sayfaya ekleyemediğim için böyle geçici çözdüm. // double fazlaTutar = satilacakSepet.getOdenenTutar() - satilacakSepet.sepetToplamTutari(); // sorgu.prepare("INSERT INTO faturalar(id, fatura_no, cari, tipi, tarih, kullanici, toplamtutar, odenentutar, kalantutar, evrakno, aciklama, odemetipi) " // "VALUES (nextval('faturalar_sequence'), ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); // sorgu.bindValue(0, yeniFaturaNo()); // sorgu.bindValue(1, satisYapilanCariID); // sorgu.bindValue(2, 1); // sorgu.bindValue(3, QDateTime::currentDateTime()); // sorgu.bindValue(4, satisYapanKullanici.getUserID()); // sorgu.bindValue(5, fazlaTutar); // sorgu.bindValue(6, 0); // sorgu.bindValue(7, fazlaTutar); // sorgu.bindValue(8, ""); // sorgu.bindValue(9, FaturaNo + "'lu işlemde fazla ödenen tutar alacaklandirildi"); // sorgu.bindValue(10, 1); // sorgu.exec(); // if(sorgu.lastError().isValid()){ // qDebug() << qPrintable(sorgu.lastError().text()); // } // } //******************************************************** } // odenen para küçükse sepettoplamtutarindan sepet eksik veya veresiye ödendi. if(pOdenenTutar < mSepetler[pSepetIndex].toplamTutar){ kasaHareketiEkle(pKullaniciID, KasaHareketi::Giris, pOdenenTutar, "SATIŞ FAT.NO:" + FaturaNo, mSepetler[pSepetIndex].kazanc);// veresiye veya eksik ödediği için kar olarak eklemiyorum. } }
@mamoo said in I can't access the variable in the structure from within the class:
it just reads my array variable 'mSepetler' as empty
What exactly is "empty"?
The array itself is for sure not empty as it has fixed size of 4 elements.
You should really provide more details.
