• 大小: 61KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-08
  • 语言: C#
  • 标签: 数据库  

资源简介

C#连接数据库实现删改查代码,但是没有实现增加功能___

资源截图

代码片段和文件信息

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 SE_SQL
{
    public partial class Form1 : Form
    {
        private string select2 = “select book.bname 书名book.bpname 出版社count(*) 借阅次数 “+
            “from booklist “ + 
            “where book.bid = list .bid “ +
            “group by book.bnamebook.bpname “+
            “order by count(*) desc“;
        private string select1 = “select book.bname 所借书籍list.ldate 借阅日期 “+
            “from bookreaderlist “+
            “where reader.rid = list.rid and list.bid = book.bid and “+
            “reader.rname = ‘{0}‘“;
        private string updateNoID = “update reader set rname = ‘{1}‘rsex = ‘{2}‘ where rid = ‘{0}‘“;
        private string updateID = “update reader set rid = ‘{1}‘ where rid = ‘{0}‘“;
        private string deletestr = “delete reader where rid = ‘{0}‘“;
        private string select3 = “select reader.rid 编号 reader.rname 名字reader.rsex 性别 from reader“;
        private string selectCom = “select rname from reader“;
        private string oldId;
        public Form1()
        {
            InitializeComponent();
        }

        private void ReadCombox1()
        {
            DataTable dt = SQLOperation.GetDataBySql(selectCom);
            comboBox1.Items.Clear();
            if (dt.Rows.Count <= 0)
            {
                return;
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    comboBox1.Items.Add(dt.Rows[i][j] + ““);
                }
            }
            comboBox1.SelectedIndex = 0;
        }
        private void Form1_Load(object sender EventArgs e)
        {
            ReadCombox1();
        }

        private void button1_Click(object sender EventArgs e)
        {
            string sql = String.Format(select1 comboBox1.Text);
            dataGridView1.DataSource = SQLOperation.GetDataBySql(sql);
        }

        private void button2_Click(object sender EventArgs e)
        {
            if(dataGridView3.SelectedRows.Count==0)
            {
                return;
            }
            string sql = String.Format(deletestr dataGridView3.SelectedRows[0].Cells[0].Value);
            try
            {
                SQLOperation.SetBySql(sql);
                dataGridView3.DataSource = SQLOperation.GetDataBySql(select3);
            }
            catch (Exception)
            {
                MessageBox.Show(“删除错误请检查该读者是否有借书记录“);
            }
        }

        private void dataGridView3_CellBeginEdit(object sender DataGridViewCellCancelEventArgs e)
        {
            if(e.ColumnIndex == 0)
            {
                oldId = dataGridView3.Rows[e.RowIndex].Cells[e.C

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

    ..A..H.     52224  2019-03-19 15:19  SE_SQL\.vs\SE_SQL\v14\.suo

     文件        189  2019-03-19 12:16  SE_SQL\SE_SQL\App.config

     文件        189  2019-03-19 12:16  SE_SQL\SE_SQL\bin\Debug\SQL.exe.config

     文件      22696  2019-03-19 15:18  SE_SQL\SE_SQL\bin\Debug\SQL.vshost.exe

     文件        189  2019-03-19 12:16  SE_SQL\SE_SQL\bin\Debug\SQL.vshost.exe.config

     文件      16896  2019-03-19 15:16  SE_SQL\SE_SQL\bin\Debug\WindowsFormsApplication1.exe

     文件        189  2019-03-19 12:16  SE_SQL\SE_SQL\bin\Debug\WindowsFormsApplication1.exe.config

     文件      28160  2019-03-19 15:16  SE_SQL\SE_SQL\bin\Debug\WindowsFormsApplication1.pdb

     文件        189  2019-03-19 12:16  SE_SQL\SE_SQL\bin\Debug\WindowsFormsApplication1.vshost.exe.config

     文件        490  2018-04-12 07:35  SE_SQL\SE_SQL\bin\Debug\WindowsFormsApplication1.vshost.exe.manifest

     文件       4564  2019-03-19 15:19  SE_SQL\SE_SQL\Form1.cs

     文件      14560  2019-03-19 15:19  SE_SQL\SE_SQL\Form1.Designer.cs

     文件       5817  2019-03-19 15:11  SE_SQL\SE_SQL\Form1.resx

     文件       7365  2019-03-19 15:19  SE_SQL\SE_SQL\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2019-03-19 12:16  SE_SQL\SE_SQL\obj\Debug\TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs

     文件          0  2019-03-19 12:16  SE_SQL\SE_SQL\obj\Debug\TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs

     文件          0  2019-03-19 12:16  SE_SQL\SE_SQL\obj\Debug\TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs

     文件       3584  2019-03-19 15:18  SE_SQL\SE_SQL\obj\Debug\TempPE\Properties.Resources.Designer.cs.dll

     文件       1411  2019-03-19 15:18  SE_SQL\SE_SQL\obj\Debug\WindowsFormsApplication1.csproj.FileListAbsolute.txt

     文件       1012  2019-03-19 15:15  SE_SQL\SE_SQL\obj\Debug\WindowsFormsApplication1.csproj.GenerateResource.Cache

     文件       2384  2019-03-19 12:17  SE_SQL\SE_SQL\obj\Debug\WindowsFormsApplication1.csprojResolveAssemblyReference.cache

     文件      16896  2019-03-19 15:16  SE_SQL\SE_SQL\obj\Debug\WindowsFormsApplication1.exe

     文件        180  2019-03-19 15:15  SE_SQL\SE_SQL\obj\Debug\WindowsFormsApplication1.Form1.resources

     文件      28160  2019-03-19 15:16  SE_SQL\SE_SQL\obj\Debug\WindowsFormsApplication1.pdb

     文件        180  2019-03-19 14:43  SE_SQL\SE_SQL\obj\Debug\WindowsFormsApplication1.Properties.Resources.resources

     文件        518  2019-03-19 15:19  SE_SQL\SE_SQL\Program.cs

     文件       1356  2019-03-19 12:16  SE_SQL\SE_SQL\Properties\AssemblyInfo.cs

     文件       2846  2019-03-19 15:18  SE_SQL\SE_SQL\Properties\Resources.Designer.cs

     文件       5612  2019-03-19 12:16  SE_SQL\SE_SQL\Properties\Resources.resx

     文件       1103  2019-03-19 15:18  SE_SQL\SE_SQL\Properties\Settings.Designer.cs

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

评论

共有 条评论