コード例 #1
0
    public string GetAllProductsCategories()
    {
        JavaScriptSerializer j       = new JavaScriptSerializer();
        Reg_Auction          auction = new Reg_Auction();

        return(j.Serialize(auction.GetAllProductsCategories()));
    }
コード例 #2
0
    public string GetAuctionPrice(int auctionCode)
    {
        JavaScriptSerializer j       = new JavaScriptSerializer();
        Reg_Auction          auction = new Reg_Auction();

        auction.AuctionID = auctionCode;
        return(j.Serialize(auction.GetLatestBid()));
    }
コード例 #3
0
    public string GetAuctionByCode(Reg_Auction auc)
    {
        JavaScriptSerializer j = new JavaScriptSerializer();

        //Reg_Auction auc = new Reg_Auction(auctionCode);
        auc.GetDataByCode();
        return(j.Serialize(auc));
    }
コード例 #4
0
    public bool OfferBid(int auc, int bid, int buyer)
    {
        //JavaScriptSerializer j = new JavaScriptSerializer();
        Reg_Auction auction = new Reg_Auction();

        auction.AuctionID = auc;
        int lastBid = auction.GetLatestBid();

        if (lastBid < bid)
        {
            return(auction.OfferBid(bid, buyer));
        }
        else
        {
            return(false);
        }
    }
コード例 #5
0
    public string AddingProductAuction(string itemName, string itemDesc, string city, string cat, string days, string assoc, string price, string user)
    {
        DbService            db       = new DbService();
        DataSet              DS       = new DataSet();
        JavaScriptSerializer j        = new JavaScriptSerializer();
        Item                  NewItem = new Item();
        Reg_Auction           Auction = new Reg_Auction();
        City                  c       = new City(int.Parse(city));
        Item_Category         IC      = new Item_Category(int.Parse(cat));
        Voluntary_association Vol     = new Voluntary_association(assoc);
        UserT                 Seller  = new UserT(user, true);
        int ProductCode = 0;

        NewItem.ItemName        = itemName;
        NewItem.ItemDesc        = itemDesc;
        NewItem.Location        = c;
        NewItem.Item_Categories = IC;
        NewItem.Price           = price;

        Auction.End_Date = DateTime.Now.AddDays(double.Parse(days)).ToString();
        Auction.Vol_asc  = Vol;
        Auction.Price    = int.Parse(price);
        Auction.Seller   = Seller;

        NewItem.AddItem(int.Parse(Auction.Seller.UserId));

        string StrSql = "select max(product_code) from product ";

        DS = db.GetDataSetByQuery(StrSql);

        if (DS.Tables.Count > 0)
        {
            ProductCode = int.Parse(DS.Tables[0].Rows[0][0].ToString());
        }

        Auction.AddNewAuction(ProductCode, int.Parse(assoc));

        return(j.Serialize(ProductCode));
    }
コード例 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     Auction auc = new Reg_Auction();
 }
コード例 #7
0
    public static List <Reg_Auction> GetAuctionsByParam(int lowPrice, int highPrice, int catCode, int id, double lat, double lng, int radius)
    {
        DbService db      = new DbService();
        DataSet   DS      = new DataSet();
        DataSet   DSprice = new DataSet();
        DataSet   DSpic   = new DataSet();

        List <Reg_Auction> relevantAuctions = new List <Reg_Auction>();
        int    low  = 0;
        int    high = 0;
        string code = "";

        if (lowPrice == -1)
        {
            low = 0;
        }
        else
        {
            low = lowPrice;
        }
        if (highPrice == -1)
        {
            high = 1000000;
        }
        else
        {
            high = highPrice;
        }
        if (catCode == 0)
        {
            code = "> 0";
        }
        else
        {
            code = "=" + catCode;
        }

        string StrSql = "SELECT dbo.auction.auction_code, dbo.product_category.category_code, dbo.product_category.category_name, dbo.auction.end_date, dbo.auction.donation_percentage, dbo.product.product_description, " +
                        "dbo.product.product_Name, dbo.product.product_category_code, dbo.product.price, dbo.product.product_code,dbo.product.city_code " +
                        "FROM  dbo.auction INNER JOIN dbo.product ON dbo.auction.product_code = dbo.product.product_code " +
                        "INNER JOIN dbo.product_category ON dbo.product.product_category_code = dbo.product_category.category_code " +
                        "GROUP BY dbo.product_category.category_code, dbo.product_category.category_name, dbo.auction.end_date, dbo.auction.donation_percentage, dbo.product.product_description, dbo.product.product_category_code, " +
                        "dbo.auction.auction_code, dbo.product.price,dbo.product.product_code,dbo.product.product_Name,dbo.product.city_code ";

        StrSql += "HAVING (dbo.product.price BETWEEN " + low + " AND " + high + " and dbo.product.product_category_code " + code + " and dbo.auction.end_date > CONVERT(DATETIME, '" + DateTime.Now.ToString("yyyy-MM-dd 00:00:00") + "', 102)) ";

        DS = db.GetDataSetByQuery(StrSql);
        if (DS.Tables.Count > 0)
        {
            // נבדוק האם יש למכרז בידים, אם כן נציג את הביד הגבוה, אם לא נביא את המחיר ההתחלתי שלו
            foreach (DataRow row in DS.Tables[0].Rows)
            {
                bool          b       = true; // כדי לדעת מה המצב עם מחיר הבידים - אם הם גבוהים מהמחיר בטווח
                Reg_Auction   auction = new Reg_Auction(int.Parse(row[0].ToString()));
                List <string> images  = new List <string>();
                StrSql  = @"SELECT dbo.auction.auction_code, MAX(dbo.bid.price) AS Expr1
                         FROM dbo.bid INNER JOIN
                         dbo.auction ON dbo.bid.auction_code = dbo.auction.auction_code
                         GROUP BY dbo.auction.auction_code
                         HAVING  (dbo.auction.auction_code = " + auction.AuctionID.ToString() + ")";
                DSprice = db.GetDataSetByQuery(StrSql);

                if (DSprice.Tables[0].Rows.Count > 0)
                {
                    if (int.Parse(DSprice.Tables[0].Rows[0][1].ToString()) > high)
                    {
                        b = false;
                    }
                    else
                    {
                        //auction.Price = int.Parse(DSprice.Tables[0].Rows[0][1].ToString());
                        auction.Price = int.Parse(DSprice.Tables[0].Rows[0][0].ToString());
                    }
                }
                else
                {
                    auction.Price = int.Parse(row[8].ToString());
                }

                StrSql = "SELECT dbo.product_pictures.path " +
                         "FROM dbo.product_pictures INNER JOIN " +
                         "dbo.product ON dbo.product_pictures.product_code = dbo.product.product_code " +
                         "WHERE(dbo.product_pictures.product_code = " + row[9].ToString() + ") ";
                DSpic = db.GetDataSetByQuery(StrSql);
                if (DSpic.Tables.Count > 0)
                {
                    foreach (DataRow img in DSpic.Tables[0].Rows)
                    {
                        images.Add(img[0].ToString());
                    }
                }
                auction.CatDesc = row[2].ToString();
                //DateTime G = DateTime.Parse(row[3].ToString());
                //string ng = G.ToString("MM/dd/yyyy HH:mm:ss");
                //auction.End_Date = DateTime.Parse(ng);
                auction.Location   = new City(int.Parse(row[8].ToString()));
                auction.End_Date   = row[3].ToString();
                auction.Percentage = int.Parse(row[4].ToString());
                auction.ProdDesc   = row[5].ToString();
                auction.ProdName   = row[6].ToString();
                auction.ItemCode   = int.Parse(row["product_code"].ToString());
                auction.Images     = images.Count > 0 ? images.ToArray() : null;

                if (b)
                {
                    relevantAuctions.Add(auction);
                }
            }
        }

        //var coord1 = new GeoCoordinate(lat, long);
        //var coord2 = new GeoCoordinate(lat2, long2);

        //var distance = coord1.GetDistanceTo(coord2);

        AddNewSearch(id, lat, lng, radius, lowPrice, highPrice, catCode);
        return(relevantAuctions);
    }
コード例 #8
0
    public string GetAuctionByParam(int lowPrice, int highPrice, int catCode, int id, double lat, double lng, int radius)
    {
        JavaScriptSerializer j = new JavaScriptSerializer();

        return(j.Serialize(Reg_Auction.GetAuctionsByParam(lowPrice, highPrice, catCode, id, lat, lng, radius)));
    }