예제 #1
0
        public List <SatisDetay> getForSatisID(int ID)
        {
            string            sorgu  = string.Format("select * from {0} where {1} = {2}", _Table, _SatisID, ID);
            SqlDataReader     reader = getReader(sorgu);
            List <SatisDetay> detays = new List <SatisDetay>();

            while (reader.Read())
            {
                detays.Add(new SatisDetay()
                {
                    ID          = reader[_ID].getValue <int>(),
                    SatısID     = reader[_SatisID].getValue <int>(),
                    UrunID      = reader[_UrunID].getValue <int>(),
                    Fiyat       = reader[_Fiyat].getValue <float>(),//float.Parse(reader[_Fiyat].ToString())
                    IndirimID   = reader[_IndirimID].getValue <int>(),
                    IndirimOran = reader[_IndirimOran].getValue <int>(),
                    Adet        = (int)reader[_Adet],
                });
            }
            reader.Close();
            UrunDatabase udatabase = new UrunDatabase();

            foreach (SatisDetay item in detays)
            {
                item.Urun = udatabase.GetForID(item.UrunID);
            }
            return(detays);
        }
예제 #2
0
        public override List <Satis> GetAll()
        {
            string        sorgu    = string.Format("select * from {0} ", _Table);
            List <Satis>  satislar = new List <Satis>();
            SqlDataReader reader   = getReader(sorgu);

            while (reader.Read())
            {
                satislar.Add(new Satis()
                {
                    ID           = (int)reader[_ID],
                    KullaniciID  = (int)reader[_KullaniciID],
                    Zaman        = (DateTime)reader[_Zaman],
                    SatisDurumID = (int)reader[_SatisDurumID],
                    KargoKod     = reader[_KargoKod].ToString(),
                    KargoDurum   = (bool)reader[_KargoDurum],
                    KargoUcret   = float.Parse(reader[_KargoUcret].ToString()),
                    AdresID      = (int)reader[_AdresID]
                });
            }
            reader.Close();
            AdresDatabase      adresDatabase = new AdresDatabase();
            SatisDetayDatabase satisdatabase = new SatisDetayDatabase();
            MusteriDatabase    kdatabase     = new MusteriDatabase();
            UrunDatabase       udatabase     = new UrunDatabase();

            foreach (Satis item in satislar)
            {
                item.Kullanici  = kdatabase.GetForID(item.KullaniciID);
                item.satisDetay = satisdatabase.getForSatisID(item.ID);
                float toplam = 0;
                int   adet   = 0;
                foreach (SatisDetay satisDetay in item.satisDetay)
                {
                    toplam += (satisDetay.Fiyat * satisDetay.Adet);
                    adet   += (satisDetay.Adet);
                }
                item.Adet   = adet;
                item.Toplam = toplam;
                item.Adres  = adresDatabase.GetForID(item.AdresID);
            }
            return(satislar);
        }
예제 #3
0
        public List <Satis> Arama(SatisArama arama)
        {
            string sorgu = "select * from Satis where ID in(select Satis.ID from Satis Join Kullanici on Satis.KullaniciID=Kullanici.ID where 1=1";

            if (arama.MusteriAdi != null && arama.MusteriAdi.Length != 0)
            {
                sorgu += string.Format(" and Kullanici.Adi like '%{0}%'", arama.MusteriAdi);
            }
            if (arama.Email != null && arama.Email.Length != 0)
            {
                sorgu += string.Format(" and Kullanici.Email like '%{0}%'", arama.Email);
            }
            if (arama.SatisDurum != 0)
            {
                sorgu += string.Format(" and Satis.SatisDurumID ={0}", arama.SatisDurum);
            }
            if (arama.SatisNo != 0)
            {
                sorgu += string.Format(" Satis.ID={0}", arama.SatisNo);
            }
            sorgu += ")";
            Debug.WriteLine(sorgu + "Sorgu ");
            SqlDataReader reader   = getReader(sorgu);
            List <Satis>  satislar = new List <Satis>();

            while (reader.Read())
            {
                satislar.Add(new Satis()
                {
                    ID           = (int)reader[_ID],
                    KullaniciID  = (int)reader[_KullaniciID],
                    Zaman        = (DateTime)reader[_Zaman],
                    SatisDurumID = (int)reader[_SatisDurumID],
                    KargoKod     = reader[_KargoKod].ToString(),
                    KargoDurum   = (bool)reader[_KargoDurum],
                    KargoUcret   = float.Parse(reader[_KargoUcret].ToString()),
                    AdresID      = (int)reader[_AdresID]
                });
            }
            reader.Close();
            AdresDatabase      adresDatabase = new AdresDatabase();
            SatisDetayDatabase satisdatabase = new SatisDetayDatabase();
            MusteriDatabase    kdatabase     = new MusteriDatabase();
            UrunDatabase       udatabase     = new UrunDatabase();

            foreach (Satis item in satislar)
            {
                item.Kullanici  = kdatabase.GetForID(item.KullaniciID);
                item.satisDetay = satisdatabase.getForSatisID(item.ID);
                float toplam = 0;
                int   adet   = 0;
                foreach (SatisDetay satisDetay in item.satisDetay)
                {
                    toplam += (satisDetay.Fiyat * satisDetay.Adet);
                    adet   += (satisDetay.Adet);
                }
                item.Adet   = adet;
                item.Toplam = toplam;
                item.Adres  = adresDatabase.GetForID(item.AdresID);
            }
            return(satislar);
        }