using LibraryMangementSystem.BookManage;
using LibraryMangementSystem.BookRental;
using LibraryMangementSystem.BookQuery;
using LibraryMangementSystem.BookRead;
using LibraryMangementSystem.CertManage;
using LibraryMangementSystem.SystemSet;
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;
using LibraryMangementSystem.StatisticData;

namespace LibraryMangementSystem
{
    public partial class index : Form
    {
        public index()
        {
            InitializeComponent();
            StartPosition = FormStartPosition.CenterScreen;
        }
        //在panel中打开指定窗体，调用该方法时，只需传入一个窗体对象即可
        private void OpenFrm(Form frm)
        {
            frm.TopLevel = false;//取消非顶级窗体
            frm.WindowState = FormWindowState.Maximized;//将窗体最大化
            frm.FormBorderStyle = FormBorderStyle.None;//设为无边框
            frm.Parent = this.palParent;//指定该窗体的父窗体
            frm.Show();//展示窗体
        }
        //用于关闭panel中的窗体，直接调用即可
        private void CloseFrm()
        {
            //palParent为panel控件
            foreach (Control item in this.palParent.Controls)
            {
                if (item is Form)
                {
                    Form form = (Form)item;
                    form.Close();
                    this.palParent.Controls.Remove(form);
                }
            }
        }
        //图书信息管理/图书录入
        private void bookAdd_click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new BookAdd());
        }

        //图书租赁/借书登记
        private void bookRegistration_click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new BookRegistration());

        }


        //图书租赁/还书登记
        private void ReturnBook_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new ReturnBook());
        }
        //图书信息管理/图书删除
        private void 图书删除ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new BookDel());
        }
        //系统统计
        private void ToolStripMenuItem_StatisicData_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new StatisticCount());
        }

        private void 按图书编号检索ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new BookQueryById());
        }

        private void 办新证件ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new CertAdd());
        }

        private void 挂失ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new CertLoss());
        }

        private void 按图书类别检索ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new BookQueryByClass());
        }

        private void 注销ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new CertLogout());
        }

        private void 出版社信息管理ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new PublisherInfoForm());
        }

        private void 摘要浏览ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new BookAbstract());
        }

        private void 新书预览ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new NewBook());
        }

        private void 借书数量ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new SysSet());
        }

        private void 借书天数设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new DaysSet());
        }

        private void 罚款利率设置ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CloseFrm();
            OpenFrm(new RatesSet());
        }
    }
}
