?? form_jzgcx.cs
字號:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
namespace bizdb
{
/// <summary>
/// Form_jzg2 的摘要說明。
/// </summary>
public class Form_jzgcx : System.Windows.Forms.Form
{
private System.Windows.Forms.Label lbl_cxtj;
private System.Windows.Forms.DataGrid dgd_jzgcx;
private System.Windows.Forms.CheckBox ckb_xm;
private System.Windows.Forms.CheckBox ckb_xb;
private System.Windows.Forms.CheckBox ckb_mz;
private System.Windows.Forms.Button btn_cx;
private System.Windows.Forms.TextBox txt_xm;
private System.Windows.Forms.Label lbl_xm;
private System.Windows.Forms.Label lbl_xb;
private System.Windows.Forms.Label lbl_mz;
private System.Windows.Forms.ComboBox cbb_xb;
private System.Windows.Forms.ComboBox cbb_mz;
/// <summary>
/// 必需的設(shè)計器變量。
/// </summary>
private System.ComponentModel.Container components = null;
public Form_jzgcx()
{
//
// Windows 窗體設(shè)計器支持所必需的
//
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 Form Designer generated code
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </summary>
private void InitializeComponent()
{
this.lbl_cxtj = new System.Windows.Forms.Label();
this.dgd_jzgcx = new System.Windows.Forms.DataGrid();
this.ckb_xm = new System.Windows.Forms.CheckBox();
this.ckb_xb = new System.Windows.Forms.CheckBox();
this.ckb_mz = new System.Windows.Forms.CheckBox();
this.btn_cx = new System.Windows.Forms.Button();
this.txt_xm = new System.Windows.Forms.TextBox();
this.lbl_xm = new System.Windows.Forms.Label();
this.lbl_xb = new System.Windows.Forms.Label();
this.lbl_mz = new System.Windows.Forms.Label();
this.cbb_xb = new System.Windows.Forms.ComboBox();
this.cbb_mz = new System.Windows.Forms.ComboBox();
((System.ComponentModel.ISupportInitialize)(this.dgd_jzgcx)).BeginInit();
this.SuspendLayout();
//
// lbl_cxtj
//
this.lbl_cxtj.Location = new System.Drawing.Point(192, 40);
this.lbl_cxtj.Name = "lbl_cxtj";
this.lbl_cxtj.Size = new System.Drawing.Size(80, 16);
this.lbl_cxtj.TabIndex = 0;
this.lbl_cxtj.Text = "查詢條件:";
//
// dgd_jzgcx
//
this.dgd_jzgcx.DataMember = "";
this.dgd_jzgcx.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgd_jzgcx.Location = new System.Drawing.Point(0, 248);
this.dgd_jzgcx.Name = "dgd_jzgcx";
this.dgd_jzgcx.ReadOnly = true;
this.dgd_jzgcx.Size = new System.Drawing.Size(792, 320);
this.dgd_jzgcx.TabIndex = 1;
this.dgd_jzgcx.MouseDown += new System.Windows.Forms.MouseEventHandler(this.dgd_jzgcx_MouseDown);
this.dgd_jzgcx.MouseUp += new System.Windows.Forms.MouseEventHandler(this.dgd_jzgcx_MouseUp);
//
// ckb_xm
//
this.ckb_xm.Location = new System.Drawing.Point(256, 64);
this.ckb_xm.Name = "ckb_xm";
this.ckb_xm.Size = new System.Drawing.Size(16, 24);
this.ckb_xm.TabIndex = 2;
this.ckb_xm.CheckedChanged += new System.EventHandler(this.ckb_xm_CheckedChanged);
//
// ckb_xb
//
this.ckb_xb.Location = new System.Drawing.Point(256, 104);
this.ckb_xb.Name = "ckb_xb";
this.ckb_xb.Size = new System.Drawing.Size(16, 24);
this.ckb_xb.TabIndex = 3;
this.ckb_xb.CheckedChanged += new System.EventHandler(this.ckb_xb_CheckedChanged);
//
// ckb_mz
//
this.ckb_mz.Location = new System.Drawing.Point(256, 144);
this.ckb_mz.Name = "ckb_mz";
this.ckb_mz.Size = new System.Drawing.Size(16, 24);
this.ckb_mz.TabIndex = 4;
this.ckb_mz.CheckedChanged += new System.EventHandler(this.ckb_mz_CheckedChanged);
//
// btn_cx
//
this.btn_cx.Location = new System.Drawing.Point(472, 104);
this.btn_cx.Name = "btn_cx";
this.btn_cx.Size = new System.Drawing.Size(56, 23);
this.btn_cx.TabIndex = 6;
this.btn_cx.Text = "查詢";
this.btn_cx.Click += new System.EventHandler(this.btn_cx_Click);
//
// txt_xm
//
this.txt_xm.Location = new System.Drawing.Point(280, 64);
this.txt_xm.Name = "txt_xm";
this.txt_xm.TabIndex = 7;
this.txt_xm.Text = "";
//
// lbl_xm
//
this.lbl_xm.Location = new System.Drawing.Point(392, 64);
this.lbl_xm.Name = "lbl_xm";
this.lbl_xm.Size = new System.Drawing.Size(32, 16);
this.lbl_xm.TabIndex = 10;
this.lbl_xm.Text = "姓名";
//
// lbl_xb
//
this.lbl_xb.Location = new System.Drawing.Point(392, 104);
this.lbl_xb.Name = "lbl_xb";
this.lbl_xb.Size = new System.Drawing.Size(32, 16);
this.lbl_xb.TabIndex = 11;
this.lbl_xb.Text = "性別";
//
// lbl_mz
//
this.lbl_mz.Location = new System.Drawing.Point(392, 144);
this.lbl_mz.Name = "lbl_mz";
this.lbl_mz.Size = new System.Drawing.Size(32, 16);
this.lbl_mz.TabIndex = 12;
this.lbl_mz.Text = "民族";
//
// cbb_xb
//
this.cbb_xb.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbb_xb.Location = new System.Drawing.Point(280, 104);
this.cbb_xb.Name = "cbb_xb";
this.cbb_xb.Size = new System.Drawing.Size(104, 20);
this.cbb_xb.TabIndex = 13;
//
// cbb_mz
//
this.cbb_mz.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbb_mz.Location = new System.Drawing.Point(280, 144);
this.cbb_mz.Name = "cbb_mz";
this.cbb_mz.Size = new System.Drawing.Size(104, 20);
this.cbb_mz.TabIndex = 14;
//
// Form_jzgcx
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(792, 573);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.cbb_mz,
this.cbb_xb,
this.lbl_mz,
this.lbl_xb,
this.lbl_xm,
this.txt_xm,
this.btn_cx,
this.ckb_mz,
this.ckb_xb,
this.ckb_xm,
this.dgd_jzgcx,
this.lbl_cxtj});
this.Name = "Form_jzgcx";
this.Text = "教職工資料查詢";
this.Load += new System.EventHandler(this.Form_jzgcx_Load);
((System.ComponentModel.ISupportInitialize)(this.dgd_jzgcx)).EndInit();
this.ResumeLayout(false);
}
#endregion
private void Form_jzgcx_Load(object sender, System.EventArgs e)
{
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.ControlBox = false;
this.cbb_mz.Enabled = false;
this.cbb_xb.Enabled=false;
this.txt_xm.Enabled=false;
this.Combo_Add();
}
private void btn_cx_Click(object sender, System.EventArgs e)
{
dbAccess dba=new dbAccess();
string sel="";
string select="Select emp_id as '教職工編號',emp_name as '姓名',sex.sex_name as '性別',nation.nat_name as '民族',"
+"emp_birthday as '出生年月',nativePlace.natp_name as '籍貫',PoliticalFeature.polf_name as '政治面貌',"
+"Maritalstatus.mars_name as '婚姻狀況',emp_identityNo as '身份證號',emp_address as '聯(lián)系地址',"
+"emp_tel as '聯(lián)系電話',emp_email as '電子郵箱',emp_postcode as '郵政編碼',emp_hometel as '家庭住址',"
+"emp_hometel as '家庭電話',cultureDegree.culd_name as '文化程度',emp_college as '畢業(yè)院校',"
+"emp_speciality as '專業(yè)',technicalPosition.tecp_name as '專業(yè)技術(shù)職務(wù)',emp_CertificateNo as '教師資格證編號',"
+"emp_certificateDate as '發(fā)證日期',emp_certificateDept as '發(fā)證部門',emp_isTeacher as '是否教師',"
+"emp_propositionFirst as '首次參與命題時間',emp_propositionRecent as '最近參與命題時間',"
+"role.rol_name as '角色',emp_memo as '備注' from Employee,sex,nation,technicalPosition,Maritalstatus,role,"
+"PoliticalFeature,cultureDegree,nativePlace where sex.sex_code=Employee.sex_code and"
+" nation.nat_code=Employee.nat_code and technicalPosition.tecp_code=Employee.tecp_code "
+"and Maritalstatus.mars_code=Employee.mars_code and PoliticalFeature.polf_code=Employee.polf_code "
+"and cultureDegree.culd_code=Employee.culd_code and nativePlace.natp_code = Employee.natp_code"
+" and role.rol_no=Employee.rol_no";
if (this.ckb_xm.Checked)
select += " and Employee.emp_name like '%" + this.txt_xm.Text+"%'";
if (this.ckb_xb.Checked)
select += " and sex.sex_name like '%" + this.cbb_xb.Text+"%'";
if (this.ckb_mz.Checked)
select += " and nation.nat_name like '%" + this.cbb_mz.Text+"%'";
if (select.Length > 469)
{
try
{
sel=select;
System.Data.SqlClient.SqlConnection sqlcon=new System.Data.SqlClient.SqlConnection(dba.connStr);
sqlcon.Open();
System.Data.SqlClient.SqlDataAdapter sqldat=new System.Data.SqlClient.SqlDataAdapter(sel,sqlcon);
System.Data.DataSet dst=new System.Data.DataSet();
sqldat.Fill(dst,"Employee");
this.dgd_jzgcx.DataSource=dst;
this.dgd_jzgcx.DataMember="Employee";
sqlcon.Close();
for (int i=0;i<dst.Tables["Employee"].Rows.Count;i++)
{
if (dst.Tables["Employee"].Rows[i]["是否教師"].ToString()=="0")
{
dst.Tables["Employee"].Rows[i]["是否教師"]='是';
}
else
{
dst.Tables["Employee"].Rows[i]["是否教師"]='否';
}
}
}
catch(System.Exception error)
{
MessageBox.Show(error.Message);
}
}
else
{
try
{
sel=select.Substring(0,select.Length-5);
System.Data.SqlClient.SqlConnection sqlcon_all=new System.Data.SqlClient.SqlConnection(dba.connStr);
sqlcon_all.Open();
System.Data.SqlClient.SqlDataAdapter sqldat_all=new System.Data.SqlClient.SqlDataAdapter(sel,sqlcon_all);
System.Data.DataSet dst_all=new System.Data.DataSet();
sqldat_all.Fill(dst_all,"Employee");
this.dgd_jzgcx.DataSource=dst_all;
this.dgd_jzgcx.DataMember="Employee";
sqlcon_all.Close();
for (int i=0;i<dst_all.Tables["Employee"].Rows.Count;i++)
{
if (dst_all.Tables["Employee"].Rows[i]["是否教師"].ToString()=="0")
{
dst_all.Tables["Employee"].Rows[i]["是否教師"]='是';
}
else
{
dst_all.Tables["Employee"].Rows[i]["是否教師"]='否';
}
}
}
catch(System.Exception error)
{
MessageBox.Show(error.Message);
}
}
}
private void ckb_xm_CheckedChanged(object sender, System.EventArgs e)
{
if(this.ckb_xm.Checked)
this.txt_xm.Enabled=true;
else
{
this.txt_xm.Enabled=false;
this.txt_xm.Text="";
}
}
private void ckb_xb_CheckedChanged(object sender, System.EventArgs e)
{
if(this.ckb_xb.Checked)
this.cbb_xb.Enabled=true;
else
{
this.cbb_xb.Enabled=false;
this.cbb_xb.Text="";
}
}
private void ckb_mz_CheckedChanged(object sender, System.EventArgs e)
{
if(this.ckb_mz.Checked)
this.cbb_mz.Enabled=true;
else
{
this.cbb_mz.Enabled=false;
this.cbb_mz.Text="";
}
}
private void dgd_jzgcx_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
}
private void dgd_jzgcx_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
if (e.Button==System.Windows.Forms.MouseButtons.Left)
{
Point pt = new Point(e.X,e.Y);
DataGrid.HitTestInfo hit = this.dgd_jzgcx.HitTest(pt);
if(hit.Type == DataGrid.HitTestType.Cell)
{
this.dgd_jzgcx.Select(hit.Row);
}
}
}
private void Combo_Add()
{
dbAccess dba=new dbAccess();
try
{
System.Data.DataSet dat_mb=new System.Data.DataSet();
System.Data.SqlClient.SqlCommand sqlcom_sex=new System.Data.SqlClient.SqlCommand();
System.Data.SqlClient.SqlConnection sqlcon=new System.Data.SqlClient.SqlConnection();
System.Data.SqlClient.SqlDataAdapter sqlada_mb=new System.Data.SqlClient.SqlDataAdapter("select * from sex",
dba.connStr);
sqlada_mb.Fill(dat_mb,"sex");
foreach (System.Data.DataRow dater in dat_mb.Tables["sex"].Rows )
{
this.cbb_xb.Items.Add(dater[1]);
}
}
catch(System.Exception m)
{
MessageBox.Show(m.Message);
}
try
{
System.Data.DataSet dat_mb=new System.Data.DataSet();
System.Data.SqlClient.SqlCommand sqlcom_sex=new System.Data.SqlClient.SqlCommand();
System.Data.SqlClient.SqlConnection sqlcon=new System.Data.SqlClient.SqlConnection();
System.Data.SqlClient.SqlDataAdapter sqlada_mb=new System.Data.SqlClient.SqlDataAdapter("select * from nation",
dba.connStr);
sqlada_mb.Fill(dat_mb,"nation");
foreach (System.Data.DataRow dater in dat_mb.Tables["nation"].Rows )
{
this.cbb_mz.Items.Add(dater[1]);
}
}
catch(System.Exception m)
{
MessageBox.Show(m.Message);
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -