境外人员来访信息管理系统(C#)

用windows窗体应用程序做一个简单的
“境外人员来访信息管理系统”。它主要可以实现的功能:对来访人员进行国籍,姓名,性别,手机号,出生日期等信息开始统计,并保存到已有的文件中,在另外的一个窗口可以查看已存的人员的信息,并在另一个窗口进行显示。(可以根据自己的喜欢调整窗口的颜色和大小)

插上图片:

在这里插入图片描述
在这里插入图片描述

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        string[] stuinf;
        int num = 0;
        int stuindex = 0;//已存信息的下标
        int delnum = 0;//欲删除的的信息计数
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            stuinf = new string[100];
            this.cboGender.SelectedIndex = 0;
            string[] stuinfsaved = System.IO.File.ReadAllLines("stu.txt");//信息存在文件
            for (int i = 0; i < stuinfsaved.Length; i++)
            {
                stuinf[i] = stuinfsaved[i];
                num++;
            }
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (this.txtChain.Text.Trim() == "")//输入信息要无空格;
            {
                MessageBox.Show("您好,来访人员国籍是不能为空!");
                return;
            }
            if (this.txtName.Text.Trim() == "")
            {
                MessageBox.Show("您好,来访人员姓名是不能为空!");
                return;
            }
            if (this.dtpBirthday.Text.Trim() == "")
            {
                MessageBox.Show("您好,来访人员出生日期是不能为空!");
                return;
            }
            if (this.txtPhone.Text.Trim() == "")
            {
                MessageBox.Show("您好,来访人员手机号码是不能为空!");
                return;
            }
            if (this.txtTag.Text.Trim() == "")
            {
                MessageBox.Show("您好,请输入来访人员的位号!");
                return;
            }
            string info;
            info ="人员位号:"+this.txtTag.Text+";"+"人员国籍:" + this.txtChain.Text + ";" +"人员姓名:" + this.txtName.Text + ";" + "人员性别:"+this.cboGender.Text + ";" +"出生日期:"+ this.dtpBirthday.Text + ";"
               +"电话号码:"+ this.txtPhone.Text;
            stuinf[num] = info;
            num++;
            MessageBox.Show("录入成功!");
            this.txtName.Text = "";
            this.txtPhone.Text = "";
            this.txtChain.Text = "";
            this.cboGender.SelectedIndex = 0;

        }

        private void button1_Click(object sender, EventArgs e)
        {
            string[] stuData = new string[num - delnum];
            for (int i = 0,k=0; i < num; i++)//将信息删除后重新有顺序的记录在数组中
            {
                if (stuinf[i][0] != '*')
                {
                    stuData[k] = stuinf[i];
                    k++;
                }
            }
            System.IO.File.WriteAllLines("stu.txt", stuData, Encoding.Unicode);
            this.Close();
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            this.txtName.Text = "";
            this.txtPhone.Text = "";
            this.txtChain.Text = "";
            this.cboGender.SelectedIndex = 0;
        }

        private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.tabControl1.SelectedIndex == 1)  //进入学生信息显示界面
            {
                this.txtStuinf.Lines = stuinf[0].Split(';');
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
           // stuindex++;
           do
           {
            stuindex = (stuindex + 1) % num;
           } while (stuinf[stuindex][0]=='*');
          this.txtStuinf.Lines = stuinf[stuindex].Split(';');
        }

        private void txtName_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtStuid_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnDelete_Click(object sender, EventArgs e)
        {
            stuinf[stuindex] = "*" + stuinf[stuindex];//用“*”记录要删除的相关人员的信息
            MessageBox.Show("删除成功!");
            delnum++;
            do
           {
                 stuindex = (stuindex + 1) % num;
           } while (stuinf[stuindex][0]=='*');
            this.txtStuinf.Lines = stuinf[stuindex].Split(';');
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (stuindex == 0)
                stuindex = num;
            stuindex = (stuindex -1) % num;
            this.txtStuinf.Lines = stuinf[stuindex].Split(';');
        }

        private void txtStuinf_TextChanged(object sender, EventArgs e)
        {

        }

        private void txtTag_TextChanged(object sender, EventArgs e)
        {

        }

        
    }
}

小萌新刚刚学习C#,就已经被其强大的功能所振服~~~

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
某高校,主要人员有:领导、教师和学生,共有的信息包括:编号、姓名、性别、年龄。其中领导还应包含的信息有:任职部门(学院、各系部)、职称;教师还应包含的信息有:职称、任职时间、专业;学生还应包含的信息有:所在班级、所在宿舍等。 某高校有四类员工:教师、实验员、行政人员,教师兼行政人员;共有的信息包括:编号、姓名、性别、年龄等。其中,教师还包含的信息有:所在系部、专业、职称;实验员还包含的信息由:所在实验室、职务;行政人员还包含的信息有:政治面貌、职称等。 2、功能要求 (1)基本功能 1) 添加功能:程序能够任意添加上述四类人员的记录,可提供选择界面供用户选择所要添加的人员类别,要求员工的编号要唯一,如果添加了重复编号的记录时,则提示数据添加重复并取消添加。 2) 查询功能:可根据编号、姓名等信息对已添加的记录进行查询,如果未找到,给出相应的提示信息,如果找到,则显示相应的记录信息。 3) 显示功能:可显示当前系统中所有记录,每条记录占据一行。 4) 编辑功能:可根据查询结果对相应的记录进行修改,修改时注意编号的唯一性。 5)删除功能:主要实现对已添加的人员记录进行删除。如果当前系统中没有相应的人员记录,则提示“记录为空!”并返回操作;否则,输入要删除的人员的编号或姓名,根据所输入的信息删除该人员记录,如果没有找到该人员信息,则提示相应的记录不存。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值