人事信息管理系统

1.1项目背景

随着科学技术的不断提高,计算机科学日渐成熟,其强大的功能已为人们深刻认识,它已进入人类社会的各个领域并发挥着越来越重要的作用。作为计算机应用的一部分,使用计算机对人事信息进行管理,具有着手工管理所无法比拟的优点.例如:检索迅速、查找方便、可靠性高、存储量大、保密性的事情,在下面的各章中我们将以开发一套人事管理系统为例,谈谈其开发过程和所涉及到的问题及解决方法。

2.1可行性分析报告

在各企业中计算机已经普遍存在,并且在事物处理,工作安排,人员管理等方面使用起来非常迅速。使用计算机来对企业的操作,安排,大大提高了工作的效率,还节省了许多人力物力,节省出大量的时间,也为管理者对企业的管理,对人员的了解方便许多。因此,用计算机来管理企业人事信息,是非常必需的。

2.2技术条件方面的可行性:

该软件的基本要求与功能是实现员工的基本信息数据包括和员工有关的数据的管理与操作处理。工种设置,部门管理,员工管理,收入管理,以及有关信息查询,修改,删除要求所产生的数据输出。

 本系统选择C#语言,目前使用的开发技术来说建议系统的功能目标应该能够达到;.利用现有的技术在规定的期限内开发工作基本能够完成。到时具体的困难到时与同学们,老师相互讨论。

C#语言的描述:

●简洁的语法

●精心地面向对象设计

●与Web的紧密结合

●完整的安全性与错误处理

●版本处理技术

●灵活性与兼容性

2.3经济方面的可行性:

由于是本学期老师布置的课程设计,未涉及到资金问题,因此在此就一笔带过,把较重要的因素考虑进去并列出来。

2.4社会因素方面的可行性:

在各企业中计算机已经普遍存在,并且在事物处理,工作安排,人员管理等方面使用起来非常迅速。使用计算机来对企业的操作,安排,大大提高了工作的效率,还节省了许多人力物力,节省出大量的时间,也为管理者对企业的管理,对人员的了解方便许多。因此,用计算机来管理企业人事信息,是非常必需的。

2.5结论

根据以上分析可知,开发该人事信息管理系统具有很大的价值意义,但是时间有限,该管理系统考虑不太健全,我会在这方面加强学习和改进。所以,我认为开发此系统的条件已经具备,可以开始进行开发。

3.1系统总体功能需求

功能概述:该系统界面友好,操作简便,能完成添加工种,浏览工种,修改工种,删除工种等一系列人事信息管理功能,开发本系统的总体任务是实现人事管理的系统化和自动化。本着实用性和介绍性的原则,整个系统由四大模块组成,每个大的模块又包括三至四个小的模块。

一、  工种管理部分:包括工种添加和工种浏览,其功能是实现对各部分数据内容进行添加、修改、查询等操作。

二、  部门管理部分:包括部门浏览和部门添加,其功能是实现对各部分数据内容的添加和修改等操作。

三、  员工管理部分:包括员工浏览和员工添加,其功能是实现对各部分数据内容的添加和查询等操作。

四、  收入管理部分:包括收入浏览和收入添加,其功能是实现对各部分数据内容的添加和查询等操作。 

系统具有高效、易操作、易维护等特点,并且系统结构清晰、界面友好,功能较为齐全,能有效地协助管理人员进行人事管理工作。如果想真正把它用到实际的人事信息管理中,还需要读者对该系统进行一步的完善工作。

3.3计算机系统的配置方案

硬件环境:

内容

最低配置

 建议配置

主机

 P/200

PII/266以上

 内存

 64M

B 128MB以上

硬盘

10GB

20GB以上

显示器 

VGA

VGA以上

软件环境:

操作系统

Windows 98中文版或Windows XP中文版

3.4系统的安全性和可靠性设计
   系统不完善,还没有用户登陆功能。

4.系统设计

4.1概要设计

各子系统的设计

本系统包括四个子系统:工种设置管理子系统,部门管理子系统,员工信息管理子系统和收入管理子系统。

4.2软件控制流设计

(1)添加操作

系统将向数据库中添加一条新的记录,并修改相关表的信息(如在添加新的部门时,系统将自动修改部门的信息)

(2)查询操作

系统根据查询条件在数据库中进行查询,然后讲查询结果显示在界面上。

(3)修改操作

要进行修改操作,必须先执行查询操作。执行修改操作系统将更新数据库中的相应记录。

(4)删除操作

要进行删除操作,必须先执行查询操作。执行删除操作系统将删除数据库中的相应记录。

4.3数据表说明:

(1)部门信息表:

字段名

数据类型

说明

编号

文本

字段大小50,必添字段“是”,允许空字符为“否”

部门名称

文本

字段大小50,必添字段“是”,允许空字符为“否”

部门领导

文本

字段大小50,必添字段“是”,允许空字符为“否”

(2)工种种类信息表:

字段名

数据类型

说明

编号

文本

字段大小50,必添字段“是”,允许空字符为“否”

工种名称

文本

字段大小50,必添字段“是”,允许空字符为“否”

描述

文本

字段大小50,必添字段“是”,允许空字符为“否”

(3)部门员工表:

字段名

数据类型

说明

员工编号

文本

字段大小50,必添字段“是”,允许空字符为“否”

月份

日期/时间

短日期

月收入

文本

字段大小50,必添字段“是”,允许空字符为“否”

备注

文本

字段大小50,必添字段“是”,允许空字符为“否”

员工姓名

文本

字段大小50,必添字段“是”,允许空字符为“否”

自动编号

文本

字段大小50,必添字段“是”,允许空字符为“否”

字段名

数字类型

说明

员工编号

文本

字段大小50,必添字段“是”,允许空字符为“否”

学历

文本

字段大小50,必添字段“是”,允许空字符为“否”

姓名

文本

字段大小50,必添字段“是”,允许空字符为“否”

专业

文本

字段大小50,必添字段“是”,允许空字符为“否”

性别

文本

字段大小50,必添字段“是”,允许空字符为“否”

工种

文本

字段大小50,必添字段“是”,允许空字符为“否”

籍贯

文本

字段大小50,必添字段“是”,允许空字符为“否”

部门

文本

字段大小50,必添字段“是”,允许空字符为“否”

职称

文本

字段大小50,必添字段“是”,允许空字符为“否”

备注

文本

字段大小50,必添字段“是”,允许空字符为“否”

6.系统详细说明书

6.1系统界面:

人事信息管理系统_第1张图片

人事信息管理系统_第2张图片

人事信息管理系统_第3张图片

人事信息管理系统_第4张图片

人事信息管理系统_第5张图片

人事信息管理系统_第6张图片

人事信息管理系统_第7张图片

人事信息管理系统_第8张图片

人事信息管理系统_第9张图片

人事信息管理系统_第10张图片

(2)部分源代码:

关于窗体的源代码:

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

namespace personMIS

{

///

/// about 的摘要说明。

///

public class about : System.Windows.Forms.Form

{

private System.Windows.Forms.Label label1;

private System.Windows.Forms.Label label2;

///

/// 必需的设计器变量。

///

private System.ComponentModel.Container components = null;

public about()

{

//

// Windows 窗体设计器支持所必需的

//

InitializeComponent();

//

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

//

}

///

/// 清理所有正在使用的资源。

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

#region Windows 窗体设计器生成的代码

///

/// 设计器支持所需的方法 - 不要使用代码编辑器修改

/// 此方法的内容。

///

private void InitializeComponent()

{

this.label1 = new System.Windows.Forms.Label();

this.label2 = new System.Windows.Forms.Label();

this.SuspendLayout();

//

// label1

//

this.label1.Font = new System.Drawing.Font("宋体", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.label1.Location = new System.Drawing.Point(80, 176);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(136, 56);

this.label1.TabIndex = 0;

this.label1.Text = "版权所有!侵权必究!";

//

// label2

//

this.label2.Font = new System.Drawing.Font("隶书", 21.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.label2.ForeColor = System.Drawing.Color.Red;

this.label2.Location = new System.Drawing.Point(24, 40);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(264, 56);

this.label2.TabIndex = 1;

this.label2.Text = "员工管理信息系统";

//

// about

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClientSize = new System.Drawing.Size(292, 266);

this.Controls.Add(this.label2);

this.Controls.Add(this.label1);

this.Name = "about";

this.Text = "about";

this.ResumeLayout(false);

}

#endregion

}

}

添加部门的代码:

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data.OleDb;

using System.Data;

using System.Runtime.InteropServices;

namespace personMIS

{

///

/// AddDepart 的摘要说明。

///

public class AddDepart : System.Windows.Forms.Form

{

private System.Windows.Forms.Label label1;

private System.Windows.Forms.Label label2;

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.Label label3;

private System.Windows.Forms.TextBox textBox2;

private System.Windows.Forms.Label label4;

private System.Windows.Forms.TextBox textBox3;

private System.Windows.Forms.Button button1;

private System.Windows.Forms.Button button2;

private System.Data.OleDb.OleDbConnection oleDbConnection1;

///

/// 必需的设计器变量。

///

[DllImport("User32.dll")]

public static extern int MessageBox(int h,string m,string c,int type);

private System.ComponentModel.Container components = null;

public AddDepart()

{

//

// Windows 窗体设计器支持所必需的

//

InitializeComponent();

//

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

//

}

///

/// 清理所有正在使用的资源。

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

private void InitializeComponent()

{

this.label1 = new System.Windows.Forms.Label();

this.label2 = new System.Windows.Forms.Label();

this.textBox1 = new System.Windows.Forms.TextBox();

this.label3 = new System.Windows.Forms.Label();

this.textBox2 = new System.Windows.Forms.TextBox();

this.label4 = new System.Windows.Forms.Label();

this.textBox3 = new System.Windows.Forms.TextBox();

this.button1 = new System.Windows.Forms.Button();

this.button2 = new System.Windows.Forms.Button();

this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();

this.SuspendLayout();

//

// label1

//

this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.label1.Location = new System.Drawing.Point(128, 16);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(112, 24);

this.label1.TabIndex = 0;

this.label1.Text = "添加部门信息";

//

// label2

//

this.label2.Location = new System.Drawing.Point(16, 56);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(56, 24);

this.label2.TabIndex = 1;

this.label2.Text = "部门名称";

//

// textBox1

//

this.textBox1.Location = new System.Drawing.Point(72, 56);

this.textBox1.Name = "textBox1";

this.textBox1.TabIndex = 2;

this.textBox1.Text = "";

//

// label3

//

this.label3.Location = new System.Drawing.Point(192, 56);

this.label3.Name = "label3";

this.label3.Size = new System.Drawing.Size(56, 23);

this.label3.TabIndex = 3;

this.label3.Text = "部门领导";

//

// textBox2

//

this.textBox2.Location = new System.Drawing.Point(248, 56);

this.textBox2.Name = "textBox2";

this.textBox2.TabIndex = 4;

this.textBox2.Text = "";

//

// label4

//

this.label4.Location = new System.Drawing.Point(16, 96);

this.label4.Name = "label4";

this.label4.Size = new System.Drawing.Size(56, 23);

this.label4.TabIndex = 5;

this.label4.Text = "备注";

//

// textBox3

//

this.textBox3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.textBox3.ForeColor = System.Drawing.SystemColors.ControlText;

this.textBox3.Location = new System.Drawing.Point(72, 96);

this.textBox3.Multiline = true;

this.textBox3.Name = "textBox3";

this.textBox3.Size = new System.Drawing.Size(248, 64);

this.textBox3.TabIndex = 9;

this.textBox3.Text = "";

//

// button1

//

this.button1.Location = new System.Drawing.Point(64, 176);

this.button1.Name = "button1";

this.button1.TabIndex = 10;

this.button1.Text = "确定";

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// button2

//

this.button2.Location = new System.Drawing.Point(232, 176);

this.button2.Name = "button2";

this.button2.TabIndex = 11;

this.button2.Text = "取消";

this.button2.Click += new System.EventHandler(this.button2_Click);

//

// oleDbConnection1

//

this.oleDbConnection1.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source=""E:\C#\CH06\code\StoreMIS\StoreMIS\bin\StoreMIS.mdb"";Mode=Share Deny None;Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";

//

// AddDepart

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClientSize = new System.Drawing.Size(368, 214);

this.Controls.Add(this.button2);

this.Controls.Add(this.button1);

this.Controls.Add(this.textBox3);

this.Controls.Add(this.textBox2);

this.Controls.Add(this.textBox1);

this.Controls.Add(this.label4);

this.Controls.Add(this.label3);

this.Controls.Add(this.label2);

this.Controls.Add(this.label1);

this.Name = "AddDepart";

this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

this.Text = "添加部门信息";

this.ResumeLayout(false);

}

#endregion

private void button1_Click(object sender, System.EventArgs e)

{

if(textBox1.Text.Trim()==""||textBox2.Text.Trim()=="")

MessageBox(0,"请输入完整信息!","提示",0);

else

{

oleDbConnection1.Open();

string sql1 = "select * from departinfo where Dname='"+textBox1.Text.Trim()+"'";

OleDbCommand cmd = new OleDbCommand(sql1,oleDbConnection1);

if(cmd.ExecuteScalar() != null)

MessageBox(0,"部门名称重复,请重新输入!","提示",0);

else

{

string sql = "insert into departinfo (Dname,Dleader,Remark) values ('"+textBox1.Text.Trim()+"','"+textBox2.Text.Trim()+"','"+textBox3.Text.Trim()+"')";

cmd.CommandText = sql;

cmd.ExecuteNonQuery();

MessageBox(0,"添加部门信息成功!","提示",0);

textBox1.Clear();

textBox2.Clear();

textBox3.Clear();

}

oleDbConnection1.Close();

}

}

private void button2_Click(object sender, System.EventArgs e)

{

this.Close();

}

}

}

添加收入的代码:

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data.OleDb;

using System.Data;

using System.Runtime.InteropServices;

namespace personMIS

{

///

/// AddIncome 的摘要说明。

///

public class AddIncome : System.Windows.Forms.Form

{

private System.Windows.Forms.TextBox textBox3;

private System.Windows.Forms.TextBox textBox2;

private System.Windows.Forms.Label label4;

private System.Windows.Forms.Label label3;

private System.Windows.Forms.Label label2;

private System.Windows.Forms.Label label1;

private System.Windows.Forms.Button button2;

private System.Windows.Forms.Button button1;

private System.Windows.Forms.Label label5;

private System.Windows.Forms.TextBox textBox4;

private System.Windows.Forms.ComboBox comboBox1;

private System.Data.OleDb.OleDbConnection oleDbConnection1;

///

/// 必需的设计器变量。

///

[DllImport("User32.dll")]

public static extern int MessageBox(int h,string m,string c,int type);

private System.ComponentModel.Container components = null;

public AddIncome()

{

//

// Windows 窗体设计器支持所必需的

//

InitializeComponent();

//

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

//

}

///

/// 清理所有正在使用的资源。

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if(components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

private void InitializeComponent()

{

this.textBox3 = new System.Windows.Forms.TextBox();

this.textBox2 = new System.Windows.Forms.TextBox();

this.label4 = new System.Windows.Forms.Label();

this.label3 = new System.Windows.Forms.Label();

this.label2 = new System.Windows.Forms.Label();

this.label1 = new System.Windows.Forms.Label();

this.button2 = new System.Windows.Forms.Button();

this.button1 = new System.Windows.Forms.Button();

this.label5 = new System.Windows.Forms.Label();

this.textBox4 = new System.Windows.Forms.TextBox();

this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();

this.comboBox1 = new System.Windows.Forms.ComboBox();

this.SuspendLayout();

//

// textBox3

//

this.textBox3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.textBox3.ForeColor = System.Drawing.SystemColors.ControlText;

this.textBox3.Location = new System.Drawing.Point(72, 96);

this.textBox3.Multiline = true;

this.textBox3.Name = "textBox3";

this.textBox3.TabIndex = 18;

this.textBox3.Text = "";

//

// textBox2

//

this.textBox2.Location = new System.Drawing.Point(248, 56);

this.textBox2.Name = "textBox2";

this.textBox2.TabIndex = 16;

this.textBox2.Text = "";

//

// label4

//

this.label4.Location = new System.Drawing.Point(16, 96);

this.label4.Name = "label4";

this.label4.Size = new System.Drawing.Size(40, 14);

this.label4.TabIndex = 17;

this.label4.Text = "备注";

//

// label3

//

this.label3.Location = new System.Drawing.Point(192, 56);

this.label3.Name = "label3";

this.label3.Size = new System.Drawing.Size(56, 14);

this.label3.TabIndex = 15;

this.label3.Text = "月份";

//

// label2

//

this.label2.Location = new System.Drawing.Point(16, 56);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(56, 14);

this.label2.TabIndex = 13;

this.label2.Text = "员工姓名";

//

// label1

//

this.label1.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.label1.Location = new System.Drawing.Point(128, 16);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(112, 24);

this.label1.TabIndex = 12;

this.label1.Text = "添加收入信息";

//

// button2

//

this.button2.Location = new System.Drawing.Point(232, 144);

this.button2.Name = "button2";

this.button2.TabIndex = 20;

this.button2.Text = "取消";

this.button2.Click += new System.EventHandler(this.button2_Click);

//

// button1

//

this.button1.Location = new System.Drawing.Point(64, 144);

this.button1.Name = "button1";

this.button1.TabIndex = 19;

this.button1.Text = "确定";

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// label5

//

this.label5.Location = new System.Drawing.Point(192, 96);

this.label5.Name = "label5";

this.label5.Size = new System.Drawing.Size(48, 23);

this.label5.TabIndex = 21;

this.label5.Text = "收入";

//

// textBox4

//

this.textBox4.Location = new System.Drawing.Point(248, 96);

this.textBox4.Name = "textBox4";

this.textBox4.TabIndex = 22;

this.textBox4.Text = "";

//

// oleDbConnection1

//

this.oleDbConnection1.ConnectionString = "Data Source=personMIS.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet.OLEDB.4." +

"0;";

//

// comboBox1

//

this.comboBox1.Location = new System.Drawing.Point(72, 56);

this.comboBox1.Name = "comboBox1";

this.comboBox1.Size = new System.Drawing.Size(104, 20);

this.comboBox1.TabIndex = 23;

//

// AddIncome

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClientSize = new System.Drawing.Size(368, 182);

this.Controls.Add(this.comboBox1);

this.Controls.Add(this.textBox4);

this.Controls.Add(this.label5);

this.Controls.Add(this.button2);

this.Controls.Add(this.button1);

this.Controls.Add(this.textBox3);

this.Controls.Add(this.textBox2);

this.Controls.Add(this.label4);

this.Controls.Add(this.label3);

this.Controls.Add(this.label2);

this.Controls.Add(this.label1);

this.Name = "AddIncome";

this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

this.Text = "添加收入信息";

this.Load += new System.EventHandler(this.AddIncome_Load);

this.ResumeLayout(false);

}

#endregion

private void button1_Click(object sender, System.EventArgs e)

{

if (textBox2.Text.Trim()=="" || comboBox1.Text.Trim()=="" || textBox3.Text.Trim()=="" || textBox4.Text.Trim()=="")

MessageBox(0,"请填写完整的信息","提示",0);

else

{

string strSQL = "select * from income where PID="+comboBox1.SelectedValue.ToString()+"";

OleDbCommand cmd=new OleDbCommand(strSQL,oleDbConnection1);

// if (null!=cmd.ExecuteScalar())

// MessageBox(0,"员工姓名重复","提示",0);

// else

// {

string sql1,sql2,sql;

sql1="insert into income (Imonth,Remark,Income,PID";

sql2="values ('"+textBox2.Text.ToString()+"','"+textBox3.Text.ToString()+"','"+textBox4.Text.ToString()+"',"+comboBox1.SelectedValue.ToString();

sql=sql1+") "+sql2+")";

cmd.CommandText=sql;

cmd.ExecuteNonQuery();

MessageBox(0,"收入信息添加成功","提示",0);

// }

}

}

private void button2_Click(object sender, System.EventArgs e)

{

this.Close();

}

private void AddIncome_Load(object sender, System.EventArgs e)

{

oleDbConnection1.Open();

OleDbDataAdapter adp=new OleDbDataAdapter("select PID,Pname from personinfo",oleDbConnection1);

DataSet ds=new DataSet();

adp.Fill(ds,"person");

comboBox1.DisplayMember="Pname";

comboBox1.ValueMember="PID";

comboBox1.DataSource=ds.Tables[0].DefaultView;

}

}

}

添加工种的代码:

//引用命名空间

using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data.OleDb;

using System.Runtime.InteropServices;

namespace personMIS

{

///

/// Addjob 的摘要说明。

///

public class Addjob : System.Windows.Forms.Form

{

private System.Windows.Forms.Label label1;

private System.Windows.Forms.Label label3;

private System.Windows.Forms.Label label2;

private System.Windows.Forms.TextBox textBox2;

private System.Windows.Forms.TextBox textBox1;

private System.Windows.Forms.Button button2;

private System.Data.OleDb.OleDbConnection oleDbConnection1;

private System.Windows.Forms.Button button1;

///

/// 必需的设计器变量。

///

[DllImport("User32.dll")]

public static extern int MessageBox(int h,string m,string c,int type);

private System.ComponentModel.Container components = null;

public Addjob()

{

//

// Windows 窗体设计器支持所必需的

//

InitializeComponent();

//

// TODO: 在 InitializeComponent 调用后添加任何构造函数代码

//

}

///

/// 清理所有正在使用的资源。

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}

private void InitializeComponent()

{

this.label1 = new System.Windows.Forms.Label();

this.label3 = new System.Windows.Forms.Label();

this.label2 = new System.Windows.Forms.Label();

this.textBox2 = new System.Windows.Forms.TextBox();

this.textBox1 = new System.Windows.Forms.TextBox();

this.button2 = new System.Windows.Forms.Button();

this.button1 = new System.Windows.Forms.Button();

this.oleDbConnection1 = new System.Data.OleDb.OleDbConnection();

this.SuspendLayout();

//

// label1

//

this.label1.AutoSize = true;

this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.label1.ForeColor = System.Drawing.SystemColors.ControlText;

this.label1.Location = new System.Drawing.Point(136, 16);

this.label1.Name = "label1";

this.label1.Size = new System.Drawing.Size(54, 17);

this.label1.TabIndex = 5;

this.label1.Text = "添加工种";

//

// label3

//

this.label3.AutoSize = true;

this.label3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.label3.ForeColor = System.Drawing.SystemColors.ControlText;

this.label3.Location = new System.Drawing.Point(16, 104);

this.label3.Name = "label3";

this.label3.Size = new System.Drawing.Size(54, 17);

this.label3.TabIndex = 12;

this.label3.Text = "工种描述";

//

// label2

//

this.label2.AutoSize = true;

this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.label2.ForeColor = System.Drawing.SystemColors.ControlText;

this.label2.Location = new System.Drawing.Point(16, 48);

this.label2.Name = "label2";

this.label2.Size = new System.Drawing.Size(54, 17);

this.label2.TabIndex = 11;

this.label2.Text = "工种名称";

//

// textBox2

//

this.textBox2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.textBox2.ForeColor = System.Drawing.SystemColors.ControlText;

this.textBox2.Location = new System.Drawing.Point(80, 80);

this.textBox2.Multiline = true;

this.textBox2.Name = "textBox2";

this.textBox2.Size = new System.Drawing.Size(248, 64);

this.textBox2.TabIndex = 8;

this.textBox2.Text = "";

//

// textBox1

//

this.textBox1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.textBox1.ForeColor = System.Drawing.SystemColors.ControlText;

this.textBox1.Location = new System.Drawing.Point(80, 40);

this.textBox1.Name = "textBox1";

this.textBox1.Size = new System.Drawing.Size(248, 21);

this.textBox1.TabIndex = 7;

this.textBox1.Text = "";

//

// button2

//

this.button2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.button2.ForeColor = System.Drawing.SystemColors.ControlText;

this.button2.Location = new System.Drawing.Point(240, 160);

this.button2.Name = "button2";

this.button2.TabIndex = 10;

this.button2.Text = "取消";

this.button2.Click += new System.EventHandler(this.button2_Click);

//

// button1

//

this.button1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));

this.button1.ForeColor = System.Drawing.SystemColors.ControlText;

this.button1.Location = new System.Drawing.Point(48, 160);

this.button1.Name = "button1";

this.button1.TabIndex = 9;

this.button1.Text = "确定";

this.button1.Click += new System.EventHandler(this.button1_Click);

//

// oleDbConnection1

//

this.oleDbConnection1.ConnectionString = "Data Source=personMIS.mdb;Jet OLEDB:Engine Type=5;Provider=Microsoft.Jet.OLEDB.4." +

"0;";

//

// Addjob

//

this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);

this.ClientSize = new System.Drawing.Size(344, 190);

this.Controls.Add(this.label3);

this.Controls.Add(this.label2);

this.Controls.Add(this.textBox2);

this.Controls.Add(this.textBox1);

this.Controls.Add(this.label1);

this.Controls.Add(this.button2);

this.Controls.Add(this.button1);

this.Name = "Addjob";

this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

this.Text = "添加工种";

this.ResumeLayout(false);

}

#endregion

///

/// 应用程序的主入口点。

///

[STAThread]

static void Main()

{

Application.Run(new Main());

}

//推出按钮单击事件

private void button2_Click(object sender, System.EventArgs e)

{

this.Close();

}

//确定按钮单击事件

private void button1_Click(object sender, System.EventArgs e)

{

if(textBox1.Text.Trim()==""||textBox2.Text.Trim()=="")

MessageBox(0,"请输入工种名称和描述!","提示",0);

else

{

oleDbConnection1.Open();

OleDbCommand cmd = new OleDbCommand("select * from jobinfo where JobName='"+textBox1.Text.Trim()+"'",oleDbConnection1);

if(cmd.ExecuteScalar() != null)

MessageBox(0,"工种名称重复,请重新输入!","提示",0);

else

{

string sql = "insert into jobinfo (JobName,Remark) values ('"+textBox1.Text.Trim()+"','"+textBox2.Text.Trim()+"')";

cmd.CommandText = sql;

cmd.ExecuteNonQuery();

MessageBox(0,"添加工种信息成功!","提示",0);

textBox1.Clear();

textBox2.Clear();

}

oleDbConnection1.Close();

}

你可能感兴趣的:(前端)