?? fmmark.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
namespace 招聘考試成績管理系統(tǒng)
{
/// <summary>
/// FMmark 的摘要說明。
/// </summary>
public class FMmark : System.Windows.Forms.Form
{
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button btok;
private System.Windows.Forms.TextBox txtenglish;
private System.Windows.Forms.Button btreset;
private System.Windows.Forms.TextBox txtchinese;
private System.Windows.Forms.TextBox txtpoli;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox txtzhunkaozheng;
/// <summary>
/// 必需的設(shè)計(jì)器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public FMmark()
{
//
// Windows 窗體設(shè)計(jì)器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計(jì)器生成的代碼
/// <summary>
/// 設(shè)計(jì)器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.btok = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.txtenglish = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.btreset = new System.Windows.Forms.Button();
this.txtchinese = new System.Windows.Forms.TextBox();
this.txtpoli = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.txtzhunkaozheng = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
// btok
//
this.btok.Location = new System.Drawing.Point(96, 272);
this.btok.Name = "btok";
this.btok.TabIndex = 5;
this.btok.Tag = "0";
this.btok.Text = "確定";
this.btok.Click += new System.EventHandler(this.btok_Click);
//
// label1
//
this.label1.Font = new System.Drawing.Font("華文楷體", 14.25F, System.Drawing.FontStyle.Bold);
this.label1.Location = new System.Drawing.Point(128, 24);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(296, 23);
this.label1.TabIndex = 1;
this.label1.Tag = "0";
this.label1.Text = "輸入考生成績";
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// txtenglish
//
this.txtenglish.Location = new System.Drawing.Point(176, 120);
this.txtenglish.Name = "txtenglish";
this.txtenglish.Size = new System.Drawing.Size(200, 21);
this.txtenglish.TabIndex = 2;
this.txtenglish.Tag = "*請輸入正確的英語成績";
this.txtenglish.Text = "";
this.txtenglish.Leave += new System.EventHandler(this.txtpoli_Leave);
//
// label2
//
this.label2.Location = new System.Drawing.Point(56, 120);
this.label2.Name = "label2";
this.label2.TabIndex = 3;
this.label2.Text = "英語:";
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label3
//
this.label3.Location = new System.Drawing.Point(56, 160);
this.label3.Name = "label3";
this.label3.TabIndex = 4;
this.label3.Text = "語文:";
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// label4
//
this.label4.Location = new System.Drawing.Point(56, 208);
this.label4.Name = "label4";
this.label4.TabIndex = 5;
this.label4.Text = "政治:";
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// btreset
//
this.btreset.Location = new System.Drawing.Point(328, 272);
this.btreset.Name = "btreset";
this.btreset.TabIndex = 0;
this.btreset.Tag = "0";
this.btreset.Text = "重置";
this.btreset.Click += new System.EventHandler(this.btreset_Click);
//
// txtchinese
//
this.txtchinese.Location = new System.Drawing.Point(176, 160);
this.txtchinese.Name = "txtchinese";
this.txtchinese.Size = new System.Drawing.Size(200, 21);
this.txtchinese.TabIndex = 3;
this.txtchinese.Tag = "*請輸入正確的語文成績";
this.txtchinese.Text = "";
this.txtchinese.Leave += new System.EventHandler(this.txtpoli_Leave);
//
// txtpoli
//
this.txtpoli.Location = new System.Drawing.Point(176, 206);
this.txtpoli.Name = "txtpoli";
this.txtpoli.Size = new System.Drawing.Size(200, 21);
this.txtpoli.TabIndex = 4;
this.txtpoli.Tag = "*請輸入正確的政治成績";
this.txtpoli.Text = "";
this.txtpoli.Leave += new System.EventHandler(this.txtpoli_Leave);
//
// label5
//
this.label5.Location = new System.Drawing.Point(56, 80);
this.label5.Name = "label5";
this.label5.TabIndex = 6;
this.label5.Text = "準(zhǔn)考證號:";
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
//
// txtzhunkaozheng
//
this.txtzhunkaozheng.Location = new System.Drawing.Point(176, 80);
this.txtzhunkaozheng.Name = "txtzhunkaozheng";
this.txtzhunkaozheng.Size = new System.Drawing.Size(200, 21);
this.txtzhunkaozheng.TabIndex = 1;
this.txtzhunkaozheng.Tag = "*請輸入正確的準(zhǔn)考證";
this.txtzhunkaozheng.Text = "";
this.txtzhunkaozheng.Leave += new System.EventHandler(this.zno_Leave);
//
// FMmark
//
this.AcceptButton = this.btok;
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(560, 374);
this.Controls.Add(this.txtzhunkaozheng);
this.Controls.Add(this.label5);
this.Controls.Add(this.txtpoli);
this.Controls.Add(this.txtchinese);
this.Controls.Add(this.btreset);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtenglish);
this.Controls.Add(this.label1);
this.Controls.Add(this.btok);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "FMmark";
this.Tag = "0";
this.Text = "輸入成績信息";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ResumeLayout(false);
}
#endregion
private void btok_Click(object sender, System.EventArgs e)
{
if(this.txtzhunkaozheng.Text.Trim()=="")
{
MessageBox.Show("準(zhǔn)考證不能為空");
this.txtzhunkaozheng.Focus();
return;
}
if(this.txtchinese.Text.Trim()=="")
{
MessageBox.Show("成績不能為空");
this.txtzhunkaozheng.Focus();
return;
}
if(this.txtenglish.Text.Trim()=="")
{
MessageBox.Show("成績不能為空");
this.txtzhunkaozheng.Focus();
return;
}
if(this.txtpoli.Text.Trim()=="")
{
MessageBox.Show("成績不能為空");
this.txtzhunkaozheng.Focus();
return;
}
string SQL ="select Zno from student where Zno =";
SQL+=this.txtzhunkaozheng.Text;
string myConstr ="workstation id=\"GHX-82E19EF0633\";packet size=4096;integrated security=SSPI;data s" +
"ource=\".\";persist security info=False;initial catalog=zhaopin";
SqlCommand myCom= null;
SqlConnection myCon=null;
try
{
myCon =new SqlConnection(myConstr);
myCon.Open();
myCom =new SqlCommand(SQL,myCon);
int power=Convert.ToInt32(myCom.ExecuteScalar());
if(power<=0)
{
MessageBox.Show("不存在此考生");
return;
}
myCom.CommandText=SQL;
power=Convert.ToInt32(myCom.ExecuteScalar());
if(power<=0)
{
SQL="insert into mark Values ('"+this.txtzhunkaozheng.Text;
SQL+="','"+Convert.ToInt32(this.txtenglish.Text)+"','"+Convert.ToInt32(this.txtchinese.Text)+"','"+Convert.ToInt32(this.txtpoli.Text)+"');";
myCom.CommandText=SQL;
myCom.ExecuteNonQuery();
MessageBox.Show("提交成功");
}
else
{
MessageBox.Show("此人成績信息已經(jīng)存在");
}
}
catch(Exception o)
{
MessageBox.Show(o.Message,"error");
}
finally
{
if(myCon.State==ConnectionState.Open)
myCon.Close();
}
}
private void btreset_Click(object sender, System.EventArgs e)
{
int i;
for(i=0;i<this.Controls.Count;i++)
{
if(this.Controls[i] is TextBox)
this.Controls[i].Text="";
}
}
private void txtpoli_Leave(object sender, System.EventArgs e)
{
int t;
if((sender as TextBox).Text.Trim() !="")
{
t=Convert.ToInt32((sender as TextBox).Text.Trim());
if(t<0 || t>100)
{
MessageBox.Show("成績輸入錯誤");
(sender as TextBox).Text="";
(sender as TextBox).Focus();
}
}
/*if((sender as TextBox).Text=="")
{
MessageBox.Show((sender as TextBox).Tag.ToString());
(sender as TextBox).Focus();
return;
}
int i=0;
if((sender as TextBox).Name=="txtpoli")
{
for(i=0;i<this.Controls.Count;i++)
{
if(this.Controls[i] is TextBox&&this.Controls[i].Text.Trim()=="")
{
MessageBox.Show(this.Controls[i].Tag.ToString());
break;
}
}
}
if(i==this.Controls.Count)
;*/
}
private void zno_Leave(object sender, System.EventArgs e)
{
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -