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.SystemSet
{
    public partial class RatesSet : Form
    {
        public RatesSet()
        {
            InitializeComponent();
        }
        LibraryEntities1 dbContext = new LibraryEntities1();
        private void button_loan_Click(object sender, EventArgs e)
        {
            if (textBox1.Text == "")
            {
                MessageBox.Show("罚款利率不得为空！");
                return;
            }
            int Rates = int.Parse(textBox1.Text);
            BaseSet baseSet = dbContext.BaseSet.Find("1");
            baseSet.Rates = Rates;
            int i = dbContext.SaveChanges();
            String str = i == 1 ? "修改成功" : "修改失败";
            MessageBox.Show(str);
            load_data(sender, e);
        }
        private void load_data(object sender, EventArgs e)
        {
            BaseSet baseSet = dbContext.BaseSet.Find("1");
            label1.Text = "现过期罚款利息为" + baseSet.Rates + "元/天";
        }
    }
}
