예제 #1
0
        //Получаем список торгов из базы данных
        static public ObservableCollection <Bargaining> LoatBargaesFromDataBase()
        {
            ObservableCollection <Bargaining> bargaCollection = new ObservableCollection <Bargaining>();
            string sqlCommand = "Select * from Bargaining";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand, connection);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);
                DataTable    tableLots = ds.Tables[0];
                int          n         = tableLots.Rows.Count;
                Bargaining[] barga     = new Bargaining[n];

                for (int i = 0; i < n; i++)
                {
                    barga[i]               = new Bargaining();
                    barga[i].IdLot         = (int)tableLots.Rows[i][1];
                    barga[i].StartAuction  = (DateTime)tableLots.Rows[i][2];
                    barga[i].FinishAuction = (DateTime)tableLots.Rows[i][3];
                    barga[i].LoginOwner    = (string)tableLots.Rows[i][4];
                    barga[i].LoginWinner   = (string)tableLots.Rows[i][5];
                    barga[i].CurrentPrice  = (int)tableLots.Rows[i][6];
                }
                for (int i = 0; i < n; i++)
                {
                    bargaCollection.Add(barga[i]);
                }
            }
            return(bargaCollection);
        }
예제 #2
0
        //Добавление нового аукциона для лота
        static public void AddNewBargaining(Bargaining barga)
        {
            string sqlCommand = "Select * from Bargaining";

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();

                SqlDataAdapter adapter = new SqlDataAdapter(sqlCommand, connection);
                DataSet        ds      = new DataSet();
                adapter.Fill(ds);
                DataTable dt = ds.Tables[0];

                DataRow newRow = dt.NewRow();
                newRow["idLot"]         = barga.IdLot;
                newRow["startAuction"]  = barga.StartAuction;
                newRow["finishAuction"] = barga.FinishAuction;
                newRow["loginOwner"]    = barga.LoginOwner;
                newRow["loginWinner"]   = barga.LoginWinner;
                newRow["currentPrice"]  = barga.CurrentPrice;
                dt.Rows.Add(newRow);
                SqlCommandBuilder commandBuilder = new SqlCommandBuilder(adapter);
                adapter.Update(ds);
            }
        }
예제 #3
0
 public LotInfoViewModel()
 {
     Lots          = DataBaseService.LoadLotsFromDataBase();
     user          = DataBaseService.GetUserInfo(currentUser.login);
     Bargaes       = DataBaseService.LoatBargaesFromDataBase();
     selectedBarga = new Bargaining();
     summa         = 0;
     TimeLeft      = "";
     Task.Factory.StartNew(() =>
     {
         while (true)
         {
             Task.Delay(1000).Wait();
             timer();
         }
     });
 }
예제 #4
0
 public AddLotViewModel()
 {
     selectedLot = new LotInfo();
     user        = DataBaseService.GetUserInfo(currentUser.login);
     Barga       = new Bargaining();
 }