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

📄 salarymanage.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.Data.SqlClient;
using System.Collections;

namespace renshiguanli
{
    public partial class salarycharge : Form
    {
        dataClass SD=new dataClass();
        public static string dp;
        public static int empl=-1;
        //public static int empl1=-1;
        public salarycharge()
        {
            InitializeComponent();
        }
            
        private void 员工查询_Click(object sender, EventArgs e)
        {
            Search sch = new Search();
            if (sch.ShowDialog() == DialogResult.OK)
            {
                ArrayList found_employee = Information.sql.search_employee(Search.name_search, Search.email_search, Search.deptid_search);
                if (found_employee.Count == 0)
                {
                    MessageBox.Show("查无此人");
                }
                else
                {
                    SqlConnection mycon = new SqlConnection("Server=NUAA\\SQLEXPRESS;Integrated Security=SSPI;DataBase=aaa");
                    mycon.Open();
                    SqlDataAdapter myAdapter = new SqlDataAdapter("select * from tblEmployee", mycon);
                    SqlCommandBuilder myBuilder = new SqlCommandBuilder(myAdapter);
                    DataSet myDataset = new DataSet();
                    myAdapter.Fill(myDataset, "tblEmployee");
                    dataGridView1.Rows.Clear();
                    for (int k = 0; k < found_employee.Count; k++)
                    {
                        dataGridView1.Rows.Add();
                        dataGridView1["EmployeeID", k].Value = (int)myDataset.Tables["tblEmployee"].Rows[(int)found_employee[k]]["EmployeeID"];
                        dataGridView1["name", k].Value = myDataset.Tables["tblEmployee"].Rows[(int)found_employee[k]]["Name"];
                        dataGridView1["BasicSalary", k].Value = (int)myDataset.Tables["tblEmployee"].Rows[(int)found_employee[k]]["BasicSalary"];
                    }
                    mycon.Close();
                }
            }
/*            searchman form = new searchman();
            if (form.ShowDialog() == DialogResult.OK)
                 SD.search(dataGridView1);
            //Form form = new searchman();
            //form.Show();*/
        }

        private void 设定薪资_Click(object sender, EventArgs e)
        {
            makebsalary form = new makebsalary();
//            salarycharge form1 = new salarycharge();
            if (empl != -1)
            {
                if (form.ShowDialog() == DialogResult.OK)
                    SD.fresh(dataGridView1);
 //               this.Close();
//                form1.Show();
            }
            else
                MessageBox.Show("请选择您要进行操作的员工!");
            
        }

        private void 历史查询_Click(object sender, EventArgs e)
        {
            Form form = new history();
            if (empl != -1)
                form.Show();
            else MessageBox.Show("请点击选择您将要进行查询的员工!");
        }

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

        private void 部门汇总_Click(object sender, EventArgs e)
        {
            department form=new department();
            if (form.ShowDialog() == DialogResult.OK)
            SD.dpttotal(dataGridView1);
        }

        private void salarycharge_Load(object sender, EventArgs e)
        {
            string strConnecton = "Server=NUAA\\SQLEXPRESS;Integrated Security=SSPI;DataBase=aaa";
            SqlConnection thisConnection = new SqlConnection(strConnecton);
            string strTable = "dbo.tblEmployee";
            SqlDataAdapter thisAdapter = new SqlDataAdapter("SELECT * FROM dbo.tblEmployee", thisConnection);
            SqlCommandBuilder thisBuilder = new SqlCommandBuilder(thisAdapter);
            DataSet thisDataSet = new DataSet();
            thisConnection.Open();
            thisAdapter.Fill(thisDataSet, strTable);
            for (int k = 0; k < thisDataSet.Tables[strTable].Rows.Count; k++)
            {
                dataGridView1.Rows.Add();
                dataGridView1["EmployeeID", k].Value = (int)thisDataSet.Tables[strTable].Rows[k]["EmployeeID"];
                dataGridView1["name", k].Value = thisDataSet.Tables[strTable].Rows[k]["Name"];
                dataGridView1["BasicSalary", k].Value = (int)thisDataSet.Tables[strTable].Rows[k]["BasicSalary"];

            }
            thisConnection.Close();
        }

        private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if(e.RowIndex!=dataGridView1.Rows.Count-1&&e.RowIndex!=-1)
            empl=(int)dataGridView1["EmployeeID", e.RowIndex].Value ;
        }

        private void btn_showall_Click(object sender, EventArgs e)
        {
            SD.fresh(dataGridView1);
        }          
    }
}

⌨️ 快捷键说明

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