码迷,mamicode.com
首页 > 其他好文 > 详细

2019/01/08

时间:2019-01-08 12:20:50      阅读:129      评论:0      收藏:0      [点我收藏+]

标签:status   help   new   county   val   asics   com   trim   list   

1. 查询条件

        /// <summary>
        /// 查询条件
        /// </summary>
        /// <returns></returns>
        private List<ConditionHelper.SqlqueryCondition> InquiryCondition()
        {
            var wheres = new List<ConditionHelper.SqlqueryCondition>();

            string branchname = hidBranchCode.Text;
            wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Branch, Comparison.Equals, branchname));

            if (!string.IsNullOrEmpty(txtEnterpriseName.Text.Trim()))
            {

                wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Enterprisename,
                    Comparison.Like, "%" + StringHelper.FilterSql(txtEnterpriseName.Text) + "%"));
            }

            if (!string.IsNullOrEmpty(ddlIndustryCode1.SelectedValue) && ddlIndustryCode1.SelectedValue != "-1")
            {
                var indusM1 = Basics_industry.SingleOrDefault(x => x.Classcode1 == ddlIndustryCode1.SelectedValue && x.Classgrade == 1);
                wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Industrycode1,
                    Comparison.Equals, indusM1.Id));
            }
            if (!string.IsNullOrEmpty(ddlIndustryCode2.SelectedValue) && ddlIndustryCode2.SelectedValue != "-1")
            {
                var indusM2 = Basics_industry.SingleOrDefault(x => x.Classcode2 == ddlIndustryCode2.SelectedValue);
                wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Industrycode2,
                    Comparison.Equals, indusM2.Id));
            }
            if (!string.IsNullOrEmpty(ddlIndustryCode3.SelectedValue) && ddlIndustryCode3.SelectedValue != "-1")
            {
                var indusM3 = Basics_industry.SingleOrDefault(x => x.Classcode3 == ddlIndustryCode3.SelectedValue);
                wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Industrycode3,
                    Comparison.Equals, indusM3.Id));
            }
            if (!string.IsNullOrEmpty(ddlIndustryCode4.SelectedValue) && ddlIndustryCode4.SelectedValue != "-1")
            {
                var indusM4 = Basics_industry.SingleOrDefault(x => x.Classcode4 == ddlIndustryCode4.SelectedValue);
                wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Industrycode4,
                    Comparison.Equals, indusM4.Id));
            }

            //
            if (!string.IsNullOrEmpty(ddlProvince.SelectedText.Trim()) && ddlProvince.SelectedText.Trim() != "选择省")
            {
                wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Provinceid,
                    Comparison.Equals, StringHelper.FilterSql(ddlProvince.SelectedValue.Trim())));
            }
            //
            if (!string.IsNullOrEmpty(ddlCity.SelectedText.Trim()) && ddlCity.SelectedText.Trim() != "选择市")
            {
                wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Cityid,
                    Comparison.Equals, StringHelper.FilterSql(ddlCity.SelectedValue.Trim())));
            }
            //
            if (!string.IsNullOrEmpty(ddlCounty.SelectedText.Trim()) && ddlCounty.SelectedText.Trim() != "选择区县")
            {
                wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Countyid,
                    Comparison.Equals, StringHelper.FilterSql(ddlCounty.SelectedValue.Trim())));
            }
            ///审核状态
            //if (!string.IsNullOrEmpty(ddlAuditStatus.SelectedValue))
            //{
            //    wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Auditstatus,
            //        Comparison.Equals, StringHelper.FilterSql(ddlAuditStatus.SelectedValue)));
            //}
            wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Iszjaj,
                   Comparison.NotEquals, StringHelper.FilterSql("2")));
            //wheres.Add(new ConditionHelper.SqlqueryCondition(ConstraintType.And, V_b_u_chemicalenterpriseTable.Iszjaj,
            //        Comparison.Equals, StringHelper.FilterSql("1")));

            return wheres;
        }

 

2019/01/08

标签:status   help   new   county   val   asics   com   trim   list   

原文地址:https://www.cnblogs.com/hexx/p/10237814.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!