• 大小: 1.01MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-10-23
  • 语言: C#
  • 标签: winform  access  

资源简介

有数据的查询,编辑,添加,删除,生成报表等功能的demo,可以运行

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
//using Microsoft.Office.Interop.Word;
//using Microsoft.Office.Interop.Excel;
using System.Threading;

namespace ComputerManage
{
    public partial class Form1 : Form
    {
        OleDbConnection conn = new OleDbConnection(“Data Source=“ + System.Windows.Forms.Application.StartupPath + “\\config\\cinfor.mdb;Provider=Microsoft.Jet.OLEDB.4.0“);
        Form2 dataEdit = new Form2();
       // int rowIndex = -1;
       // bool serchFlag = false;

        public Form1()
        {
            InitializeComponent();
            //初始化
            InitCombo();
            InitGridView();

        }
        //初始化下拉列表
        private void InitCombo()
        {
            this.comboGroup.Items.Add(“全部“);
            this.comboGroup.Items.Add(“502“);
            this.comboGroup.Items.Add(“508“);
            this.comboGroup.Items.Add(“510“);
            this.comboGroup.Items.Add(“506“);
            this.comboGroup.Items.Add(“617“);
            this.comboGroup.Items.Add(“503“);
            this.comboGroup.Items.Add(“530“);
            this.comboGroup.Items.Add(“614“);

            this.comboState.Items.Add(“全部“);
            this.comboState.Items.Add(“使用中“);
            this.comboState.Items.Add(“停用“);
        }
       
        //初始化gridview1
        private void InitGridView()
        {
            //不显示最后一行的空白行
            dataGridView1.AllowUserToAddRows = false;
            DataTable dt = new DataTable();
            string allInformation = “select * from detailInfor order by ID“;
            dt = DataTableExcute(allInformation);
            dataGridView1.DataSource = dt;

        }
        //得到所选行索引
        public int getSelectedIndex()
        {
            int count = this.dataGridView1.Rows.Count;
            for (int i = 0; i < count - 1; i++)
            {
                if (dataGridView1.Rows[i].Selected == true)
                    return i;
            }
            return -1;   
        }
        //查询得到datatable
        public DataTable DataTableExcute(string cmdstr)
        {
            OleDbCommand cmd = new OleDbCommand(cmdstr conn);
            OleDbDataAdapter dataAdapter = new OleDbDataAdapter(cmd);
            DataTable datatable = new DataTable();
            DataSet dataset = new DataSet();
            try
            {
                conn.Open();
                dataAdapter.Fill(dataset);
                if (dataset.Tables[0].Rows.Count > 0)
                {
                    datatable = dataset.Tables[0];
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                conn.Close();
                cmd.D

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-11-23 13:38  ComputerManage\
     目录           0  2016-11-23 13:38  ComputerManage\ComputerManage\
     文件        4382  2016-10-30 10:28  ComputerManage\ComputerManage\ComputerManage.csproj
     文件       20214  2016-10-30 10:55  ComputerManage\ComputerManage\Form1.Designer.cs
     文件       20314  2016-11-03 19:37  ComputerManage\ComputerManage\Form1.cs
     文件       11391  2016-10-30 10:55  ComputerManage\ComputerManage\Form1.resx
     文件       11688  2016-11-03 19:27  ComputerManage\ComputerManage\Form2.Designer.cs
     文件        3243  2016-11-03 19:27  ComputerManage\ComputerManage\Form2.cs
     文件        5817  2016-11-03 19:27  ComputerManage\ComputerManage\Form2.resx
     文件         495  2016-10-24 15:48  ComputerManage\ComputerManage\Program.cs
     目录           0  2016-11-23 13:38  ComputerManage\ComputerManage\Properties\
     文件        1378  2016-10-24 15:48  ComputerManage\ComputerManage\Properties\AssemblyInfo.cs
     文件        1150  2016-10-28 10:25  ComputerManage\ComputerManage\Properties\Close_up_16px_1181430_easyicon.net.ico
     文件        1150  2016-10-28 10:26  ComputerManage\ComputerManage\Properties\Delete_16px_1181442_easyicon.net.ico
     文件        2880  2016-10-24 15:48  ComputerManage\ComputerManage\Properties\Resources.Designer.cs
     文件        5612  2016-10-24 15:48  ComputerManage\ComputerManage\Properties\Resources.resx
     文件        1101  2016-10-24 15:48  ComputerManage\ComputerManage\Properties\Settings.Designer.cs
     文件         249  2016-10-24 15:48  ComputerManage\ComputerManage\Properties\Settings.settings
     文件        1150  2016-10-28 10:25  ComputerManage\ComputerManage\Properties\add_16px_1181422_easyicon.net.ico
     文件         894  2016-10-25 17:02  ComputerManage\ComputerManage\Properties\doc_16px_1181400_easyicon.net.ico
     文件        1150  2016-10-25 17:01  ComputerManage\ComputerManage\Properties\query_16px_1181401_easyicon.net.ico
     文件        1150  2016-10-28 10:28  ComputerManage\ComputerManage\Properties\write_16px_1181413_easyicon.net.ico
     目录           0  2016-11-23 13:38  ComputerManage\ComputerManage\bin\
     目录           0  2016-11-23 13:38  ComputerManage\ComputerManage\bin\Debug\
     文件       33280  2016-11-03 19:37  ComputerManage\ComputerManage\bin\Debug\ComputerManage.exe
     文件       48640  2016-11-03 19:37  ComputerManage\ComputerManage\bin\Debug\ComputerManage.pdb
     文件       11600  2017-08-22 21:26  ComputerManage\ComputerManage\bin\Debug\ComputerManage.vshost.exe
     文件         490  2013-03-18 17:00  ComputerManage\ComputerManage\bin\Debug\ComputerManage.vshost.exe.manifest
     文件     1100392  2007-10-10 09:48  ComputerManage\ComputerManage\bin\Debug\Microsoft.Office.Interop.Excel.dll
     文件      662120  2007-10-10 09:48  ComputerManage\ComputerManage\bin\Debug\Microsoft.Office.Interop.Word.dll
     文件       64088  2007-10-10 09:48  ComputerManage\ComputerManage\bin\Debug\Microsoft.Vbe.Interop.dll
............此处省略37个文件信息

评论

共有 条评论