C#windows personnel information management system, employee evaluation system

Chinese abstract

In order to improve the management efficiency of personnel information, this subject uses C# language and SQL Server database system to develop a WinForm personnel management system to manage personnel information efficiently and improve the quality of management. This system includes administrator login and registration, administrator information modification module, adding personnel information module, deleting personnel information module, searching personnel information module, modifying personnel information module, employee evaluation module. The design report elaborates on six aspects: feasibility study, project development plan and system development environment; system requirements analysis; outline design (including database design) and detailed design; specific coding implementation of each functional module; system test; design summary. Through the development of this system, the complete process of software project design and development has been practiced.

Keywords : personnel management system, C#, SQL Server, three-tier architecture

1 Software feasibility study and project development plan

1.1 Problem Definition

1.2 Feasibility analysis

1.3 Progress plan

2. Demand analysis

2.1 Introduction

2.2 Function Description

2.3 Other requirements

Operating system: Windows10

Operating environment: VisualStudio

Database environment: SQL Server

3. Outline design

3.1 Functional module design

The main functions of this personnel management system are login and registration, adding personnel information, deleting personnel information, searching personnel information, modifying personnel information, employee evaluation, etc.

The system function block diagram is shown in Figure 3-1.

insert image description here

Figure 3-1 System function module diagram

1) Login and registration function

A. Login: Enter the user name and password to log in, verify the user name and password, and log in.

B. Registration: Create a new user and password to log in and enter basic information.

2) Add, delete, check and modify functions

A. Modification of administrator registration information: Change of administrator's own information.

B. Add personnel information: enter personnel information.

C. Deletion of personnel information: removal of personnel information.

D. Search personnel information: You can query personnel information based on education, political affiliation, and professional title, or you can inquire personnel information based on education + political affiliation, education + professional title.

E. Modify personnel information: modify the wrong information of personnel information.

F. Evaluation query: perform employee evaluation query based on name. And you can directly query the information of employees who have been evaluated and those who have not been evaluated.

G. Write evaluation: evaluate the employees who have not been evaluated, and modify the evaluation of the employees who have been evaluated.

3.2 Database design

4. Detailed design

4.1 Overall Design

(1) System use case diagram

insert image description here

Figure 4-1 System use case

(2) ER diagram

insert image description here

Figure 4-3 Administrator

insert image description here

Figure 4-4 Personnel information

insert image description here

Figure 4-5 Evaluation information

insert image description here

Figure 4-6 Entity relationship

insert image description here

Figure 4-7 Complete ER diagram

4.2 Detailed analysis of functional modules

5. Software Coding

5.1 Administrator module

(1) Login module design

insert image description here

5-1.1 Login window

This form interface is used for administrator login, and users without an account can click to register.

The key function codes of the login window are as follows:

private void btnLogin_Click(object sender, EventArgs e)
{
    
    
    try
    {
    
    
        if (textBox1.Text == "" || textBox2.Text == "")
        {
    
    
            MessageBox.Show("请输入完整信息!!!");
            return;
        }
        string count = textBox1.Text;
        string pwd = ToMD5(textBox2.Text);
        Models.Login user = new Models.Login {
    
     account = count,password=pwd };
        bool result = ma.Login(user);
        if (result)
        {
    
    
            this.Hide();
            main mainForm = new main(textBox1.Text);
            mainForm.StartPosition = FormStartPosition.CenterScreen;
            mainForm.Show();
        }
        else
        {
    
    
            MessageBox.Show("账号或密码错误!!!");
        }
    }
    catch
    {
    
    
        MessageBox.Show("登录失败!!!");
    }
    
}

(2) Registration module design

insert image description here

5-1.2 Registration window

This form interface is used for administrator registration, in which the account number, nickname, and password are formatted. The account number is 4 digits, the nickname can only be in Chinese, and the password needs to be entered twice to register successfully.

The key function codes of the registration interface are as follows:

private void btnSubmit_Click(object sender, EventArgs e)
{
    
    
     string count = txt_count.Text;
     string pwd =ToMD5(txt_pwd.Text);
     string nc = txt_name.Text;
     string rePwd = ToMD5(txt_submit.Text);
     if (count == "" || pwd == "" || nc == "" || rePwd == "")
     {
    
    
         MessageBox.Show("请输入完整信息!!!");
         return;
     }
     if (!ver.IsCode(txt_count.Text))    //验证账号格式是否正确4-16位数字
     {
    
    
         MessageBox.Show("格式不正确,请输入非0开头的4-16位数字");
         return;
     }

     if (pwd == rePwd)
     {
    
    
         Models.Login user = new Models.Login {
    
     account = count, password = pwd, name = nc };
         bool result = ma.Register(user);

         if (result)
         {
    
    
             MessageBox.Show("注册成功!!!");
             txt_count.Text = "";
             txt_pwd.Text="";
             txt_name.Text="";
             txt_submit.Text="";
         }
         else
         {
    
    
             MessageBox.Show("注册失败!!!");
         }
     }
     else
     {
    
    
         MessageBox.Show("密码输入不一致,请重新输入!!!");
     }
 }

5.2 Main page design

5-2 Main page windowinsert image description here

This form interface is used to display the successful login of the administrator, and serves as the entrance of each sub-function module.

The key function codes of the main interface are as follows:

private void main_Load(object sender, EventArgs e)
{
    
    
    label3.Text = login.GetUser(SendAccount).DataSet.Tables[0].Rows[0]["昵称"].ToString();
}

private void Exit_Click(object sender, EventArgs e)
{
    
    
    this.Close();
    Login mainForm = new Login();
    mainForm.StartPosition = FormStartPosition.CenterScreen;
    mainForm.Show();
}

private void Add_Click(object sender, EventArgs e)
{
    
    
    Add mainForm = new Add();
    mainForm.StartPosition = FormStartPosition.CenterScreen;
    mainForm.Show();
}

5.3 The administrator modifies the password module design

insert image description here

5-3 Modify password window

This form interface is used to modify the administrator password

The key function code for modifying the password is as follows:

private void button1_Click(object sender, EventArgs e)
{
    
    
    if (box2.Text == "" || box3.Text == "")
    {
    
    
        MessageBox.Show("请输入完整");
    }
    else
    {
    
    
        if (box2.Text.Equals(box3.Text))
        {
    
    
            string no = SendAccount;
            string pwd = ToMD5(box2.Text);
            Models.Login u = new Models.Login
            {
    
    
                account = no,
                password = pwd
            };
            bool result = lm.UpdatePwd(u);
            if (result)
            {
    
    
                MessageBox.Show("修改成功");
            }
            else
            {
    
    
                MessageBox.Show("修改失败");
            }
        }
        else
        {
    
    
            MessageBox.Show("两次密码不一致");
        }
    }
}

5.4 Add information management module design

insert image description here

5-4 Add window

This form interface is used to add personnel information. The administrator enters the necessary data according to the required fields. All fields cannot be empty.

The key function codes for adding personnel information are as follows:

private void btnSubmit_Click(object sender, EventArgs e)
{
    
    
    string borthDay = box2.Text.Replace('年', '-').Replace('月', '-').Replace('日', '-');

    string admission = box5.Text.Replace('年', '-').Replace('月', '-').Replace('日', '-');
    
    if (checkNull())
    {
    
    
        string b1 = box1.Text, b2 = borthDay.Substring(0, borthDay.Length - 1), b3 = box3.Text, b4 = box4.Text, b5 = admission.Substring(0, admission.Length - 1);
        string b6 = box6.Text, b7 = box7.Text, b8 = box8.Text, b9 = box9.Text, b10 = box10.Text;
        string b11 = box11.Text;

        Tab items = new Tab{
    
    
            box1 = b1,box2 = b2,box3 = b3,box4 = b4,box5 = b5,box6 = b6,box7 = b7,
            box8 = b8,box9 = b9,box10 = b10,box11 = b11
        };
        bool result = tabm.Add(items);
        if (result)
        {
    
    
            MessageBox.Show("添加成功");
            getAll();
            ClearAll();
        }
        else
        {
    
    
            MessageBox.Show("添加失败,主键重复");
        }
    }
    else
    {
    
    
        MessageBox.Show("请输入完整信息");
    }
}

5.5 Delete information module design

insert image description here

5-5 Delete information window

This form interface is used for data deletion, and the administrator can perform the deletion operation by entering the ID to be deleted.

Delete the key function code as follows:

private void button1_Click(object sender, EventArgs e)
{
    
    
    string dels = box1.Text;
    if (tabm.GetOnedelete(dels).Rows.Count == 0)         //数据库是否有需要删除的数据
    {
    
    
        MessageBox.Show("没有检索到要删除的数据");
        return;
    }
    if (box1.Text.Equals(""))
    {
    
    
        MessageBox.Show("请输入要删除的数据");
    }
    else
    {
    
    
        int a = 0;
        try
        {
    
    
            a = int.Parse(box1.Text);
            
        }
        catch
        {
    
    

        }
        Tab del = new Tab {
    
     box12 = a };

        bool result = tabm.Delete(del);
        if (result)
        {
    
    
            MessageBox.Show("删除成功");
        }
        else
        {
    
    
            MessageBox.Show("删除失败");
        }
        getAll();
        box1.Text = "";
    }
}

5.6 Query information module design

insert image description here

5-6 Query information window

This form interface is used to query data, and personnel information can be queried based on education background, political affiliation, and professional title, or education + political affiliation, education + professional title.

The query key function code is as follows:

private void select_equal_Click(object sender, EventArgs e)
{
    
    
    dataGridView1.DataSource = tabm.GetOneEqual(xl1.Text, box4.Text);
}
private void getAll()
{
    
    
    dataGridView1.DataSource = tabm.GetAllData();
}

private void Select_Load(object sender, EventArgs e)
{
    
    
    getAll();
}

private void select_like_Click(object sender, EventArgs e)
{
    
    
    dataGridView1.DataSource = tabm.GetOneLike(xl2.Text, textBox2.Text);
    
}

5.7 Modify information module design

insert image description here

5-7 Modify the information window

This form interface is used to modify personnel information. Select a piece of information that needs to be modified, and the information will be automatically filled into the text box, and then change the data according to the required fields. All fields cannot be empty.

The key function codes for modifying personnel information are as follows:

 private void btnSubmit_Click(object sender, EventArgs e)
 {
    
    
      string borthDay = box2.Text.Replace('年', '-').Replace('月', '-').Replace('日', '-');

      string admission = box5.Text.Replace('年', '-').Replace('月', '-').Replace('日', '-');

      if (checkNull())
      {
    
    
          string b1 = box1.Text, b2 = borthDay.Substring(0, borthDay.Length - 1), b3 = box3.Text, b4 = box4.Text, b5 = admission.Substring(0, admission.Length - 1);
          string b6 = box6.Text, b7 = box7.Text, b8 = box8.Text, b9 = box9.Text, b10 = box10.Text;
          string b11 = box11.Text,b12=label6.Text;

          Tab items = new Tab {
    
    
              box1 = b1,
              box2 = b2,
              box3 = b3,
              box4 = b4,
              box5 = b5,
              box6 = b6,
              box7 = b7,
              box8 = b8,
              box9 = b9,
              box10 = b10,
              box11 = b11,
              box12= int.Parse(b12)
          };

          bool result = tabm.Update(items);
          if (result)
          {
    
    
              MessageBox.Show("修改成功");
              getAll();
              ClearAll();
          }
          else
          {
    
    
              MessageBox.Show("修改失败");
          }
      }
      else
      {
    
    
          MessageBox.Show("请输入完整信息");
      }
  }

5.8 Design of employee evaluation module

insert image description here

5-8 employee evaluation window

This form interface is used for employee evaluation query, evaluation input and modification, and employee evaluation query based on name. And you can directly query the information of employees who have been evaluated and those who have not been evaluated. Write evaluation: evaluate the employees who have not been evaluated, and modify the evaluation of the employees who have been evaluated.

The key function codes are as follows:

private void button4_Click(object sender, EventArgs e)
{
    
    
    //录入评价
    if (box2.Text=="")      
    {
    
    
        if (box4.Text=="")
        {
    
    
            MessageBox.Show("录入评价不能为空");
        }
        else
        {
    
    
            try
            {
    
    
                string b1 = box4.Text, b2 = box1.Text;
                judge items = new judge
                {
    
    
                    judgetext = b1,
                    baseid = int.Parse(b2),

                };
                bool result = jm.Add(items);
                if (result)
                {
    
    
                    MessageBox.Show("添加成功");
                    getAll();
                    ClearAll();
                }
                else
                {
    
    
                    MessageBox.Show("添加失败,主键重复");
                }
            }
            catch
            {
    
    

            }
            
        }
    }
    //修改评价
    else
    {
    
    
        if (box4.Text == "")
        {
    
    
            MessageBox.Show("修改评价不能为空");
        }
        else
        {
    
    
            judge items = new judge
            {
    
    
                judgetext = box4.Text,
                ID=int.Parse(box2.Text)
            };
            bool result = jm.Update(items);
            if (result)
            {
    
    
                getAll();
                ClearAll();
                MessageBox.Show("修改成功");
            }
            else
            {
    
    
                MessageBox.Show("修改失败");
            }
        }
    }
}

6. Test

6.1 Test plan

6.2 Test case design and execution

6.3 Test Summary

7. Summary

Access to source code and original documents: home of winform

Guess you like

Origin blog.csdn.net/qq_44423029/article/details/128897507