using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Data;
using System.Data.SqlClient;

using Sybase.DataWindow;
using TXSoft.Common;
using TXSoft.ExtPB;
using TXSoft.DataStore;


namespace A8ERP.CaiWu.FaPiaoGuanLi
{
    public partial class W_KaiPiaoDanTongJi
    {
        public W_KaiPiaoDanTongJi()
        {

        }
        public override void OnLoad()
        {
            base.OnLoad();

            ddlb_kplx.Items.Add("全部");
            ddlb_pjzl.Items.Add("全部");
            ddlb_wczt.Items.Add("全部");

            DataTable dt = null;
            DBHelp db = new DBHelp();

            dt = db.QueryRDataTable(" select csbh,csmc from da_qj_csb where csfl='cw_pjlx' ");
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    ddlb_kplx.Items.Add("[" + dt.Rows[i]["csbh"].ToString() + "]" + dt.Rows[i]["csmc"].ToString());
                }
            }
           
            dt = db.QueryRDataTable(" select csbh,csmc from da_qj_csb where csfl='cw_pjzl' ");
            int count1 = dt.Rows.Count;
            if (count1 > 0)
            {
                for (int i = 0; i < count1; i++)
                {
                    ddlb_pjzl.Items.Add("[" + dt.Rows[i]["csbh"].ToString() + "]" + dt.Rows[i]["csmc"].ToString());
                }
            }

            dt = db.QueryRDataTable(" select fhjb,fhmc from da_qx_mokuai_fuhejibie where cdbh='" + this.FunctionID + "'");
            int count2 = dt.Rows.Count;
            if (count2 > 0)
            {
                for (int i = 0; i < count2; i++)
                {
                    ddlb_wczt.Items.Add(dt.Rows[i]["fhmc"].ToString());
                }
            }

            db.Close();
            dt.Dispose();

            #region  处理权限
            dw_mkfhjb.Retrieve(this.FunctionID);  // 审核级别 
            #endregion

            dw_hz.DataStore.DataWindowObject = "dw_fp_hz_list";
            dw_hz.SetTransaction(this.AdoTransaction);
            dw_mx_top.DataStore.DataWindowObject = "da_fp_hzxz_top";
            dw_mx_top.SetTransaction(this.AdoTransaction);
            dw_mx.DataStore.DataWindowObject = "da_fp_hz_mx";
            dw_mx.SetTransaction(this.AdoTransaction);
            
            //数据窗口关联服务
            LinkageService service = (LinkageService)dw_mx_top.Services.Add(ServiceName.Linkage);
            service.SetMaster(dw_hz.DataStore);
            service.Add("fplsh", "fplsh");
            service.LinkageStyle = LinkageStyle.Retrieve;

            service = (LinkageService)dw_mx.Services.Add(ServiceName.Linkage);
            service.SetMaster(dw_mx_top.DataStore);
            service.Add("fplsh", "fplsh");
            service.LinkageStyle = LinkageStyle.Retrieve;

            A8ERP.Common.DWServiceHelp.AddReportService(dw_hz);

            string yhbh = A8ERP.AppService.GetUserID();
            this.SetParm("curYhbh",yhbh);

            DataWindowChild dwc = dw_mx_top.GetChild("kplx");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("cw_pjlx");
            dwc = dw_mx_top.GetChild("pjzl");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("cw_pjzl");
            dwc = dw_mx_top.GetChild("kpr");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("%");
            dwc = dw_mx_top.GetChild("jbr");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("%");
            dwc = dw_mx_top.GetChild("bmbh");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("%", yhbh, "all");
            dwc = dw_mx_top.GetChild("wldw");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("00", "%",yhbh);
            dwc = dw_mx.GetChild("djlx");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("fp_djlb");

            if (this.Page != null)
            {
                this.Page.ClientScript.RegisterClientScriptInclude("OpenWindowQueryBase", "/DangAn/Base/OpenWindowQueryBase.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("W_KaiPiaoDanTongJi", "/CaiWu/FaPiaoGuanLi/W_KaiPiaoDanTongJi.win.js?JSV=" + AppService.GetJSVesion());
            }

            this.IsRegisterScriptFile = false;
        }
    }
}
