111,126
社区成员
发帖
与我相关
我的任务
分享
private void button1_Click(object sender, EventArgs e)
{
string sql = "";
if (textBox1.Text.Trim() != "" && textBox2.Text.Trim() == "")
{
if (sql != null)
{
sql += " s.Stu_Name='" + textBox1.Text.Trim() + "'";
}
}
if (textBox2.Text.Trim() != "" && textBox1.Text.Trim() == "")
{
if (sql != null)
{
sql += " s.Stu_ID='" + textBox2.Text.Trim() + "'";
}
}
else if (textBox2.Text.Trim() != "" && textBox2.Text.Trim() != "")
{
if (sql != null)
{
sql += " s.Stu_ID='" + textBox2.Text.Trim() + "' and s.Stu_Name=" + textBox1.Text.Trim();
}
}
ds = null;
sqlconn.SQL = "select p.ID as ID,Stu_Name,s.Stu_ID as Stu_ID ,p1.Pay_Name as Pay_Name ,c.Code_Name as Code_Name ,p.Remarks as Remarks from Pay p left join Student_Info s on p.Stu_ID=s.Stu_ID left join Pay_Info p1 on p.Pay_ID=p1.Pay_ID left join CodeMaster c on p.State=c.Code_No and c.Code_Type='102' where " +sql;
ds = sqlconn.ReturnDataSet();
dataGridView1.DataSource = ds.Tables[0];
}
string sql = "";
if (textBox1.Text.Trim() != "" && textBox2.Text.Trim() =="")
{
if (sql != null)
{
sql += "and s.Stu_Name='" + textBox1.Text.Trim() + "'";
}
}
if (textBox2.Text.Trim() != "" && textBox1.Text.Trim() == "")
{
if (sql != null)
{
sql += "and s.Stu_ID='" + textBox2.Text.Trim() + "'";
}
}
else if (textBox2.Text.Trim() != "" && textBox2.Text.Trim() != "")
{
if (sql != null)
{
sql += "and s.Stu_ID='" + textBox2.Text.Trim() + "' and s.Stu_Name=" + textBox1.Text.Trim();
}
}
if (sql != null)
{
sql += "and s.Stu_Name='" + textBox1.Text.Trim() + "'";
}
}
if (textBox2.Text.Trim() != "" && textBox1.Text.Trim() == "")
{
if (sql != null)
{
sql += "and s.Stu_ID='" + textBox2.Text.Trim() + "'";
}
}
else if (textBox2.Text.Trim() != "" && textBox2.Text.Trim() != "")
{
if (sql != null)
{
sql += "and s.Stu_ID='" + textBox2.Text.Trim() + "' and s.Stu_Name=" + textBox1.Text.Trim();
}
}