Exemplo n.º 1
0
        // Загрузка ставки в БД
        public int LoadBet(Bets bet)
        {
            try
            {
                comm.CommandText = "INSERT INTO BetsDB VALUES " +
                                   "(@IdClien, " +
                                   "@Date, " +
                                   "@Summ, " +
                                   "@Ratio, " +
                                   "@Result, " +
                                   "@Prise)";
                comm.Parameters.AddWithValue("IdClien", bet.IdClient);
                comm.Parameters.AddWithValue("Date", bet.Date);
                comm.Parameters.AddWithValue("Summ", bet.Summ);
                comm.Parameters.AddWithValue("Ratio", bet.Ratio);
                comm.Parameters.AddWithValue("Result", bet.Result);
                comm.Parameters.AddWithValue("Prise", bet.Prise);
                comm.CommandType = CommandType.Text;
                conn.Open();

                return(comm.ExecuteNonQuery());
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }
Exemplo n.º 2
0
        // Запрос ставок из БД
        public List <Bets> GetBets(string Command_Text)
        {
            List <Bets> BetsFromDB = new List <Bets>();

            try
            {
                comm.CommandText = Command_Text;
                comm.CommandType = CommandType.Text;
                conn.Open();
                SqlDataReader sqlData = comm.ExecuteReader();

                while (sqlData.Read())
                {
                    Bets row = new Bets();
                    row.Id       = Convert.ToInt32(sqlData["Id"]);
                    row.IdClient = Convert.ToInt32(sqlData["IdClien"]);
                    row.Date     = sqlData["Date"].ToString();
                    row.Summ     = Convert.ToDouble(sqlData["Summ"]);
                    row.Ratio    = Convert.ToDouble(sqlData["Ratio"]);
                    row.Result   = Convert.ToInt32(sqlData["Result"]);
                    row.Prise    = Convert.ToDouble(sqlData["Prise"]);
                    BetsFromDB.Add(row);
                }

                return(BetsFromDB);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                if (conn != null)
                {
                    conn.Close();
                }
            }
        }