protected void rctxtStartingCycle_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string whereStr;

        vUTPCycle endingCycle;//终止区域

        if (rctxtCompany.SelectedValue != "N/A")
        {
            whereStr     = "  and it.CompanyID='" + rctxtCompany.SelectedValue + "'";
            this.OrderBy = " it.Cycle asc ";

            BLL_vUTPCustomer = new vUTPCustomerBLL();
            endingCycle      = BLL_vUTPCustomer.FindLastCycleByCompanyId(rctxtCompany.SelectedValue, this.OrderBy);

            whereStr = " and it.CompanyID='" + rctxtCompany.SelectedValue + "' and it.Cycle >= " +
                       rctxtStartingCycle.SelectedValue + " and it.Cycle <= " + endingCycle.Cycle + "";

            vUTPCycleObjs = BLL_vUTPCustomer.GetUTPCycles(whereStr, this.OrderBy);

            if (vUTPCycleObjs.Count() > 0)
            {
                rctxtEndingCycle.DataSource     = vUTPCycleObjs;
                rctxtEndingCycle.DataValueField = "Cycle";
                rctxtEndingCycle.DataTextField  = "Cycle";
                rctxtEndingCycle.DataBind();
            }
        }
    }
    protected void chkAllCycles_CheckedChanged(object sender, EventArgs e)
    {
        this.OrderBy = " it.Cycle asc";

        vUTPCycle startingCycle; //起始区域
        vUTPCycle endingCycle;   //终止区域

        string vUTPCompanyId;

        if (chkAllCycles.Checked == true)
        {
            vUTPCompanyId = rctxtCompany.SelectedValue;
            if (vUTPCompanyId != "N/A" && !rctxtEndingCycle.SelectedValue.Equals("N/A") &&
                !rctxtStartingCycle.SelectedValue.Equals("N/A"))
            {
                BLL_vUTPCustomer = new vUTPCustomerBLL();
                startingCycle    = BLL_vUTPCustomer.FindFirstCycleByCompanyId(vUTPCompanyId, this.OrderBy);
                endingCycle      = BLL_vUTPCustomer.FindLastCycleByCompanyId(vUTPCompanyId, this.OrderBy);

                //给空间赋值
                rctxtStartingCycle.SelectedValue = startingCycle.Cycle.ToString().Trim();

                rctxtEndingCycle.SelectedValue = endingCycle.Cycle.ToString().Trim();

                //区域控件置灰
                rctxtEndingCycle.Enabled   = false;
                rctxtStartingCycle.Enabled = false;
            }
        }
        else
        {
            rctxtEndingCycle.Enabled   = true;
            rctxtStartingCycle.Enabled = true;
        }
    }
    protected void AllComboBoxBind()
    {
        RadComboBoxItem Status;//Telerik的状态控件

        vUTPCompany vUTPCompanyObj;

        this.OrderBy = " it.CompName desc ";
        string whereStr;

        whereStr         = "";
        BLL_vUTPCustomer = new vUTPCustomerBLL();
        vUTPCompanyObjs  = BLL_vUTPCustomer.GetUTPCompanys(whereStr, this.OrderBy);

        if (vUTPCompanyObjs.Count() > 0)
        {
            rctxtCompany.DataSource     = vUTPCompanyObjs;
            rctxtCompany.DataValueField = "CompanyID";
            rctxtCompany.DataTextField  = "Comp";
            rctxtCompany.DataBind();
        }
        vUTPCompanyObj = vUTPCompanyObjs.ToList().First();

        CycleComboBoxBind(vUTPCompanyObj.CompanyID);

        whereStr              = " and it.Billable=true";
        this.OrderBy          = " it.StatType desc ";
        vUTPCustomerStateObjs = BLL_vUTPCustomer.GetUTPCustomerStates(whereStr, this.OrderBy);

        if (vUTPCustomerStateObjs.Count() > 0)
        {
            try
            {
                rctxtStatusCode.DataSource     = vUTPCustomerStateObjs;
                rctxtStatusCode.DataValueField = "CustomerStateID";
                rctxtStatusCode.DataTextField  = "StatCode";
                rctxtStatusCode.DataBind();

                Status = new RadComboBoxItem("All", "All");
                rctxtStatusCode.Items.Add(Status);
                rctxtStatusCode.SelectedValue = "All";
            }
            catch (Exception)
            {
                rctxtStatusCode.Items.Clear();

                Status = new RadComboBoxItem("All", "All");
                rctxtStatusCode.Items.Add(Status);
                rctxtStatusCode.SelectedValue = "All";
            }
        }
    }
    protected void FindValue()
    {
        vUTPCycle startingCycle;            //起始区域
        vUTPCycle endingCycle;              //终止区域

        Boolean         startCycle = false; //是否是起始区域
        Boolean         endCycle   = false; //是否是结束区域
        RadComboBoxItem endingCycleComboBox;
        RadComboBoxItem startingCycleComboBox;

        string[] cycle;

        if (this.KeyId != string.Empty)
        {
            if (SchedulerObj.Company != null)
            {
                rctxtCompany.SelectedValue = SchedulerObj.Company.Trim();
            }
            if (SchedulerObj.Cycle != null)
            {
                cycle = SchedulerObj.Cycle.Split(',');
                if (SchedulerObj.Cycle != null)
                {
                    cycle = SchedulerObj.Cycle.Split(',');
                    if (cycle != null)
                    {
                        int i = 0;
                        foreach (var item in cycle)
                        {
                            if (i == 0)
                            {
                                if (item.Equals("N/A"))
                                {
                                    //清空起始区域
                                    rctxtStartingCycle.Items.Clear();

                                    startingCycleComboBox = new RadComboBoxItem("N/A", "N/A");
                                    rctxtStartingCycle.Items.Add(startingCycleComboBox);
                                }
                                else
                                {
                                    rctxtStartingCycle.SelectedValue = item.Trim();
                                }
                                i++;
                                //是否数据集的first
                                if (!item.Equals("N/A"))
                                {
                                    this.OrderBy     = " it.Cycle asc";
                                    BLL_vUTPCustomer = new vUTPCustomerBLL();
                                    startingCycle    = BLL_vUTPCustomer.FindFirstCycleByCompanyId(rctxtCompany.SelectedValue, this.OrderBy);
                                    if (item.Equals(startingCycle.Cycle.ToString()))
                                    {
                                        startCycle = true;
                                    }
                                }
                            }
                            else if (i == 1)
                            {
                                if (item.Equals("N/A"))
                                {
                                    //清空终止区域
                                    rctxtEndingCycle.Items.Clear();

                                    endingCycleComboBox = new RadComboBoxItem("N/A", "N/A");
                                    rctxtEndingCycle.Items.Add(endingCycleComboBox);
                                }
                                else
                                {
                                    rctxtEndingCycle.SelectedValue = item.Trim();
                                }
                                //是否数据的Last
                                if (!item.Equals("N/A"))
                                {
                                    endingCycle = BLL_vUTPCustomer.FindLastCycleByCompanyId(rctxtCompany.SelectedValue, this.OrderBy);
                                    if (item.Equals(endingCycle.Cycle.ToString()))
                                    {
                                        endCycle = true;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (SchedulerObj.Copy != null && SchedulerObj.Copy.Equals("True"))
            {
                chkCopy.Checked = true;
            }
            if (SchedulerObj.Calc != null && SchedulerObj.Calc.Equals("True"))
            {
                chkCalc.Checked = true;
            }
            if (SchedulerObj.Status != null)
            {
                if (SchedulerObj.Status.Trim().Equals("All"))
                {
                    rctxtStatusCode.SelectedValue = "All";
                }
                else
                {
                    rctxtStatusCode.SelectedValue = SchedulerObj.Status.Trim();
                }
            }

            //如果起始区域和结束区域是数据的frist和last,则AllCycle为true
            if (startCycle == true && endCycle == true)
            {
                chkAllCycles.Checked = true;
                //区域控件置灰
                rctxtEndingCycle.Enabled   = false;
                rctxtStartingCycle.Enabled = false;
            }
        }
    }
    protected void CycleComboBoxBind(string UTPCompanyId)
    {
        RadComboBoxItem startingCycle; //起始区域Telerik控件
        RadComboBoxItem endingCycle;   //结束区域Telerik控件
        string          whereStr;

        whereStr     = " and it.CompanyID='" + UTPCompanyId + "'";
        this.OrderBy = " it.Cycle asc ";

        try
        {
            vUTPCycleObjs = BLL_vUTPCustomer.GetUTPCycles(whereStr, this.OrderBy);
        }
        catch (NullReferenceException)
        {
            BLL_vUTPCustomer = new vUTPCustomerBLL();
            vUTPCycleObjs    = BLL_vUTPCustomer.GetUTPCycles(whereStr, this.OrderBy);
        }

        if (vUTPCycleObjs.Count() > 0)
        {
            try
            {
                //起始区域
                rctxtStartingCycle.DataSource     = vUTPCycleObjs;
                rctxtStartingCycle.DataValueField = "Cycle";
                rctxtStartingCycle.DataTextField  = "Cycle";
                rctxtStartingCycle.DataBind();

                //终止区域
                rctxtEndingCycle.DataSource     = vUTPCycleObjs;
                rctxtEndingCycle.DataValueField = "Cycle";
                rctxtEndingCycle.DataTextField  = "Cycle";
                rctxtEndingCycle.DataBind();
            }
            catch (Exception)
            {
                //清空终止区域
                rctxtEndingCycle.Items.Clear();

                endingCycle = new RadComboBoxItem("N/A", "N/A");
                rctxtEndingCycle.Items.Add(endingCycle);

                //清空起始区域
                rctxtStartingCycle.Items.Clear();

                startingCycle = new RadComboBoxItem("N/A", "N/A");
                rctxtStartingCycle.Items.Add(startingCycle);
            }
        }
        else
        {
            //清空终止区域
            rctxtEndingCycle.Items.Clear();

            endingCycle = new RadComboBoxItem("N/A", "N/A");
            rctxtEndingCycle.Items.Add(endingCycle);

            //清空起始区域
            rctxtStartingCycle.Items.Clear();

            startingCycle = new RadComboBoxItem("N/A", "N/A");
            rctxtStartingCycle.Items.Add(startingCycle);

            //无数据chkAllCycles置灰
            chkAllCycles.Checked = false;
            chkAllCycles.Enabled = false;
        }
    }