111,126
社区成员
发帖
与我相关
我的任务
分享
DGVLog.Columns.Clear();
string SQL = "Select * from SMSLog where ID > 0 ";//初始化一个SQL查询语句
if (!(CHKBOperationType.Checked || CHKBCarNumber.Checked || CHKBDate.Checked || CHKDWResult.Checked))
{
MessageBox.Show("开始查询前,请至少选择一个查询条件!", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
//if (CHKBUserName.Checked)
//{
// if (combUserName.Text == "")
// {
// MessageBox.Show("请选择或输入需要查询的用户名!", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
// return;
// }
// else
// {
// SQL += " and username = '" + combUserName.SelectedItem.ToString().Trim() + "'";
// }
//}
if (CHKBOperationType.Checked)
{
if (combOperationType.Text == "")
{
MessageBox.Show("请选择或输入需要查询的操作类型!", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
SQL += " and RecOrSend = '" + combOperationType.SelectedItem.ToString().Trim() + "'";
}
}
if (CHKBCarNumber.Checked)
{
if (combCarNumber.Text == "")
{
MessageBox.Show("请选择或输入需要查询车牌号码!", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
SQL += " and CarNumber ='" + combCarNumber.SelectedItem.ToString().Trim() + "'";
}
}
if (CHKDWResult.Checked)
{
if (ComboxDWResult.Text == "")
{
MessageBox.Show("定位结果不能为空,如果不过滤定位结果,\r请不要将其上的复选框选中!", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
//MessageBox.Show("接收手机号不能为空,如果不需要过滤其他关键字,请不要将其他关键字复选框选中!", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
SQL += " and DWResult = '" + ComboxDWResult.Text.Trim() + "'";
}
}
if (CHKBRecNumber.Checked)
{
if (TextRecNumber.Text == "")
{
MessageBox.Show("接收手机号不能为空,如果不需要过滤手机号,\r请不要将其上的复选框选中!", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
SQL += " and RecPhoneNumber like '%" + TextRecNumber.Text + "%'";
}
}
if (CHKBDate.Checked)
{
if (DTPEnd.Value.Date < DTPStart.Value.Date)
{
MessageBox.Show("开始日期不能晚于结束日期", "查询提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
else
{
SQL += "and OperationDateTime > #" + DTPStart.Value.Date + "# and OperationDateTime < #" + DTPEnd.Value.Date.AddDays(1.0) + "#";
}
}
SQL += " order by ID";
LoadDGV(SQL);
}
}
catch(Exception err)
{
Tools.ShowMessage(err.ToString(), MessageBoxIcon.Information);
}