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;

using System.Linq;
using System.Web.SessionState;


namespace A8ERP.CaiGou.MoRenCaiGouBuMenSheZhi
{
    public partial class W_MoRenCaiGouBuMenSheZhi
    {
        public W_MoRenCaiGouBuMenSheZhi()
        {

        }
        public override void OnLoad()
        {
            base.OnLoad();
            string FunID = this.FunctionID;

            DataTable dt = new DataTable();
            DBHelp dbHelp = new DBHelp();
            StringBuilder sqlstr = new StringBuilder();
            //检索
            sqlstr.Remove(0, sqlstr.Length);
            sqlstr.Append(" SELECT  A.sjbh,A.sjmc,A.ywdjbh,B.bmbh,b.ywbh,b.yhbh  FROM DA_XT_SJCD AS A  LEFT JOIN YW_MRBM AS B ON A.YWDJBH =B.YWBH  WHERE   A.SJBH ='" + FunID + "'");
            try
            {
                dt = dbHelp.QueryRDataTable(sqlstr.ToString());
                if (dt.Rows.Count >= 1)
                {
                    this.Title = dt.Rows[0]["sjmc"].ToString();
                    this.dw_mrbm.DataWindowObject = "dw_yw_cg_mrbm";
                    if (this.dw_mrbm.Retrieve(dt.Rows[0]["ywdjbh"].ToString(), AppService.GetUserID()) <= 0)
                    {
                        int row = dw_mrbm.InsertRow(0);
                        dw_mrbm.SetItemString(row, "ywbh", dt.Rows[0]["ywdjbh"].ToString());
                        dw_mrbm.SetItemString(row, "yhbh", AppService.GetUserID());
                        //dw_mrbm.SetItemString(row, "bmbh", " ");
                    }
                }
              
            }
            catch //(Exception ex)
            {

            }
            finally
            {
                dbHelp.Close();
                dbHelp = null;
            }

            string curQxlx = "all";
            if (this.Title.IndexOf("连锁") >= 0)
            {
                curQxlx = "ls";
            }
            if (this.Title.IndexOf("渠道") >= 0)
            {
                curQxlx = "qd";
            }
            else if (this.Title.IndexOf("批发") >= 0)
            {
                curQxlx = "pf";
            }
            else if (this.Title.IndexOf("调拨") >= 0)
            {
                curQxlx = "db";
                dw_mrbm.Modify("bmbh_t.Text='调出部门编号'");
            }
            else if (this.Title.IndexOf("采购") >= 0)
            {
                curQxlx = "cg";

            }
            this.SetParm("curQxlx", curQxlx);
            //this.SetParm("curyhbh", AppService.GetUserID());
            if (this.Page != null)
            {
                this.Page.ClientScript.RegisterClientScriptInclude("W_MoRenCaiGouBuMenSheZhi", "/CaiGou/MoRenCaiGouBuMenSheZhi/W_MoRenCaiGouBuMenSheZhi.win.js?JSV=" + AppService.GetJSVesion());

                this.Page.ClientScript.RegisterClientScriptInclude("OpenWindowQueryBase", "/DangAn/Base/OpenWindowQueryBase.win.js?JSV=" + AppService.GetJSVesion());

            }
            this.IsRegisterScriptFile = false;
        }
    }


}
