Exemplo n.º 1
0
        static void MainOld(string[] args)
        {
            SqlConnection conn;

            conn = new SqlConnection(@"Data Source=.\sqlexpress;Initial Catalog=AuctionProject;Integrated Security=True");
            conn.Open();
            SqlCommand cmd;

            cmd = new SqlCommand("select * from Offers", conn);


            var reader = cmd.ExecuteReader();

            Console.WriteLine($"Number of Fields:{reader.FieldCount}");

            for (int i = 0; i < reader.FieldCount; i++)
            {
                Console.WriteLine(reader.GetName(i));
            }

            List <OfferDAL> L               = new List <OfferDAL>();
            int             offeridcolumn   = reader.GetOrdinal("OfferID");
            int             productidcolumn = reader.GetOrdinal("ProductID");
            int             buyeridcolumn   = reader.GetOrdinal("BuyerID");


            while (reader.Read())
            {
                //for (int i = 0; i < reader.FieldCount; i++)
                //{
                //    Console.Write(reader.GetValue(i));
                //    Console.Write(' ');

                //}
                //Console.WriteLine();

                OfferDAL o = new OfferDAL();

                o.OfferID   = reader.GetInt32(offeridcolumn);
                o.ProductID = reader.GetInt32(productidcolumn);

                o.BuyerID    = reader.GetInt32(buyeridcolumn);
                o.OfferPrice = reader.GetDecimal(3);
                o.OfferState = reader.GetInt32(4);
                o.ExpireDate = reader.GetDateTime(5);
                if (reader.IsDBNull(6))
                {
                }
                else
                {
                    o.Comments = reader.GetString(6);
                }

                L.Add(o);
            }
            // after the while loop is over
            // it is acceptable to close the connection
        }
Exemplo n.º 2
0
        public OfferBLL FindOfferByID(int OfferID)
        {
            OfferBLL rv  = null;
            OfferDAL dal = ctx.FindOfferByID(OfferID);

            if (dal != null)
            {
                rv = new OfferBLL(dal);
            }

            return(rv);
        }
Exemplo n.º 3
0
 public OfferBLL(OfferDAL dal)
 {
     this.OfferID           = dal.OfferID;
     this.BuyerEmailAddress = this.BuyerEmailAddress;
     this.BuyerID           = this.BuyerID;
     this.BuyerName         = this.BuyerName;
     this.Comments          = this.Comments;
     this.ExpireDate        = this.ExpireDate;
     this.OfferPrice        = dal.OfferPrice;
     this.OfferState        = dal.OfferState;
     this.ProductID         = dal.ProductID;
     this.ProductName       = dal.ProductName;
 }