///<reference path="/Scripts/ExtPB_Net.js" />
///<reference path="/Scripts/MyExtPB.js" />
///<reference path="/Scripts/ExtPB_Dll_Pb_Http.js" />
///<reference path="/Scripts/MyExtPb_Input.js" />

function W_WeiKaiPiaoDanTongJi() {

	 var self=this;
	 var requestor= new PBWindow();
	 var sle_ykje= new SingleLineEdit( requestor );
	 var sle_zdbm= new SingleLineEdit( requestor );
	 var sle_zdr= new SingleLineEdit( requestor );
	 var sle_djbh= new SingleLineEdit( requestor );
	 var sle_kkje= new SingleLineEdit( requestor );
	 var dp_2= new DatePicker( requestor );
	 var dp_1= new DatePicker( requestor );
	 var dw_1= new DataWindow( requestor );
	 var tb_1= new ToolStrip( requestor );

	 if(typeof(this.bind)=="function") var baseBind=this.bind;
	 this.bind=function(win){
	 if(typeof( baseBind )=="function") baseBind(win);

		 if(requestor == null ) requestor= new PBWindow();
		 requestor.Attach(win);
		 if(sle_ykje == null ) sle_ykje= new SingleLineEdit( requestor );
		 sle_ykje.Attach( win.Control( "sle_ykje") ); 
		 if(sle_zdbm == null ) sle_zdbm= new SingleLineEdit( requestor );
		 sle_zdbm.Attach( win.Control( "sle_zdbm") ); 
		 if(sle_zdr == null ) sle_zdr= new SingleLineEdit( requestor );
		 sle_zdr.Attach( win.Control( "sle_zdr") ); 
		 if(sle_djbh == null ) sle_djbh= new SingleLineEdit( requestor );
		 sle_djbh.Attach( win.Control( "sle_djbh") ); 
		 if(sle_kkje == null ) sle_kkje= new SingleLineEdit( requestor );
		 sle_kkje.Attach( win.Control( "sle_kkje") ); 
		 if(dp_2 == null ) dp_2= new DatePicker( requestor );
		 dp_2.Attach( win.Control( "dp_2") ); 
		 if(dp_1 == null ) dp_1= new DatePicker( requestor );
		 dp_1.Attach( win.Control( "dp_1") ); 
		 if(dw_1 == null ) dw_1= new DataWindow( requestor );
		 dw_1.Attach( win.Control( "dw_1") ); 
		 if(tb_1 == null ) tb_1= new ToolStrip( requestor );
		 tb_1.Attach( win.Control( "tb_1") ); 

		 if(typeof(self.PostOpen)=="function") 
			 win.AttachEvent("window","PostOpen",self.PostOpen); 

		 if(typeof(self.Zdbm)=="function") 
			 win.AttachEvent("cb_zdbm","Clicked",self.Zdbm); 

		 if(typeof(self.Zdr)=="function") 
			 win.AttachEvent("cb_zdr","Clicked",self.Zdr); 

		 if(typeof(self.Query)=="function") 
			 win.AttachEvent("btn_Query","Clicked",self.Query); 

		 if(typeof(self.PostOpen)=="function") 
			 win.AttachEvent("btn_Clear","Clicked",self.PostOpen); 

		 if(typeof(self.Exit)=="function") 
			 win.AttachEvent("btn_Exit","Clicked",self.Exit); 

	 }

	 if(typeof(this.unbind)=="function") var baseUnBind=this.unbind; 
	 this.unbind=function() {
	 if(typeof(this.Release)=="function") this.Release(); 
	 if(typeof(baseUnBind)=="function") baseUnBind(); 

		 sle_ykje.Detach(); sle_ykje=null; 
		 sle_zdbm.Detach(); sle_zdbm=null; 
		 sle_zdr.Detach(); sle_zdr=null; 
		 sle_djbh.Detach(); sle_djbh=null; 
		 sle_kkje.Detach(); sle_kkje=null; 
		 dp_2.Detach(); dp_2=null; 
		 dp_1.Detach(); dp_1=null; 
		 dw_1.Detach(); dw_1=null; 
		 tb_1.Detach(); tb_1=null; 
		 requestor.Detach(); requestor=null; 

		 setTimeout(CollectGarbage, 100); 
	 }

	 //以上代码由设计器自动生成,请不要手工修改
     //ExtPB.Net JavaScript End  设计器查找标志,请不要删除或修改

var curW_OPEN_BMDA = new OpenWindowQueryBase();

var curW_OPEN_BMDA_NEW = new OpenWindowQueryNewBase();
var curW_OPEN_BMDA_URL = "OpenWindowQueryNewBase";
    
    
     var curYhbh = "";

     //#region PostOpen
     this.PostOpen = function () {
    curYhbh = requestor.GetParm("curYhbh");
    sle_kkje.SetText("");
    sle_djbh.SetText("");
    sle_ykje.SetText("");
    sle_zdr.SetText("");
    sle_zdbm.SetText("");
    var myDate = new Date();
    var nian = myDate.getFullYear().toString();
    var yue = myDate.getMonth();
    var ri = "01";
    var objDate = new Date(nian, yue, ri);
    dp_1.SetValue(objDate.getVarDate())
    dp_2.SetValue(UtcDateFormatToString(new Date().getVarDate()));
    }
    //#endregion

     //#region Function 呼出数据窗口的函数群 
    this.Zdbm = function (x, y, row, dwoName) {
    dwoName == "bmbh";
    curW_OPEN_BMDA_NEW.SetDataWindow(W_WeiKaiPiaoDanTongJi, "bmbh", "bmmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
    requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base." + curW_OPEN_BMDA_URL + "&treeDw=dw_da_bmda_fl_tree&listDw=dw_pub_list_bmda&treeRootLabel=部门分类&treeData=flbh&treeLabel=flmc&treeParentData=fflbh&treeLeave=islast&selectStyle=multiple&curQxlx=all"), curW_OPEN_BMDA_NEW, null);
    }

    this.Zdr = function (x, y, row, dwoName) {
    dwoName == "zdr";
    curW_OPEN_BMDA.SetDataWindow(W_WeiKaiPiaoDanTongJi, "zdr", "ygmc", "M", self)  // 这个用来给子窗口Set当前数据窗口
    requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowQueryBase&treeDw=dw_da_ryda_zw_tree&listDw=dw_pub_ygda_list1&treeRootLabel=职务分类&treeData=csbh&treeLabel=csmc&treeParentData=fcsbh&treeLeave=islast&selectStyle=multiple"), curW_OPEN_BMDA, null);
    }
    //#endregion

     //#region 选中后赋值
    this.SetSleValue = function (difBh, val) {
    if ("''" == val)
        val = "";

    if ("bmbh" == difBh)
        sle_zdbm.SetText(val);
    else if ("zdr" == difBh)
        sle_zdr.SetText(val);
    
    }

    //#endregion

     //#region Query
    this.Query = function () {
    var curKssj = UtcDateFormatToString(dp_1.GetValue());
    var curJssj = UtcDateFormatToString(dp_2.GetValue());
    var sqlWhere = " CONVERT(date,kdrq,120) between '" + curKssj + "' and '" + curJssj + "' ";

    if (sle_kkje.GetText().length > 0) {
        sqlWhere += " and (kkje <= CONVERT(float," + sle_kkje.GetText() + ")) ";
    }
    if (sle_ykje.GetText().length > 0) {
        sqlWhere += " and (ykje <= CONVERT(float," + sle_ykje.GetText() + ")) ";
    }
    if (sle_djbh.GetText().length > 0) {
        sqlWhere += " and (pzh like '%" + sle_djbh.GetText() + "%') ";
    }
    if (sle_zdbm.GetText().length > 0) {
        sqlWhere += " and (t1.bmbh in (" + self.DealWords(sle_zdbm.GetText()) + ")) ";
    }
    if (sle_zdr.GetText().length > 0) {
        sqlWhere += " and (t2.ygmc in (" + self.DealWords(sle_zdr.GetText()) + ")) ";
    }

    dw_1.RetrieveEx(sqlWhere);
    }
    //#endregion

     //#region Function DealWords
    this.DealWords = function (words) {

    var temChar = words.toString().charAt(0);
    if (!(temChar == "'"))
        words = "'" + words + "'";
    return words;
    }
    //#endregion

     this.Exit = function () {
        setTimeout("window.close()", 100);
    }
 }