动态组织SQl语句:助手类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace EatGood.Model.FoodManage
{
    /// <summary>
    /// 食法要求查询:动态查询Model
    /// 郑松涛
    /// </summary>
   public class SearchFeelKind
    {
        #region  筛选参数
        private string _ShopId = null;
        private string _Kindname = null;
        private string _FeelKindName = null;
        private string _FeelNo = null;
        private string _Feedname = null;

       /// <summary>
       /// 门店ID
       /// </summary>
        public string FShopId
        {
            get
            {
                if (_ShopId.Length != 0)
                {
                    return "and (fshopid in(1050)) ";
                }
                return _ShopId;
            }
            set { _ShopId = value; }
        }
       /// <summary>
       /// 食品大类名
       /// </summary>
        public string Kindname
        {
            get
            {
                //if (_Kindname.Length != 0)
                //{
                //    return "and (kindname in('" + _Kindname + "'))";
                //}
                return _Kindname;
            }
            set { _Kindname = value; }
        }
       /// <summary>
       /// 要去组别名
       /// </summary>
        public string FeelKindName
        {
            get
            {
                //if (_FeelKindName.Length != 0)
                //{
                //    return "and (FeelKindName in('" + _FeelKindName + "'))";
                //}
                //else
                    return _FeelKindName;
            }
            set { _FeelKindName = value; }
        }
       /// <summary>
       /// 口味编号
       /// </summary>
        public string FeelNo
        {
            get
            {
                if (_FeelNo.Length != 0)
                {
                    return "and (feelno in('" + _FeelNo + "'))";
                }
                return _FeelNo;
            }
            set { _FeelNo = value; }
        }

       /// <summary>
       /// 口味名称
       /// </summary>
        public string FeelName
        {
            get
            {
                if (_Feedname.Length != 0)
                {
                    return "and ( feelname in ('" + _Feedname + "'))";
                }
                return _Feedname;
            }
            set
            {
                _Feedname = value;
            }
        }

       

        #endregion

 

        #region SQL模板解释
        public string GetSQLFromTempl()
        {
            string str = null;
            StringBuilder strSql = new StringBuilder();

            strSql.Append(" select r.* from");
            strSql.Append("(select c.fshopid,c.comname,fk.FeelKindName,fk.FeelKind,f.FeelNo,f.FeelName,");
            strSql.Append(" f.CalcType,f.CalcAmt,ct.CalcName,fd.kindname");
            strSql.Append(" from POS_FeelKind fk inner join");
            strSql.Append(" POS_Feels f on fk.FeelKind = f.FeelKind");
            strSql.Append(" and fk.fshopid = f.fshopid and f.isrevoked = 0 inner join");
            strSql.Append(" POS_CalcType ct on f.CalcType = ct.CalcType");
            strSql.Append(" left outer join pos_foodkind fd on f.kindno = fd.kindno");
            strSql.Append(" and f.fshopid = fd.fshopid");
            strSql.Append(" inner join psm_coms c on fk.fshopid = c.fshopid and f.fshopid = c.fshopid) r");
            strSql.Append("  where feelkind > 9  and 1=1");
            str = strSql.ToString();

            //组装第一个参数(%s) -->筛选条件
            string s1 = FShopId + Kindname + FeelKindName + FeelNo + FeelName;
            str = str + s1 + "order by fshopid,feelkind";
            return str;
         
        }
        #endregion
    }
}

转载于:https://www.cnblogs.com/a1991322/archive/2012/08/22/2650706.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值