Beispiel #1
0
        protected void btnOfferBuy1_Click(object sender, EventArgs e)
        {
            bool        res = updateTranStatus(3);
            Database    db  = new Database();
            Transakcija t   = db.getTransakcijaByID(tranID);
            Ponuda      p   = db.getOffer(t.ID);

            if (t.AlbumID == -1)
            {
                db.addPoseduvaRelation(t.Username, p.AlbumID, p.BrojSlika, 0);
                db.updateQuantity(t.Username, p.AlbumID, p.BrojSlika, 1);
            }
            Session["state"] = "prodavam";
            Response.Redirect("~/Transakcii.aspx");
        }
        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);
            }
        }
        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);
            }
        }
 protected void btnOfferBuy1_Click(object sender, EventArgs e)
 {
     bool res = updateTranStatus(3);
     Database db = new Database();
     Transakcija t = db.getTransakcijaByID(tranID);
     Ponuda p = db.getOffer(t.ID);
     if(t.AlbumID == -1){
         db.addPoseduvaRelation(t.Username, p.AlbumID, p.BrojSlika, 0);
         db.updateQuantity(t.Username, p.AlbumID, p.BrojSlika, 1);
     }
     Session["state"] = "prodavam";
     Response.Redirect("~/Transakcii.aspx");
 }