⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fbook.cs

📁   一个用C#编写的图书管系统
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Library
{
    public partial class fBook : Form
    {
         //属性
        #region 用来实现单例模式
        private static fBook instance = null;
        public static fBook Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new fBook();
                }
                return instance;
            }
        }
        private fBook()
        {
            InitializeComponent();
            instance = this;
        }
        private void fBook_FormClosed(object sender, FormClosedEventArgs e)
        {
            instance = null;
        }
        #endregion
        //窗体首次加载时

        private void ShowDetail()
        {
            dataGridView1.DataSource = Library.ExecuteDataSet("select BookID,BookName,BookPublish,BookAuthor,PublishTime,ISBN,YNState,BookCount,YNDate from Book").Tables[0];
        }

        private void fBook_Load(object sender, EventArgs e)
        {
            dataGridView1.DataSource = Library.ExecuteDataSet("select BookID,BookName,BookPublish,BookAuthor,PublishTime,ISBN,YNState,BookCount,YNDate from Book").Tables[0];
        }

     

        private void tsbChange_Click(object sender, EventArgs e)
        {
            fBookDetail f = new fBookDetail();
            f.Tag = dataGridView1.CurrentRow;
            f.ShowDialog();

            //刷新
            if (f.DialogResult == DialogResult.OK)
            {
                ShowDetail();
            }  
            
        }

        private void tsbDelete_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("是否确认删除该条记录?", "系统提示:", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2)
                == DialogResult.Yes)
            {
                Library.ExecuteNoQuery("delete from Book where BookID='" + dataGridView1.CurrentRow.Cells["ColumnBookID"].Value.ToString() +"'");
                ShowDetail();
            }
        }

        private void tsbRefresh_Click(object sender, EventArgs e)
        {
            ShowDetail();
        }

        private void tsbExit_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void tsbAdd_Click(object sender, EventArgs e)
        {
            fBookDetail a = new fBookDetail();
            a.ShowDialog();
            if (a.DialogResult == DialogResult.OK)
            {

                ShowDetail();
            }
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }
        

       
      

       
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -