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

📄 form1.cs

📁 学生学籍管理软件 提供输入
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CrystalDecisions;
using CrystalDecisions.CrystalReports;
using CrystalDecisions.ReportSource;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
using CrystalDecisions.Windows.Forms;




namespace CrystalReportsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

        }
           /* CryRptMStockRecordStockOut rpt = new CryRptMStockRecordStockOut();
            rpt.SetDataSource(DS);

            this.CRViewer.ReportSource = rpt;
            this.CRViewer.RefreshReport();   */


     
        private void Form1_Load(object sender, EventArgs e)
        {

        /*    //    Form2.Form2_FormClosing; Form2_FormClosing f2_1 = new Form2_FormClosing();
            //string strcnn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb";  //绝对路径
            string strcnn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + AppDomain.CurrentDomain.BaseDirectory + "..\\db1.mdb";
            //string strcnn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\\DATA\\XJGL.mdb";
            //string strcnn = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + MapPathSecure("XJGL.mdb");

            OleDbConnection str = new OleDbConnection(strcnn);
            string sql = "insert into student(id,name) values(123456789,'zhuzhu')";
            OleDbCommand RS = new OleDbCommand(sql, str);
            str.Open();
            int result = RS.ExecuteNonQuery();
            if (result == 1)
             {
                 MessageBox.Show("插入数据成功");
             }
             else
             {
                 Console.Write("插入数据失败");
             }

            str.Close();*/

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form f2 = new Form();
            f2.Show();
            //    Form2.Form2_FormClosing; Form2_FormClosing f2_1 = new Form2_FormClosing();
            //string strcnn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\db1.mdb";  //绝对路径
            string strcnn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + AppDomain.CurrentDomain.BaseDirectory + "..\\db1.mdb";
            //string strcnn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\\DATA\\XJGL.mdb";
            //string strcnn = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + MapPathSecure("XJGL.mdb");

            OleDbConnection str = new OleDbConnection(strcnn);
            string sql = "insert into student(id,name) values(123456789,'zhuzhu')";
            OleDbCommand RS = new OleDbCommand(sql, str);
            str.Open();
            int result = RS.ExecuteNonQuery();
            if (result == 1)
            {
                MessageBox.Show("插入数据成功");
            }
            else
            {
                Console.Write("插入数据失败");
            }

            str.Close();
        
           CrystalReport1 rpt = new CrystalReport1();
            rpt.SetDataSource(RS);
         //   CrystalReportViewer1.ReportSource = rpt;

         //  CrystalReportViewer1.RefreshReport();  


        
        
        
        }
            
            /*    private void CrystalReport11_InitReport(object sender, EventArgs e)
        {
                 this.CRViewer.ReportSource = rpt;

                 this.CRViewer.RefreshReport();   
    
        }  */

        private void CrystalReportViewer_Load(object sender, EventArgs e)
        {
             
    
        }


        public void CrystalReportViewer3()
        {
           // InitializeComponent();

        }

        private void crystalReportViewer3_Load(object sender, EventArgs e)
        {
            CrystalReport1 cr = new CrystalReport1();
            CrystalReportViewer3 cr2 = new CrystalReportViewer3();
            DataSet ds = new DataSet();




            string strcnn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source= " + AppDomain.CurrentDomain.BaseDirectory + "..\\db1.mdb";
            //string strcnn = @"provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + System.Reflection.Assembly.GetExecutingAssembly().Location + "\\DATA\\XJGL.mdb";
            //string strcnn = @"Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + MapPathSecure("XJGL.mdb");

            OleDbConnection str = new OleDbConnection(strcnn);
            string sql = "insert into student(id,name) values(123456789,'zhuzhu')";
            OleDbCommand RS = new OleDbCommand(sql, str);
            str.Open();
            int result = RS.ExecuteNonQuery();
            if (result == 1)
            {
                MessageBox.Show("插入数据成功");
            }
            else
            {
                Console.Write("插入数据失败");
            }


            string sqll = "SELECT * FROM student";
            ds = DBM.getDataSet(sqll);//DBM是一个取数据集的类,能正常运行 
            cr.SetDataSource(ds);
            CrystalReportViewer1.ReportSource = cr; 




            str.Close();
            


        }

        private void CrystalReport11_InitReport(object sender, EventArgs e)
        {

        }
            
            
        
          


          
        }

      
     



       
    }

⌨️ 快捷键说明

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