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

📄 student.cs

📁 学生学籍管理系统 学生管理 教材管理 成绩管理
💻 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.OleDb;
using System.Configuration;

namespace 学籍管理系统
{
    public partial class student :DevComponents .DotNetBar .Office2007Form 
    {
        public student()
        {
            InitializeComponent();
            
        }
       
       
        private void conn()
        {
        }
        //通用检索函数
        private void constring(string command)
        {
            string cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\xjgl.mdb" + ";Persist Security Info=True";
            OleDbConnection cnn = new OleDbConnection(cn);
            string updatas = command;
            OleDbCommand com = new OleDbCommand(updatas, cnn);
            try
            {

                cnn.Open();
                com.ExecuteNonQuery();
                cnn.Close();
                student_Load(null, null);
                cls();
            }
            catch (Exception)
            {
                MessageBox.Show("输入的不正确!");
            }
            finally
            {
                cnn.Close();
            }
        }
       
        private DataTable dt;
        private OleDbDataAdapter da;
        private void student_Load(object sender, EventArgs e)
        {
         
              string cn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\\xjgl.mdb" + ";Persist Security Info=True";
                OleDbConnection cnn = new OleDbConnection(cn);
                 string mysel = "Select Stu_id as 学号,Stu_name as 姓名,Stu_major as 专业,Stu_department as 学院 from Students";
                OleDbCommand com = new OleDbCommand(mysel, cnn);
                 dt = new DataTable();
                  da = new OleDbDataAdapter();
                  da.SelectCommand = com;
                 OleDbCommandBuilder cb = new OleDbCommandBuilder(da);
                 da.Fill(dt);
               dataGridView1 .DataSource = dt;

        }
       public static string cobk ;
        private void buttonItem1_Click(object sender, EventArgs e)
        {

          string   mycom = "insert into Students(Stu_id,Stu_name,Stu_major,Stu_department) values( "+"'"+txxh .Text +"'"+","+"'"+txname .Text +"'"+","+"'"+txmajor .Text +"'"+","+"'"+txxb .Text  +"')";
          constring(mycom); 
      }
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

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

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

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

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

        }
        private void dataGridView1_CellContentClick_1(object sender, DataGridViewCellEventArgs e)
        {
       
        
          
    
        }
        private void dataGridView1_CellContentClick_2(object sender, DataGridViewCellEventArgs e)
        {
            int x = e.RowIndex;
         txxh.Text=dt.Rows [x][0].ToString () ;
         txname.Text = dt.Rows[x][1].ToString();
         txmajor.Text = dt.Rows[x][2].ToString();
         txxb.Text = dt.Rows[x][3].ToString();
        
        }
        private void cls()
        {
            txxh.Text = "";
            txname.Text = "";
            txmajor.Text = "";
            txxb.Text = "";
        }
        private void del_Click(object sender, EventArgs e)
        {
           
            string del = "delete from Students where Stu_id=" + "'" + txxh.Text.Trim() + "'";

            constring(del);
        }
        private void buttonItem2_Click(object sender, EventArgs e)
        {
         
            string updates = "update Students  set Stu_name =" + "'" + txname.Text.Trim() + "',Stu_major=" + "'" + txmajor.Text.Trim () + "',Stu_department="+"'"+txxb .Text .Trim ()+"' Where Stu_id="+"'"+txxh .Text .Trim ()+"'";
            constring(updates);
        }
    }
}

⌨️ 快捷键说明

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