• 大小: 81KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-16
  • 语言: 其他
  • 标签:

资源简介

简单的图书管理系统

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace BookMagStm
{
    public partial class Book : UserControl
    {
        public Book()
        {
            InitializeComponent();
        }

        private void Book_Load(object sender EventArgs e)
        {
            DataBind();
        }
        private void DataBind()
        {
            SqlConnection conn = new SqlConnection(“server=.; database=book; integrated security=True“);
            conn.Open();
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = “select bkID 书号 bkName 书名 bkAuthor 作者 bkPress 出版社 bkPrice 单价bkState 是否在馆 from Book“;
            SqlDataAdapter sda = new SqlDataAdapter(cmd);
            DataSet ds = new DataSet();
            sda.Fill(ds);
            dgvBook.DataSource = ds.Tables[0];

            txtbkID.DataBindings.Clear();
            txtbkName.DataBindings.Clear();
            txtbkAuthor.DataBindings.Clear();
            txtbkPress.DataBindings.Clear();
            txtbkPrice.DataBindings.Clear();
            txtbkState.DataBindings.Clear();

            txtbkID.DataBindings.Add(“Text“ ds.Tables[0] “书号“);
            txtbkName.DataBindings.Add(“Text“ ds.Tables[0] “书名“);
            txtbkAuthor.DataBindings.Add(“Text“ ds.Tables[0] “作者“);
            txtbkPress.DataBindings.Add(“Text“ ds.Tables[0] “出版社“);
            txtbkPrice.DataBindings.Add(“Text“ ds.Tables[0] “单价“);
            txtbkState.DataBindings.Add(“Text“ ds.Tables[0] “是否在馆“);
        }

        private void btnadd_Click(object sender EventArgs e)
        {
            SqlConnection conn = new SqlConnection(“server=.; database=book; integrated security=True“);
            conn.Open();
            SqlCommand cmd = conn.CreateCommand();
            cmd.CommandText = “insert into Book values(@bkID @bkName @bkAuthor @bkPress @bkPrice@bkState)“;
            cmd.Parameters.AddWithValue(“@bkID“ txtbkID.Text);
            cmd.Parameters.AddWithValue(“@bkName“ txtbkName.Text);
            cmd.Parameters.AddWithValue(“@bkAuthor“ txtbkAuthor.Text);
            cmd.Parameters.AddWithValue(“@bkPress“ txtbkPress.Text);
            cmd.Parameters.AddWithValue(“@bkPrice“ txtbkPrice.Text);
            cmd.Parameters.AddWithValue(“@bkState“ txtbkState.Text);
            try
            {
                cmd.ExecuteNonQuery();
                MessageBox.Show(“插入成功!“);
                //DataBind();
            }
            catch (Exception ex)
            {
                MessageBox.Show(“插入失败!“ + ex.Message);
            }
        }

        private void btnupdate_Click(object sender EventArgs e)
        {
            SqlConnection conn = new SqlConnection(“server=.; database=book; integrated security=True“);
        

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       1531  2017-05-18 20:39  BookMagStm\BookMagStm.cs

     文件       4749  2017-05-18 20:39  BookMagStm\BookMagStm.Designer.cs

     文件        611  2017-05-17 16:47  BookMagStm\Program.cs

     文件       5052  2017-05-18 20:21  BookMagStm\BookMagStm.csproj

     文件       5817  2017-05-18 20:39  BookMagStm\BookMagStm.resx

     文件       4630  2017-05-18 20:42  BookMagStm\Reader.cs

     文件      10338  2017-05-17 19:22  BookMagStm\Reader.Designer.cs

     文件       5817  2017-05-17 19:22  BookMagStm\Reader.resx

     文件       5895  2017-05-17 19:15  BookMagStm\Book.cs

     文件      10974  2017-05-17 19:15  BookMagStm\Book.Designer.cs

     文件       5817  2017-05-17 19:15  BookMagStm\Book.resx

     文件       4488  2017-05-17 19:26  BookMagStm\ReaderType.cs

     文件       8598  2017-05-17 19:26  BookMagStm\ReaderType.Designer.cs

     文件       5817  2017-05-17 19:26  BookMagStm\ReaderType.resx

     文件       3901  2017-05-18 21:26  BookMagStm\BorrowBook.cs

     文件       9063  2017-05-18 20:19  BookMagStm\BorrowBook.Designer.cs

     文件       5817  2017-05-18 21:26  BookMagStm\BorrowBook.resx

     文件       1340  2017-05-17 16:03  BookMagStm\Properties\AssemblyInfo.cs

     文件       5612  2017-05-17 16:03  BookMagStm\Properties\Resources.resx

     文件       2872  2017-05-17 16:03  BookMagStm\Properties\Resources.Designer.cs

     文件        249  2017-05-17 16:03  BookMagStm\Properties\Settings.settings

     文件       1097  2017-05-17 16:03  BookMagStm\Properties\Settings.Designer.cs

     文件      22688  2017-05-19 15:23  BookMagStm\bin\Debug\BookMagStm.vshost.exe

     文件      30208  2017-05-19 14:09  BookMagStm\bin\Debug\BookMagStm.exe

     文件      54784  2017-05-19 14:09  BookMagStm\bin\Debug\BookMagStm.pdb

     文件        490  2013-06-18 20:28  BookMagStm\bin\Debug\BookMagStm.vshost.exe.manifest

     文件       6996  2017-05-19 15:23  BookMagStm\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        180  2017-05-18 20:39  BookMagStm\obj\Debug\BookMagStm.BookMagStmForm1.resources

     文件        180  2017-05-18 20:21  BookMagStm\obj\Debug\BookMagStm.Properties.Resources.resources

     文件       5737  2017-05-19 15:32  BookMagStm\obj\Debug\BookMagStm.csproj.FileListAbsolute.txt

............此处省略24个文件信息

评论

共有 条评论