zoukankan      html  css  js  c++  java
  • 动态组织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
        }
    }

  • 相关阅读:
    Java学习笔记8(面向对象3:接口)
    面向对象2(继承,抽象类)
    java学习笔记6(面向对象1:概念,private)
    排序方法-循环和数组练习
    ArrayList方法综合练习
    Eclipse的配置
    集合(ArrayList)简述
    java学习笔记5(方法)
    数据结构9——最小生成树
    数据结构8——图的遍历
  • 原文地址:https://www.cnblogs.com/a1991322/p/2650706.html
Copyright © 2011-2022 走看看