C#windows competition management system

Chinese abstract

In order to improve the management efficiency of competition project information, this topic uses C# language and SQL Server database system to develop a WinForm type competition management system to efficiently manage competition project information to improve management quality. This system includes teacher login and registration, teacher information modification module, adding student information module, deleting student information module, finding student information module, modifying student information module, competition project management module, and student submission competition project application 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 : competition management system, C#, SQL Server

Software feasibility study and project development plan

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

This competition management system is mainly for login registration, adding student information, deleting student information, finding student information, modifying student information, competition project management, and students submitting competition project applications, 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 teacher registration information: Change of teacher's own information.

B. Add student information: enter student information.

C. Deletion of Student Information: Removal of student information.

D. Find student information: provide the function of querying student information for student ID and student name.

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

F. Approval of competition projects: update the approval status of submitted competition projects

G. Competition project query: keyword query for submitted projects

H. Students submit competition projects: Students submit their own competition projects to the administrator for approval.

I. Students query competition projects: Students can query the status of their submitted projects.

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 Teacher
insert image description here

Figure 4-4 Student account
insert image description here

Figure 4-5 Student information

insert image description here

Figure 4-6 Competition items

insert image description here

Figure 4-7 Entity relationship

insert image description here

4.2 Detailed analysis of functional modules

5. Software Coding

5.1 Teacher Module

(1) Login module design

[External link picture transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the picture and upload it directly (img-OStOc9V5-1675409407326)(file:///C:\Users\ccucc\AppData\Local\Temp\ksohtml3780 \wps32.jpg)]

5-1.1 Login window

This form interface is used for the login of teachers and students. Teachers who do not have an account can click to register, and the account of students is the student ID.

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

private void btnLogin_Click(object sender, EventArgs e)
{
    
    
    if (rdo_teacher.Checked)
    {
    
    
        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 teacher 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

insert image description here

5-2 Main page window

This form interface is used to display the teacher's successful login, 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 Add_Click(object sender, EventArgs e)
 {
    
    
     Add mainForm = new Add();
     mainForm.StartPosition = FormStartPosition.CenterScreen;
     mainForm.Show();
 }

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

5.3 The teacher modifies the password module design

insert image description here

5-3 Modify password window

This form interface is used to modify the teacher account 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 student information to realize the addition of student information, in which the format of the input data is verified, the student number is in digital form, the contact number is in the basic format of 11 digits, and the name is in Chinese characters. And neither can be empty.

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

private void btnSubmit_Click(object sender, EventArgs e)
 {
    
    
     if (!(ver.IsNumber(box1.Text)))
     {
    
    
         MessageBox.Show("学号只能为数字!");
         return;
     }
     if (!ver.IsChinese(box2.Text))
     {
    
    
         MessageBox.Show("姓名只能为中文");
         return;
     }
     if (!(box3.Text == "男" || box3.Text == "女"))
     {
    
    
         MessageBox.Show("性别只能是男/女");
         return;
     }
     if (!ver.IsHandset(box7.Text))
     {
    
    
         MessageBox.Show("联系电话格式错误,请重新输入!!!");
         return;
     }

     if (checkNull())
     {
    
               
         string b1 = box1.Text,b2 = box2.Text,b3 = box3.Text,b4 = box4.Text,b5 = box5.Text,b6 = box6.Text,b7 = box7.Text;
         Tab items = new Tab{
    
     box1 = b1,box2 = b2,box3 = b3,box4 = b4,box5 = b5,box6 = b6,box7 = b7};
         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 teacher can delete the student by entering the student number to be deleted.

Delete the key function code as follows:

private void button1_Click(object sender, EventArgs e){
    
    string dels = box1.Text;if (tabm.GetOneEqual(dels).Rows.Count == 0)     //数据库是否有需要删除的数据{
    
    
​        MessageBox.Show("没有检索到要删除的数据");return;}if (box1.Text.Equals("")){
    
    
​        MessageBox.Show("请输入要删除的数据");}else{
    
    string a = box1.Text;
​        Tab del = new Tab {
    
     box1 = a };
​        bool result = tabm.Delete(del);if (result){
    
    
​          MessageBox.Show("删除成功");}else{
    
    
​          MessageBox.Show("删除失败");}getAll();
​        box1.Text = "";}}private void getAll(){
    
    
​      dataGridView1.DataSource = tabm.GetAllData();}private void Delete_Load(object sender, EventArgs e){
    
    getAll();}

5.6 Query information module design

insert image description here

5-6 Query information window

This form interface is used to query data. The query is divided into precise search and fuzzy search. The precise search is to conduct accurate student information query through the student ID, and the fuzzy query is to conduct keyword query through the student's name.

The query key function code is as follows:

private void select_equal_Click(object sender, EventArgs e)
{
    
    
    if (textBox1.Text.Equals(""))
    {
    
    
        MessageBox.Show("未检索到你的输入信息!");
    }
    else
    {
    
    
        dataGridView1.DataSource = tabm.GetOneEqual(textBox1.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)
{
    
    
    if (textBox2.Text.Equals(""))
    {
    
    
        MessageBox.Show("未检索到你的输入信息!");
    }
    else
    {
    
    
        dataGridView1.DataSource = tabm.GetOneLike(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 student information to realize the modification of student information, in which the input data is format verified, the student number is in digital form, the contact phone number is in 11-digit basic format, gender is selected as a designated field, and name is in Chinese characters. And neither can be empty.

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

private void btnSubmit_Click(object sender, EventArgs e)
{
    
    
     if (!(ver.IsNumber(box1.Text)))
     {
    
    
         MessageBox.Show("学号只能为数字!");
         return;
     }
     if (!ver.IsChinese(box2.Text))
     {
    
    
         MessageBox.Show("姓名只能为中文");
         return;
     }
     if (!(box3.Text == "男" || box3.Text == "女"))
     {
    
    
         MessageBox.Show("性别只能是男/女");
         return;
     }
     if (!ver.IsHandset(box7.Text))
     {
    
    
         MessageBox.Show("联系电话格式错误,请重新输入!!!");
         return;
     }

     if (checkNull())
     {
    
    
         string b1 = box1.Text, b2 = box2.Text, b3 = box3.Text, b4 = box4.Text, b5 = box5.Text, b6 = box6.Text, b7 = box7.Text;
         Tab items = new Tab {
    
     box1 = b1, box2 = b2, box3 = b3, box4 = b4, box5 = b5, box6 = b6, box7 = b7 };

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

5.8 Competition project management module design

insert image description here

5-8 Competition project management window

This form interface is used to query and approve competition projects. Query provides three key fields: student number, project name, and project status for query, which can be combined or individually queried. Approval passes the ID of the corresponding project, and selects the status that needs to be modified to update the status.

The key function codes of competition project management are as follows:

private void button1_Click(object sender, EventArgs e)
{
    
    
    string xh = "";
    string xmmc = "";
    string xmzt = "";
    if (textBox1.Text != "")
    {
    
    
        xh = textBox1.Text;
    }
    if (textBox2.Text != "")
    {
    
    
        xmmc = textBox2.Text;
    }
    if (comboBox1.Text != "")
    {
    
    
        xmzt = comboBox1.Text;
    }
    dataGridView1.DataSource = tabm.getApplyForManStatusParams(xh,xmmc,xmzt);
}
private void button2_Click(object sender, EventArgs e)
{
    
    
    if (textBox3.Text!="" && comboBox2.Text!="" )
    {
    
    
        int id = 0;
        try
        {
    
    
            id = int.Parse(textBox3.Text);
        }
        catch
        {
    
    
            MessageBox.Show("ID格式错误");
            return;
        }
        string status = comboBox2.Text;

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

5.9 Student home page design

insert image description here

5-9 Student home page window

This form interface is used for students to query the status of their own competition projects, as well as records of all submitted competition information.

The key function codes of student homepage design are as follows:

private void button1_Click(object sender, EventArgs e)
 {
    
    
      dataGridView1.DataSource = tabm.getApplyForStuStatus(SendAccount,comboBox1.Text);
  }

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

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

5.10 Student Competition Project Submission Module

insert image description here

5-10 student competition project submission window

This form interface is used for students to submit applications for competition projects. It is necessary to fill in the project name and project introduction.

The key function codes submitted by students for competition projects are as follows:

//添加项目
private void button1_Click(object sender, EventArgs e)
{
    
    
    if (checkNull())
    {
    
    
        string b1 = textBox1.Text, b2 = textBox2.Text;
        project items = new project {
    
     xh = SendAccount, xmmc = b1, xmjs = b2};
        bool result = tabm.AddApply(items);
        if (result)
        {
    
    
            MessageBox.Show("添加成功");
            dataGridView1.DataSource = tabm.getApplyForStu(SendAccount);
            ClearAll();
        }
        else
        {
    
    
            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/128868462