2019/01/08

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;
        }

猜你喜欢

转载自www.cnblogs.com/hexx/p/10237814.html