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

📄 browse_form.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.SqlClient;

namespace renshiguanli
{
    public partial class Browse_form : Form
    {
        private int temp1;   //EmployeeID
        private string temp2;//Name
        private int temp3;   //DeptID

        public Browse_form()
        {
            InitializeComponent();
            //连接数据库
            SqlConnection Myconn = new SqlConnection("Data Source=NUAA\\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=aaa");
            SqlCommand selectCMD = new SqlCommand("SELECT EmployeeID,Name,DeptID FROM dbo.tblEmployee", Myconn);
            selectCMD.CommandTimeout = 30;
            SqlDataAdapter deptDA = new SqlDataAdapter();
            deptDA.SelectCommand = selectCMD;
            Myconn.Open();

            DataSet deptDS = new DataSet();
            deptDA.Fill(deptDS, "dbo.tblEmployee");
            Myconn.Close();
            //把人员的部分信息填入表
            DataView myview;
            myview = deptDS.Tables["dbo.tblEmployee"].DefaultView;
            employee_dataGridView.DataSource = myview;
        }
        public void Settemp1(int a)
        {
            temp1 = a;
        }
        public int Gettemp1()
        {
            return temp1;
        }
        public void Settemp2(string a)
        {
            temp2 = a;
        }
        public string Gettemp2()
        {
            return temp2;
        }
        public void Settemp3(int a)
        {
            temp3 = a;
        }
        public int Gettemp3()
        {
            return temp3;
        }

        private void abort_Click(object sender, EventArgs e)
        {
            //this.Close();
            this.Hide();
        }

        private void sure_Click(object sender, EventArgs e)
        {
            string a = temp1.ToString();
            MainForm.core.SetText(a);
            MainForm.core.GiveText();
            this.Hide();
            //this.Close();
        }

        private void employee_dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1 && e.RowIndex != employee_dataGridView.Rows.Count - 1)
            {
                temp1 = (int)employee_dataGridView["EmployeeID", e.RowIndex].Value;
                temp2 = employee_dataGridView["Name", e.RowIndex].Value.ToString();
                temp3 = (int)employee_dataGridView["DeptID", e.RowIndex].Value;
            }
        }
    }
}

⌨️ 快捷键说明

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