///<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_ZhangHuYuETongJi() {

    var self = this;
    this.Instance = null;
    var requestor = new PBWindow();
    var cb_1 = new CommandButton(requestor);
    var cb_2 = new CommandButton(requestor);
    var sle_zh = new SingleLineEdit(requestor);
    var sle_bmbh = new SingleLineEdit(requestor);
    var dp_2 = new DatePicker(requestor);
    var dp_1 = new DatePicker(requestor);
    var dw_data_list = new DataWindow(requestor);
    var dw_list = new DataWindow(requestor);
    var dw_temp = new DataWindow(requestor);
    var tb_1 = new ToolStrip(requestor);

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

        if (requestor == null) requestor = new PBWindow();
        requestor.Attach(win);
        if (cb_1 == null) cb_1 = new CommandButton(requestor);
        cb_1.Attach(win.Control("cb_1"));
        if (cb_2 == null) cb_2 = new CommandButton(requestor);
        cb_2.Attach(win.Control("cb_2"));
        if (sle_zh == null) sle_zh = new SingleLineEdit(requestor);
        sle_zh.Attach(win.Control("sle_zh"));
        if (sle_bmbh == null) sle_bmbh = new SingleLineEdit(requestor);
        sle_bmbh.Attach(win.Control("sle_bmbh"));
        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_data_list == null) dw_data_list = new DataWindow(requestor);
        dw_data_list.Attach(win.Control("dw_data_list"));
        if (dw_list == null) dw_list = new DataWindow(requestor);
        dw_list.Attach(win.Control("dw_list"));
        if (dw_temp == null) dw_temp = new DataWindow(requestor);
        dw_temp.Attach(win.Control("dw_temp"));
        if (tb_1 == null) tb_1 = new ToolStrip(requestor);
        tb_1.Attach(win.Control("tb_1"));

        if (typeof (self.Changezhanghu) == "function")
            win.AttachEvent("cb_1", "Clicked", self.Changezhanghu);

        if (typeof (self.Changebmbh) == "function")
            win.AttachEvent("cb_2", "Clicked", self.Changebmbh);

        if (typeof (self.DoubleClicked) == "function")
            win.AttachEvent("dw_list", "DoubleClicked", self.DoubleClicked);

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

        if (typeof (self.Filter) == "function")
            win.AttachEvent("btn_Filter", "Clicked", self.Filter);

        if (typeof (self.Print) == "function")
            win.AttachEvent("btn_print", "Clicked", self.Print);

        if (typeof (self.Export) == "function")
            win.AttachEvent("btn_Export", "Clicked", self.Export);

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

    }

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

        cb_1.Detach(); cb_1 = null;
        cb_2.Detach(); cb_2 = null;
        sle_zh.Detach(); sle_zh = null;
        sle_bmbh.Detach(); sle_bmbh = null;
        dp_2.Detach(); dp_2 = null;
        dp_1.Detach(); dp_1 = null;
        dw_data_list.Detach(); dw_data_list = null;
        dw_list.Detach(); dw_list = null;
        dw_temp.Detach(); dw_temp = null;
        tb_1.Detach(); tb_1 = null;
        requestor.Detach(); requestor = null;

        setTimeout(CollectGarbage, 100);
    }

    //以上代码由设计器自动生成,请不要手工修改
    //ExtPB.Net JavaScript End  设计器查找标志,请不要删除或修改
    var webReq = new WebRequestor();
    webReq.SetWebServiceUrl("/Service/ServiceCaiWu.ashx");

    var webReq1 = new WebRequestor();
    webReq1.SetWebServiceUrl("/Service/ServiceCaiWu.ashx");

    var webReq2 = new WebRequestor();
    webReq2.SetWebServiceUrl("/Service/ServiceCaiWu.ashx");

    webReqsql = new WebRequestor();
    webReqsql.SetWebServiceUrl("/Service/ServiceForDwSyndax.ashx");

    var webReq_save = new WebRequestor();
    webReq_save.SetWebServiceUrl("/Service/ServiceWeShop.ashx");

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

    var curW_OPEN_SIMPLE_CHOSE = new OpenWindowSimpleChoseBase();

    var syntax = "";

    this.Query = function () {
        var curStartDate = UtcDateFormatToString(dp_1.GetValue());
        var curEndDate = UtcDateFormatToString(dp_2.GetValue());

        var curStartDateForInt = Number(curStartDate)
        var cyrEndDateForInt = Number(curEndDate)
        var sql = "";
        var curMonth = "";
        var curZhStr = "";
        //        webReq.Invoke("GetMonthStr", "beginDate=" + self.getPreMonth(UtcDateFormatToString(dp_1.GetValue())) + "&enddate=" + UtcDateFormatToString(new Date()));
        webReq.Invoke("GetMonthStr", "beginDate=" + self.getPreMonth(UtcDateFormatToString(dp_1.GetValue())) + "&enddate=" + UtcDateFormatToString(new Date()));
        if (webReq.StatusCode() == 200) {
            sql += " INSERT INTO dbo.cw_zhye_cxtj ( zhmc ,zh ,nian ,yue ,syye ,byfse ,byzje,byjse ,byye ,jzrq ,zt  )  SELECT a.zhmc ,a.zh ,a.nian ,a.yue ,a.syye ,a.byfse ,a.byzje ,abs(a.byjse),a.byye ,jzrq ,zt FROM   (";
            for (var i = 0; i < webReq.ResponseText().split(",").length; i++) {
                if (i != webReq.ResponseText().split(",").length - 1) {
                    sql += " SELECT   a.zhmc,a.zh,a.nian,a.yue,a.syye,a.byfse,a.byzje,a.byjse,a.byye,'" + webReq.ResponseText().split(",")[i + 1] + "' jzrq,'已月转' zt FROM ( ";
                }
                else {
                    sql += " SELECT   a.zhmc,a.zh,a.nian,a.yue,a.syye,a.byfse,a.byzje,a.byjse,a.byye,null jzrq,'未月转' zt FROM ( ";
                }

                sql += " SELECT  a.zhmc,a.zh,a.nian,a.yue,SUM(a.syye)-abs(SUM(a.byzje))+abs(SUM(a.byjse)) syye,SUM(a.byfse) byfse , SUM(a.byzje)    byzje,SUM(a.byjse)byjse ,SUM(byye) byye FROM( SELECT    zhmc ,zhbh zh ,YEAR('" + webReq.ResponseText().split(",")[i] + "') nian ,MONTH('" + webReq.ResponseText().split(",")[i] + "') yue ,dqye syye ,0 byfse ,0 byzje ,0 byjse ,dqye byye FROM  cw_xianjin_yinhang_zh  where 1 = 1 " + self.GetSqlWhere() + " GROUP BY zhbh ,zhmc,dqye";
                sql += " UNION  "
                sql += " SELECT  b.zhmc ,a.zh ,YEAR(MAX(a.kdsj)) nian ,MONTH('" + webReq.ResponseText().split(",")[i] + "') yue ,0 syye,0 byfse,0 byzje,0 byjse,0 byye FROM    cw_yhxjzh_lsz a LEFT JOIN cw_xianjin_yinhang_zh b ON a.zh = b.zhbh WHERE   MONTH(a.kdsj) = MONTH('" + webReq.ResponseText().split(",")[i] + "')-1 AND YEAR(a.kdsj) = YEAR('" + webReq.ResponseText().split(",")[i] + "')  " + self.GetSqlWhere().replace("zhbh", "zh") + " GROUP BY zh ,zhmc";
                sql += " UNION ALL ";
                sql += " SELECT  b.zhmc ,a.zh ,YEAR(MAX(a.kdsj)) nian ,MONTH(MAX(a.kdsj)) yue ,0 syye,SUM(ABS(je)) byfse,SUM(CASE WHEN je>0 THEN je ELSE 0 END)  byzje,SUM(CASE WHEN je<0 THEN je ELSE 0 END)  byjse,0 byye FROM    cw_yhxjzh_lsz a LEFT JOIN cw_xianjin_yinhang_zh b ON a.zh = b.zhbh WHERE   MONTH(a.kdsj) = MONTH('" + webReq.ResponseText().split(",")[i] + "')AND YEAR(a.kdsj) = YEAR('" + webReq.ResponseText().split(",")[i] + "')GROUP BY zh ,zhmc) a  where 1=1 " + self.GetSqlWhere().replace(/zhbh/g, "zh") + " GROUP BY zhmc,zh,nian,yue) a";
                sql += " UNION ALL ";
            }
            sql += " ) a ORDER BY zhmc,zh,nian";

            sql = sql.replace(/(.*)UNION ALL/, '$1 ');

            requestor.ClipBoard(sql)
            sql = sql.replace(/\+/g, "%2B");
            sql = sql.replace(/\&/g, "%26");
            sql = sql.replace(/\%/g, "%25");
            webReq1.Invoke("InsertSql_cw_zhye_cxtj", "curSql=" + sql);


            if (webReq1.StatusCode() == 200) {
                dw_data_list.Retrieve();

                webReq2.Invoke("GetZhStr", "");

                if (webReq2.StatusCode() == 200) {
                    curZhStr = webReq2.ResponseText();
                }
//                return;
                for (var i = 0; i < curZhStr.split(",").length; i++) {
                    dw_data_list.SetFilter("");
                    dw_data_list.Filter();
                    dw_data_list.SetFilter("zh='" + curZhStr.split(",")[i] + "'");
                    dw_data_list.Filter();
                    //alert(curZhStr.split(",")[i]);
                    for (var j = 2; j <= dw_data_list.RowCount(); j++) {
                        //                        if (dw_data_list.GetItemNumber(j, "yue") == 7) {
                        //                            alert([j, "syye", dw_data_list.GetItemNumber(j, "byye") + dw_data_list.GetItemNumber(j, "byjse") - dw_data_list.GetItemNumber(j, "byzje")])
                        //                        }
                        dw_data_list.SetItem(j, "byye", dw_data_list.GetItemNumber(j - 1, "syye"));
                        dw_data_list.SetItem(j, "syye", dw_data_list.GetItemNumber(j, "byye") + dw_data_list.GetItemNumber(j, "byjse") - dw_data_list.GetItemNumber(j, "byzje"));

                    }


                }

                dw_data_list.SetFilter("");
                dw_data_list.Filter();
                self.Save(dw_data_list);
                dw_list.RetrieveEx("CONVERT(VARCHAR(4),nian)+RIGHT('00'+CONVERT(VARCHAR(2),yue),2) IN(" + self.getDateArry(curStartDate, curEndDate) + ") AND zh IN (SELECT zh FROM dbo.cw_xianjin_yinhang_zh )")
                dw_list.SetSort("zh,nian,yue A")
                dw_list.Sort();

            } else {

                alert("error!");
            }
        }
                else {
                    requestor.MessageBox("提示111", webReq.ResponseText(), ICON.StopSign);
                }

    }

    this.GetSqlWhere = function () {
        var realSql = "";

        var curBm = sle_bmbh.GetText();
        var curZh = sle_zh.GetText();
        var curYhbh = requestor.GetParm("curYhbh")
        var realSql = " "

        if (curBm.length > 0) {
            var is_quotes = curBm.substring(0, 1);
            if (is_quotes == "'") {

                realSql += "and zhbh in (SELECT yhzh FROM dbo.cw_bmzhdzb WHERE bmbh IN (" + curBm + "))";
            }
        } else {
            realSql += "and zhbh in (SELECT yhzh FROM dbo.cw_bmzhdzb WHERE   bmbh IN (select bmbh  from da_qx_bmqxsz where yhbh = '" + curYhbh + "'and cwcx = '1') ) "
        }

        if (curZh.length > 0) {
            var is_quotes = curZh.substring(0, 1);
            if (is_quotes == "'") {
                realSql += " and zhbh in(" + curZh + ")";
            }
            else {
                var tempspkh = self.GetQuotes(curBm);
                realSql += " and zhbh  in(        SELECT yhzh FROM dbo.cw_bmzhdzb WHERE bmbh IN (" + tempspkh + "))";
            }
        } 
        return realSql;
    }
    //#region dw 宽度调整
    this.Set_Width_DW = function (colCount) {
        var ls_columntitle = "";
        for (var li_loop1 = 1; li_loop1 <= colCount; li_loop1++) {
            var ls_columnname = dw_list.Describe('#' + String(li_loop1) + '.name');

            switch (ls_columnname) {

                case "xh":
                    ls_columntitle = "序号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;

                case "zhmc":
                    ls_columntitle = "账户名称"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 1200 + "'");
                    break;

                case "zh":
                    ls_columntitle = "账户编号"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 1200 + "'");
                    break;

                case "nian":
                    ls_columntitle = "年"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;

                case "yue":
                    ls_columntitle = "月"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 200 + "'");
                    break;

                case "syye":
                    ls_columntitle = "上月余额"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".format='###########0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 600 + "'");
                    break;

                case "byfse":
                    ls_columntitle = "本月发生额"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".format='###########0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 600 + "'");
                    break;


                case "byzje":
                    ls_columntitle = "本月增加额"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".format='###########0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 600 + "'");
                    break;

                case "byye":
                    ls_columntitle = "本月余额"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".format='###########0.00' ")
                    dw_list.Modify(ls_columnname + ".width = '" + 600 + "'");
                    break;

                case "jzrq":
                    ls_columntitle = "结转日期"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;

                case "zt":
                    ls_columntitle = "状态"
                    dw_list.Modify(ls_columnname + "_t.text='" + ls_columntitle + "'");
                    dw_list.Modify(ls_columnname + ".width = '" + 400 + "'");
                    break;

                //  
            }
        }
        //        

        A8erp_Report.ReportDataWindowHeaderColor(dw_list);
        self.A8erp_Report_Style(dw_list);
        self.A8erp_Report_Header_Row_Height(dw_list, false);
        self.A8erp_Report_Detail_Row_Height(dw_list);
        dw_list.Modify(" create text(band=header alignment='2' text='序号' border='0' color='33554432' x='0' y='0' height='68' width='200' html.valueishtml='0'  name=hx_t visible='1'  font.face='Tahoma' font.height='-9' font.weight='400'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='536870912' background.transparency='0' background.gradient.color='8421504' background.gradient.transparency='0' background.gradient.angle='0' background.brushmode='0' background.gradient.repetition.mode='0' background.gradient.repetition.count='0' background.gradient.repetition.length='100' background.gradient.focus='0' background.gradient.scale='100' background.gradient.spread='100' tooltip.backcolor='134217752' tooltip.delay.initial='0' tooltip.delay.visible='32000' tooltip.enabled='0' tooltip.hasclosebutton='0' tooltip.icon='0' tooltip.isbubble='0' tooltip.maxwidth='0' tooltip.textcolor='134217751' tooltip.transparency='0' transparency='0' )")
        self.SetSummary();
    }
    //#endregion 

    //#region 定义title高度
    this.A8erp_Report_Header_Row_Height = function (curDw_List) {
        curDw_List.Modify("datawindow.header.height='86'");
    }
    //#endregion

    //#region 定义Detail高度
    this.A8erp_Report_Detail_Row_Height = function (curDw_List) {
        curDw_List.Modify("datawindow.detail.height='86'");
    }
    //#endregion

    //#region 定义单据样式

    this.A8erp_Report_Style = function (curDw_List) {//67108864    15780518
        curDw_List.Modify("datawindow.detail.color='67108864' datawindow.detail.gradient.color='16777215' datawindow.detail.brushmode='1' ")
    }


    //#region 合计列
    this.SetSummary = function () {
        var ls_bqkcx = "";
        var ls_lswidth = "";
        var ls_syntax = '';
        var ls_bqkcwidth = "";
        var ls_bqrkwidth = "";

        var ls_xhx = dw_list.Describe("xh.x");
        var ls_xhwidth = dw_list.Describe("xh.width");

        var ls_byfsex = dw_list.Describe("byfse.x");
        var ls_byfsewidth = dw_list.Describe("byfse.width")

        var ls_syyex = dw_list.Describe("syye.x");
        var ls_syyewidth = dw_list.Describe("syye.width")

        var ls_byzjex = dw_list.Describe("byzje.x");
        var ls_byzjewidth = dw_list.Describe("byzje.width")

        var ls_byyex = dw_list.Describe("byye.x");
        var ls_byyewidth = dw_list.Describe("byye.width")


        ls_syntax = dw_list.Modify("DataWindow.Footer.Height=90");
        ls_syntax = ls_syntax + " create text(band=footer alignment='1'  text='合计:' border='0' color='128' x='" + ls_xhx + "'  y='8' height='53' width='" + ls_xhwidth + "' html.valueishtml='0'   name=hj visible='1'  font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='2' background.color='1073741824')"
        ls_syntax = ls_syntax + " create compute(band=footer alignment='1' expression='sum(syye  for all)' border='0' color='128' x='" + ls_syyex + "' y='8' height='52' width='" + ls_syyewidth + "' name=sum_lsjze  visible='1' font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='1' background.color='536870912' format='0.00')"
        ls_syntax = ls_syntax + " create compute(band=footer alignment='1' expression='sum(byfse  for all)' border='0' color='128' x='" + ls_byfsex + "' y='8' height='52' width='" + ls_byfsewidth + "' name=sum_jjze  visible='1' font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='1' background.color='536870912'  format='0.00')"
        ls_syntax = ls_syntax + " create compute(band=footer alignment='1' expression='sum(byzje  for all)' border='0' color='128' x='" + ls_byzjex + "' y='8' height='52' width='" + ls_byzjewidth + "' name=sum_zjsl  visible='1' font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='1' background.color='536870912'  format='#####')"
        ls_syntax = ls_syntax + " create compute(band=footer alignment='1' expression='sum(byye  for all)' border='0' color='128' x='" + ls_byyex + "' y='8' height='52' width='" + ls_byyewidth + "' name=sum_dpjze  visible='1' font.face='Arial' font.height='-9' font.weight='700'  font.family='2' font.pitch='2' font.charset='0' background.mode='1' background.color='536870912'  format='0.00')"

        dw_list.Modify(ls_syntax);
    }
    //#endregion 

    //#region Function 呼出数据窗口的函数群 

    this.Changebmbh = function (x, y, row, dwoName) {
        dwoName == "bmbh";
        curW_OPEN_BMDA_NEW.SetDataWindow(W_ZhangHuYuETongJi, "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.Changezhanghu = function (x, y, row, dwoName) {
        dwoName == "zhbh";
        curW_OPEN_SIMPLE_CHOSE.SetDataWindow(W_ZhangHuYuETongJi, "zhbh", "zhmc", "M", self)   // 这个用来给子窗口Set当前数据窗口
        requestor.Open(encodeURI("/Service/LoadWindow.ashx?WinName=A8ERP.DangAn.Base.OpenWindowSimpleChoseBase&listDw=dw_pub_yinhangzhanghao_list&selectStyle=multiple"), curW_OPEN_SIMPLE_CHOSE, null);
    }
    //#endregion


    this.getPreMonth = function (date) {
        var arr = date.split('-');
        var year = arr[0]; //获取当前日期的年份
        var month = arr[1]; //获取当前日期的月份
        var day = arr[2]; //获取当前日期的日
        var days = new Date(year, month, 0);
        days = days.getDate(); //获取当前日期中月的天数
        var year2 = year;
        var month2 = parseInt(month,10) - 1;
        if (month2 == 0) {
            year2 = parseInt(year2) - 1;
            month2 = 12;
        }
        var day2 = day;
        var days2 = new Date(year2, month2, 0);
        days2 = days2.getDate();
        if (day2 > days2) {
            day2 = days2;
        }
        if (month2 < 10) {
            month2 = '0' + month2;
        }
        var t2 = year2 + '-' + month2 + '-' + day2;
        return t2;
    }


    this.Save = function (aaa) {
        var dwObject = aaa.GetDataObject();
        var dwChanges = aaa.GetChanges();
        if (dwChanges == "") {
            //requestor.MessageBox("提示", "没有数据需要保存！", ICON.Information);
            return;
        }
        webReq_save.Invoke("ykbCsDwSaveTy", "dwObject=" + dwObject + "&dwChanges=" + dwChanges);
        if (webReq_save.StatusCode() == 200) {
        } else {
            requestor.MessageBox("提示", webReq_save.ResponseText(), ICON.StopSign);
        }
    }
    this.getDateArry = function (d1, d2) {

        var dateArry = new Array();
        var s1 = d1.split("-");
        var s2 = d2.split("-");
        var mCount = 0;
        var curDateStr = "'";
        if (parseInt(s1[0], 10) < parseInt(s2[0], 10)) {
            mCount = (parseInt(s2[0], 10) - parseInt(s1[0], 10)) * 12 + parseInt(s2[1], 10) - parseInt(s1[1], 10) + 1;
        } else {
            mCount = parseInt(s2[1], 10) - parseInt(s1[1], 10) + 1;
        }
        if (mCount > 0) {
            var startM = parseInt(s1[1],10);
            var startY = parseInt(s1[0],10);
            for (var i = 0; i < mCount; i++) {
                if (startM < 12) {
                    dateArry[i] = startY + "-" + (startM > 9 ? startM : "0" + startM);
                    startM += 1;
                } else {
                    dateArry[i] = startY + "-" + (startM > 9 ? startM : "0" + startM);
                    startM = 1;
                    startY += 1;
                }
            }
        }
        for (var i = 0; i < dateArry.length; i++) {
            curDateStr += dateArry[i].replace("-", "") + "','"
        }
        return curDateStr.substring(0, curDateStr.length-2);
    }

    //#region  赋值
    this.SetSleValue = function (difBh, val) {

        if ("''" == val)
            val = "";
        if ("bmbh" == difBh)
            sle_bmbh.SetText(val);
        else if ("zhbh" == difBh)
            sle_zh.SetText(val);

    }

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

    //#region 双击反调查询账户明细
    this.DoubleClicked = function (x, y, row, dwcName) {
        if (row > 0) {
            var curZhbh = dw_list.GetItemString(row, "zh");
            var curStartDate = UtcDateFormatToString(dp_1.GetValue());
            var curYear = new Date(dp_2.GetValue()).getFullYear();
            var curMonth = new Date(dp_2.GetValue()).getMonth();
            curStartDate = curStartDate.substring(0, curStartDate.length - 2) + "01";
            var m = curMonth + 1;
            var curEndDate = curYear.toString() + "-" + m.toString() + "-" + new Date(curYear, m, 0).getDate().toString();
            if (curZhbh.length > 0) {
                var ts_1 = window.external.Control("ts_1");
                ts_1.CloseItem("SJ548");
                ts_1.Open("SJ548", "现金银行流水统计", '', encodeURI("/Service/OpenSheet.aspx?FunID=SJ548&curDate=" + new Date().toLocaleTimeString() + "&Reload=Y&curFormPzh=" + curZhbh + "&curBeginDate=" + curStartDate + "&curEndDate=" + curEndDate), true);

            }
        }
    }

    //#endregion
}