コード例 #1
0
        private bool GetNormalValue(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 normals = PolicyManageService.GetNormalPolicy(Guid.Parse(Request.QueryString["Id"]));

            try
            {
                if (type == "Update")
                {
                    var normal = new NormalPolicy
                    {
                        CustomCode       = ddlCustomCode.Visible ? ddlCustomCode.SelectedValue.Trim() : lblCustomerCode.Text,
                        Airline          = lblAirline.Text,
                        OfficeCode       = hidOfficeNo.Value,
                        Arrival          = txtArrivalAirports.AirportsCode.ToList().Join("/"),
                        AutoAudit        = chkAuto.Checked,
                        ChangePNR        = chkChangePNR.Checked,
                        IsInternal       = neibuTh.Visible,
                        IsPeer           = tonghang.Visible,
                        Departure        = txtDepartureAirports.AirportsCode.ToList().Join("/"),
                        Transit          = "",
                        DepartureDateEnd = DateTime.Parse(txtDepartrueEnd.Text),
                        //DepartureDatesFilter = "",
                        DepartureDateStart = DateTime.Parse(txtDepartrueStart.Text),
                        //DepartureDatesFilterType = DateMode.Date,
                        DepartureFlightsFilter     = derpartrueFilghtType == LimitType.None ? "" : txtDepartrueFilght.Text,
                        DepartureFlightsFilterType = derpartrueFilghtType,
                        //ReturnDateStart = normals.ReturnDateStart,
                        //ReturnDateEnd = normals.ReturnDateEnd,
                        Remark          = txtRemark.Text.Replace("\r", "").Replace("\n", ""),
                        DrawerCondition = txtDrawerCondition.Text.Replace("\r", "").Replace("\n", ""),
                        //ReturnDatesFilter = "",
                        ReturnFlightsFilter     = returnFilghtType == LimitType.None ? "" : txtReturnFilght.Text,
                        ReturnFlightsFilterType = returnFilghtType,
                        SuitReduce            = chkRound.Checked,
                        StartPrintDate        = DateTime.Parse(txtProvideDate.Text),
                        DepartureDateFilter   = txtPaiChu.Text,
                        DepartureWeekFilter   = weekStr,
                        SubordinateCommission = decimal.Parse(txtSubordinateCommission.Text) / 100,
                        ProfessionCommission  = decimal.Parse(txtProfessionCommission.Text) / 100,
                        InternalCommission    = decimal.Parse(txtInternalCommission.Text) / 100,
                        MultiSuitReduce       = chkddlc.Checked,
                        //Vip = 0,
                        ExceptAirways = txtExceptAirways.Text,
                        //TravelDays = 0,
                        TicketType = chkTicket.Text == "B2B" ? TicketType.B2B : TicketType.BSP,
                        Berths     = hidBunks.Value,
                        VoyageType = voyage,
                        //ReturnDatesFilterType = DateMode.Date,
                        ImpowerOffice       = Convert.ToBoolean(dropOffice.SelectedValue),
                        Audited             = normals.Audited,
                        AuditTime           = normals.AuditTime,
                        AutoPrint           = normals.AutoPrint,
                        CreateTime          = normals.CreateTime,
                        Creator             = normals.Creator,
                        Freezed             = normals.Freezed,
                        Owner               = normals.Owner,
                        Suspended           = normals.Suspended,
                        PrintBeforeTwoHours = chkPrintBeforeTwoHours.Checked,
                        Id = Guid.Parse(Request.QueryString["Id"])
                    };
                    if (zhongzhuanTh.Visible)
                    {
                        normal.Transit = txtArrivalAirports.AirportsCode.Join("/");
                        normal.Arrival = txtZhongzhuanAirports.AirportsCode.Join("/");
                    }
                    if (normal.Departure.Trim() == "")
                    {
                        RegisterScript("alert('出发地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    if (normal.VoyageType == VoyageType.TransitWay && normal.Transit.Trim() == "")
                    {
                        RegisterScript("alert('中转地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    if (normal.Arrival.Trim() == "")
                    {
                        RegisterScript("alert('到达地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    PolicyManageService.UpdateNormalPolicy(normal, this.CurrentUser.UserName);
                }
                if (type == "Copy")
                {
                    var normalInfo = new NormalPolicyReleaseInfo
                    {
                        BasicInfo = new NormalPolicyBasicInfo
                        {
                            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("/"),
                            //DepartureDatesFilter = "",
                            //DepartureDatesFilterType = DateMode.Date,
                            DepartureFlightsFilter     = derpartrueFilghtType == LimitType.None ? "" : txtDepartrueFilght.Text,
                            DepartureFlightsFilterType = derpartrueFilghtType,
                            Remark          = txtRemark.Text.Replace("\r", "").Replace("\n", ""),
                            DrawerCondition = txtDrawerCondition.Text.Replace("\r", "").Replace("\n", ""),
                            //ReturnDatesFilter = "",
                            ReturnFlightsFilter     = returnFilghtType == LimitType.None ? "" : txtReturnFilght.Text,
                            ReturnFlightsFilterType = returnFilghtType,
                            ExceptAirways           = txtExceptAirways.Text,
                            //TravelDays = 0,
                            VoyageType = voyage,
                            //ReturnDatesFilterType = DateMode.Date,
                            OfficeCode    = hidOfficeNo.Value,
                            ImpowerOffice = Convert.ToBoolean(dropOffice.SelectedValue),
                            Owner         = this.CurrentUser.Owner
                        }
                    }; if (zhongzhuanTh.Visible)
                    {
                        normalInfo.BasicInfo.Transit = txtArrivalAirports.AirportsCode.Join("/");
                        normalInfo.BasicInfo.Arrival = txtZhongzhuanAirports.AirportsCode.Join("/");
                    }
                    var list = new List <NormalPolicyRebateInfo>
                    {
                        new NormalPolicyRebateInfo
                        {
                            DepartureDateFilter = txtPaiChu.Text,
                            DepartureWeekFilter = weekStr,
                            AutoAudit           = chkAuto.Checked,
                            ChangePNR           = chkChangePNR.Checked,
                            DepartureDateEnd    = DateTime.Parse(txtDepartrueEnd.Text),
                            DepartureDateStart  = DateTime.Parse(txtDepartrueStart.Text),
                            //ReturnDateStart =  normals.ReturnDateStart,
                            //ReturnDateEnd =  normals.ReturnDateEnd,
                            SuitReduce            = chkRound.Checked,
                            StartPrintDate        = DateTime.Parse(txtProvideDate.Text),
                            SubordinateCommission = decimal.Parse(txtSubordinateCommission.Text),
                            ProfessionCommission  = decimal.Parse(txtProfessionCommission.Text),
                            InternalCommission    = decimal.Parse(txtInternalCommission.Text),
                            MultiSuitReduce       = chkddlc.Checked,
                            //Vip = 0,
                            TicketType          = chkTicket.Text == "B2B" ? TicketType.B2B : TicketType.BSP,
                            Berths              = hidBunks.Value,
                            PrintBeforeTwoHours = chkPrintBeforeTwoHours.Checked
                        }
                    };
                    normalInfo.Rebates = list;
                    if (normalInfo.BasicInfo.Departure.Trim() == "")
                    {
                        RegisterScript("alert('出发地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    if (normalInfo.BasicInfo.VoyageType == VoyageType.TransitWay && normalInfo.BasicInfo.Transit.Trim() == "")
                    {
                        RegisterScript("alert('中转地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    if (normalInfo.BasicInfo.Arrival.Trim() == "")
                    {
                        RegisterScript("alert('到达地不能为空,请选择至少一个城市作为出发地!');");
                        return(false);
                    }
                    PolicyManageService.ReleaseNormalPolicies(normalInfo, this.CurrentUser.UserName);
                }
                if (Request.QueryString["Check"] == "view")
                {
                    RegisterScript(
                        type == "Update"
                            ? "alert('修改成功');window.location.href='./base_policy_view.aspx'"
                            : "alert('复制成功');window.location.href='./base_policy_view.aspx'", true);
                }
                else
                {
                    RegisterScript(
                        type == "Update"
                            ? "alert('修改成功');window.location.href='./base_policy_manage.aspx'"
                            : "alert('复制成功');window.location.href='./base_policy_manage.aspx'", true);
                }
            }
            catch (Exception ex)
            {
                ShowExceptionMessage(ex, type == "Update" ? "修改普通政策" : "复制普通政策");
            }
            return(true);
        }