Пример #1
0
        public List <UserAskData> ReadUserAskDataWithUserId(int UserId)
        {
            List <UserAskData> AskDataList = new List <UserAskData>();
            SqlConnection      con         = new SqlConnection(@"Data Source = (local)\SQLEXPRESS; Initial Catalog = SysWal; Integrated Security = True");
            SqlCommand         myCommand   = new SqlCommand("select * from UserAskData where UserId = " + UserId, con);

            con.Open();
            SqlDataReader myReader = myCommand.ExecuteReader();

            while (myReader.Read())
            {
                UserAskData ask = new UserAskData();
                ask.SetAskId((int)myReader["AskId"]);
                ask.SetUserId((int)myReader["UserId"]);
                ask.Setcash(Convert.ToDouble(myReader["cash"]));
                ask.SetFromCurrency(myReader["fromCurrency"].ToString());
                ask.SetToCurrency(myReader["toCurrency"].ToString());
                // ask.SetResult(Convert.ToDouble(myReader["result"]));
                ask.SetFriends((int)myReader["friends"]);
                ask.SetControlNo((int)myReader["controlNo"]);
                ask.SetAccepted((bool)myReader["accepted"]);
                //ask.SetDone((bool)myReader["done"]);
                ask.SetResult(0.00);

                AskDataList.Add(ask);
            }
            return(AskDataList);
        }
Пример #2
0
        public void SaveUserAskData(UserAskData ask)
        {
            SqlConnection con = new SqlConnection(@"Data Source=(local)\SQLEXPRESS; Initial Catalog=SysWal;Integrated Security=True");

            con.Open();
            SqlCommand cmd = new SqlCommand("INSERT INTO UserAskData(AskId, UserId, cash, fromCurrency, toCurrency, friends, controlNo, accepted) values (@AskId, @UserId, @cash, @fromCurrency, @toCurrency, @Friends, @ControlNo, @Accepted)", con);

            cmd.Parameters.AddWithValue("@AskId", ask.GetAskId());
            cmd.Parameters.AddWithValue("@UserId", ask.GetUserId());
            cmd.Parameters.AddWithValue("@cash", ask.Getcash());
            cmd.Parameters.AddWithValue("@fromCurrency", ask.GetCurrencyFrom());
            cmd.Parameters.AddWithValue("@toCurrency", ask.GetCurrencyTo());
            // cmd.Parameters.AddWithValue("@Result", ask.Getresult());
            cmd.Parameters.AddWithValue("@Friends", ask.GetFriends());
            cmd.Parameters.AddWithValue("@ControlNo", ask.GetControlNo());
            cmd.Parameters.AddWithValue("@Accepted", ask.GetAccepted());
            //   cmd.Parameters.AddWithValue("@Done", ask.GetDone());

            cmd.ExecuteNonQuery();
        }