C#高校人力管理系统

本文探讨了如何使用C#编程语言开发高效的高校人力管理系统。内容涉及系统设计、功能实现以及C#相较于Java的独特优势。通过实例,展示了C#在数据处理、界面交互等方面的高效性能。
摘要由CSDN通过智能技术生成
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

using System.Data.SqlClient;

namespace FrmManagement_System
{
    public partial class FrmInsert : Form
    {
        DBHelper helper = new DBHelper();

        public FrmInsert()
        {
            InitializeComponent();
        }
        #region 去登录
        private void btnLogin1_Click(object sender, EventArgs e)
        {
            FrmLogin login = new FrmLogin();
            login.Show();
            this.Hide();
        }
        #endregion

        private void btnSave_Click(object sender, EventArgs e)
        {
            if (Insert()==true)
            {
                InsertInto();
            }
        }

        private void InsertInto()
        {
            try
            {
                helper.OpenConnection();
                string sql = string.Format(@"INSERT INTO [Login]
           ([UserName]
           ,[passWord]
           ,[pwd]
           ,[Email])
     VALUES
           ('{0}'
           ,'{1}'
           ,'{2}',
           '{3}')", this.txtName.Text.Trim(), this.txtPass.Text.Trim(), this.txtPwd.Text.Trim(),this.txtEmail.Text.Trim());
                SqlCommand comm = new SqlCommand(sql, helper.Connection);
               int iRet=comm.ExecuteNonQuery();
               if (iRet>0)
               {
                   MessageBox.Show("添加成功");
               }
               else
               {
                   MessageBox.Show("添加失败");
               }

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                helper.CloseConnection();
            }
        }
        private bool Insert()
        {
            if (this.txtPass.Text.Trim()==string.Empty)
            {
                MessageBox.Show("密码不为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
            if (this.txtName.Text.Trim() == string.Empty)
            {
                MessageBox.Show("用户名不为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
            if (this.txtPwd.Text.Trim() == string.Empty)
            {
                MessageBox.Show("确认密码不为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
            if (this.txtEmail.Text.Trim() == string.Empty)
            {
                MessageBox.Show("邮箱不为空", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
            if (this.txtPwd.Text.Trim()!=this.txtPass.Text.Trim())
            {
                MessageBox.Show("两次密码不正确", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return false;
            }
            return true;
        }
    }
}






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

using System.Data.SqlClient;

namespace FrmManagement_System
{
    public partial class FrmLogin : Form
    {
        DBHelper helper = new DBHelper();
        public FrmLogin()
        {
            InitializeComponent();
        }
        #region 取消
        private void btnclose_Click(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("确认取消登录吗?", "系统提示", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
            if (result==DialogResult.Yes)
            {
                Application.Exit();
            }
        }
        #endregion

        #region 注册
        private void btnenroll_Click(object sender, EventArgs e)
        {
            FrmInsert insert = new FrmInsert();
            insert.Show();
            this.Hide();
        }
        #endregion

        #region 登录
        private void btnLogin_Click(object sender, EventArgs e)
        {
            if (Login()==true)
            {
               LoginP();
               
            }
        }

        private bool LoginP()
        {

            try
            {
                helper.OpenConnection();
                String sql = string.Format(@"SELECT [id]
                                              ,[UserName]
                                              ,[passWord]
                                          FROM [Login]
                                          where UserName='{0}' and passWord='{1}'",this.txtName.Text.Trim(),this.txtPass.Text.Trim());
                SqlCommand comm = new SqlCommand(sql, helper.Connection);
                int iRet=Convert.ToInt32(comm.ExecuteScalar());
                if (iRet>0)
                {
                    MessageBox.Show("登录成功");

                    FrmMangment Mangment = new FrmMangment();
                    Mangment.User = this.txtName.Text.Trim();
                    Mangment.Pwd = this.txtPass.Text.Trim();
                    Mangment.Show();
                    this.Hide();
                    return true;
                }
                else
                {
                    MessageBox.Sh
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值