Beispiel #1
0
        /// <summary>
        /// 매개변수로 넘어온 데이터를 가진 대여데이터를 만든다.
        /// </summary>
        /// <param name="rentalData">대여정보가 담겨있는 VO</param>
        public void AddAfterRent(RentalData rentalData)
        {
            connection.Open();

            command             = connection.CreateCommand();
            command.CommandText = "INSERT INTO rentaldata values(@no,@name,@publisher,@Author,@Lender,@Date,@extendCount)";
            command.Parameters.Add("@no", MySqlDbType.VarChar).Value         = rentalData.BookNo;
            command.Parameters.Add("@name", MySqlDbType.VarChar).Value       = rentalData.BookName;
            command.Parameters.Add("@publisher", MySqlDbType.VarChar).Value  = rentalData.BookPbls;
            command.Parameters.Add("@Author", MySqlDbType.VarChar).Value     = rentalData.BookAuthor;
            command.Parameters.Add("@Lender", MySqlDbType.VarChar).Value     = rentalData.BookLender;
            command.Parameters.Add("@Date", MySqlDbType.VarChar).Value       = rentalData.BookReturnTime.ToString("yyyy-MM-dd");
            command.Parameters.Add("extendCount", MySqlDbType.VarChar).Value = rentalData.ExtendCount;
            command.ExecuteNonQuery();
            connection.Close();
        }
Beispiel #2
0
        /// <summary>
        /// 데이터베이스에 저장된 대여정보를 가져온다.
        /// </summary>
        /// <param name="id">가져올 정보의 아이디</param>
        /// <param name="no">가져올 정보의 no</param>
        /// <returns></returns>
        public RentalData GetRentalData(string id, string no)
        {
            int count = 0;

            connection.Open();

            command             = connection.CreateCommand();
            command.CommandText = "Select * from rentaldata where bookLender = @id and isbn = @no";
            command.Parameters.Add("@no", MySqlDbType.VarChar).Value = no;
            command.Parameters.Add("@id", MySqlDbType.VarChar).Value = id;
            reader = command.ExecuteReader();

            while (reader.Read())
            {
                rentalData = new RentalData(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4), reader.GetDateTime(5), reader.GetInt32(6), ++count);
            }
            connection.Close();

            return(rentalData);
        }