private void BindData()
    {
        Org_StaffBLL bll = new Org_StaffBLL((int)ViewState["ID"]);
        panel1.BindData(bll.Model);
        Header.Attributes["WebPageSubCode"] = "Modify";
        gv_List.DataSource = bll.GetUserList();
        gv_List.DataBind();

        UploadFile1.RelateID = (int)ViewState["ID"];
        UploadFile1.BindGrid();

        Org_Staff m = bll.Model;
        if (m.ApproveFlag == 1)
        {
            if (m.Dimission == 1)
            {
                bt_AddApply.Visible = false;
            }
            bt_Approve.Visible = false;
            TextBox tbx_BeginWorkTime = (TextBox)panel1.FindControl("Org_Staff_BeginWorkTime");
            // if (tbx_BeginWorkTime != null) tbx_BeginWorkTime.Enabled = false;//03-17暂停使用,便于维护资料
            if (m.Dimission == 2)
            {
                TextBox tbx_EndWorkTime = (TextBox)panel1.FindControl("Org_Staff_EndWorkTime");
                if (tbx_EndWorkTime != null) tbx_EndWorkTime.Enabled = false;
            }
        }

        if (m["State"] == "2")
        {
            //审批中
            bt_AddApply.Visible = false;
            bt_OK.Visible = false;
            bt_CreateUser.Visible = false;
            bt_TaskDetail.Visible = true;
            bt_RevocationApply.Visible = false;
        }

        if (bll.Model.OrganizeCity > 1)
        {
            #region 绑定兼管片区
            IList<Addr_OrganizeCity> staffincity = bll.StaffInOrganizeCity_GetOrganizeCitys();

            Addr_OrganizeCity currentcity = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model;
            if (currentcity != null)
            {
                Addr_OrganizeCity parent = new Addr_OrganizeCityBLL(currentcity.SuperID).Model;
                if (parent != null)
                {
                    IList<Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + parent.ID.ToString() + " AND ID <> " + bll.Model.OrganizeCity.ToString());
                    if (lists.Count > 0)
                    {
                        foreach (Addr_OrganizeCity city in lists)
                        {
                            if (staffincity.FirstOrDefault(p => p.ID == city.ID) == null)
                                ddl_StaffInOrganizeCity.Items.Add(new ListItem(parent.Name + "->" + city.Name + "(" + city.Code + ")", city.ID.ToString()));
                        }
                    }
                    Org_StaffBLL staff = new Org_StaffBLL((int)Session["UserID"]);
                    Org_Position position = new Org_PositionBLL(staff.Model.Position).Model;
                    if (currentcity.Level > 1 && position != null &&( position.IsHeadOffice == "Y" || position.Remark == "OfficeHR"))
                    {
                        int grandpacityid = new Addr_OrganizeCityBLL(currentcity.SuperID).Model.SuperID;
                        string condition = "SuperID = " + grandpacityid.ToString() + " AND ID <> " + currentcity.SuperID.ToString();
                        if (currentcity.Level < ConfigHelper.GetConfigInt("OrganizeCity-CityLevel"))
                        {
                            condition = "SuperID != " +parent.ID.ToString() + " AND Level=" + (currentcity.Level-1).ToString() + " AND ID <> " + currentcity.SuperID.ToString();
                        }
                        IList<Addr_OrganizeCity> bobos = Addr_OrganizeCityBLL.GetModelList(condition);
                        foreach (Addr_OrganizeCity bobo in bobos)
                        {
                            IList<Addr_OrganizeCity> tangxongs = Addr_OrganizeCityBLL.GetModelList("SuperID = " + bobo.ID.ToString());
                            foreach (Addr_OrganizeCity city in tangxongs)
                            {
                                if (staffincity.FirstOrDefault(p => p.ID == city.ID) == null)
                                    ddl_StaffInOrganizeCity.Items.Add(new ListItem(bobo.Name + "->" + city.Name + "(" + city.Code + ")", city.ID.ToString()));
                            }
                        }
                    }
                }

                ddl_StaffInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0"));
            }
            if (ddl_StaffInOrganizeCity.Items.Count == 0) bt_Add_StaffInOrganizeCity.Enabled = false;
            #endregion

            gv_StaffInOrganizeCity.BindGrid<Addr_OrganizeCity>(bll.StaffInOrganizeCity_GetOrganizeCitys());
        }
        else
        {
            tr_StaffInOrganizeCity.Visible = false;
        }

        bt_OK.Text = "保 存";
        bt_OK.ForeColor = System.Drawing.Color.Red;

        //if (new Org_StaffBLL((int)Session["UserID"]).Model.ID != 1)
        //{
        //    ((MCSTreeControl)panel1.FindControl("Org_Staff_Position")).Enabled = false;
        //}

        int budget = Org_StaffNumberLimitBLL.CheckOverBudget(m.OrganizeCity, m.Position);
        if (budget == 0)
            lb_OverBudgetInfo.Text = "当前城市该职位人员数量已等于预定的预算人数,请注意!";
        else if (budget < 0)
            lb_OverBudgetInfo.Text = "当前城市该职位人员数量已超过预定的预算人数 " + (0 - budget).ToString() + "人,请注意!";
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region 获取页面参数
            if (Request.QueryString["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]);
                Session["ClientID"] = ViewState["ClientID"];
            }
            else if (Session["ClientID"] != null)
                ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString());
            #endregion

            BindDropDown();

            //查找过滤添加:0:所有 1:审核 2:未审核
            if (Request.QueryString["ApproveFlag"] != null)
            {
                Session["ClientID"] = null;
                ViewState["ClientID"] = null;
                rbl_ApproveFlag.SelectedValue = Request.QueryString["ApproveFlag"];
            }

            tbx_begin.Text = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd");
            tbx_end.Text = DateTime.Now.ToString("yyyy-MM-dd");

            select_Supplier.PageUrl = "../CM/PopSearch/Search_SelectClient.aspx?ClientType=2";
            select_Client.PageUrl = "../CM/PopSearch/Search_SelectClient.aspx?ClientType=2";

            #region 调出客户的管理片区为当前人的上一级,以便向管辖外的区域调货
            try
            {
                int organizecity = new Org_StaffBLL((int)Session["UserID"]).Model.OrganizeCity;
                if (organizecity > 1)
                {
                    int superid = new Addr_OrganizeCityBLL(organizecity).Model.SuperID;

                    select_Client.PageUrl += "&OrganizeCity=" + superid.ToString();
                }
            }
            catch { }
            #endregion
            if (Request.QueryString["TransferOutClientID"] != null || Request.QueryString["TransferInClientID"] != null)
            {
                if (Request.QueryString["TransferOutClientID"] != null)
                {
                    CM_ClientBLL _s = new CM_ClientBLL(int.Parse(Request.QueryString["TransferOutClientID"]));
                    select_Supplier.SelectText = _s.Model.FullName;
                    select_Supplier.SelectValue = _s.Model.ID.ToString();
                }
                if (Request.QueryString["TransferInClientID"] != null)
                {
                    CM_ClientBLL _r = new CM_ClientBLL(int.Parse(Request.QueryString["TransferInClientID"]));
                    select_Client.SelectText = _r.Model.FullName;
                    select_Client.SelectValue = _r.Model.ID.ToString();
                }
                BindGrid();
            }
            else if (ViewState["ClientID"] != null)
            {
                Response.Redirect("TransferVolumeList.aspx?TransferOutClientID=" + ViewState["ClientID"].ToString());
            }
            else if (Request.QueryString["ApproveFlag"] != null)
            {
                BindGrid();
            }
        }
    }
Ejemplo n.º 3
0
    private void BindData()
    {
        Org_StaffBLL bll = new Org_StaffBLL((int)ViewState["ID"]);

        panel1.BindData(bll.Model);
        Header.Attributes["WebPageSubCode"] = "Modify";
        gv_List.DataSource = bll.GetUserList();
        gv_List.DataBind();

        UploadFile1.RelateID = (int)ViewState["ID"];
        UploadFile1.BindGrid();

        Org_Staff m = bll.Model;

        if (m.ApproveFlag == 1)
        {
            if (m.Dimission == 1)
            {
                bt_AddApply.Visible = false;
            }
            bt_Approve.Visible = false;
            TextBox tbx_BeginWorkTime = (TextBox)panel1.FindControl("Org_Staff_BeginWorkTime");
            // if (tbx_BeginWorkTime != null) tbx_BeginWorkTime.Enabled = false;//03-17暂停使用,便于维护资料
            if (m.Dimission == 2)
            {
                TextBox tbx_EndWorkTime = (TextBox)panel1.FindControl("Org_Staff_EndWorkTime");
                if (tbx_EndWorkTime != null)
                {
                    tbx_EndWorkTime.Enabled = false;
                }
            }
        }

        if (m["State"] == "2")
        {
            //审批中
            bt_AddApply.Visible        = false;
            bt_OK.Visible              = false;
            bt_CreateUser.Visible      = false;
            bt_TaskDetail.Visible      = true;
            bt_RevocationApply.Visible = false;
        }

        if (bll.Model.OrganizeCity > 1)
        {
            #region 绑定兼管片区
            IList <Addr_OrganizeCity> staffincity = bll.StaffInOrganizeCity_GetOrganizeCitys();

            Addr_OrganizeCity currentcity = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model;
            if (currentcity != null)
            {
                Addr_OrganizeCity parent = new Addr_OrganizeCityBLL(currentcity.SuperID).Model;
                if (parent != null)
                {
                    IList <Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + parent.ID.ToString() + " AND ID <> " + bll.Model.OrganizeCity.ToString());
                    if (lists.Count > 0)
                    {
                        foreach (Addr_OrganizeCity city in lists)
                        {
                            if (staffincity.FirstOrDefault(p => p.ID == city.ID) == null)
                            {
                                ddl_StaffInOrganizeCity.Items.Add(new ListItem(parent.Name + "->" + city.Name + "(" + city.Code + ")", city.ID.ToString()));
                            }
                        }
                    }
                    Org_StaffBLL staff    = new Org_StaffBLL((int)Session["UserID"]);
                    Org_Position position = new Org_PositionBLL(staff.Model.Position).Model;
                    if (currentcity.Level > 1 && position != null && (position.IsHeadOffice == "Y" || position.Remark == "OfficeHR"))
                    {
                        int    grandpacityid = new Addr_OrganizeCityBLL(currentcity.SuperID).Model.SuperID;
                        string condition     = "SuperID = " + grandpacityid.ToString() + " AND ID <> " + currentcity.SuperID.ToString();
                        if (currentcity.Level < ConfigHelper.GetConfigInt("OrganizeCity-CityLevel"))
                        {
                            condition = "SuperID != " + parent.ID.ToString() + " AND Level=" + (currentcity.Level - 1).ToString() + " AND ID <> " + currentcity.SuperID.ToString();
                        }
                        IList <Addr_OrganizeCity> bobos = Addr_OrganizeCityBLL.GetModelList(condition);
                        foreach (Addr_OrganizeCity bobo in bobos)
                        {
                            IList <Addr_OrganizeCity> tangxongs = Addr_OrganizeCityBLL.GetModelList("SuperID = " + bobo.ID.ToString());
                            foreach (Addr_OrganizeCity city in tangxongs)
                            {
                                if (staffincity.FirstOrDefault(p => p.ID == city.ID) == null)
                                {
                                    ddl_StaffInOrganizeCity.Items.Add(new ListItem(bobo.Name + "->" + city.Name + "(" + city.Code + ")", city.ID.ToString()));
                                }
                            }
                        }
                    }
                }

                ddl_StaffInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0"));
            }
            if (ddl_StaffInOrganizeCity.Items.Count == 0)
            {
                bt_Add_StaffInOrganizeCity.Enabled = false;
            }
            #endregion

            gv_StaffInOrganizeCity.BindGrid <Addr_OrganizeCity>(bll.StaffInOrganizeCity_GetOrganizeCitys());
        }
        else
        {
            tr_StaffInOrganizeCity.Visible = false;
        }

        bt_OK.Text      = "保 存";
        bt_OK.ForeColor = System.Drawing.Color.Red;

        //if (new Org_StaffBLL((int)Session["UserID"]).Model.ID != 1)
        //{
        //    ((MCSTreeControl)panel1.FindControl("Org_Staff_Position")).Enabled = false;
        //}

        int budget = Org_StaffNumberLimitBLL.CheckOverBudget(m.OrganizeCity, m.Position);
        if (budget == 0)
        {
            lb_OverBudgetInfo.Text = "当前城市该职位人员数量已等于预定的预算人数,请注意!";
        }
        else if (budget < 0)
        {
            lb_OverBudgetInfo.Text = "当前城市该职位人员数量已超过预定的预算人数 " + (0 - budget).ToString() + "人,请注意!";
        }
    }
Ejemplo n.º 4
0
    private void BindData()
    {
        Org_StaffBLL bll = new Org_StaffBLL((int)ViewState["ID"]);

        if (bll.Model == null)
        {
            return;
        }

        panel1.BindData(bll.Model);

        gv_List.DataSource = bll.GetUserList();
        gv_List.DataBind();

        UploadFile1.RelateID = (int)ViewState["ID"];
        UploadFile1.BindGrid();

        Org_Staff m = bll.Model;

        if (m.ApproveFlag == 1)
        {
            if (m.Dimission == 1)
            {
                bt_AddApply.Visible = false;
            }
            bt_Approve.Visible = false;
            Header.Attributes["WebPageSubCode"] = "Modify";
            TextBox tbx_BeginWorkTime = (TextBox)panel1.FindControl("Org_Staff_BeginWorkTime");
            // if (tbx_BeginWorkTime != null) tbx_BeginWorkTime.Enabled = false;//03-17暂停使用,便于维护资料
            if (m.Dimission == 2)
            {
                TextBox tbx_EndWorkTime = (TextBox)panel1.FindControl("Org_Staff_EndWorkTime");
                if (tbx_EndWorkTime != null)
                {
                    tbx_EndWorkTime.Enabled = false;
                }
            }
        }

        if (m["State"] == "2")
        {
            //审批中
            bt_AddApply.Visible   = false;
            bt_OK.Visible         = false;
            bt_CreateUser.Visible = false;
            bt_TaskDetail.Visible = true;
        }

        if (bll.Model.OrganizeCity > 1)
        {
            #region 绑定兼管片区
            IList <Addr_OrganizeCity> staffincity = bll.StaffInOrganizeCity_GetOrganizeCitys();

            Addr_OrganizeCity currentcity = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model;
            if (currentcity != null)
            {
                Addr_OrganizeCity parent = new Addr_OrganizeCityBLL(currentcity.SuperID).Model;
                if (parent != null)
                {
                    IList <Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + parent.ID.ToString() + " AND ID <> " + bll.Model.OrganizeCity.ToString());
                    if (lists.Count > 0)
                    {
                        foreach (Addr_OrganizeCity city in lists)
                        {
                            if (staffincity.FirstOrDefault(p => p.ID == city.ID) == null)
                            {
                                ddl_StaffInOrganizeCity.Items.Add(new ListItem(parent.Name + "->" + city.Name + "(" + city.Code + ")", city.ID.ToString()));
                            }
                        }
                    }

                    if (currentcity.Level > 1)
                    {
                        int grandpacityid = new Addr_OrganizeCityBLL(currentcity.SuperID).Model.SuperID;
                        IList <Addr_OrganizeCity> bobos = Addr_OrganizeCityBLL.GetModelList("SuperID = " + grandpacityid.ToString() + " AND ID <> " + currentcity.SuperID.ToString());
                        foreach (Addr_OrganizeCity bobo in bobos)
                        {
                            IList <Addr_OrganizeCity> tangxongs = Addr_OrganizeCityBLL.GetModelList("SuperID = " + bobo.ID.ToString());
                            foreach (Addr_OrganizeCity city in tangxongs)
                            {
                                if (staffincity.FirstOrDefault(p => p.ID == city.ID) == null)
                                {
                                    ddl_StaffInOrganizeCity.Items.Add(new ListItem(bobo.Name + "->" + city.Name + "(" + city.Code + ")", city.ID.ToString()));
                                }
                            }
                        }
                    }
                }

                ddl_StaffInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0"));
            }
            if (ddl_StaffInOrganizeCity.Items.Count == 0)
            {
                bt_Add_StaffInOrganizeCity.Enabled = false;
            }
            #endregion

            gv_StaffInOrganizeCity.BindGrid <Addr_OrganizeCity>(bll.StaffInOrganizeCity_GetOrganizeCitys());
        }
        else
        {
            tr_StaffInOrganizeCity.Visible = false;
        }

        bt_OK.Text      = "保 存";
        bt_OK.ForeColor = System.Drawing.Color.Red;

        //if (new Org_StaffBLL((int)Session["UserID"]).Model.ID != 1)
        //{
        //    ((MCSTreeControl)panel1.FindControl("Org_Staff_Position")).Enabled = false;
        //}
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            #region 获取页面参数
            if (Request.QueryString["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Request.QueryString["ClientID"]);
                Session["ClientID"]   = ViewState["ClientID"];
            }
            else if (Session["ClientID"] != null)
            {
                ViewState["ClientID"] = Int32.Parse(Session["ClientID"].ToString());
            }
            #endregion

            BindDropDown();

            //查找过滤添加:0:所有 1:审核 2:未审核
            if (Request.QueryString["ApproveFlag"] != null)
            {
                Session["ClientID"]           = null;
                ViewState["ClientID"]         = null;
                rbl_ApproveFlag.SelectedValue = Request.QueryString["ApproveFlag"];
            }

            tbx_begin.Text = DateTime.Now.AddMonths(-3).ToString("yyyy-MM-dd");
            tbx_end.Text   = DateTime.Now.ToString("yyyy-MM-dd");

            select_Supplier.PageUrl = "../CM/PopSearch/Search_SelectClient.aspx?ClientType=2";
            select_Client.PageUrl   = "../CM/PopSearch/Search_SelectClient.aspx?ClientType=2";

            #region 调出客户的管理片区为当前人的上一级,以便向管辖外的区域调货
            try
            {
                int organizecity = new Org_StaffBLL((int)Session["UserID"]).Model.OrganizeCity;
                if (organizecity > 1)
                {
                    int superid = new Addr_OrganizeCityBLL(organizecity).Model.SuperID;

                    select_Client.PageUrl += "&OrganizeCity=" + superid.ToString();
                }
            }
            catch { }
            #endregion
            if (Request.QueryString["TransferOutClientID"] != null || Request.QueryString["TransferInClientID"] != null)
            {
                if (Request.QueryString["TransferOutClientID"] != null)
                {
                    CM_ClientBLL _s = new CM_ClientBLL(int.Parse(Request.QueryString["TransferOutClientID"]));
                    select_Supplier.SelectText  = _s.Model.FullName;
                    select_Supplier.SelectValue = _s.Model.ID.ToString();
                }
                if (Request.QueryString["TransferInClientID"] != null)
                {
                    CM_ClientBLL _r = new CM_ClientBLL(int.Parse(Request.QueryString["TransferInClientID"]));
                    select_Client.SelectText  = _r.Model.FullName;
                    select_Client.SelectValue = _r.Model.ID.ToString();
                }
                BindGrid();
            }
            else if (ViewState["ClientID"] != null)
            {
                Response.Redirect("TransferVolumeList.aspx?TransferOutClientID=" + ViewState["ClientID"].ToString());
            }
            else if (Request.QueryString["ApproveFlag"] != null)
            {
                BindGrid();
            }
        }
    }
Ejemplo n.º 6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            #region 获取页面参数
            ViewState["VolumeID"] = Request.QueryString["VolumeID"] == null ? 0 : int.Parse(Request.QueryString["VolumeID"]);
            ViewState["IsCXP"]    = Request.QueryString["IsCXP"] == null ? false : int.Parse(Request.QueryString["IsCXP"]) != 0; //是否是赠品销量录入 0:成品 1:赠品

            BindDropDown();

            if ((int)ViewState["VolumeID"] == 0)
            {
                ViewState["TransferOutClientID"] = Request.QueryString["TransferOutClientID"] == null ? 0 : int.Parse(Request.QueryString["TransferOutClientID"]);
                ViewState["TransferInClientID"]  = Request.QueryString["TransferInClientID"] == null ? 0 : int.Parse(Request.QueryString["TransferInClientID"]);

                ViewState["Type"] = 6;        //销量类型  6:经销商成品调拨单

                if ((int)ViewState["TransferOutClientID"] == 0)
                {
                    MessageBox.ShowAndRedirect(this, "对不起,必须选择要调出货的经销商!", "TransferVolumeList.aspx");
                    return;
                }
            }
            #endregion

            select_Supplier.PageUrl = "../CM/PopSearch/Search_SelectClient.aspx?ClientType=2&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7)=1\"";
            select_Client.PageUrl   = "../CM/PopSearch/Search_SelectClient.aspx?ClientType=2&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7)=1\"";

            #region 调入客户的管理片区为当前人的上一级,以便向管辖外的区域调货
            try
            {
                int organizecity = new Org_StaffBLL((int)Session["UserID"]).Model.OrganizeCity;
                if (organizecity > 1)
                {
                    int superid = new Addr_OrganizeCityBLL(organizecity).Model.SuperID;

                    select_Client.PageUrl += "&OrganizeCity=" + superid.ToString();
                }
            }
            catch { }
            #endregion

            if ((int)ViewState["VolumeID"] == 0)
            {
                tbx_VolumeDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
                BindClientInfo((int)ViewState["TransferOutClientID"], (int)ViewState["TransferInClientID"]);

                int month = int.Parse(ddl_AccountMonth.SelectedValue);

                DataTable    dt   = SVM_SalesVolumeBLL.InitProductList((int)ViewState["VolumeID"], (int)ViewState["TransferOutClientID"], (int)ViewState["Type"], month, (bool)ViewState["IsCXP"]); //初始化产品列表
                DataColumn[] keys = { dt.Columns["Product"] };
                dt.PrimaryKey         = keys;
                ViewState["DTDetail"] = dt;

                bt_Delete.Visible  = false;
                bt_Approve.Visible = false;
            }
            else
            {
                cb_OnlyDisplayUnZero.Checked = true;
                BindData();
            }

            BindDropDown_ByIsCXP();

            //Header.Attributes["WebPageSubCode"] = "Type=" + ViewState["Type"].ToString();
        }
    }
    private void BindData()
    {
        Org_StaffBLL bll = new Org_StaffBLL((int)ViewState["ID"]);
        if (bll.Model == null) return;

        panel1.BindData(bll.Model);

        gv_List.DataSource = bll.GetUserList();
        gv_List.DataBind();

        UploadFile1.RelateID = (int)ViewState["ID"];
        UploadFile1.BindGrid();

        Org_Staff m = bll.Model;
        if (m.ApproveFlag == 1)
        {
            if (m.Dimission == 1)
            {
                bt_AddApply.Visible = false;
            }
            bt_Approve.Visible = false;
            Header.Attributes["WebPageSubCode"] = "Modify";
            TextBox tbx_BeginWorkTime = (TextBox)panel1.FindControl("Org_Staff_BeginWorkTime");
            // if (tbx_BeginWorkTime != null) tbx_BeginWorkTime.Enabled = false;//03-17暂停使用,便于维护资料
            if (m.Dimission == 2)
            {
                TextBox tbx_EndWorkTime = (TextBox)panel1.FindControl("Org_Staff_EndWorkTime");
                if (tbx_EndWorkTime != null) tbx_EndWorkTime.Enabled = false;
            }
        }

        if (m["State"] == "2")
        {
            //审批中
            bt_AddApply.Visible = false;
            bt_OK.Visible = false;
            bt_CreateUser.Visible = false;
            bt_TaskDetail.Visible = true;
        }

        if (bll.Model.OrganizeCity > 1)
        {
            #region 绑定兼管片区
            IList<Addr_OrganizeCity> staffincity = bll.StaffInOrganizeCity_GetOrganizeCitys();

            Addr_OrganizeCity currentcity = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model;
            if (currentcity != null)
            {
                Addr_OrganizeCity parent = new Addr_OrganizeCityBLL(currentcity.SuperID).Model;
                if (parent != null)
                {
                    IList<Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + parent.ID.ToString() + " AND ID <> " + bll.Model.OrganizeCity.ToString());
                    if (lists.Count > 0)
                    {
                        foreach (Addr_OrganizeCity city in lists)
                        {
                            if (staffincity.FirstOrDefault(p => p.ID == city.ID) == null)
                                ddl_StaffInOrganizeCity.Items.Add(new ListItem(parent.Name + "->" + city.Name + "(" + city.Code + ")", city.ID.ToString()));
                        }
                    }

                    if (currentcity.Level > 1)
                    {
                        int grandpacityid = new Addr_OrganizeCityBLL(currentcity.SuperID).Model.SuperID;
                        IList<Addr_OrganizeCity> bobos = Addr_OrganizeCityBLL.GetModelList("SuperID = " + grandpacityid.ToString() + " AND ID <> " + currentcity.SuperID.ToString());
                        foreach (Addr_OrganizeCity bobo in bobos)
                        {
                            IList<Addr_OrganizeCity> tangxongs = Addr_OrganizeCityBLL.GetModelList("SuperID = " + bobo.ID.ToString());
                            foreach (Addr_OrganizeCity city in tangxongs)
                            {
                                if (staffincity.FirstOrDefault(p => p.ID == city.ID) == null)
                                    ddl_StaffInOrganizeCity.Items.Add(new ListItem(bobo.Name + "->" + city.Name + "(" + city.Code + ")", city.ID.ToString()));
                            }
                        }
                    }
                }

                ddl_StaffInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0"));
            }
            if (ddl_StaffInOrganizeCity.Items.Count == 0) bt_Add_StaffInOrganizeCity.Enabled = false;
            #endregion

            gv_StaffInOrganizeCity.BindGrid<Addr_OrganizeCity>(bll.StaffInOrganizeCity_GetOrganizeCitys());
        }
        else
        {
            tr_StaffInOrganizeCity.Visible = false;
        }

        bt_OK.Text = "保 存";
        bt_OK.ForeColor = System.Drawing.Color.Red;

        //if (new Org_StaffBLL((int)Session["UserID"]).Model.ID != 1)
        //{
        //    ((MCSTreeControl)panel1.FindControl("Org_Staff_Position")).Enabled = false;
        //}
    }
    private void BindGrid()
    {
        if (ViewState["ClientID"] != null)
        {
            CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]);

            #region 绑定住宿人员
            gv_Staff.ConditionString = "MCS_CM.dbo.CM_StaffInProperty.Client = " + ViewState["ClientID"].ToString() + " AND Org_Staff.Dimission=1";
            gv_Staff.BindGrid();
            #endregion

            #region 绑定兼管片区
            if (bll.Model.OrganizeCity > 1)
            {
                ddl_PropertyInOrganizeCity.Items.Clear();

                int superid = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID;
                IList<Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + superid.ToString() +
                    " AND ID <> " + bll.Model.OrganizeCity.ToString() +
                    " AND ID NOT IN (SELECT OrganizeCity FROM MCS_CM.dbo.CM_PropertyInOrganizeCity WHERE Client=" + bll.Model.ID.ToString() + ")");
                if (lists.Count > 0)
                {
                    foreach (Addr_OrganizeCity city in lists)
                    {
                        ddl_PropertyInOrganizeCity.Items.Add(new ListItem("(" + city.Code + ")" + city.Name, city.ID.ToString()));
                    }
                }

                ddl_PropertyInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0"));

                gv_PropertyInOrganizeCity.BindGrid<Addr_OrganizeCity>(bll.ClientInOrganizeCity_GetOrganizeCitys());
            }
            else
            {
                tr_PropertyInOrganizeCity.Visible = false;
            }
            #endregion

            #region 绑定电话列表
            gv_Telephone.ConditionString = "Client=" + bll.Model.ID.ToString();
            gv_Telephone.BindGrid();
            #endregion

            #region 绑定合同列表
            gv_List_Contract.BindGrid(CM_ContractBLL.GetModelList("Client=" + bll.Model.ID.ToString()));
            #endregion

        }
    }
    private void BindGrid()
    {
        if (ViewState["ClientID"] != null)
        {
            CM_ClientBLL bll = new CM_ClientBLL((int)ViewState["ClientID"]);

            #region 绑定住宿人员
            gv_Staff.ConditionString = "MCS_CM.dbo.CM_StaffInProperty.Client = " + ViewState["ClientID"].ToString() + " AND Org_Staff.Dimission=1";
            gv_Staff.BindGrid();
            #endregion

            #region 绑定兼管片区
            if (bll.Model.OrganizeCity > 1)
            {
                ddl_PropertyInOrganizeCity.Items.Clear();

                int superid = new Addr_OrganizeCityBLL(bll.Model.OrganizeCity).Model.SuperID;
                IList <Addr_OrganizeCity> lists = Addr_OrganizeCityBLL.GetModelList("SuperID = " + superid.ToString() +
                                                                                    " AND ID <> " + bll.Model.OrganizeCity.ToString() +
                                                                                    " AND ID NOT IN (SELECT OrganizeCity FROM MCS_CM.dbo.CM_PropertyInOrganizeCity WHERE Client=" + bll.Model.ID.ToString() + ")");
                if (lists.Count > 0)
                {
                    foreach (Addr_OrganizeCity city in lists)
                    {
                        ddl_PropertyInOrganizeCity.Items.Add(new ListItem("(" + city.Code + ")" + city.Name, city.ID.ToString()));
                    }
                }

                ddl_PropertyInOrganizeCity.Items.Insert(0, new ListItem("请选择...", "0"));

                gv_PropertyInOrganizeCity.BindGrid <Addr_OrganizeCity>(bll.ClientInOrganizeCity_GetOrganizeCitys());
            }
            else
            {
                tr_PropertyInOrganizeCity.Visible = false;
            }
            #endregion

            #region 绑定电话列表
            gv_Telephone.ConditionString = "Client=" + bll.Model.ID.ToString();
            gv_Telephone.BindGrid();
            #endregion

            #region 绑定合同列表
            gv_List_Contract.BindGrid(CM_ContractBLL.GetModelList("Client=" + bll.Model.ID.ToString()));
            #endregion
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            #region 获取页面参数
            ViewState["VolumeID"] = Request.QueryString["VolumeID"] == null ? 0 : int.Parse(Request.QueryString["VolumeID"]);
            ViewState["IsCXP"] = Request.QueryString["IsCXP"] == null ? false : int.Parse(Request.QueryString["IsCXP"]) != 0;    //是否是赠品销量录入 0:成品 1:赠品

            BindDropDown();

            if ((int)ViewState["VolumeID"] == 0)
            {
                ViewState["TransferOutClientID"] = Request.QueryString["TransferOutClientID"] == null ? 0 : int.Parse(Request.QueryString["TransferOutClientID"]);
                ViewState["TransferInClientID"] = Request.QueryString["TransferInClientID"] == null ? 0 : int.Parse(Request.QueryString["TransferInClientID"]);

               ViewState["Type"] = 6;         //销量类型  6:经销商成品调拨单

                if ((int)ViewState["TransferOutClientID"] == 0)
                {
                    MessageBox.ShowAndRedirect(this, "对不起,必须选择要调出货的经销商!", "TransferVolumeList.aspx");
                    return;
                }
            }
            #endregion

            select_Supplier.PageUrl = "../CM/PopSearch/Search_SelectClient.aspx?ClientType=2&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7)=1\"";
            select_Client.PageUrl = "../CM/PopSearch/Search_SelectClient.aspx?ClientType=2&ExtCondition=\"MCS_SYS.dbo.UF_Spilt(CM_Client.ExtPropertys,~|~,7)=1\"";

            #region 调入客户的管理片区为当前人的上一级,以便向管辖外的区域调货
            try
            {
                int organizecity = new Org_StaffBLL((int)Session["UserID"]).Model.OrganizeCity;
                if (organizecity > 1)
                {
                    int superid = new Addr_OrganizeCityBLL(organizecity).Model.SuperID;

                    select_Client.PageUrl += "&OrganizeCity=" + superid.ToString();
                }
            }
            catch { }
            #endregion

            if ((int)ViewState["VolumeID"] == 0)
            {
                tbx_VolumeDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
                BindClientInfo((int)ViewState["TransferOutClientID"], (int)ViewState["TransferInClientID"]);

                int month = int.Parse(ddl_AccountMonth.SelectedValue);

                DataTable dt = SVM_SalesVolumeBLL.InitProductList((int)ViewState["VolumeID"], (int)ViewState["TransferOutClientID"], (int)ViewState["Type"], month, (bool)ViewState["IsCXP"]); //初始化产品列表
                DataColumn[] keys = { dt.Columns["Product"] };
                dt.PrimaryKey = keys;
                ViewState["DTDetail"] = dt;

                bt_Delete.Visible = false;
                bt_Approve.Visible = false;
            }
            else
            {
                cb_OnlyDisplayUnZero.Checked = true;
                BindData();
            }

            BindDropDown_ByIsCXP();

            //Header.Attributes["WebPageSubCode"] = "Type=" + ViewState["Type"].ToString();
        }
    }