凯云水利水电造价工程系统 (三) 材料单价 (3)

凯云水利水电造价工程系统 (三) 材料单价 (3)

接着 上一篇 材料单价(2)

3.4-3.2.10 根据条件查询

(1)根据不同的添加对材料单价进行查询

 当没有选中下拉树的节点时,所查处的数据是整张表的数据,如图:


(图 18)

当你选中节点,再进行根据条件查询时,所查出的就是根据材料单价分类进行查询的,如下图:


(图 19)

(2)当点击根据条件查询下拉框的数据,所执行的方法的界面层代码:


 
 //按是否业主查询   也可以先把查询的方法写好,用的时候直接调用
                      function  SelectYeZhu(){
                          var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');
                            //先把材料单价的所有数据查询出来
                                    for(var i=0;i<CaiLiaoDanJia.rows.length;i++){  //循环遍历数据
                                       if( CaiLiaoDanJia.rows[i].IfMainMaterial==true){
                                          //如果循环到是否主材的是true,就把值赋值给If
                                            If=true;
                                           
                                         }
                                         }
                                        var IfMainMaterial=If;
                                        $.getJSON("/CaiLiaoDanJia/SelectYeZhu?BuildProjectID="+@Session["项目ID"]+"&"
                                                       +"IfMainMaterial="+If,
                                                        function(data){
                                                          $('#w材料单价').datagrid('loadData',data);
                                                              });
                                          }

(3)按条件查询,控制器所涉及到的代码,下面的都是 按条件查询所用到的查询方法:

//按条件查询
function ConditionSelect(){

var TiaoJian=$('#TiaoJian').combobox('getValue');
//获取下拉框所选中的id
var Tree=$('#treMaterial').tree('getSelected');
//选中下拉树的节点
if(Tree){
//如果节点存在,就根据节点下的id进行条件查询
if (TiaoJian==49){
//如果所选择的的id是49,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
//根据是否主材进行选择
//循环遍历复选框里看是否被选中
if( CaiLiaoDanJia.rows[i].IfMainMaterial==true){

If=true;

}
}
var IfMainMaterial=If;
$.getJSON("/CaiLiaoDanJia/GenJuXiaLaShuifZhuCai?BuildProjectID="+@Session["项目ID"]+"&"
+"IfMainMaterial="+If+"&"
//把被选中的复选框赋值给变量,传到控制器去
+"MaterialPriceClassesID="+Tree.id,
function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
else{
if(TiaoJian==48){
//如果所选择的的id是48,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].OwnerSupplyMaterial==true){

If=true;

}
}
var OwnerSupplyMaterial=If;
$.getJSON("/CaiLiaoDanJia/XiaLaifGongCai?BuildProjectID="+@Session["项目ID"]+"&"
+"OwnerSupplyMaterial="+If+"&"
+"MaterialPriceClassesID="+Tree.id,
function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
else{
if(TiaoJian==50){
如果所选择的的id是50,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].OwnerSupplyMaterial==true){

If=true;

}
}
var OwnerSupplyMaterial=If;

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].IfMainMaterial==true){

IfS=true;

}
}
var IfMainMaterial=IfS;
$.getJSON("/CaiLiaoDanJia/XiaLaifGongCaiand?BuildProjectID="+@Session["项目ID"]+"&"
+"OwnerSupplyMaterial="+If+"&"
+"IfMainMaterial="+IfS+"&"
+"MaterialPriceClassesID="+Tree.id,

function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
else{
if(TiaoJian==51){
//如果所选择的的id是51,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].IfMainMaterial==true){

If=true;

}
}
var IfMainMaterial=If;
$.getJSON("/CaiLiaoDanJia/XiaLaZhuCai?BuildProjectID="+@Session["项目ID"]+"&"
+"IfMainMaterial="+If+"&"
+"MaterialPriceClassesID="+Tree.id,
function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
else{
if(TiaoJian==52){
//如果所选择的的id是52,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].OwnerSupplyMaterial==true){

If=true;

}
}
var OwnerSupplyMaterial=If;
$.getJSON("/CaiLiaoDanJia/XiaLaGongCai?BuildProjectID="+@Session["项目ID"]+"&"
+"OwnerSupplyMaterial="+If+"&"
+"MaterialPriceClassesID="+Tree.id,
function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
else{
if(TiaoJian==47){
//如果所选择的的id是47,则就执行下面的代码
BangDingSuoYouCaiLiao();
//调用查询所有的材料的方法

}
}
}

}
}
}
}
else{
//没有选中下拉树的节点,就执行下面的代码
if(TiaoJian==47){
如果所选择的的id是47则就执行下面的代码
BangDingSuoYouCaiLiao();

}
else{
if(TiaoJian==49){
//如果所选择的的id是49,则就执行下面的代码
SelectYeZhu();
//调用按是否业主查询进行查询
}
else{
if (TiaoJian==48){
//如果所选择的的id是48,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].OwnerSupplyMaterial==true){

If=true;

}
}
var OwnerSupplyMaterial=If;
$.getJSON("/CaiLiaoDanJia/ifGongCai?BuildProjectID="+@Session["项目ID"]+"&"
+"OwnerSupplyMaterial="+If,
function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
else{
if (TiaoJian==50){
//如果所选择的的id是50,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].OwnerSupplyMaterial==true){

If=true;

}
}
var OwnerSupplyMaterial=If;

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].IfMainMaterial==true){

IfS=true;

}
}
var IfMainMaterial=IfS;
$.getJSON("/CaiLiaoDanJia/ifGongCaiand?BuildProjectID="+@Session["项目ID"]+"&"
+"OwnerSupplyMaterial="+If+"&"
+"IfMainMaterial="+IfS,
function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
else{
if(TiaoJian==51){
//如果所选择的的id是51,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].IfMainMaterial==true){

If=true;

}
}
var IfMainMaterial=If;
$.getJSON("/CaiLiaoDanJia/XianShiYeZhu?BuildProjectID="+@Session["项目ID"]+"&"
+"IfMainMaterial="+If,
function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
else{
if(TiaoJian==52){
//如果所选择的的id是52,则就执行下面的代码
var CaiLiaoDanJia=$('#w材料单价').datagrid('getData');

for(var i=0;i<CaiLiaoDanJia.rows.length;i++){
if( CaiLiaoDanJia.rows[i].OwnerSupplyMaterial==true){

If=true;

}
}
var OwnerSupplyMaterial=If;
$.getJSON("/CaiLiaoDanJia/XianShiGongCai?BuildProjectID="+@Session["项目ID"]+"&"
+"OwnerSupplyMaterial="+If,
function(data){
$('#w材料单价').datagrid('loadData',data);
});
}
}
 
}
 
}
 
}

}
}

}

(3)控制器涉及到的代码:

    #region  查询全部材料
        public ActionResult SelectAllCaiLiao(int BuildProjectID)
        {
            DataTable dt = myCaiLiaoDanJia.SelectAllCaiLiao(Convert.ToInt32(BuildProjectID));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);


        }//是否供材
        public ActionResult ifGongCai(int BuildProjectID, string OwnerSupplyMaterial)
        {
            DataTable dt = myCaiLiaoDanJia.ifGongCai(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(OwnerSupplyMaterial));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }
        //根据下拉树只显示主材
        public ActionResult GenJuXiaLaShuifZhuCai(int BuildProjectID, string IfMainMaterial, string MaterialPriceClassesID)
        {
            DataTable dt = myCaiLiaoDanJia.GenJuXiaLaShuifZhuCai(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(IfMainMaterial), Convert.ToInt32(MaterialPriceClassesID));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }
        //根据下拉树只显示供材
        public ActionResult XiaLaifGongCai(int BuildProjectID, Boolean OwnerSupplyMaterial, int MaterialPriceClassesID)
        {
            DataTable dt = myCaiLiaoDanJia.XiaLaifGongCai(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(OwnerSupplyMaterial), Convert.ToInt32(MaterialPriceClassesID));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }
        //根据下拉树只显示供材and主材
        public ActionResult XiaLaifGongCaiand(int BuildProjectID, Boolean OwnerSupplyMaterial, Boolean IfMainMaterial, int MaterialPriceClassesID)
        {
            DataTable dt = myCaiLiaoDanJia.XiaLaifGongCaiand(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(OwnerSupplyMaterial), Convert.ToBoolean(IfMainMaterial), Convert.ToInt32(MaterialPriceClassesID));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }
        //根据下拉树显示主材
        public ActionResult XiaLaZhuCai(int BuildProjectID, Boolean IfMainMaterial, int MaterialPriceClassesID)
        {
            DataTable dt = myCaiLiaoDanJia.XiaLaZhuCai(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(IfMainMaterial), Convert.ToInt32(MaterialPriceClassesID));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }
        //根据下拉树显示供材
        public ActionResult XiaLaGongCai(int BuildProjectID, Boolean OwnerSupplyMaterial, int MaterialPriceClassesID)
        {
            DataTable dt = myCaiLiaoDanJia.XiaLaGongCai(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(OwnerSupplyMaterial), Convert.ToInt32(MaterialPriceClassesID));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }




        //是否主材
        public ActionResult SelectYeZhu(int BuildProjectID, string IfMainMaterial)
        {
            DataTable dt = myCaiLiaoDanJia.SelectYeZhu(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(IfMainMaterial));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }


        //供材abd业主
        public ActionResult ifGongCaiand(int BuildProjectID, string OwnerSupplyMaterial, string IfMainMaterial)
        {
            DataTable dt = myCaiLiaoDanJia.ifGongCaiand(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(OwnerSupplyMaterial), Convert.ToBoolean(IfMainMaterial));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }

        //绑定下拉框
        public ActionResult ComboxSelected()
        {
            DataTable dt = myCaiLiaoDanJia.ComboxSelected();
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }
        //显示供材
        public ActionResult XianShiGongCai(int BuildProjectID, string OwnerSupplyMaterial)
        {
            DataTable dt = myCaiLiaoDanJia.XianShiGongCai(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(OwnerSupplyMaterial));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }//显示主材
        public ActionResult XianShiYeZhu(int BuildProjectID, string IfMainMaterial)
        {
            DataTable dt = myCaiLiaoDanJia.XianShiYeZhu(Convert.ToInt32(BuildProjectID), Convert.ToBoolean(IfMainMaterial));
            List<Dictionary<string, object>> ListResult = ConvertHelper.DtToList(dt);
            return Json(ListResult, JsonRequestBehavior.AllowGet);
            //返回Json格式数据给界面

        }
        #endregion


 

 

(4)逻辑层所涉及到的代码:

  #region   查询全部材料组成
        public DataTable SelectAllCaiLiao(int BuildProjectID)
        {
             SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
                                             
                                             };
            mySqlParameter[0].Value = "SelectAllCaiLiao"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }

        #endregion
        //只显示主材
        public DataTable SelectYeZhu(int BuildProjectID, Boolean IfMainMaterial)
        {
            SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
            new SqlParameter("@IfMainMaterial",SqlDbType.Bit),
                                             
                                             };
            mySqlParameter[0].Value = "ifZhuCai"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            mySqlParameter[2].Value = IfMainMaterial;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }

        //根据下拉树只显示主材
        public DataTable GenJuXiaLaShuifZhuCai(int BuildProjectID, Boolean IfMainMaterial, int MaterialPriceClassesID)
        {
            SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
            new SqlParameter("@IfMainMaterial",SqlDbType.Bit),
            new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),

                                             
                                             };
            mySqlParameter[0].Value = "GenJuXiaLaShuifZhuCai"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            mySqlParameter[2].Value = IfMainMaterial;
            mySqlParameter[3].Value = MaterialPriceClassesID;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }
        //根据下拉树只显示供材
        public DataTable XiaLaifGongCai(int BuildProjectID, Boolean OwnerSupplyMaterial, int MaterialPriceClassesID)
        {
            SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
            new SqlParameter("@OwnerSupplyMaterial",SqlDbType.Bit),
            new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),

                                             
                                             };
            mySqlParameter[0].Value = "XiaLaifGongCai"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            mySqlParameter[2].Value = OwnerSupplyMaterial;
            mySqlParameter[3].Value = MaterialPriceClassesID;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }
        //根据下拉树只显示主材和供材
        public DataTable XiaLaifGongCaiand(int BuildProjectID, Boolean OwnerSupplyMaterial, Boolean IfMainMaterial, int MaterialPriceClassesID)
        {
            SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
            new SqlParameter("@OwnerSupplyMaterial",SqlDbType.Bit),
            new SqlParameter("@IfMainMaterial",SqlDbType.Bit),
            new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int)
                                             
                                             };
            mySqlParameter[0].Value = "XiaLaifGongCaiand"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            mySqlParameter[2].Value = OwnerSupplyMaterial;
            mySqlParameter[3].Value = IfMainMaterial;
            mySqlParameter[4].Value = MaterialPriceClassesID;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }
        //根据下拉树显示供材
        public DataTable XiaLaGongCai(int BuildProjectID, Boolean OwnerSupplyMaterial, int MaterialPriceClassesID)
        {
            SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
            new SqlParameter("@OwnerSupplyMaterial",SqlDbType.Bit),
            new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),

                                             
                                             };
            mySqlParameter[0].Value = "XiaLaGongCai"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            mySqlParameter[2].Value = OwnerSupplyMaterial;
            mySqlParameter[3].Value = MaterialPriceClassesID;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }
        //根据下拉树显示主材
        public DataTable XiaLaZhuCai(int BuildProjectID, Boolean IfMainMaterial, int MaterialPriceClassesID)
        {
            SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
            new SqlParameter("@IfMainMaterial",SqlDbType.Bit),
            new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),

                                             
                                             };
            mySqlParameter[0].Value = "XiaLaZhuCai"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            mySqlParameter[2].Value = IfMainMaterial;
            mySqlParameter[3].Value = MaterialPriceClassesID;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }
        //只显示供材
        public DataTable ifGongCai(int BuildProjectID, Boolean OwnerSupplyMaterial)
        {
            SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
            new SqlParameter("@OwnerSupplyMaterial",SqlDbType.Bit),
                                             
                                             };
            mySqlParameter[0].Value = "ifGongCai"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            mySqlParameter[2].Value = OwnerSupplyMaterial;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }
        //只显示主材和供材
        public DataTable ifGongCaiand(int BuildProjectID, Boolean OwnerSupplyMaterial, Boolean IfMainMaterial)
        {
            SqlParameter[] mySqlParameter ={
            new SqlParameter("@Type",SqlDbType.Char),
            new SqlParameter("@BuildProjectID",SqlDbType.Int),
            new SqlParameter("@OwnerSupplyMaterial",SqlDbType.Bit),
            new SqlParameter("@IfMainMaterial",SqlDbType.Bit),
                                             
                                             };
            mySqlParameter[0].Value = "ifGongCaiand"; //数据层的存储过程名
            mySqlParameter[1].Value = BuildProjectID;
            mySqlParameter[2].Value = OwnerSupplyMaterial;
            mySqlParameter[3].Value = IfMainMaterial;
            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySqlParameter);
            return dt;
            //返回数据给控制器
        }


</pre><pre>

(5)数据层SQL语句:

--只显示主材
if @Type='ifZhuCai'
begin
SELECT     SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.IfMainMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and IfMainMaterial=@IfMainMaterial
end
--选中下拉树只显示主材
if @Type='GenJuXiaLaShuifZhuCai'
begin
SELECT     SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.IfMainMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and IfMainMaterial=@IfMainMaterial and SYS_MaterialPriceClassesList.MaterialPriceClassesID=@MaterialPriceClassesID
end
--只显示供材
if @Type='ifGongCai'
begin
SELECT     SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.OwnerSupplyMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and OwnerSupplyMaterial=@OwnerSupplyMaterial
end
--根据下拉树只显示供材
if @Type='XiaLaifGongCai'
begin
SELECT     SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.OwnerSupplyMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and OwnerSupplyMaterial=@OwnerSupplyMaterial and SYS_MaterialPriceClassesList.MaterialPriceClassesID=@MaterialPriceClassesID
end
--只显示主材和供材
if @Type='ifGongCaiand'
begin
SELECT     SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.OwnerSupplyMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName,SYS_MaterialPriceList.IfMainMaterial
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and OwnerSupplyMaterial=@OwnerSupplyMaterial and IfMainMaterial=@IfMainMaterial
end
--根据下拉树只显示主材和供材
if @Type='XiaLaifGongCaiand'
begin
SELECT      SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.OwnerSupplyMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName,SYS_MaterialPriceList.IfMainMaterial
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and OwnerSupplyMaterial=@OwnerSupplyMaterial and IfMainMaterial=@IfMainMaterial and SYS_MaterialPriceClassesList.MaterialPriceClassesID=@MaterialPriceClassesID
end
if @Type='ComboxSelected'
begin
SELECT     NatureGatherDetailID, NatureGatherDetailName
FROM         SYS_NatureGatherDetailList
where NatureGatherID=13
end
--显示主材
if @Type='ZhuCai'
begin
SELECT     SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.OwnerSupplyMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName,SYS_MaterialPriceList.IfMainMaterial
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and IfMainMaterial=@IfMainMaterial
end
--根据下拉树显示主材
if @Type='XiaLaZhuCai'
begin
SELECT      SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.OwnerSupplyMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName,SYS_MaterialPriceList.IfMainMaterial
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and IfMainMaterial=@IfMainMaterial and SYS_MaterialPriceClassesList.MaterialPriceClassesID=@MaterialPriceClassesID
end
--显示供材
if @Type='GongCai'
begin
SELECT    SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.OwnerSupplyMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName,SYS_MaterialPriceList.IfMainMaterial
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and OwnerSupplyMaterial=@OwnerSupplyMaterial
end

--根据下拉树显示供材
if @Type='XiaLaGongCai'
begin
SELECT     SYS_MaterialPriceList.MaterialPriceID,SYS_MaterialPriceList.BuildProjectID, SYS_MaterialPriceList.MaterialPriceClassesID, ltrim(rtrim(SYS_MaterialPriceList.Code))as Code,ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit,ltrim(rtrim(SYS_MaterialPriceList.MaterialCostPrice))as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice))as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare))as Fare,ltrim(rtrim(SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost, ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice,SYS_MaterialPriceList.OwnerSupplyMaterial, ltrim(rtrim(SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno,
SYS_MaterialPriceClassesList.MaterialPriceClassesName,SYS_MaterialPriceList.IfMainMaterial
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID
where BuildProjectID=@BuildProjectID and OwnerSupplyMaterial=@OwnerSupplyMaterial and SYS_MaterialPriceClassesList.MaterialPriceClassesID=@MaterialPriceClassesID
end


3.4-3.2.11 多条件的模糊查询

(1)先在下拉框里选择进行查询的方式,然后在关键字里输入查询的条件,如果选中模糊查询的复选框,则进行模糊查询,否则就是精确查询:


(图 20)

(2)当输入完相关的条件后,就点击查询按钮,进行条件查询,传值到界面层的代码:

 

        // 查询 前面的是模糊查找,后面的是精确查找

   function ww(){ //模糊查找
    var f= $('#fangshi').combobox('getValue');//获取下拉框里的值
       var t =$('#guanjianzichanxun').val().trim();//获取文本框里的关键词

        var   obj=document.getElementById("shiyong");//仅显示已使用
     
        var   r=document.getElementById("chaxun");//选中模糊查询的checkbox
        if(r.checked==true){//如果模糊查询的checkbox被选中,则执行下面的代码,根剧代号、名称、名称的首字母进行模糊查询
         
        if(f==29){//29表示属性明细的ID,如果选中,则执行下面的代码  拼音的首字母
               var e = $('#treMaterial').tree('getSelected');
             if(e){//如果选中下拉树,就执行下面的代码
                $.getJSON("/CaiLiaoDanJia/JiXieDanJiashouzimuChaXun?MachineryPriceClassesFurID=" + e.id + "&"
                                           +"chcke="+obj.checked+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);    
                });
             }
           else{
              $.getJSON("/CaiLiaoDanJia/JiXieDanJiashouzimuChaXun1?chcke="+obj.checked+"&"
                                           +"ID="+ @Session["项目ID"]+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);  
                      });
           }
    } 
     if(f==30){ //id=30,就对代号进行查询 
           
             var e = $('#treMaterial').tree('getSelected');
              
             if(e){
                $.getJSON("/CaiLiaoDanJia/JiXieDanJiashouzimuChaXunDaiHao?MachineryPriceClassesFurID=" + e.id + "&"
                                           +"chcke="+obj.checked+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);       
                });
             }
           else{

              $.getJSON("/CaiLiaoDanJia/JiXieDanJiashouzimuChaXunDaiHao1?chcke="+obj.checked+"&"
                                            +"ID="+ @Session["项目ID"]+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);  
                      
                      });
           }
          }
           if(f==31){//id=30,就对名称进行查询 
                   var e = $('#treMaterial').tree('getSelected');
             if(e){
                  $.getJSON("/CaiLiaoDanJia/JiXieDanJiashouzimuChaXunmingcheng1?MachineryPriceClassesFurID=" + e.id + "&"
                                           +"chcke="+obj.checked+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                       $('#w材料单价').datagrid('loadData', data);     
                }); 
             }
             else{
  
             $.getJSON("/CaiLiaoDanJia/JiXieDanJiashouzimuChaXunmingcheng?chcke="+obj.checked+"&"
                                        +"ID="+ @Session["项目ID"]+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);  
                      
                      });
                } 
           }
     }
     




   else{//如果模糊查询的checkbox没被选中,则根据代号、名称为条件进行精确查找
     
         if(f==29){ 
               var e = $('#treMaterial').tree('getSelected');
             if(e){
          
                $.getJSON("/CaiLiaoDanJia/jingqueJiXieDanJiashouzimuChaXun?MachineryPriceClassesFurID=" + e.id + "&"
                                           +"chcke="+obj.checked+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);     
                });
             
             }
           
           else{
              $.getJSON("/CaiLiaoDanJia/jingqueJiXieDanJiashouzimuChaXun1?chcke="+obj.checked+"&"
                                           +"ID="+ @Session["项目ID"]+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);  
                 });
           }
           } 
        if(f==30){
            var e = $('#treMaterial').tree('getSelected');
             if(e){
                $.getJSON("/CaiLiaoDanJia/jingqueJiXieDanJiashouzimuChaXunDaiHao?MachineryPriceClassesFurID=" + e.id + "&"
                                           +"chcke="+obj.checked+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);  
                });
             }
           else{
              $.getJSON("/CaiLiaoDanJia/jingqueJiXieDanJiashouzimuChaXunDaiHao1?chcke="+obj.checked+"&"
                                            +"ID="+ @Session["项目ID"]+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);  
                 });
           }
        }
        if(f==31){
          var e = $('#treMaterial').tree('getSelected');
             if(e){
                $.getJSON("/CaiLiaoDanJia/jingqueJiXieDanJiashouzimuChaXunMingCheng?MachineryPriceClassesFurID=" + e.id + "&"
                                           +"chcke="+obj.checked+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);   
                });
             }
           else{
              $.getJSON("/CaiLiaoDanJia/jingqueJiXieDanJiashouzimuChaXunMingCheng1?chcke="+obj.checked+"&"
                                           +"ID="+ @Session["项目ID"]+"&"
                                           +"guanjianzichanxun="+t,
                function (data) {
                      $('#w材料单价').datagrid('loadData', data);  
                 });
           }
        }
     }
       
   }


 
 

(3)界面层的值传入到控制器的代码:

        #region 模糊查找 首字母
        public ActionResult JiXieDanJiashouzimuChaXun(string MachineryPriceClassesFurID, string chcke, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.JiXieDanJiashouzimuChaXun(Convert.ToInt32(MachineryPriceClassesFurID), Convert.ToBoolean(chcke), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }


        public ActionResult JiXieDanJiashouzimuChaXun1(string chcke, string ID, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.JiXieDanJiashouzimuChaXun1(Convert.ToBoolean(chcke), Convert.ToInt32(ID), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }
        #endregion
        #region 模糊查找 名称
        public ActionResult JiXieDanJiashouzimuChaXunmingcheng(string chcke, string ID, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.JiXieDanJiashouzimuChaXunmingcheng(Convert.ToBoolean(chcke), Convert.ToInt32(ID), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }


        public ActionResult JiXieDanJiashouzimuChaXunmingcheng1(string MachineryPriceClassesFurID, string chcke, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.JiXieDanJiashouzimuChaXunmingcheng1(Convert.ToInt32(MachineryPriceClassesFurID), Convert.ToBoolean(chcke), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }
        #endregion
        #region 模糊查找 代号
        public ActionResult JiXieDanJiashouzimuChaXunDaiHao(string MachineryPriceClassesFurID, string chcke, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.JiXieDanJiashouzimuChaXunDaiHao(Convert.ToInt32(MachineryPriceClassesFurID), Convert.ToBoolean(chcke), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }

        public ActionResult JiXieDanJiashouzimuChaXunDaiHao1(string chcke, string ID, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.JiXieDanJiashouzimuChaXunDaiHao1(Convert.ToBoolean(chcke), Convert.ToInt32(ID), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }
        #endregion
        //精确查询

        // 首字母
        public ActionResult jingqueJiXieDanJiashouzimuChaXun(string MachineryPriceClassesFurID, string chcke, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.jingqueJiXieDanJiashouzimuChaXun(Convert.ToInt32(MachineryPriceClassesFurID), Convert.ToBoolean(chcke), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }

        public ActionResult jingqueJiXieDanJiashouzimuChaXun1(string chcke, string ID, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.jingqueJiXieDanJiashouzimuChaXun1(Convert.ToBoolean(chcke), Convert.ToInt32(ID), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }

        //代号
        public ActionResult jingqueJiXieDanJiashouzimuChaXunDaiHao(string MachineryPriceClassesFurID, string chcke, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.jingqueJiXieDanJiashouzimuChaXunDaiHao(Convert.ToInt32(MachineryPriceClassesFurID), Convert.ToBoolean(chcke), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }

        public ActionResult jingqueJiXieDanJiashouzimuChaXunDaiHao1(string chcke, string ID, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.jingqueJiXieDanJiashouzimuChaXunDaiHao1(Convert.ToBoolean(chcke), Convert.ToInt32(ID), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }


        //名称
        public ActionResult jingqueJiXieDanJiashouzimuChaXunMingCheng(string MachineryPriceClassesFurID, string chcke, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.jingqueJiXieDanJiashouzimuChaXunMingCheng(Convert.ToInt32(MachineryPriceClassesFurID), Convert.ToBoolean(chcke), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }

        public ActionResult jingqueJiXieDanJiashouzimuChaXunMingCheng1(string chcke, string ID, string guanjianzichanxun)
        {
            DataTable dt = myCaiLiaoDanJia.jingqueJiXieDanJiashouzimuChaXunMingCheng1(Convert.ToBoolean(chcke), Convert.ToInt32(ID), guanjianzichanxun);
            List<Dictionary<string, object>> listReturn = ConvertHelper.DtToList(dt);
            return Json(listReturn, JsonRequestBehavior.AllowGet);
        }


   (4)控制器的值传到逻辑层的代码:

   #region 材料单价首字母查询 模糊
        public DataTable JiXieDanJiashouzimuChaXun(int MachineryPriceClassesFurID, bool chcke, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                   new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                   new SqlParameter("@Pinyincode",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceInitialSelect";
            mySQL[1].Value = MachineryPriceClassesFurID;
            mySQL[2].Value = chcke;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }


        public DataTable JiXieDanJiashouzimuChaXun1(bool chcke, int ID, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                    new SqlParameter("@BuildProjectID",SqlDbType.Int),
                               new SqlParameter("@Pinyincode",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceInitialSelect";

            mySQL[1].Value = chcke;
            mySQL[2].Value = ID;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }

        #endregion
        #region 材料单价名称查询 模糊

        public DataTable JiXieDanJiashouzimuChaXunmingcheng(bool chcke, int ID, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                
                                     new SqlParameter("@effectivityno",SqlDbType.Bit),
                                     new SqlParameter("@BuildProjectID",SqlDbType.Int),
                                     new SqlParameter("@Name",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceNameSelect";

            mySQL[1].Value = chcke;
            mySQL[2].Value = ID;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }

        public DataTable JiXieDanJiashouzimuChaXunmingcheng1(int MachineryPriceClassesFurID, bool chcke, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                   new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                   new SqlParameter("@Name",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceNameSelect";
            mySQL[1].Value = MachineryPriceClassesFurID;
            mySQL[2].Value = chcke;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }

        #endregion
        #region 材料单价单号查询 模糊

        public DataTable JiXieDanJiashouzimuChaXunDaiHao(int MachineryPriceClassesFurID, bool chcke, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                   new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                    new SqlParameter("@Code",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceCodeSelect";
            mySQL[1].Value = MachineryPriceClassesFurID;
            mySQL[2].Value = chcke;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }




        public DataTable JiXieDanJiashouzimuChaXunDaiHao1(bool chcke, int ID, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                
                                    new SqlParameter("@effectivityno",SqlDbType.Bit),
                                    new SqlParameter("@BuildProjectID",SqlDbType.Int),
                                    new SqlParameter("@Code",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceCodeSelect";

            mySQL[1].Value = chcke;
            mySQL[2].Value = ID;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }
        #endregion


        //精确查询
        #region 精确查询 首字母
        public DataTable jingqueJiXieDanJiashouzimuChaXun(int MachineryPriceClassesFurID, bool chcke, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                   new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                   new SqlParameter("@Pinyincode",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceInitialExavt";
            mySQL[1].Value = MachineryPriceClassesFurID;
            mySQL[2].Value = chcke;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }


        public DataTable jingqueJiXieDanJiashouzimuChaXun1(bool chcke, int ID, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                    new SqlParameter("@BuildProjectID",SqlDbType.Int),
                                    new SqlParameter("@Pinyincode",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceInitialExavt";

            mySQL[1].Value = chcke;
            mySQL[2].Value = ID;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }

        #endregion



        #region 精确查询 代号
        public DataTable jingqueJiXieDanJiashouzimuChaXunDaiHao(int MachineryPriceClassesFurID, bool chcke, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                   new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                   new SqlParameter("@Code",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceCodeExcet";
            mySQL[1].Value = MachineryPriceClassesFurID;
            mySQL[2].Value = chcke;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }


        public DataTable jingqueJiXieDanJiashouzimuChaXunDaiHao1(bool chcke, int ID, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                   new SqlParameter("@BuildProjectID",SqlDbType.Int),
                                   new SqlParameter("@Code",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceCodeExcet";

            mySQL[1].Value = chcke;
            mySQL[2].Value = ID;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }



        #endregion
        #region 精确查询名称
        public DataTable jingqueJiXieDanJiashouzimuChaXunMingCheng(int MachineryPriceClassesFurID, bool chcke, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                   new SqlParameter("@MaterialPriceClassesID",SqlDbType.Int),
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                   new SqlParameter("@Name",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceNameExcet";
            mySQL[1].Value = MachineryPriceClassesFurID;
            mySQL[2].Value = chcke;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }


        public DataTable jingqueJiXieDanJiashouzimuChaXunMingCheng1(bool chcke, int ID, string guanjianzichanxun)
        {
            SqlParameter[] mySQL = {
                                   new SqlParameter("@type",SqlDbType.Char),  
                                
                                   new SqlParameter("@effectivityno",SqlDbType.Bit),
                                    new SqlParameter("@BuildProjectID",SqlDbType.Int),
                                     new SqlParameter("@Name",SqlDbType.Char),
                                   };
            mySQL[0].Value = "MaterialPriceNameExcet";

            mySQL[1].Value = chcke;
            mySQL[2].Value = ID;
            mySQL[3].Value = guanjianzichanxun;


            DataTable dt = myDALMethod.DAL_SelectDB_Par("CaiLiaoDanJia", mySQL);
            return dt;
        }

        #endregion

(5)数据层的SQL语句:

--多条件查询模糊查询首字母查询

if @type='MaterialPriceInitialSelect'
begin
declare @sq varchar(1000)=''
if @MaterialPriceClassesID!=''
begin
set  @sq=' where SYS_MaterialPriceClassesList.MaterialPriceClassesID like ''%'+ltrim(rtrim(@MaterialPriceClassesID))+'%'''

end

if @effectivityno!=''
begin
if @sq !=''
set @sq=@sq+' and effectivityno like ''%'+LTRIM(RTRIM(@effectivityno))+'%'''
else set @sq=' where effectivityno like ''%'+LTRIM(RTRIM(@effectivityno))+'%'''
end

if @BuildProjectID!=''
begin
if @sq !=''
set @sq=@sq+' and SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
else set @sq=' where SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
end
if @Pinyincode!=''
begin
if @sq !=''
set @sq=@sq+' and Pinyincode like ''%'+LTRIM(RTRIM(@Pinyincode))+'%'''
else set @sq=@sq+' where Pinyincode like ''%'+LTRIM(RTRIM(@Pinyincode))+'%'''
end

exec('SELECT     SYS_MaterialPriceList.MaterialPriceID, SYS_MaterialPriceList.BuildProjectID,SYS_MaterialPriceList.MaterialPriceClassesID,ltrim(rtrim(SYS_MaterialPriceList.Code))as Code, ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit ,ltrim(rtrim( SYS_MaterialPriceList.MaterialCostPrice)) as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice)) as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare)) as Fare,ltrim(rtrim( SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost,ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice, SYS_MaterialPriceList.IfMainMaterial, SYS_MaterialPriceList.OwnerSupplyMaterial,
ltrim(rtrim(SYS_MaterialPriceClassesList.MaterialPriceClassesName))as MaterialPriceClassesName, ltrim(rtrim(SYS_BuildProjectList.BuildProjectName))as BuildProjectName,ltrim(rtrim( SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID INNER JOIN
SYS_BuildProjectList ON SYS_MaterialPriceList.BuildProjectID = SYS_BuildProjectList.BuildProjectID '+@sq)

return
end



--查询名称模糊查询
if @type='MaterialPriceNameSelect'
begin
declare @s varchar(1000)=''

if @MaterialPriceClassesID!=''
begin
set  @s=' where SYS_MaterialPriceClassesList.MaterialPriceClassesID like ''%'+ltrim(rtrim(@MaterialPriceClassesID))+'%'''

end

if @effectivityno!=''
begin
if @s !=''
set @s=@s+' and effectivityno like ''%'+LTRIM(RTRIM(@effectivityno))+'%'''
else set @s=' where effectivityno like ''%'+LTRIM(RTRIM(@effectivityno))+'%'''
end
if @BuildProjectID!=''
begin
if @s !=''
set @s=@s+' and SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
else set @s=' where SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
end

if @Name!=''
begin
if @s !=''
set @s=@s+' and Name like ''%'+LTRIM(RTRIM(@Name))+'%'''
else set @s=@s+' where Name like ''%'+LTRIM(RTRIM(@Name))+'%'''
end

exec('SELECT SYS_MaterialPriceList.MaterialPriceID, SYS_MaterialPriceList.BuildProjectID,SYS_MaterialPriceList.MaterialPriceClassesID,ltrim(rtrim(SYS_MaterialPriceList.Code))as Code, ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit ,ltrim(rtrim( SYS_MaterialPriceList.MaterialCostPrice)) as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice)) as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare)) as Fare,ltrim(rtrim( SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost,ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice, SYS_MaterialPriceList.IfMainMaterial, SYS_MaterialPriceList.OwnerSupplyMaterial,
ltrim(rtrim(SYS_MaterialPriceClassesList.MaterialPriceClassesName))as MaterialPriceClassesName, ltrim(rtrim(SYS_BuildProjectList.BuildProjectName))as BuildProjectName,ltrim(rtrim( SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID INNER JOIN
SYS_BuildProjectList ON SYS_MaterialPriceList.BuildProjectID = SYS_BuildProjectList.BuildProjectID '+@s)

return
end


--查询单号模糊查询
if @type='MaterialPriceCodeSelect'
begin
declare @sr varchar(1000)=''

if @MaterialPriceClassesID!=''
begin
set  @sr=' where SYS_MaterialPriceClassesList.MaterialPriceClassesID like ''%'+ltrim(rtrim(@MaterialPriceClassesID))+'%'''

end

if @effectivityno!=''
begin
if @sr !=''
set @sr=@sr+' and effectivityno like ''%'+LTRIM(RTRIM(@effectivityno))+'%'''
else set @sr=' where effectivityno like ''%'+LTRIM(RTRIM(@effectivityno))+'%'''
end
if @BuildProjectID!=''
begin
if @sr !=''
set @sr=@sr+' and SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
else set @sr=' where SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
end

if @Code!=''
begin
if @sr !=''
set @sr=@sr+' and Code like ''%'+LTRIM(RTRIM(@Code))+'%'''
else set @sr=@sr+' where Code like ''%'+LTRIM(RTRIM(@Code))+'%'''
end

exec('SELECT     SYS_MaterialPriceList.MaterialPriceID, SYS_MaterialPriceList.BuildProjectID,SYS_MaterialPriceList.MaterialPriceClassesID,ltrim(rtrim(SYS_MaterialPriceList.Code))as Code, ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit ,ltrim(rtrim( SYS_MaterialPriceList.MaterialCostPrice)) as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice)) as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare)) as Fare,ltrim(rtrim( SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost,ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice, SYS_MaterialPriceList.IfMainMaterial, SYS_MaterialPriceList.OwnerSupplyMaterial,
ltrim(rtrim(SYS_MaterialPriceClassesList.MaterialPriceClassesName))as MaterialPriceClassesName, ltrim(rtrim(SYS_BuildProjectList.BuildProjectName))as BuildProjectName,ltrim(rtrim( SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID INNER JOIN
SYS_BuildProjectList ON SYS_MaterialPriceList.BuildProjectID = SYS_BuildProjectList.BuildProjectID '+@sr)

return
end

--精确查询  首字母
if @type='MaterialPriceInitialExavt'


BEGIN
declare @sql varchar(1000)
if @MaterialPriceClassesID !=''
begin
set @sql=' where SYS_MaterialPriceClassesList.MaterialPriceClassesID='''+ltrim(rtrim(@MaterialPriceClassesID))+''''
end
if @effectivityno!=''
begin
if @sql !=''
set @sql=@sql+' and effectivityno='''+ltrim(rtrim(@effectivityno))+''''
else set @sql=' where effectivityno='''+ltrim(rtrim(@effectivityno))+''''
end

if @BuildProjectID!=''
begin
if @sql !=''
set @sql=@sql+' and SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
else set @sql=' where SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
end
if @Pinyincode!=''
begin
if @sql !=''
set @sql=@sql+' and Pinyincode='''+@Pinyincode+''''
else set @sql=' where Pinyincode='''+@Pinyincode+''''
end

exec('SELECT     SYS_MaterialPriceList.MaterialPriceID, SYS_MaterialPriceList.BuildProjectID,SYS_MaterialPriceList.MaterialPriceClassesID,ltrim(rtrim(SYS_MaterialPriceList.Code))as Code, ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit ,ltrim(rtrim( SYS_MaterialPriceList.MaterialCostPrice)) as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice)) as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare)) as Fare,ltrim(rtrim( SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost,ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice, SYS_MaterialPriceList.IfMainMaterial, SYS_MaterialPriceList.OwnerSupplyMaterial,
ltrim(rtrim(SYS_MaterialPriceClassesList.MaterialPriceClassesName))as MaterialPriceClassesName, ltrim(rtrim(SYS_BuildProjectList.BuildProjectName))as BuildProjectName,ltrim(rtrim( SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID INNER JOIN
SYS_BuildProjectList ON SYS_MaterialPriceList.BuildProjectID = SYS_BuildProjectList.BuildProjectID '+@sql)
return
END




--  精确单号
if @type='MaterialPriceCodeExcet'


BEGIN
declare @sqlw varchar(1000)
if @MaterialPriceClassesID !=''
begin
set @sqlw=' where SYS_MaterialPriceClassesList.MaterialPriceClassesID='''+ltrim(rtrim(@MaterialPriceClassesID))+''''
end
if @effectivityno!=''
begin
if @sqlw !=''
set @sqlw=@sqlw+' and effectivityno='''+ltrim(rtrim(@effectivityno))+''''
else set @sqlw=' where effectivityno='''+ltrim(rtrim(@effectivityno))+''''
end
if @BuildProjectID!=''
begin
if @sqlw !=''
set @sqlw=@sqlw+' and SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
else set @sqlw=' where SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
end

if @Code!=''
begin
if @sqlw !=''
set @sqlw=@sqlw+' and Code='''+@Code+''''
else set @sqlw=' where Code='''+@Code+''''
end

exec('SELECT     SYS_MaterialPriceList.MaterialPriceID, SYS_MaterialPriceList.BuildProjectID,SYS_MaterialPriceList.MaterialPriceClassesID,ltrim(rtrim(SYS_MaterialPriceList.Code))as Code, ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit ,ltrim(rtrim( SYS_MaterialPriceList.MaterialCostPrice)) as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice)) as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare)) as Fare,ltrim(rtrim( SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost,ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice, SYS_MaterialPriceList.IfMainMaterial, SYS_MaterialPriceList.OwnerSupplyMaterial,
ltrim(rtrim(SYS_MaterialPriceClassesList.MaterialPriceClassesName))as MaterialPriceClassesName, ltrim(rtrim(SYS_BuildProjectList.BuildProjectName))as BuildProjectName,ltrim(rtrim( SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID INNER JOIN
SYS_BuildProjectList ON SYS_MaterialPriceList.BuildProjectID = SYS_BuildProjectList.BuildProjectID '+@sqlw)
return
END





-- 查找精确名称
if @type='MaterialPriceNameExcet'


BEGIN
declare @sqlweQ varchar(1000)
if @MaterialPriceClassesID !=''
begin
set @sqlweQ=' where SYS_MaterialPriceClassesList.MaterialPriceClassesID='''+ltrim(rtrim(@MaterialPriceClassesID))+''''
end
if @effectivityno!=''
begin
if @sqlweQ !=''
set @sqlweQ=@sqlweQ+' and effectivityno='''+ltrim(rtrim(@effectivityno))+''''
else set @sqlweQ=' where effectivityno='''+ltrim(rtrim(@effectivityno))+''''
end
if @BuildProjectID!=''
begin
if @sqlweQ !=''
set @sqlweQ=@sqlweQ+' and SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
else set @sqlweQ=' where SYS_BuildProjectList.BuildProjectID='''+LTRIM(RTRIM(@BuildProjectID))+''''
end

if @Name!=''
begin
if @sqlweQ !=''
set @sqlweQ=@sqlweQ+' and Name='''+@Name+''''
else set @sqlweQ=' where Name='''+@Name+''''
end



exec('SELECT     SYS_MaterialPriceList.MaterialPriceID, SYS_MaterialPriceList.BuildProjectID,SYS_MaterialPriceList.MaterialPriceClassesID,ltrim(rtrim(SYS_MaterialPriceList.Code))as Code, ltrim(rtrim(SYS_MaterialPriceList.Name))as Name,
ltrim(rtrim(SYS_MaterialPriceList.Unit))as Unit ,ltrim(rtrim( SYS_MaterialPriceList.MaterialCostPrice)) as MaterialCostPrice, ltrim(rtrim(SYS_MaterialPriceList.PackagingPrice)) as PackagingPrice, ltrim(rtrim(SYS_MaterialPriceList.Fare)) as Fare,ltrim(rtrim( SYS_MaterialPriceList.BuyingAndHoldPrice))as BuyingAndHoldPrice,
ltrim(rtrim(SYS_MaterialPriceList.TransferSafeCost))as TransferSafeCost,ltrim(rtrim(SYS_MaterialPriceList.BudgetPrice))as BudgetPrice, SYS_MaterialPriceList.IfMainMaterial, SYS_MaterialPriceList.OwnerSupplyMaterial,
ltrim(rtrim(SYS_MaterialPriceClassesList.MaterialPriceClassesName))as MaterialPriceClassesName, ltrim(rtrim(SYS_BuildProjectList.BuildProjectName))as BuildProjectName,ltrim(rtrim( SYS_MaterialPriceList.Pinyincode))as Pinyincode, SYS_MaterialPriceList.effectivityno
FROM         SYS_MaterialPriceList INNER JOIN
SYS_MaterialPriceClassesList ON SYS_MaterialPriceList.MaterialPriceClassesID = SYS_MaterialPriceClassesList.MaterialPriceClassesID INNER JOIN
SYS_BuildProjectList ON SYS_MaterialPriceList.BuildProjectID = SYS_BuildProjectList.BuildProjectID '+@sqlweQ)
return
END


                 仅供学习参考,禁止商业用途,否则后果自负!


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值