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.CaiWuTongJiFenXi
{
    public partial class W_YW_LIST
    {
        string curpzh = string.Empty;
        string ywflag = string.Empty;
        string curJqdbm = string.Empty;
        public W_YW_LIST()
        {

        }
        public override void OnLoad()
        {
            base.OnLoad();
            string yhbh = A8ERP.AppService.GetUserID();
            DataWindowChild dwc;
            if (Request["curpzh"] != null)
            {
                curpzh = Request["curpzh"].ToString();
                ywflag = curpzh.Substring(0, 2);
                curJqdbm = Request["curJqdbm"].ToString();
                //批发
                if ("PF".Equals(ywflag) || "PT".Equals(ywflag))
                {

                    dw_1.DataWindowObject = "dw_yw_pf_rkdmx_top";
                    dw_2.DataWindowObject = "dw_yw_pf_rkdmx_list";

                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);
                    dwc = dw_1.GetChild("cgy");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", yhbh);
                    dwc = dw_1.GetChild("fklx");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("FKLX");
                    dwc = dw_1.GetChild("fhlx");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("fhlx");
                    dwc = dw_1.GetChild("cgfs");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("CG_CGFS");
                    dwc = dw_1.GetChild("skfs");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("skfs");
                    sc_1.SplitterDistance = 150;
                    if ("PF".Equals(ywflag))
                    {
                        dw_1.Modify("title_t.Text='批发出库单'");
                    }
                    else
                    {
                        dw_1.Modify("title_t.Text='批发退货单'");
                    }
                    if (curJqdbm == "1")
                    {
                        dw_1.Modify("khsdjy.visible='0'  khljqk.visible='0' ");
                        dw_1.Modify("sdjy.visible='1'  ljqk.visible='1' ");
                    }
                    else
                    {
                        dw_1.Modify("sdjy.visible='0' ljqk.visible='0' ");
                        dw_1.Modify("khsdjy.visible='1' khljqk.visible='1' ");
                    }
                    Add35CmCol(true);
                }
                //连锁
                else if ("LC".Equals(ywflag) || "LT".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "dw_yw_ls_rkdmx_top";
                    dw_2.DataWindowObject = "dw_yw_ls_rkdmx_list";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);
                    Add35CmCol(true);
                }
                //调拨
                else if ("DC".Equals(ywflag) || "DT".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "dw_yw_db_rkdmx_top";
                    dw_2.DataWindowObject = "dw_yw_db_rkdmx_list";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);
                    Add35CmCol(true);
                }
                //渠道
                else if ("QC".Equals(ywflag) || "QT".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "dw_yw_qd_rkdmx_top";
                    dw_2.DataWindowObject = "dw_yw_qd_rkdmx_list";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);
                    Add35CmCol(true);
                }
                //收入凭证
                else if ("SR".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "da_cw_xjsr_mx_top";
                    dw_2.DataWindowObject = "da_cw_xjsr_mx_new";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);
                    dwc = dw_2.GetChild("km");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("001");
                    dwc = dw_1.GetChild("zdr");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", yhbh, "cw");
                    sc_1.SplitterDistance = 150;
                    if (curJqdbm == "1")
                    {
                        dw_1.Modify("khsdye.visible='0'  khbdye.visible='0' ");
                        dw_1.Modify("sdye.visible='1'  bdye.visible='1' ");
                    }
                    else
                    {
                        dw_1.Modify("sdye.visible='0' bdye.visible='0' ");
                        dw_1.Modify("khsdye.visible='1' khbdye.visible='1' ");
                    }
                }
                //支出凭证
                else if ("ZC".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "da_cw_xjzc_top";
                    dw_2.DataWindowObject = "da_cw_xjzc_mx_new";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);

                    dwc = dw_1.GetChild("bmbh");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", A8ERP.AppService.GetUserID(), "cw");

                    dwc = dw_2.GetChild("km");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("001");
                    dwc = dw_1.GetChild("zdr");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", yhbh, "cw");
                    //dwc1 = dw_2.GetChild("zczh");
                    //dwc1.SetTransaction(this.AdoTransaction);

                    sc_1.SplitterDistance = 150;
                    if (curJqdbm == "1")
                    {
                        dw_1.Modify("gyssdye.visible='0'  gysbdye.visible='0' ");
                        dw_1.Modify("sdye.visible='1' bdye.visible='1' ");
                    }
                    else
                    {
                        dw_1.Modify("sdye.visible='0' bdye.visible='0' ");
                        dw_1.Modify("gyssdye.visible='1' gysbdye.visible='1'  ");
                    }
                }
                else if ("CR".Equals(ywflag) || "CT".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "dw_yw_cg_rkdmx_top";
                    dw_2.DataWindowObject = "dw_yw_cg_rkdmx_list";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);
                    dwc = dw_1.GetChild("gysbh");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", A8ERP.AppService.GetUserID());

                    dwc = dw_1.GetChild("bmbh");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", A8ERP.AppService.GetUserID(), "cg");

                    dwc = dw_1.GetChild("cgry");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", yhbh,"cg");

                    dwc = dw_1.GetChild("cgfs");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("CG_CGFS");

                    if ("CR".Equals(ywflag))
                    {
                        dw_1.Modify("title_t.Text='采购入库单'");
                    }
                    else
                    {
                        dw_1.Modify("title_t.Text='采购退货单'");
                    }
                    Add35CmCol(true);
                }
                else if ("XS".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "da_cw_xhskd_top";
                    dw_2.DataWindowObject = "da_cw_xhskd_mx";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh, curJqdbm);
                    dwc = dw_1.GetChild("skfs");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("skfs");
                    dwc = dw_1.GetChild("ywy");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", yhbh,"HY");
                }
                else if ("XF".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "da_cw_xhfyd_top";
                    dw_2.DataWindowObject = "da_cw_xhfyd_mx_new";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);
                    //if (curJqdbm == "1")
                    //{
                    //    dw_2.SetItemDouble(1, "sdye", dw_2.GetItemDouble(1, "bmsdjy"));
                    //    dw_2.SetItemDouble(1, "bdye", dw_2.GetItemDouble(1, "bmljye"));
                    //}
                    //else
                    //{
                    //    dw_2.SetItemDouble(1, "sdye", dw_2.GetItemDouble(1, "sdjy"));
                    //    dw_2.SetItemDouble(1, "bdye", dw_2.GetItemDouble(1, "ljye"));
                    //}
                    dwc = dw_1.GetChild("fkfs");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("skfs");

                    dwc = dw_1.GetChild("zdr");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", yhbh,"cw");
                }
                else if ("JF".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "da_cw_jhfyd_top";
                    dw_2.DataWindowObject = "da_cw_jhfyd_mx_new";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh);
                    dwc = dw_1.GetChild("fkfs");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("skfs");

                    dwc = dw_1.GetChild("zdr");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", yhbh,"cw");
                    //if (curJqdbm == "1")
                    //{
                    //    dw_2.SetItemDouble(1, "sdye", dw_2.GetItemDouble(1, "bmsdjy"));
                    //    dw_2.SetItemDouble(1, "bdye", dw_2.GetItemDouble(1, "bmljye"));
                    //}
                    //else
                    //{
                    //    dw_2.SetItemDouble(1, "sdye", dw_2.GetItemDouble(1, "sdjy"));
                    //    dw_2.SetItemDouble(1, "bdye", dw_2.GetItemDouble(1, "ljye"));
                    //}
                }
                else if ("FK".Equals(ywflag))
                {
                    dw_1.DataWindowObject = "da_cw_jhfkd_top";
                    dw_2.DataWindowObject = "da_cw_jhfkd_mx";
                    dw_1.Retrieve(curpzh);
                    dw_2.Retrieve(curpzh, curJqdbm);

                    dwc = dw_1.GetChild("fkfs");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("skfs");

                    dwc = dw_1.GetChild("ywy");
                    dwc.SetTransaction(this.AdoTransaction);
                    dwc.Retrieve("%", yhbh,"cw");
                }

            }

            dw_1.Modify("DataWindow.Readonly=yes");
            dw_2.Modify("DataWindow.Readonly=yes");

            if (this.Page != null)
            {
                this.Page.ClientScript.RegisterClientScriptInclude("W_YW_LIST", "/CaiWu/CaiWuTongJiFenXi/W_YW_LIST.win.js?JSV=" + AppService.GetJSVesion());
            }

        }

        void Add35CmCol(bool isShow)
        {
            if (isShow)
                Common.DWServiceHelp.Add35CmCol(dw_2, false);
        }
    }
}
