📄 query.cs
字号:
this.cbOldgraduation.Text = "请选择或输入新项";
this.QueryTip.SetToolTip(this.cbOldgraduation, "毕业时间为必填项");
this.cbOldgraduation.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.cbOldgraduation_KeyPress);
//
// cbOlddiploma
//
this.cbOlddiploma.ForeColor = System.Drawing.SystemColors.ControlText;
this.cbOlddiploma.Items.AddRange(new object[] {
"普通全日制",
"成人",
"网络教育",
"研究生"});
this.cbOlddiploma.Location = new System.Drawing.Point(432, 46);
this.cbOlddiploma.Name = "cbOlddiploma";
this.cbOlddiploma.Size = new System.Drawing.Size(121, 20);
this.cbOlddiploma.TabIndex = 2;
this.cbOlddiploma.Text = "请选择或输入新项";
this.QueryTip.SetToolTip(this.cbOlddiploma, "学历类型为必填项");
this.cbOlddiploma.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.cbOlddiploma_KeyPress);
//
// txtOldname
//
this.txtOldname.Location = new System.Drawing.Point(80, 40);
this.txtOldname.Name = "txtOldname";
this.txtOldname.Size = new System.Drawing.Size(120, 21);
this.txtOldname.TabIndex = 1;
this.txtOldname.Tag = "";
this.txtOldname.Text = "";
this.QueryTip.SetToolTip(this.txtOldname, "姓名或证书编号任填一项");
this.txtOldname.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.txtOldname_KeyPress);
//
// label4
//
this.label4.Location = new System.Drawing.Point(16, 91);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(64, 16);
this.label4.TabIndex = 21;
this.label4.Text = "毕业时间:";
//
// label2
//
this.label2.Location = new System.Drawing.Point(368, 48);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(64, 16);
this.label2.TabIndex = 20;
this.label2.Text = "学历类型:";
//
// Query
//
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.lv);
this.Name = "Query";
this.Size = new System.Drawing.Size(600, 512);
this.Load += new System.EventHandler(this.Query_Load);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void Query_Load(object sender, System.EventArgs e)
{
this.txtOldname.Focus();
db = new DBAgent();
}
private void txtOlddiplomaid_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if( !(( 48 <= e.KeyChar && e.KeyChar <=57 )|| e.KeyChar == 8 ))
{
e.Handled = true;
}
if ( e.KeyChar == 13 )
{
pictureBox1_Click( sender, e );
}
}
private void lv_DoubleClick(object sender, System.EventArgs e)
{
btnYN = true;
ListViewItem ltemp = lv.SelectedItems[0];
string xm = lv.SelectedItems[0].Text;
string xb = lv.SelectedItems[0].SubItems[1].Text;
string csrq = lv.SelectedItems[0].SubItems[2].Text;
string pycc = lv.SelectedItems[0].SubItems[3].Text;
string xxxs = lv.SelectedItems[0].SubItems[4].Text;
string xz = lv.SelectedItems[0].SubItems[5].Text;
string yxmc = lv.SelectedItems[0].SubItems[6].Text;
string zymc = lv.SelectedItems[0].SubItems[7].Text;
string bjyjl = lv.SelectedItems[0].SubItems[8].Text;
string rxrq = lv.SelectedItems[0].SubItems[9].Text;
string byrq = lv.SelectedItems[0].SubItems[10].Text;
string zsbh = lv.SelectedItems[0].SubItems[11].Text;
//string shjl = lv.SelectedItems[0].SubItems[11].Text;
DialogResult k = DetailForm.ShowForm(xm,xb,csrq,pycc,xxxs,xz,yxmc,zymc,bjyjl,rxrq,byrq,zsbh,OldOrNew( lv.Tag.ToString( )));
if( k == DialogResult.OK )
{
lv.SelectedItems[0].Text = DetailForm.Namem;
lv.SelectedItems[0].SubItems[1].Text = DetailForm.Sex;
lv.SelectedItems[0].SubItems[2].Text = DetailForm.Birthday;
lv.SelectedItems[0].SubItems[3].Text = DetailForm.Classo;
lv.SelectedItems[0].SubItems[4].Text = DetailForm.Diploma;
lv.SelectedItems[0].SubItems[5].Text = DetailForm.Xz;
lv.SelectedItems[0].SubItems[6].Text = DetailForm.Yxmc;
lv.SelectedItems[0].SubItems[7].Text = DetailForm.Zymc;
lv.SelectedItems[0].SubItems[8].Text = DetailForm.Byjl;
lv.SelectedItems[0].SubItems[9].Text = DetailForm.Rxrq;
lv.SelectedItems[0].SubItems[10].Text = DetailForm.Byrq;
lv.SelectedItems[0].SubItems[11].Text = DetailForm.Zsbh;
}
else if( k == DialogResult.No)
{
lv.Items.Remove( ltemp);
}
else
{
}
}
/// <summary>
/// 判断是旧库还是新库
/// </summary>
/// <param name="condition">条件</param>
/// <returns>true就是新库</returns>
private bool OldOrNew( string condition )
{
if( condition == "OldQuery" || condition == "OldInput" )
return true;
else
return false;
}
private void button3_Click(object sender, System.EventArgs e)
{
}
private void pictureBox1_MouseEnter(object sender, System.EventArgs e)
{
pictureBox1.Image = Image.FromFile( "img\\button-查询02.GIF" );
}
private void pictureBox1_MouseLeave(object sender, System.EventArgs e)
{
pictureBox1.Image = Image.FromFile( "img\\button-查询01.GIF" );
}
private void pictureBox1_Click(object sender, System.EventArgs e)
{
if ( cbOlddiploma.Text.Trim( ) == "请选择或输入新项" || cbOldgraduation.Text.Trim( ) == "请选择或输入新项" )
{
MessageBox.Show("错误提示:学历类型和毕业时间为必选项","查询错误提示窗口",MessageBoxButtons.OK,MessageBoxIcon.Warning );
this.Focus( );
}
else
{
if( txtOldname.Text.Trim( ).Length == 0 && txtOlddiplomaid.Text.Trim( ).Length == 0 )
{
MessageBox.Show("错误提示:姓名和证书编号为任选项,必须输入姓名和证书的一个选择","查询错误提示窗口",MessageBoxButtons.OK,MessageBoxIcon.Warning );
this.Focus( );
}
else
{
string diploma = cbOlddiploma.Text.Trim( );
string year = cbOldgraduation.Text.Trim( );
string queryString = "SELECT * FROM " + Config.GetTableName( diploma , year ) + " WHERE ";
if ( txtOldname.Text.Trim( ).Length != 0 )
{
queryString += "xm='" + txtOldname.Text.Trim( ) + "' AND ";
}
if ( txtOlddiplomaid.Text.Trim( ).Length != 0 )
{
queryString += "zsbh='" + txtOlddiplomaid.Text.Trim( ) + "' AND ";
}
queryString = queryString.Substring(0,queryString.Length - 5);
string connectingString = "Provider=vfpoledb.1;Data Source=" + Config.GetDir( diploma );
db.InitConnectionPool(connectingString,1);
try
{
DataSet ds = db.ExecuteCommand( queryString );
if( ds.Tables[0].Rows.Count == 0 )
{
MessageBox.Show( "所查找数据不存在或已删除!","查询错误提示",MessageBoxButtons.OK,MessageBoxIcon.Warning );
this.Focus( );
}
else
{
lv.Items.Clear( );
lv.Tag = "OldQuery";
for( int i = 0; i < ds.Tables[0].Rows.Count; i++ )
{
ListViewItem first = new ListViewItem( );
if( i%2 == 0 )
{
first.BackColor = Color.SkyBlue;
}
first.Text = ds.Tables[0].Rows[i]["xm"].ToString( ).Trim( );
first.SubItems.Add( ds.Tables[0].Rows[i]["xb"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["csrq"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["pycc"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["xxxs"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["xz"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["yxmc"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["zymc"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["bjyjl"].ToString( ).Trim( ) );
//first.SubItems.Add( //ds.Tables[0].Rows[i]["bjyjl"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["rxrq"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["byrq"].ToString( ).Trim( ) );
first.SubItems.Add( ds.Tables[0].Rows[i]["zsbh"].ToString( ).Trim( ) );
lv.Items.Add( first );
}
}
}
catch
{
MessageBox.Show( "所需查找数据表不存在,请重新设置源数据库" ,"查询错误提示",MessageBoxButtons.OK,MessageBoxIcon.Warning);
if ( fbd.ShowDialog( ) == DialogResult.OK )
{
Config.SetPath ( fbd.SelectedPath );
MessageBox.Show( "源数据库设置成功!","修改提示",MessageBoxButtons.OK ,MessageBoxIcon.Warning );
}
else
{
MessageBox.Show( "你还没有设置源数据库位置!不可以进行查询", "修改提示",MessageBoxButtons.OK ,MessageBoxIcon.Warning );
}
this.Focus( );
}
}
}
}
private void cbOldgraduation_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if( !(( 48 <= e.KeyChar && e.KeyChar <=57 )|| e.KeyChar == 8 ))
{
e.Handled = true;
}
if ( e.KeyChar == 13 )
{
pictureBox1_Click( sender, e );
}
}
private void cbOlddiploma_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if ( e.KeyChar == 13 )
{
pictureBox1_Click( sender, e );
}
}
private void txtOldname_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
{
if ( e.KeyChar == 13 )
{
pictureBox1_Click( sender, e );
}
}
private void lv_SelectedIndexChanged(object sender, System.EventArgs e)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -