using System;
using System.Web;

/// <summary>
/// append_sql 的摘要说明
/// </summary>
public class append_sql
{
	public append_sql()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    public string sql_str(string lei, string strtitle, string strclass, string strbit1, string strbit2, string strdate1, string strdate2, int strtop)
    {
        string connect_str = "";
        switch (lei)
        {
            case "dairy":
                connect_str = connect_str + "where id>0";
                if (strtitle != "")
                {
                    connect_str = connect_str + " and dtitle like '%" + strtitle + "%'";
                }
                if (strclass != "")
                {
                    connect_str = connect_str + " and dclass like '%" + strclass + "%'";
                }
                if (strdate1 != "" && strdate2 !="")
                {
                    connect_str = connect_str + " and dtime>='" + strdate1 + "' and dtime<='" + strdate2 + "'";
                }
                if (strbit1 != "" && strbit2 != "")
                {
                    connect_str = connect_str + " and dbit>=" + strbit1 + " and dbit<=" + strbit2;
                }
                if (strtop != 0)
                {
                    connect_str = connect_str + " and dtop=" + strtop + "";
                }
                break;
            case "pic":
                connect_str = connect_str + "where id>0";
                if (strtitle != "")
                {
                    connect_str = connect_str + " and pname like '%" + strtitle + "%'";
                }
                if (strclass != "")
                {
                    connect_str = connect_str + " and pclass like '%" + strclass + "%'";
                }
                if (strdate1 != "" && strdate2 != "")
                {
                    connect_str = connect_str + " and pdate>='" + strdate1 + "' and pdate<='"+strdate2+"'";
                }
                if (strbit1 != "" && strbit2 != "")
                {
                    connect_str = connect_str + " and pbit>=" + strbit1 + " and pbit<=" + strbit2;
                }
                if (strtop != 0)
                {
                    connect_str = connect_str + " and ptop=" + strtop + "";
                }
                break;
            case "dairy_pl":
                connect_str = connect_str + "where id>0";
                if (strtitle != "")
                {
                    connect_str = connect_str + " and drwriter like '%" + strtitle + "%'";
                }
                if (strdate1 != "" && strdate2 != "")
                {
                    connect_str = connect_str + " and drtime>='" + strdate1 + "' and drtime<='"+strdate2+"'";
                }
                if (strtop != 0)
                {
                    connect_str = connect_str + " and drunable=" + strtop + "";
                }
                break;
            case "customer_manage":
                connect_str = connect_str + "where id>0";
                if (strtitle != "")
                {
                    connect_str = connect_str + " and cname like '%" + strtitle + "%'";
                }
                if (strclass != "")
                {
                    connect_str = connect_str + " and clei='" + strclass + "'";
                }
                if (strdate1 != "" && strdate2 != "")
                {
                    connect_str = connect_str + " and cdate>='" + strdate1 + "' and cdate<='"+strdate2+"'";
                }
                if (strbit1 != "")
                {
                    connect_str = connect_str + " and csex='" + strbit1 + "'";
                }
                break;
            default:
                connect_str = "";
                break;
        }
        return connect_str;
    }


}
