Ejemplo n.º 1
0
        protected void fillOffers()
        {
            clearScreen();
            Database      db     = new Database();
            List <Ponuda> offers = db.getAllOffersForUsername(Session["UserName"].ToString(),
                                                              Ponuda.DATE);

            if (offers == null)
            {
                return;
            }

            if (offers.Count == 0)
            {
                Response.Write("<div class='alert alert-warning'>" +
                               "<strong>Внимание!</strong> Оваа порака се испишува само во случај кога нема понуди кои што вас би ве интересирале<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a> </div>");
            }
            foreach (Ponuda o in offers)
            {
                offer offerElem = (offer)LoadControl("offer.ascx");
                Album a         = db.getAlbumByID(o.AlbumID);
                Slika s         = db.getPicture(o.AlbumID, o.BrojSlika);
                offerElem.imgUrl      = s.Url;
                offerElem.Name        = o.BrojSlika + " - " + o.Name + " " + a.Year;
                offerElem.Owner       = o.Username;
                offerElem.Description = o.Desc;
                offerElem.Price       = o.Price;
                offerElem.Trust       = 5;
                offerElem.Datum       = o.Datum;
                offerElem.thisPonuda  = o;
                repeaterHomepage.Controls.Add(offerElem);
            }
        }
Ejemplo n.º 2
0
        protected void fillOffers()
        {
            clearScreen();
            Database db = new Database();
            List<Ponuda> offers = db.getAllOffersForUsername(Session["UserName"].ToString(),
                Ponuda.DATE);

            if (offers == null) return;

            if (offers.Count == 0)
            {
                Response.Write("<div class='alert alert-warning'>" +
            "<strong>Внимание!</strong> Оваа порака се испишува само во случај кога нема понуди кои што вас би ве интересирале<a href='#' class='close' data-dismiss='alert' aria-label='close'>&times;</a> </div>");
            }
            foreach (Ponuda o in offers)
            {
                offer offerElem = (offer)LoadControl("offer.ascx");
                Album a = db.getAlbumByID(o.AlbumID);
                Slika s = db.getPicture(o.AlbumID, o.BrojSlika);
                offerElem.imgUrl = s.Url;
                offerElem.Name = o.BrojSlika + " - " + o.Name + " " + a.Year;
                offerElem.Owner = o.Username;
                offerElem.Description = o.Desc;
                offerElem.Price = o.Price;
                offerElem.Trust = 5;
                offerElem.Datum = o.Datum;
                offerElem.thisPonuda = o;
                repeaterHomepage.Controls.Add(offerElem);
            }
        }
Ejemplo n.º 3
0
        private string getImageUrl(int albumID, int pictureID)
        {
            Database db = new Database();
            Slika    s  = db.getPicture(albumID, pictureID);

            if (s != null)
            {
                return(s.Url);
            }
            return("");
        }
Ejemplo n.º 4
0
        protected void fillTransakcii()
        {
            clearScreen();
            Database           db = new Database();
            List <Transakcija> transakcii;
            int tab = -1;

            if (ViewState["tab"] != null)
            {
                Int32.TryParse(ViewState["tab"].ToString(), out tab);
            }

            if (tab != -1)
            {
                if (tab == 0)
                {
                    transakcii = db.getAllTransakciiKupuvamForUsername(Session["UserName"].ToString(),
                                                                       Ponuda.DATE);
                }
                else if (tab == 1)
                {
                    transakcii = db.getAllTransakciiProdavamForUsername(Session["UserName"].ToString(),
                                                                        Ponuda.DATE);
                }
                // TODO: ovde za istorija
                else
                {
                    transakcii = db.getAllTransakciiHistoryForUsername(Session["UserName"].ToString(),
                                                                       Ponuda.DATE);
                }
            }
            else
            {
                return;
            }

            if (transakcii == null)
            {
                return;
            }
            foreach (Transakcija t in transakcii)
            {
                if (tab == 1)            // Prodavam opcii
                {
                    if (t.AlbumID == -1) //E obicna buy transakcija
                    {
                        transakciiElementHalfProdavam tranElem = (transakciiElementHalfProdavam)LoadControl("transakciiElementHalfProdavam.ascx");
                        Ponuda   p    = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika    s    = db.getPicture(p.AlbumID, p.BrojSlika);
                        Album    a    = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear    = a.Year;
                        tranElem.imgID_1      = s.Broj;
                        tranElem.Name1        = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1       = user.Email;
                        tranElem.Price1       = p.Price;
                        tranElem.Offer1ID     = p.AlbumID;
                        tranElem.User1        = t.Username;
                        tranElem.imgUrl_1     = s.Url;
                        tranElem.Date         = t.Datum;
                        tranElem.tranID       = t.ID;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                    else
                    {
                        transakciiExchangeElementHalfProdavam tranElem = (transakciiExchangeElementHalfProdavam)LoadControl("transakciiExchangeProdavam.ascx");
                        Ponuda   p        = db.getOffer(t.ID);
                        Korisnik user     = db.getUserInfoByUsername(t.Username);
                        Slika    s_moja   = db.getPicture(p.AlbumID, p.BrojSlika);
                        Slika    s_zamena = db.getPicture(t.AlbumID, t.PictureID);
                        Album    a        = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear    = a.Year;
                        tranElem.Name1        = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1       = user.Email;
                        tranElem.Price1       = p.Price;
                        tranElem.Offer1ID     = p.AlbumID;
                        tranElem.User1        = t.Username;
                        tranElem.Date         = t.Datum;
                        tranElem.imgUrl_1     = s_moja.Url;
                        tranElem.imgID_1      = s_moja.Broj;
                        tranElem.tranID       = t.ID;

                        tranElem.imgUrl_2 = s_zamena.Url;
                        tranElem.imgID_2  = s_zamena.Broj;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                }
                else if (tab == 0)
                {
                    if (t.AlbumID == -1)//E obicna buy transakcija
                    {
                        transakciiExchangeElementHalf tranElem = (transakciiExchangeElementHalf)LoadControl("transakciiExchange.ascx");
                        Ponuda   p    = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika    s    = db.getPicture(p.AlbumID, p.BrojSlika);
                        Album    a    = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear    = a.Year;
                        tranElem.imgID_1      = s.Broj;
                        tranElem.Name1        = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1       = user.Email;
                        tranElem.Price1       = p.Price;
                        tranElem.Offer1ID     = p.AlbumID;
                        tranElem.User1        = t.Username;
                        tranElem.imgUrl_1     = s.Url;
                        tranElem.Date         = t.Datum;
                        tranElem.tranID       = t.ID;
                        tranElem.Status       = t.Status;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                    else
                    {
                        transakciiElement tranElem = (transakciiElement)LoadControl("transakciiElement.ascx");
                        Ponuda            p        = db.getOffer(t.ID);
                        Korisnik          user     = db.getUserInfoByUsername(t.Username);
                        Slika             s_moja   = db.getPicture(p.AlbumID, p.BrojSlika);
                        Slika             s_zamena = db.getPicture(t.AlbumID, t.PictureID);
                        Album             a        = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear    = a.Year;
                        tranElem.Name1        = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1       = user.Email;
                        tranElem.Price1       = p.Price;
                        tranElem.Offer1ID     = p.AlbumID;
                        tranElem.User1        = t.Username;
                        tranElem.Date         = t.Datum;
                        tranElem.imgUrl_1     = s_moja.Url;
                        tranElem.imgID_1      = s_moja.Broj;
                        tranElem.tranID       = t.ID;
                        tranElem.Status       = t.Status;
                        tranElem.imgUrl_2     = s_zamena.Url;
                        tranElem.imgID_2      = s_zamena.Broj;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                }
                else
                {                        // history
                    if (t.AlbumID == -1) //E obicna buy transakcija
                    {
                        transakciiExchangeElementHalf tranElem = (transakciiExchangeElementHalf)LoadControl("transakciiExchange.ascx");
                        Ponuda   p    = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika    s    = db.getPicture(p.AlbumID, p.BrojSlika);
                        Album    a    = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear    = a.Year;
                        tranElem.imgID_1      = s.Broj;
                        tranElem.Name1        = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1       = user.Email;
                        tranElem.Price1       = p.Price;
                        tranElem.Offer1ID     = p.AlbumID;
                        tranElem.User1        = t.Username;
                        tranElem.imgUrl_1     = s.Url;
                        tranElem.Date         = t.Datum;
                        tranElem.tranID       = t.ID;
                        tranElem.Status       = t.Status;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                    else
                    {
                        transakciiElement tranElem = (transakciiElement)LoadControl("transakciiElement.ascx");
                        Ponuda            p        = db.getOffer(t.ID);
                        Korisnik          user     = db.getUserInfoByUsername(t.Username);
                        Slika             s_moja   = db.getPicture(p.AlbumID, p.BrojSlika);
                        Slika             s_zamena = db.getPicture(t.AlbumID, t.PictureID);
                        Album             a        = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear    = a.Year;
                        tranElem.Name1        = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1       = user.Email;
                        tranElem.Price1       = p.Price;
                        tranElem.Offer1ID     = p.AlbumID;
                        tranElem.User1        = t.Username;
                        tranElem.Date         = t.Datum;
                        tranElem.imgUrl_1     = s_moja.Url;
                        tranElem.imgID_1      = s_moja.Broj;
                        tranElem.tranID       = t.ID;

                        tranElem.imgUrl_2 = s_zamena.Url;
                        tranElem.imgID_2  = s_zamena.Broj;

                        tranElem.Status = t.Status;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                }

                //repeaterTransakcii.Controls.Add(tranElem);
            }
        }
Ejemplo n.º 5
0
        protected void fillTransakcii()
        {
            clearScreen();
            Database db = new Database();
            List<Transakcija> transakcii;
            int tab = -1;
            if (ViewState["tab"] != null)
                Int32.TryParse(ViewState["tab"].ToString(), out tab);

            if (tab != -1)
            {
                if (tab == 0)
                    transakcii = db.getAllTransakciiKupuvamForUsername(Session["UserName"].ToString(),
                Ponuda.DATE);
                else if (tab == 1)
                    transakcii = db.getAllTransakciiProdavamForUsername(Session["UserName"].ToString(),
                Ponuda.DATE);
                // TODO: ovde za istorija
                else
                {
                    transakcii = db.getAllTransakciiHistoryForUsername(Session["UserName"].ToString(),
                Ponuda.DATE);

                }
            }
            else return;

            if (transakcii == null) return;
            foreach (Transakcija t in transakcii)
            {
                if (tab == 1) // Prodavam opcii
                {
                    if (t.AlbumID == -1)//E obicna buy transakcija
                    {
                        transakciiElementHalfProdavam tranElem = (transakciiElementHalfProdavam)LoadControl("transakciiElementHalfProdavam.ascx");
                        Ponuda p = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika s = db.getPicture(p.AlbumID, p.BrojSlika);
                        Album a = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear = a.Year;
                        tranElem.imgID_1 = s.Broj;
                        tranElem.Name1 = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1 = user.Email;
                        tranElem.Price1 = p.Price;
                        tranElem.Offer1ID = p.AlbumID;
                        tranElem.User1 = t.Username;
                        tranElem.imgUrl_1 = s.Url;
                        tranElem.Date = t.Datum;
                        tranElem.tranID = t.ID;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                    else
                    {
                        transakciiExchangeElementHalfProdavam tranElem = (transakciiExchangeElementHalfProdavam)LoadControl("transakciiExchangeProdavam.ascx");
                        Ponuda p = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika s_moja = db.getPicture(p.AlbumID, p.BrojSlika);
                        Slika s_zamena = db.getPicture(t.AlbumID, t.PictureID);
                        Album a = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear = a.Year;
                        tranElem.Name1 = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1 = user.Email;
                        tranElem.Price1 = p.Price;
                        tranElem.Offer1ID = p.AlbumID;
                        tranElem.User1 = t.Username;
                        tranElem.Date = t.Datum;
                        tranElem.imgUrl_1 = s_moja.Url;
                        tranElem.imgID_1 = s_moja.Broj;
                        tranElem.tranID = t.ID;

                        tranElem.imgUrl_2 = s_zamena.Url;
                        tranElem.imgID_2 = s_zamena.Broj;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                }
                else if(tab == 0)
                {
                    if (t.AlbumID == -1)//E obicna buy transakcija
                    {
                        transakciiExchangeElementHalf tranElem = (transakciiExchangeElementHalf)LoadControl("transakciiExchange.ascx");
                        Ponuda p = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika s = db.getPicture(p.AlbumID, p.BrojSlika);
                        Album a = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear = a.Year;
                        tranElem.imgID_1 = s.Broj;
                        tranElem.Name1 = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1 = user.Email;
                        tranElem.Price1 = p.Price;
                        tranElem.Offer1ID = p.AlbumID;
                        tranElem.User1 = t.Username;
                        tranElem.imgUrl_1 = s.Url;
                        tranElem.Date = t.Datum;
                        tranElem.tranID = t.ID;
                        tranElem.Status = t.Status;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                    else
                    {

                        transakciiElement tranElem = (transakciiElement)LoadControl("transakciiElement.ascx");
                        Ponuda p = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika s_moja = db.getPicture(p.AlbumID, p.BrojSlika);
                        Slika s_zamena = db.getPicture(t.AlbumID, t.PictureID);
                        Album a = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear = a.Year;
                        tranElem.Name1 = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1 = user.Email;
                        tranElem.Price1 = p.Price;
                        tranElem.Offer1ID = p.AlbumID;
                        tranElem.User1 = t.Username;
                        tranElem.Date = t.Datum;
                        tranElem.imgUrl_1 = s_moja.Url;
                        tranElem.imgID_1 = s_moja.Broj;
                        tranElem.tranID = t.ID;
                        tranElem.Status = t.Status;
                        tranElem.imgUrl_2 = s_zamena.Url;
                        tranElem.imgID_2 = s_zamena.Broj;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                }
                else
                { // history
                    if (t.AlbumID == -1)//E obicna buy transakcija
                    {
                        transakciiExchangeElementHalf tranElem = (transakciiExchangeElementHalf)LoadControl("transakciiExchange.ascx");
                        Ponuda p = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika s = db.getPicture(p.AlbumID, p.BrojSlika);
                        Album a = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear = a.Year;
                        tranElem.imgID_1 = s.Broj;
                        tranElem.Name1 = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1 = user.Email;
                        tranElem.Price1 = p.Price;
                        tranElem.Offer1ID = p.AlbumID;
                        tranElem.User1 = t.Username;
                        tranElem.imgUrl_1 = s.Url;
                        tranElem.Date = t.Datum;
                        tranElem.tranID = t.ID;
                        tranElem.Status = t.Status;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                    else
                    {
                        transakciiElement tranElem = (transakciiElement)LoadControl("transakciiElement.ascx");
                        Ponuda p = db.getOffer(t.ID);
                        Korisnik user = db.getUserInfoByUsername(t.Username);
                        Slika s_moja = db.getPicture(p.AlbumID, p.BrojSlika);
                        Slika s_zamena = db.getPicture(t.AlbumID, t.PictureID);
                        Album a = db.getAlbumByID(p.AlbumID);
                        tranElem.AlbumYear = a.Year;
                        tranElem.Name1 = p.Name;
                        tranElem.Description1 = p.Desc;
                        tranElem.Email1 = user.Email;
                        tranElem.Price1 = p.Price;
                        tranElem.Offer1ID = p.AlbumID;
                        tranElem.User1 = t.Username;
                        tranElem.Date = t.Datum;
                        tranElem.imgUrl_1 = s_moja.Url;
                        tranElem.imgID_1 = s_moja.Broj;
                        tranElem.tranID = t.ID;

                        tranElem.imgUrl_2 = s_zamena.Url;
                        tranElem.imgID_2 = s_zamena.Broj;

                        tranElem.Status = t.Status;
                        repeaterTransakcii.Controls.Add(tranElem);
                    }
                }

                //repeaterTransakcii.Controls.Add(tranElem);
            }
        }
Ejemplo n.º 6
0
        protected void fillMyOffers(string username)
        {
            Database      db     = new Database();
            List <Ponuda> ponudi = db.getAllOffersByUsername(username);

            for (int i = 0; i < ponudi.Count; i += 2)               //example usage
            {
                if (ponudi.Count % 2 == 1 && i + 1 == ponudi.Count) //dokolku treba da se loadiraat neparen
                {                                                   //broj ponudi, poslednata ponuda e
                    Ponuda      p     = ponudi[i];                  //myOfferHalf.ascx
                    myOfferHalf offer = (myOfferHalf)LoadControl("myOfferHalf.ascx");
                    offer.Name        = p.Name;
                    offer.Description = p.Desc;
                    offer.Price       = p.Price;
                    offer.Offer1ID    = p.ID;
                    Slika s = db.getPicture(p.AlbumID, p.BrojSlika);
                    if (s != null)
                    {
                        offer.imgUrl = s.Url;
                    }
                    offer.albumID   = p.AlbumID;
                    offer.pictureID = p.BrojSlika;
                    repeaterMyOffers.Controls.Add(offer);
                }
                else
                {
                    Ponuda p1 = ponudi[i];
                    Ponuda p2 = ponudi[i + 1];

                    myOffer offer = (myOffer)LoadControl("myOffer.ascx");
                    offer.Name1        = p1.Name;
                    offer.Description1 = p1.Desc;
                    offer.Price1       = p1.Price;
                    offer.Offer1ID     = p1.ID;
                    Slika s1 = db.getPicture(p1.AlbumID, p1.BrojSlika);
                    if (s1 != null)
                    {
                        offer.imgUrl_1 = s1.Url;
                    }

                    offer.albumID_1   = p1.AlbumID;
                    offer.pictureID_1 = p1.BrojSlika;

                    offer.Name2        = p2.Name;
                    offer.Description2 = p2.Desc;
                    offer.Price2       = p2.Price;
                    offer.Offer2ID     = p2.ID;

                    Slika s2 = db.getPicture(p2.AlbumID, p2.BrojSlika);
                    if (s2 != null)
                    {
                        offer.imgUrl_2 = s2.Url;
                    }

                    offer.albumID_2   = p2.AlbumID;
                    offer.pictureID_2 = p2.BrojSlika;

                    repeaterMyOffers.Controls.Add(offer);
                    //TODO: fill offer with picture
                    //  somethink like this:
                    //img.ImgUrl = db.getPictureUrl(p.AlbumID, p.BrojSlika);
                }
            }
        }
Ejemplo n.º 7
0
        private string getImageUrl(int albumID, int pictureID)
        {
            Database db = new Database();
            Slika s = db.getPicture(albumID, pictureID);

            if (s != null)
                return s.Url;
            return "";
        }
Ejemplo n.º 8
0
        protected void fillMyOffers(string username)
        {
            Database db = new Database();
            List<Ponuda> ponudi = db.getAllOffersByUsername(username);

            for (int i = 0; i < ponudi.Count; i += 2) //example usage
            {
                if (ponudi.Count % 2 == 1 && i + 1 == ponudi.Count) //dokolku treba da se loadiraat neparen
                {                                                   //broj ponudi, poslednata ponuda e
                    Ponuda p = ponudi[i];                           //myOfferHalf.ascx
                    myOfferHalf offer = (myOfferHalf)LoadControl("myOfferHalf.ascx");
                    offer.Name = p.Name;
                    offer.Description = p.Desc;
                    offer.Price = p.Price;
                    offer.Offer1ID = p.ID;
                    Slika s = db.getPicture(p.AlbumID, p.BrojSlika);
                    if (s != null)
                        offer.imgUrl = s.Url;
                    offer.albumID = p.AlbumID;
                    offer.pictureID = p.BrojSlika;
                    repeaterMyOffers.Controls.Add(offer);
                }
                else
                {
                    Ponuda p1 = ponudi[i];
                    Ponuda p2 = ponudi[i + 1];

                    myOffer offer = (myOffer)LoadControl("myOffer.ascx");
                    offer.Name1 = p1.Name;
                    offer.Description1 = p1.Desc;
                    offer.Price1 = p1.Price;
                    offer.Offer1ID = p1.ID;
                    Slika s1 = db.getPicture(p1.AlbumID, p1.BrojSlika);
                    if (s1 != null)
                        offer.imgUrl_1 = s1.Url;

                    offer.albumID_1 = p1.AlbumID;
                    offer.pictureID_1 = p1.BrojSlika;

                    offer.Name2 = p2.Name;
                    offer.Description2 = p2.Desc;
                    offer.Price2 = p2.Price;
                    offer.Offer2ID = p2.ID;

                    Slika s2 = db.getPicture(p2.AlbumID, p2.BrojSlika);
                    if (s2 != null)
                        offer.imgUrl_2 = s2.Url;

                    offer.albumID_2 = p2.AlbumID;
                    offer.pictureID_2 = p2.BrojSlika;

                    repeaterMyOffers.Controls.Add(offer);
                    //TODO: fill offer with picture
                    //  somethink like this:
                    //img.ImgUrl = db.getPictureUrl(p.AlbumID, p.BrojSlika);
                }

            }
        }