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.XianJinPinZheng
{
    public partial class W_XJZhiChuPZ
    {
        public W_XJZhiChuPZ()
        {

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

            A8ERP.Common.DWServiceHelp.AddReportService(dw_hz);
           

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

            //dw_hz.Retrieve(yhbh);

            DataWindowChild dwc = dw_mx_top.GetChild("bmbh");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("%",yhbh,"cw");

            dwc = dw_mx_top.GetChild("gysbh");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("%", yhbh);

            //dwc = dw_hz.GetChild("dqzt");
            //dwc.SetTransaction(this.AdoTransaction);
            //dwc.Retrieve(this.FunctionID);
            dwc = dw_mx_top.GetChild("yljh");
            dwc.SetTransaction(this.AdoTransaction);

            dwc = dw_mx.GetChild("sfkm");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("002");

            dwc = dw_mx.GetChild("zczh");
            dwc.SetTransaction(this.AdoTransaction);

            dwc = dw_mx_top.GetChild("zdr");
            dwc.SetTransaction(this.AdoTransaction);
            dwc.Retrieve("%", yhbh,"cw");

            #region  处理权限
            dw_mkfhjb.DataStore.DataWindowObject = "dw_da_qx_fhjb_by_cdbh";
            dw_mkfhjb.SetTransaction(this.AdoTransaction);
            dw_mkfhjb.Retrieve(this.FunctionID);
            #endregion

            for (int i = 1; i <= dw_mkfhjb.RowCount; i++)
            {
                ddlb_1.Items.Add(dw_mkfhjb.GetItemString(i, "fhmc"));
            }
            ddlb_1.Items.Add("未记账");
            ddlb_1.Items.Add("已记账");
            ddlb_1.Items.Add("全部");
            ddlb_1.Text = "未记账";

            //--------------------打印----------------------------
            this.SetParm("curFunctionId", this.FunctionID);
            dw_print.AllowCreate = true;
            dw_print.AllowRetrieve = true;
            dw_print.AllowSetFullState = true;
            dw_proxy.AllowCreate = true;
            dw_proxy.AllowRetrieve = true;
            dw_proxy.AllowSetFullState = true;
            this.SetParm("curUserId", AppService.GetUserID().ToString());
            //--------------------打印结束-------------------------

            //数据窗口关联服务
            //LinkageService service = (LinkageService)dw_mx_top.Services.Add(ServiceName.Linkage);
            //service.SetMaster(dw_hz.DataStore);
            //service.Add("pzh", "pzh");

            //service.LinkageStyle = LinkageStyle.Retrieve;

            //service = (LinkageService)dw_mx.Services.Add(ServiceName.Linkage);
            //service.SetMaster(dw_mx_top.DataStore);
            //service.Add("pzh", "pzh");

            //service.LinkageStyle = LinkageStyle.Retrieve;

            #region 每页显示条数&查询天数
            string curDayAndPageSize = DBHelp.GetDayAndPageSize(this.FunctionID, "CW");

            string curPageSize = curDayAndPageSize.Split('#')[1];
            this.dw_1.PageSize = Convert.ToInt32(curPageSize);

            // 查询天数
            string seldays = curDayAndPageSize.Split('#')[0];
            this.SetParm("seldays", seldays.ToString());

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

            dt = db.QueryRDataTable(" select qybz from da_qj_csb where csfl='cw_jqdbm' and csbh='gys_jqdbm' ");
            if (dt.Rows[0]["qybz"].ToString() == "1")
            {
                dw_mx_top.Modify("gyssdye.visible='0'  gysbdye.visible='0' ");
                dw_mx_top.Modify("sdye.visible='1' bdye.visible='1' ");
            }
            else
            {

                dw_mx_top.Modify("sdye.visible='0' bdye.visible='0' ");
                dw_mx_top.Modify("gyssdye.visible='1' gysbdye.visible='1'  ");
            }
            this.SetParm("curJqdbm", dt.Rows[0]["qybz"].ToString());
            if (this.Page != null)
            {
                this.Page.ClientScript.RegisterClientScriptInclude("W_XJZhiChuPZ", "/CaiWu/XianJinPinZheng/W_XJZhiChuPZ.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("OpenWindowQueryBase", "/DangAn/Base/OpenWindowQueryBase.win.js?JSV=" + AppService.GetJSVesion());
            }
            this.IsRegisterScriptFile = false;
        }
    }
}
