view.cs

来自「用c#和access编写的仓库管理系统源码」· CS 代码 · 共 79 行

CS
79
字号
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.OleDb;


namespace WindowsApplication2
{
    public partial class View : Form
    {
        public View()
        {
            InitializeComponent();
            
        }

        public void Bind(string article_id)
        {

            View view = new View();
           
            view.Show();

            OleDbConnection ConnAcc = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Windows.Forms.Application.StartupPath + "/huochaihe.mdb");

            ConnAcc.Open();

            string article = "select article_id,article_name,article_Comment,article_author from [article] where article_id = " + article_id + "";

            //MessageBox.Show(article, "登录提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            OleDbCommand cmd = new OleDbCommand(article, ConnAcc);

            OleDbDataReader rs = cmd.ExecuteReader();
            string article_author = null;
            string article_Comment = null;
            string article_name = null;

            while (rs.Read())
            {

                //int article_id = (int)rs["article_id"];
                 article_name = (string)rs["article_name"];
                 article_Comment = (string)rs["article_Comment"];
                 article_author = (string)rs["article_author"];


            }

            view.label1.Text = article_id.ToString();
            view.label2.Text = article_name.ToString();
            view.label3.Text = article_author.ToString();
            view.richTextBox1.Text = article_Comment.ToString();


           // MessageBox.Show(article_id.ToString(), "登录提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);

            rs.Close();

            ConnAcc.Close();
        }

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

        private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }


    }
}

⌨️ 快捷键说明

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