//查询
  function add()
  {
    var selitem,fieldname,cn_item,h_item;
    if (document.Form1.queryitem.value!="")
    {
      selitem=document.Form1.queryitem.value;
      if (document.Form1.andor[0].checked)
      {
         cn_item="并且";
         h_item="and";
      }
      else
      {
         cn_item="或者";
         h_item="or";
      }
      if (selitem.substr(0,1)=="c")		   //字符
      {
         if (document.Form1.cqueryvalue.value=="")
		 {
			alert("请输入要查询的值！");
			return false;
		 }
         cn_item=cn_item+"  "+trim(document.Form1.queryitem.options[document.Form1.queryitem.selectedIndex].text);
         cn_item=cn_item+"  "+trim(document.Form1.calc.options[document.Form1.calc.selectedIndex].text);
         cn_item=cn_item+"  "+trim(document.Form1.cqueryvalue.value);
         
         h_item=h_item+" "+document.Form1.queryitem.value.substr(1,255);
         h_item=h_item+" "+document.Form1.calc.value;
         if (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="包含")
           h_item=h_item+" '%"+document.Form1.cqueryvalue.value+"%'";
         else if (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="左包含")
           h_item=h_item+" '"+document.Form1.cqueryvalue.value+"%'";
         else if (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="右包含")
           h_item=h_item+" '%"+document.Form1.cqueryvalue.value+"'";
         else
           h_item=h_item+" '"+document.Form1.cqueryvalue.value+"'";
         document.Form1.cqueryvalue.value="";
         document.Form1.querylist.options[document.Form1.querylist.length]=new Option(cn_item,h_item);
      }
      else if (selitem.substr(0,1)=="t")						  //文本
      {
         if (document.Form1.cqueryvalue.value=="")
		 {
			alert("请输入要查询的值！");
			return false;
		 }
         cn_item=cn_item+"  "+document.Form1.queryitem.options[document.Form1.queryitem.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.calc.options[document.Form1.calc.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.cqueryvalue.value;
         
         h_item=h_item+" "+document.Form1.queryitem.value.substr(1,255);
         if (document.Form1.calc.value!="like")
         {
           alert("您只能进行<包含>或<左包含>或<右包含>运算！");
           return false;
         }
         h_item=h_item+" "+document.Form1.calc.value;
         if (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="包含")
           h_item=h_item+" '%"+document.Form1.cqueryvalue.value+"%'";
         else if (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="左包含")
           h_item=h_item+" '"+document.Form1.cqueryvalue.value+"%'";
         else if (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="右包含")
           h_item=h_item+" '%"+document.Form1.cqueryvalue.value+"'";
         else
           h_item=h_item+" '"+document.Form1.cqueryvalue.value+"'";
         document.Form1.cqueryvalue.value="";
         document.Form1.querylist.options[document.Form1.querylist.length]=new Option(cn_item,h_item);
      }
      else if (selitem.substr(0,1)=="n")					//数值
      {
         if (document.Form1.nqueryvalue.value=="")
		 {
			alert("请输入要查询的值！");
			return false;
		 }
         cn_item=cn_item+"  "+document.Form1.queryitem.options[document.Form1.queryitem.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.calc.options[document.Form1.calc.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.nqueryvalue.value;
       
         h_item=h_item+" "+document.Form1.queryitem.value.substr(1,255);
         h_item=h_item+" "+document.Form1.calc.value;
         if ((document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="包含") || (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="左包含") || (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="右包含"))
         {
           alert("数值型数据不能进行<包含>运算！");
           return false;
         }
         else
           h_item=h_item+" "+document.Form1.nqueryvalue.value;
         document.Form1.nqueryvalue.value="";
         document.Form1.querylist.options[document.Form1.querylist.length]=new Option(cn_item,h_item);
      }
      else if (selitem.substr(0,1)=="d")			  //日期
      {
         cn_item=cn_item+"  "+document.Form1.queryitem.options[document.Form1.queryitem.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.calc.options[document.Form1.calc.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.cdate.value;
       
         h_item=h_item+" "+document.Form1.queryitem.value.substr(1,255);
         if (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="等于")
         {
            h_item=h_item+" between '"+document.Form1.cdate.value+"' and dateadd(minute,1439,'"+document.Form1.cdate.value+"')"   
         }else{
            h_item=h_item+" "+document.Form1.calc.value;
            if ((document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="包含") || (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="左包含") || (document.Form1.calc.options[document.Form1.calc.selectedIndex].text=="右包含"))
            {
               alert("日期型数据不能进行<包含>运算！");
               return false;
            }else
               h_item=h_item+" '"+document.Form1.cdate.value+"'";
         }
         document.Form1.querylist.options[document.Form1.querylist.length]=new Option(cn_item,h_item);
      }
      else if (selitem.substr(0,1)=="l")		//列表
      {
         cn_item=cn_item+"  "+document.Form1.queryitem.options[document.Form1.queryitem.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.calc.options[document.Form1.calc.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.lqueryvalue.options[document.Form1.lqueryvalue.selectedIndex].text;
       
         h_item=h_item+" "+document.Form1.queryitem.value.substr(1,255);
         h_item=h_item+" "+document.Form1.calc.value;
         if ((document.Form1.calc.options[document.Form1.calc.selectedIndex].text!="等于") && (document.Form1.calc.options[document.Form1.calc.selectedIndex].text!="不等于"))
         {
           alert("列表型数据只能进行[等于]或[不等于]运算！");
           return false;
         }
         else
           h_item=h_item+" '"+document.Form1.lqueryvalue.value+"'";
         document.Form1.querylist.options[document.Form1.querylist.length]=new Option(cn_item,h_item);
      }
      else if (selitem.substr(0,1)=="h")  //包含
      {
         cn_item=cn_item+"  "+document.Form1.queryitem.options[document.Form1.queryitem.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.calc.options[document.Form1.calc.selectedIndex].text;
         cn_item=cn_item+"  "+document.Form1.lqueryvalue.options[document.Form1.lqueryvalue.selectedIndex].text;
         h_item=h_item+" "+document.Form1.queryitem.value.substr(1,255);
         h_item=h_item+" "+document.Form1.calc.value;
         if ((document.Form1.calc.options[document.Form1.calc.selectedIndex].text!="包含") )
          {
            alert("列表型数据只能进行[包含]运算！");
            return false;
         }
         h_item=h_item+" '%"+document.Form1.lqueryvalue.value+"%'";
         document.Form1.querylist.options[document.Form1.querylist.length]=new Option(cn_item,h_item);
      }
    }
  }
//查询  
  function del()
  {
     if (document.Form1.querylist.selectedIndex==-1)
     {
       alert("请选择要删除的项目！")
       return false;
     }else{
       document.Form1.querylist.options[document.Form1.querylist.selectedIndex]=null;     
     } 
  }
//查询
  function setvaluecell()
  {
    var selitem,fieldname;
    if (document.Form1.queryitem.value!="")
    {
      selitem=document.Form1.queryitem.value;
      if ((selitem.substr(0,1)=="c") || (selitem.substr(0,1)=="t"))
      {
        document.Form1.cqueryvalue.value="";
        document.Form1.cqueryvalue.style.display="block";
        document.Form1.nqueryvalue.style.display="none";
        document.Form1.lqueryvalue.style.display="none";
        div1.style.display="none";
      }
      else if (selitem.substr(0,1)=="n")
      {
        document.Form1.nqueryvalue.value="";
        document.Form1.cqueryvalue.style.display="none";
        document.Form1.lqueryvalue.style.display="none";
        div1.style.display="none";
        document.Form1.nqueryvalue.style.display="block";
      }
      else if (selitem.substr(0,1)=="d")
      {
        document.Form1.nqueryvalue.value="";
        document.Form1.cqueryvalue.style.display="none";
        document.Form1.nqueryvalue.style.display="none";
        document.Form1.lqueryvalue.style.display="none";
        div1.style.display="block";
      }else if ((selitem.substr(0,1)=="l") || (selitem.substr(0,1)=="h"))
      {
        document.Form1.nqueryvalue.value="";
        document.Form1.cqueryvalue.style.display="none";
        document.Form1.nqueryvalue.style.display="none";
        document.Form1.lqueryvalue.style.display="block";
        for (var i=document.Form1.lqueryvalue.length-1;i>=0;i--){
          document.Form1.lqueryvalue.options[i]=null;
        }
        setlist(selitem.substr(1,selitem.length-1)); 
        div1.style.display="none";
      }
    }
  }
 