using LibraryMangementSystem.Dao;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryMangementSystem.StatisticData
{
    public partial class ChartDisplay : Form
    {
        public ChartDisplay()
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;
        }
        private void Chart_load(object sender, EventArgs e)
        {
            /*List<string> x = new List<string>() { "时间简史", "中国历史", "英语", "化学" };
            List<int> y = new List<int>() { 6, 7, 52, 13 };
            chart_hot.Series["图书名称"].Points.DataBindXY(x, y);*/
            List<string> x = new List<string>();
            List<int> y = new List<int>();
            string sql = "select * from PopularBooksStatistics ORDER BY borrowOnce desc";
            DaoUtil dao = new DaoUtil();
            IDataReader result = dao.Reader(sql);
            while (result.Read())
            {
                x.Add(result["Title"].ToString().Trim());
                y.Add(int.Parse(result["borrowOnce"].ToString().Trim()));
                if (x.Count==9) {
                    break;
                }
                
            }
            chart_hot.Series["图书名称"].Points.DataBindXY(x,y);
            dao.DaoClose();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
