小迪的Blog
学习ing...(注明:该Blog中的任何信息都非原创,只是作为个人的阅读笔记)
        private string GetSQL()
        
{
            
string strSQL;
//            strSQL = "select UID,MobileNum,DateTime,PayFlag,grade from SMS_Log where ";
            strSQL = "select UID,MobileNum,DateTime,PayFlag=case PayFlag when 0 then '未处理' when 1 then '成功扣费' when 2 then '扣费失败' end,grade=case grade when 0 then '未获奖' when 1 then '一等奖' when 2 then '二等奖' when 3 then '三等奖' end from SMS_Log where ";
            strSQL 
+= "1=1";    // 什么都不选的情况

            
if(tbUID.Text != "")
            
{
                strSQL 
+= " and ";
                strSQL 
+= "UID=N'" + tbUID.Text.Trim() + "'";    // 选择用户ID的情况
            }


            
if(tbBeginTime.Value != "")
            
{
                strSQL 
+= " and ";
                strSQL 
+= "DateTime>'" + tbBeginTime.Value + "'";        // 选择起始时间的情况,格式2005-4-27 17:33:04
            }


            
if(tbEndTime.Value != "")
            
{
                strSQL 
+= " and ";
                strSQL 
+= "DateTime<'" + tbEndTime.Value + "'";        // 选择结束时间的情况
            }


            
if(cblSelect.SelectedIndex == 0)
            
{
                strSQL 
+= " and ";
                strSQL 
+= "PayFlag=1";        // 选择成功扣费的情况,单选
            }


            
if(cblSelect.SelectedIndex == 1)
            
{
                strSQL 
+= " and ";
                strSQL 
+= "PayFlag=2";        // 选择扣费失败的情况,单选
            }


            
if(cblSelect.SelectedIndex == 2)
            
{
                strSQL 
+= " and ";
                strSQL 
+= "PayFlag=0";        // 选择未处理的情况,单选
            }


            
return strSQL;
        }
posted on 2005-04-30 15:05  小迪  阅读(447)  评论(0编辑  收藏  举报