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

📄 xiugaitushuxinxi.cs

📁 Vs2005C#图书管理系统初学的看看有好处的
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace tsh
{
    public partial class xiugaitushuxinxi : Form
    {
        public xiugaitushuxinxi()
        {
            InitializeComponent();
        }
        DB.ClsSQL sql=new DB.ClsSQL(".","mylw","sa","",3);
        DataSet ds,ds1;
        private string textb;
        private void xiugaitushuxinxi_Load(object sender, EventArgs e)
        {

        }

        private void textBox1_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == 13)
            {
                if (textBox1.Text == "")
                {
                    MessageBox.Show("图书编号不能为空!!!", "提示");
                }
                else
                {
                    textb = textBox1.Text;
                    string s = "select * from book where tushubianhao='" + textb + "'";
                    ds = sql.DBToDS(s, "book");
                    int n = ds.Tables["book"].Rows.Count;
                    dataGridView1.DataSource = ds.Tables["book"];
                    if (n == 0)
                    {
                        MessageBox.Show("无此图书编号!!!", "提示");
                        buttgx.Enabled = false;
                        dataGridView1.ReadOnly = true;
                    }
                    else
                    {
                        string s1 = "select * from borrow where tushubianhao='" + textb + "'";
                        ds1 = sql.DBToDS(s1, "borrow");
                        int i = ds1.Tables["borrow"].Rows.Count;
                        if (i != 0)
                        {
                            MessageBox.Show("已有读者借了这本书,不允许修改其数据!!", "提示");
                            buttgx.Enabled = false;
                            dataGridView1.ReadOnly = true;
                        }
                        else
                        {
                            buttgx.Enabled = true;
                            dataGridView1.ReadOnly = false;
                        }
                    }
                }
                textBox1.Text = "";
                textBox1.Focus();
            }


        }

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

        private void buttgx_Click(object sender, EventArgs e)
        {
            try
            {
                //SqlDataAdapter mydaer = new SqlDataAdapter();
                //mydaer.Update(ds, "book");
                string s3 = "update book set fenleihao='" + dataGridView1.CurrentRow.Cells[1].Value.ToString() + "',shuming='" + dataGridView1.CurrentRow.Cells[2].Value.ToString() + "',leibie='" + dataGridView1.CurrentRow.Cells[3].Value.ToString() + "',zuozhe='" + dataGridView1.CurrentRow.Cells[4].Value.ToString() + "',chubanshe='" + dataGridView1.CurrentRow.Cells[5].Value.ToString() + "',banci='" + dataGridView1.CurrentRow.Cells[6].Value.ToString() + "',kaiben='" + dataGridView1.CurrentRow.Cells[7].Value.ToString() + "',zishu='" + dataGridView1.CurrentRow.Cells[8].Value.ToString() + "',jiage=" + dataGridView1.CurrentRow.Cells[9].Value.ToString() + ",kucunshu=" + dataGridView1.CurrentRow.Cells[10].Value.ToString() + ",zaikushu=" + dataGridView1.CurrentRow.Cells[11].Value.ToString() + " where tushubianhao='" + textb + "'";
                sql.SQLCommand(s3);
                MessageBox.Show("已成功更新记录!!", "提示");
                buttgx.Enabled = false;
                dataGridView1.ReadOnly = true;
            }
            catch (Exception Exc)
            {
                MessageBox.Show(Exc.Message, "警告");
            }

        }
    }
}

⌨️ 快捷键说明

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