///// <summary>
        ///// 发布往返政策
        ///// </summary>
        ///// <param name="Policy"></param>
        ///// <param name="operatorAccount"></param>
        //public bool RegisterProductClassPolicy(RoundTripPolicyReleaseInfo Round)
        //{
        //    try
        //    {
        //        Round.BasicInfo.Owner = this.CurrentUser.Owner;
        //        return PolicyManageService.ReleaseRoundTripPolicies(Round, this.CurrentUser.UserName);
        //    }
        //    catch (System.Data.Common.DbException)
        //    {
        //        throw new Exception("添加信息发生未知错误,请稍后再试");
        //    }

        //}

        /// <summary>
        /// 发布团队政策
        /// </summary>
        /// <param name="Normal"> </param>
        public bool RegisterTeamPolicy(TeamPolicyReleaseInfo team)
        {
            try
            {
                team.BasicInfo.Creator = this.CurrentUser.UserName;
                team.BasicInfo.Owner   = this.CurrentUser.Owner;
                return(PolicyManageService.ReleaseTeamPolicies(team, this.CurrentUser.UserName));
            }
            catch (System.Data.Common.DbException ex)
            {
                Service.LogService.SaveExceptionLog(ex);
                throw new Exception("添加信息发生未知错误,请稍后再试");
            }
        }
        private bool GetTeamValue(string type)
        {
            VoyageType voyage = VoyageType.OneWay;

            if (titlePolicy.InnerText == "单程")
            {
                voyage = VoyageType.OneWay;
            }
            else if (titlePolicy.InnerText == "往返")
            {
                voyage = VoyageType.RoundTrip;
            }
            else if (titlePolicy.InnerText == "单程·往返")
            {
                voyage = VoyageType.OneWayOrRound;
            }
            else if (titlePolicy.InnerText == "中转联程")
            {
                voyage = VoyageType.TransitWay;
            }
            LimitType derpartrueFilghtType = LimitType.None;

            if (radYiXia.Checked)
            {
                derpartrueFilghtType = LimitType.Include;
            }
            if (radBuXian.Checked)
            {
                derpartrueFilghtType = LimitType.None;
            }
            if (radBuYiXia.Checked)
            {
                derpartrueFilghtType = LimitType.Exclude;
            }

            LimitType returnFilghtType = LimitType.None;

            if (radReturnYiXia.Checked)
            {
                returnFilghtType = LimitType.Include;
            }
            if (radReturnBuXian.Checked)
            {
                returnFilghtType = LimitType.None;
            }
            if (radReturnBuYiXia.Checked)
            {
                returnFilghtType = LimitType.Exclude;
            }
            string weekStr = "";

            if (mon.Checked)
            {
                weekStr += "1,";
            }
            if (tue.Checked)
            {
                weekStr += "2,";
            }
            if (wed.Checked)
            {
                weekStr += "3,";
            }
            if (thur.Checked)
            {
                weekStr += "4,";
            }
            if (fri.Checked)
            {
                weekStr += "5,";
            }
            if (sat.Checked)
            {
                weekStr += "6,";
            }
            if (sun.Checked)
            {
                weekStr += "7,";
            }
            if (weekStr != "")
            {
                weekStr = weekStr.Substring(0, weekStr.Length - 1);
            }

            var teams = PolicyManageService.GetTeamPolicy(Guid.Parse(Request.QueryString["Id"]));

            try
            {
                if (type == "Update")
                {
                    var team = new TeamPolicy
                    {
                        Airline                    = lblAirline.Text,
                        Arrival                    = txtArrivalAirports.AirportsCode.ToList().Join("/"),
                        OfficeCode                 = hidOfficeNo.Value,
                        AutoAudit                  = chkAuto.Checked,
                        ChangePNR                  = chkChangePNR.Checked,
                        IsInternal                 = neibuTh.Visible,
                        IsPeer                     = tonghang.Visible,
                        CustomCode                 = ddlCustomCode.Visible ? ddlCustomCode.SelectedValue.Trim() : lblCustomerCode.Text,
                        Departure                  = txtDepartureAirports.AirportsCode.ToList().Join("/"),
                        Transit                    = "",
                        DepartureDateEnd           = DateTime.Parse(txtDepartrueEnd.Text),
                        DepartureDateStart         = DateTime.Parse(txtDepartrueStart.Text),
                        DepartureFlightsFilter     = derpartrueFilghtType == LimitType.None ? "" : txtDepartrueFilght.Text,
                        DepartureFlightsFilterType = derpartrueFilghtType,
                        Remark                     = txtRemark.Text.Replace("\r", "").Replace("\n", ""),
                        DrawerCondition            = txtDrawerCondition.Text.Replace("\r", "").Replace("\n", ""),
                        ReturnFlightsFilter        = returnFilghtType == LimitType.None ? "" : txtReturnFilght.Text,
                        ReturnFlightsFilterType    = returnFilghtType,
                        SuitReduce                 = chkRound.Checked,
                        MultiSuitReduce            = chkddlc.Checked,
                        StartPrintDate             = DateTime.Parse(txtProvideDate.Text),
                        DepartureDateFilter        = txtPaiChu.Text,
                        DepartureWeekFilter        = weekStr,
                        SubordinateCommission      = decimal.Parse(txtSubordinateCommission.Text) / 100,
                        ProfessionCommission       = tonghang.Visible ? decimal.Parse(txtProfessionCommission.Text) / 100 : -1M,
                        InternalCommission         = neibuTh.Visible ? decimal.Parse(txtInternalCommission.Text) / 100 : -1M,
                        ExceptAirways              = txtExceptAirways.Text,
                        TicketType                 = chkTicket.Text == "B2B" ? TicketType.B2B : TicketType.BSP,
                        Berths                     = hidBunks.Value,
                        VoyageType                 = voyage,
                        ImpowerOffice              = Convert.ToBoolean(dropOffice.SelectedValue),
                        Audited                    = teams.Audited,
                        AuditTime                  = teams.AuditTime,
                        AutoPrint                  = teams.AutoPrint,
                        CreateTime                 = teams.CreateTime,
                        Creator                    = teams.Creator,
                        Freezed                    = teams.Freezed,
                        Owner               = teams.Owner,
                        Suspended           = teams.Suspended,
                        Id                  = Guid.Parse(Request.QueryString["Id"]),
                        AppointBerths       = zhiding.Checked,
                        PrintBeforeTwoHours = chkPrintBeforeTwoHours.Checked
                    };
                    if (zhongzhuanTh.Visible)
                    {
                        team.Arrival = txtZhongzhuanAirports.AirportsCode.Join("/");
                        team.Transit = txtArrivalAirports.AirportsCode.Join("/");
                    }
                    if (team.Departure.Trim() == "")
                    {
                        RegisterScript("alert('出发地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    if (team.VoyageType == VoyageType.TransitWay && team.Transit.Trim() == "")
                    {
                        RegisterScript("alert('中转地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    if (team.Arrival.Trim() == "")
                    {
                        RegisterScript("alert('到达地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    PolicyManageService.UpdateTeamPolicy(team, this.CurrentUser.UserName);
                }
                if (type == "Copy")
                {
                    var teamInfo = new TeamPolicyReleaseInfo
                    {
                        BasicInfo = new TeamPolicyBasicInfo
                        {
                            CustomCode                 = ddlCustomCode.Visible ? ddlCustomCode.SelectedValue.Trim() : lblCustomerCode.Text,
                            IsInternal                 = neibuTh.Visible,
                            IsPeer                     = tonghang.Visible,
                            Airline                    = ddlAirline.SelectedValue,
                            Arrival                    = txtArrivalAirports.AirportsCode.ToList().Join("/"),
                            Transit                    = "",
                            Departure                  = txtDepartureAirports.AirportsCode.ToList().Join("/"),
                            DepartureFlightsFilter     = derpartrueFilghtType == LimitType.None ? "" : txtDepartrueFilght.Text,
                            DepartureFlightsFilterType = derpartrueFilghtType,
                            Remark                     = txtRemark.Text.Replace("\r", "").Replace("\n", ""),
                            DrawerCondition            = txtDrawerCondition.Text.Replace("\r", "").Replace("\n", ""),
                            ReturnFlightsFilter        = returnFilghtType == LimitType.None ? "" : txtReturnFilght.Text,
                            ReturnFlightsFilterType    = returnFilghtType,
                            ExceptAirways              = txtExceptAirways.Text,
                            VoyageType                 = voyage,
                            OfficeCode                 = hidOfficeNo.Value,
                            ImpowerOffice              = Convert.ToBoolean(dropOffice.SelectedValue),
                            Owner = this.CurrentUser.Owner
                        }
                    }; if (zhongzhuanTh.Visible)
                    {
                        teamInfo.BasicInfo.Arrival = txtZhongzhuanAirports.AirportsCode.Join("/");
                        teamInfo.BasicInfo.Transit = txtArrivalAirports.AirportsCode.Join("/");
                    }
                    var list = new List <TeamPolicyRebateInfo>
                    {
                        new TeamPolicyRebateInfo
                        {
                            DepartureDateFilter   = txtPaiChu.Text,
                            DepartureWeekFilter   = weekStr,
                            AutoAudit             = chkAuto.Checked,
                            ChangePNR             = chkChangePNR.Checked,
                            DepartureDateEnd      = DateTime.Parse(txtDepartrueEnd.Text),
                            DepartureDateStart    = DateTime.Parse(txtDepartrueStart.Text),
                            SuitReduce            = chkRound.Checked,
                            StartPrintDate        = DateTime.Parse(txtProvideDate.Text),
                            SubordinateCommission = decimal.Parse(txtSubordinateCommission.Text),
                            ProfessionCommission  = tonghang.Visible ? decimal.Parse(txtProfessionCommission.Text): -1M,
                            InternalCommission    = neibuTh.Visible ? decimal.Parse(txtInternalCommission.Text): -1M,
                            TicketType            = chkTicket.Text == "B2B" ? TicketType.B2B : TicketType.BSP,
                            Berths              = hidBunks.Value,
                            MultiSuitReduce     = chkddlc.Checked,
                            AppointBerths       = zhiding.Checked,
                            PrintBeforeTwoHours = chkPrintBeforeTwoHours.Checked
                        }
                    };
                    teamInfo.Rebates = list;
                    if (teamInfo.BasicInfo.Departure.Trim() == "")
                    {
                        RegisterScript("alert('出发地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    if (teamInfo.BasicInfo.VoyageType == VoyageType.TransitWay && teamInfo.BasicInfo.Transit.Trim() == "")
                    {
                        RegisterScript("alert('中转地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    if (teamInfo.BasicInfo.Arrival.Trim() == "")
                    {
                        RegisterScript("alert('到达地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    PolicyManageService.ReleaseTeamPolicies(teamInfo, this.CurrentUser.UserName);
                }
                if (Request.QueryString["Check"] == "view")
                {
                    RegisterScript(
                        type == "Update"
                            ? "alert('修改成功');window.location.href='./team_policy_view.aspx'"
                            : "alert('复制成功');window.location.href='./team_policy_view.aspx'", true);
                }
                else
                {
                    RegisterScript(
                        type == "Update"
                            ? "alert('修改成功');window.location.href='./team_policy_manage.aspx'"
                            : "alert('复制成功');window.location.href='./team_policy_manage.aspx'", true);
                }
            }
            catch (Exception ex)
            {
                ShowExceptionMessage(ex, type == "Update" ? "修改团队政策" : "复制团队政策");
            }
            return(true);
        }