using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using TXSoft.Common;
using Sybase.DataWindow;
using TXSoft.Common;
using TXSoft.ExtPB;
using TXSoft.DataStore;
using A8ERP.Common;
using A8erp.Cache;
using Newtonsoft.Json;


namespace A8ERP.CaiGou.CaiGouDingDanTongJiFenXi
{
    public partial class W_HZTJ
    {
        private string cdbh = "";
        private string bbfl = "";
        private string bbmc = "";
        private string yhbh = "";
        private string pzh = "";
        public W_HZTJ()
        {
          
        }
        public override void OnLoad()
        {
           
            base.OnLoad();
            DBHelp dbhelp = new DBHelp();
            dbhelp.Open();
            if (this.Page != null)
            {
                this.Page.ClientScript.RegisterClientScriptInclude("W_Base_Report_Open_Mx", "/Base/W_Base_Report_Open_Mx.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("W_Edit", "/DangAn/Base/OpenWindowDoubleRowsChooseBase.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("OpenWindowQueryBase", "/DangAn/Base/OpenWindowQueryBase.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("OpenWindowSimpleChoseBase", "/DangAn/Base/OpenWindowSimpleChoseBase.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("W_Base_Report_Open_Mx_Ex", "/Base/W_Base_Report_Open_Mx_Ex.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("W_Base_SaveOP", "/KuCun/TongJiFenXi/Base/W_Base_SaveOP.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("W_Base_BB_List", "/KuCun/TongJiFenXi/Base/W_Base_BB_List.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("W_KC_PIC", "/KuCun/TongJiFenXi/W_KC_PIC.win.js?JSV=" + AppService.GetJSVesion());
                this.Page.ClientScript.RegisterClientScriptInclude("W_NFCheck", "/KuCun/TongJiFenXi/W_NFCheck.win.js?JSV=" + AppService.GetJSVesion());


            }
            //User user = new User();
            //user = (User)Session["User"];
            string curYhbh = AppService.GetUserID();
            string str_jgqx = A8ERP.DBHelp.GetJGTXByBMAndYH(this.FunctionID, curYhbh);
            this.SetParm("curjgqx", str_jgqx);
            this.SetParm("curYhbh", curYhbh);
            this.SetParm("curYhmc", AppService.GetUserName());
            string ywflag = "";
            
            cbx_rkfs.Visible = false;
            if (this.FunctionID.Equals("SJ099"))
            {
                ywflag = "CG";
                base.st_title.Text = "采购订单汇总统计";
                st_10.Text = "订单方式";
                cbx_fs.Text = "订单方式";

                this.cbx_fjsx1.Visible = true;
                this.cbx_fjsx2.Visible = true;
                this.cbx_fjsx3.Visible = true;
                this.cbx_fjsx4.Visible = true;
           

               string spfjsxJson=AppService. GetXiTongCanShuFroCsfl("spsx");
               System.Diagnostics.Debug.WriteLine(spfjsxJson);
                DataTable dtSpfjsx = JsonConvert.DeserializeObject<DataTable>(spfjsxJson);
                for (int i = 0; i < dtSpfjsx.Rows.Count; i++)
                {
                    if (dtSpfjsx.Rows[i]["csbh"].ToString().Equals("01"))
                    {
                        this.cbx_fjsx1.Text = dtSpfjsx.Rows[i]["value"].ToString();
                        if (dtSpfjsx.Rows[i]["qybz"].ToString().Equals("1"))
                        {
                            this.cbx_fjsx1.Enabled = true;
                        }
                        else
                        {
                            this.cbx_fjsx1.Enabled = false;
                        }

                    }
                    else if (dtSpfjsx.Rows[i]["csbh"].ToString().Equals("02"))
                    {
                        this.cbx_fjsx2.Text = dtSpfjsx.Rows[i]["value"].ToString();
                        if (dtSpfjsx.Rows[i]["qybz"].ToString().Equals("1"))
                        {
                            this.cbx_fjsx2.Enabled = true;
                        }
                        else
                        {
                            this.cbx_fjsx2.Enabled = false;
                        }

                    }
                    else if (dtSpfjsx.Rows[i]["csbh"].ToString().Equals("03"))
                    {
                        this.cbx_fjsx3.Text = dtSpfjsx.Rows[i]["value"].ToString();
                        if (dtSpfjsx.Rows[i]["qybz"].ToString().Equals("1"))
                        {
                            this.cbx_fjsx3.Enabled = true;
                        }
                        else
                        {
                            this.cbx_fjsx3.Enabled = false;
                        }

                    }
                    else if (dtSpfjsx.Rows[i]["csbh"].ToString().Equals("04"))
                    {
                        this.cbx_fjsx4.Text = dtSpfjsx.Rows[i]["value"].ToString();
                        if (dtSpfjsx.Rows[i]["qybz"].ToString().Equals("1"))
                        {
                            this.cbx_fjsx4.Enabled = true;
                        }
                        else
                        {
                            this.cbx_fjsx4.Enabled = false;
                        }
                    }
                }
            }
            else  if (this.FunctionID.Equals("SJ316"))
            {
                ywflag = "CR";
                base.st_title.Text = "采购入库单汇总统计";
                st_10.Text = "采购方式";
                cbx_fs.Text = "采购方式";
                cbx_rkfs.Visible = true;
            }

            
            //SJ321
            else if (this.FunctionID.Equals("SJ321"))
            {
                ywflag = "CS";
                base.st_title.Text = "采购退货申请单汇总统计";
                st_10.Text = "订单方式";
                cbx_fs.Text = "订单方式";
            }
            else if (this.FunctionID.Equals("SJ323"))
            {
                ywflag = "CT";
                base.st_title.Text = "采购退货汇总统计";
                st_10.Text = "采购方式";
                cbx_fs.Text = "采购方式";
                cbx_rkfs.Visible = true;
            }
            else if (this.FunctionID.Equals("SJ619"))
            {
                ywflag = "CZ";
                base.st_title.Text = "采购通知单汇总统计";
                st_10.Text = "采购方式";
                cbx_fs.Text = "采购方式";
            }
            else if (this.FunctionID.Equals("SJ620"))
            {
                ywflag = "CD";
                base.st_title.Text = "采购退货通知单汇总统计";
                st_10.Text = "采购方式";
                cbx_fs.Text = "采购方式";
            }
            this.SetParm("ywflag", ywflag);
            dw_temp.AllowCreate = true;
            dw_temp.AllowRetrieve = true;
            dw_temp.Visible = false;
            dw_list.AllowCreate = true;
            dw_list.AllowRetrieve = true;
            //curCdbh
            //this.SetParm("ywflag", ywflag);
            this.SetParm("curCdbh", this.FunctionID);
            this.sc_1.Panel2.Controls.SetChildIndex(this.dw_format,0);

            DataRow[] dt = CacheHelp.GetDataTable("REPORT_FORMAT").Select("cdbh ='" + this.FunctionID + "'  AND qdid ='" + curYhbh + "'");
            if (dt != null)
            {
                if (dt.Length > 0)
                {
                    pzh = dt[0][0].ToString();
                    bbmc = dt[0][1].ToString();
                    bbfl = dt[0][2].ToString();

                }
            }

            this.SetParm("pzh", pzh);
            this.SetParm("bbmc", bbmc);
            this.SetParm("bbfl", bbfl);


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

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

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

            #endregion


            //string sjcd = string.Empty;
            //sjcd = AppService.GetSjbhRight();
            //this.SetParm("sjcd", sjcd);
            this.IsRegisterScriptFile = false;

            ddlb_sex.Width = 80;
     
         
           
        }
    }   
}
