📄 fmadd.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 招聘考试成绩管理系统
{
/// <summary>
/// FMADD 的摘要说明。
/// </summary>
public class FMADD : System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.TextBox textBox5;
private System.Windows.Forms.TextBox textBox4;
private System.Windows.Forms.TextBox textBox3;
private System.Windows.Forms.TextBox textBox2;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox textBox6;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public FMADD()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.textBox5 = new System.Windows.Forms.TextBox();
this.textBox4 = new System.Windows.Forms.TextBox();
this.textBox3 = new System.Windows.Forms.TextBox();
this.textBox2 = new System.Windows.Forms.TextBox();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label6 = new System.Windows.Forms.Label();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.textBox6 = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.textBox5);
this.groupBox1.Controls.Add(this.textBox4);
this.groupBox1.Controls.Add(this.textBox3);
this.groupBox1.Controls.Add(this.textBox2);
this.groupBox1.Controls.Add(this.textBox1);
this.groupBox1.Controls.Add(this.label6);
this.groupBox1.Controls.Add(this.label5);
this.groupBox1.Controls.Add(this.label4);
this.groupBox1.Controls.Add(this.label3);
this.groupBox1.Controls.Add(this.label2);
this.groupBox1.Controls.Add(this.groupBox2);
this.groupBox1.Location = new System.Drawing.Point(48, 56);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(520, 240);
this.groupBox1.TabIndex = 6;
this.groupBox1.TabStop = false;
//
// textBox5
//
this.textBox5.Location = new System.Drawing.Point(128, 192);
this.textBox5.Name = "textBox5";
this.textBox5.Size = new System.Drawing.Size(144, 21);
this.textBox5.TabIndex = 10;
this.textBox5.Tag = "电话不能为空!";
this.textBox5.Text = "";
//
// textBox4
//
this.textBox4.Location = new System.Drawing.Point(128, 152);
this.textBox4.Name = "textBox4";
this.textBox4.Size = new System.Drawing.Size(144, 21);
this.textBox4.TabIndex = 9;
this.textBox4.Tag = "联系人不能为空!";
this.textBox4.Text = "";
//
// textBox3
//
this.textBox3.Location = new System.Drawing.Point(128, 112);
this.textBox3.Name = "textBox3";
this.textBox3.Size = new System.Drawing.Size(144, 21);
this.textBox3.TabIndex = 8;
this.textBox3.Tag = "邮箱不能为空!";
this.textBox3.Text = "";
//
// textBox2
//
this.textBox2.Location = new System.Drawing.Point(128, 72);
this.textBox2.Name = "textBox2";
this.textBox2.Size = new System.Drawing.Size(144, 21);
this.textBox2.TabIndex = 7;
this.textBox2.Tag = "录取分数要求不能为空!";
this.textBox2.Text = "";
//
// textBox1
//
this.textBox1.Location = new System.Drawing.Point(128, 32);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(144, 21);
this.textBox1.TabIndex = 6;
this.textBox1.Tag = "单位名称不能为空!";
this.textBox1.Text = "";
//
// label6
//
this.label6.Location = new System.Drawing.Point(16, 192);
this.label6.Name = "label6";
this.label6.TabIndex = 5;
this.label6.Text = "电话:";
this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label5
//
this.label5.Location = new System.Drawing.Point(16, 152);
this.label5.Name = "label5";
this.label5.TabIndex = 4;
this.label5.Text = "联系人:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label4
//
this.label4.Location = new System.Drawing.Point(16, 112);
this.label4.Name = "label4";
this.label4.TabIndex = 3;
this.label4.Text = "邮箱:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label3
//
this.label3.Location = new System.Drawing.Point(16, 72);
this.label3.Name = "label3";
this.label3.TabIndex = 2;
this.label3.Text = "录取分数要求:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label2
//
this.label2.Location = new System.Drawing.Point(16, 32);
this.label2.Name = "label2";
this.label2.TabIndex = 1;
this.label2.Text = "单位名称:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.textBox6);
this.groupBox2.Location = new System.Drawing.Point(288, 40);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(200, 168);
this.groupBox2.TabIndex = 5;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "公司简介";
//
// textBox6
//
this.textBox6.Location = new System.Drawing.Point(16, 24);
this.textBox6.Multiline = true;
this.textBox6.Name = "textBox6";
this.textBox6.Size = new System.Drawing.Size(168, 128);
this.textBox6.TabIndex = 7;
this.textBox6.Tag = "公司简介不能为空!";
this.textBox6.Text = "";
//
// label1
//
this.label1.Font = new System.Drawing.Font("宋体", 14.25F, System.Drawing.FontStyle.Bold);
this.label1.Location = new System.Drawing.Point(224, 16);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(144, 23);
this.label1.TabIndex = 5;
this.label1.Text = "录用单位信息";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// button1
//
this.button1.Location = new System.Drawing.Point(176, 312);
this.button1.Name = "button1";
this.button1.TabIndex = 7;
this.button1.Text = "确定";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// button2
//
this.button2.Location = new System.Drawing.Point(352, 312);
this.button2.Name = "button2";
this.button2.TabIndex = 8;
this.button2.Text = "清空";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// FMADD
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(608, 350);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.label1);
this.Name = "FMADD";
this.Text = "添加录用单位";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void button2_Click(object sender, System.EventArgs e)
{
this.textBox1.Text="";
this.textBox2.Text="";
this.textBox3.Text="";
this.textBox4.Text="";
this.textBox5.Text="";
this.textBox6.Text="";
}
private void button1_Click(object sender, System.EventArgs e)
{
if(this.textBox1.Text=="")
{
MessageBox.Show("单位名称不能为空!");
return;
}
string mystr="workstation id=\"GHX-82E19EF0633\";packet size=4096;integrated security=SSPI;data s" +
"ource=\".\";persist security info=False;initial catalog=zhaopin";
SqlConnection con=new SqlConnection(mystr);
try
{
string sql="select * from Ddaiwei where Dname='"+this.textBox1.Text.Trim()+"'";
SqlCommand com=new SqlCommand(sql,con);
con.Open();
int i=Convert.ToInt32(com.ExecuteScalar());
con.Close();
if(i>0)
{
MessageBox.Show("该记录已经存在!");
return;
}
sql="insert into Ddaiwei(Dname,Dmark,Demail,Dlixiren,Dtel,Ditem) values('"+this.textBox1.Text.Trim()+"','"+
this.textBox2.Text.Trim()+"','"+this.textBox3.Text.Trim()+"','"+this.textBox4.Text+"','"+this.textBox5.Text.Trim()+"','"+this.textBox6.Text.Trim()+"')";
com=new SqlCommand(sql,con);
con.Open();
i=com.ExecuteNonQuery();
if(i>0)
MessageBox.Show("已成功添加记录");
}
catch(Exception oe)
{
MessageBox.Show(oe.Message,"Error");
}
finally
{
if(con.State==ConnectionState.Open)
con.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -