Exemple #1
0
        /// <summary>
        /// 保存
        /// </summary>
        private void Save(string Operating)
        {
            /*
             * 初始化保存Model
             * 当存在线路Id获取原线路实体
             * 否则实例化一个新的线路实体
             */
            MRoute model = Utils.GetQueryStringValue("routeId").Length > 0 ?
                           EyouSoft.BLL.NewTourStructure.BRoute.CreateInstance().GetModel(Utils.GetQueryStringValue("routeId"))
                :
                           new MRoute();

            //确保原线路实体不为空
            if (model != null)
            {
                #region 实体赋值
                //写死
                model.B2BOrder = 50;
                model.B2COrder = 50;
                //线路类型
                model.RouteType = (AreaType)Utils.GetInt(Utils.GetQueryStringValue("travelRangeType"));
                #region 主要浏览
                if (model.RouteType == AreaType.国际线)
                {
                    #region 主要浏览国家
                    //主要浏览国家信息
                    string[] browseCountryControl = Utils.GetFormValue(hd_BrowseCountrys.UniqueID).Split(',');
                    if (browseCountryControl.Length > 0)
                    {
                        //主要浏览国家
                        model.BrowseCountrys = new List <MBrowseCountryControl>();
                        //主要浏览国家个数
                        int i = browseCountryControl.Length;
                        //主要浏览国家签证信息
                        string qzArr = Utils.GetFormValue(hd_qz.UniqueID);
                        //递减遍历
                        while (i-- > 0)
                        {
                            //国家实体
                            MBrowseCountryControl browseCityControlModel = new MBrowseCountryControl();
                            //国家id
                            browseCityControlModel.CountryId = Utils.GetInt(browseCountryControl[i]);

                            //免签没有选择,才给其他赋值,否则直接不赋值
                            if (!chk_null.Checked)
                            {
                                //判断是否签证
                                if (qzArr.IndexOf(browseCountryControl[i] + ",") >= 0)
                                {
                                    browseCityControlModel.IsVisa = true;
                                }
                            }

                            model.BrowseCountrys.Add(browseCityControlModel);
                        }
                    }
                    else
                    {
                        model.BrowseCountrys = null;
                    }
                    //是否免签
                    if (chk_null.Checked)
                    {
                        model.IsNotVisa = true;
                    }
                    else
                    {
                        model.IsNotVisa = false;
                    }
                    //国际线路成人定金
                    model.AdultPrice = Utils.GetDecimal(Utils.GetFormValue(txt_AdultDeposit.UniqueID), -1);
                    //国际线路儿童定金
                    model.ChildrenPrice = Utils.GetDecimal(Utils.GetFormValue(txt_ChildrenDeposit.UniqueID), -1);
                    #endregion
                }
                else
                {
                    #region 主要浏览城市
                    string[] browseCitys = Utils.GetFormValue(hd_BrowseCitys.UniqueID).Split(',');
                    int      i           = browseCitys.Length;
                    if (i > 0)
                    {
                        //主要浏览城市
                        IList <MBrowseCityControl> browseCityControl = new List <MBrowseCityControl>();


                        while (i-- > 0)
                        {
                            MBrowseCityControl browseCityControlModel = new MBrowseCityControl();
                            //拆分城市县
                            int[] array = Utils.StringArrToIntArr(browseCitys[i].Split('|'));
                            if (array.Length > 1)
                            {
                                //县Id
                                browseCityControlModel.CountyId = array[0];
                                //城市Id
                                browseCityControlModel.CityId = array[1];
                            }
                            else
                            {
                                //城市Id
                                browseCityControlModel.CityId = Utils.GetInt(browseCitys[i]);
                            }

                            browseCityControl.Add(browseCityControlModel);
                        }
                        model.BrowseCitys = browseCityControl;
                    }
                    else
                    {
                        model.BrowseCitys = null;
                    }
                    #endregion
                }
                #endregion
                //公司编号
                model.Publishers = SiteUserInfo.CompanyID;
                //发布人ID
                model.OperatorId = SiteUserInfo.ID;
                //发布人名称
                model.OperatorName = SiteUserInfo.CompanyName;
                //专线类型
                model.AreaId = Utils.GetInt(Utils.GetQueryStringValue("travelRangeId"));
                //线路名称
                model.RouteName = Utils.GetFormValue(txt_LineName.UniqueID);
                //推荐类型
                model.RecommendType = (RecommendType)Utils.GetInt(Utils.GetFormValue(ddl_Status.UniqueID));
                //出发交通
                model.StartTraffic = (TrafficType)Utils.GetInt(Utils.GetFormValue(ddl_DepartureTraffic.UniqueID));
                //返回交通
                model.EndTraffic = (TrafficType)Utils.GetInt(Utils.GetFormValue(ddl_ReturnTraffic.UniqueID));
                //出发城市
                string[] sCity = Utils.GetFormValue(hd_goCity.UniqueID).Split('|');
                model.StartCity     = Utils.GetInt(sCity[0]);
                model.StartCityName = sCity[1];
                //返回城市
                string[] eCity = Utils.GetFormValue(hd_returnCity.UniqueID).Split('|');
                model.EndCity     = Utils.GetInt(eCity[0]);
                model.EndCityName = eCity[1];
                //线路特色
                model.Characteristic = Utils.GetFormValue(txt_LineFeatures.UniqueID);
                //最小成团人数
                model.GroupNum = Utils.GetInt(Utils.GetFormValue(txt_MinNumberPeople.UniqueID));
                //团队参考价格
                model.IndependentGroupPrice = Utils.GetDecimal(Utils.GetFormValue(txt_ReferencePrice.UniqueID));
                //天数
                model.Day = Utils.GetInt(Utils.GetFormValue(txt_days.UniqueID));
                //夜数
                model.Late = Utils.GetInt(Utils.GetFormValue(txt_nights.UniqueID));
                //线路主题
                model.Themes = GetTheme();
                //提前几天报名
                model.AdvanceDayRegistration = Utils.GetInt(Utils.GetFormValue(txt_EarlyDays.UniqueID));
                //散客报名无需成团,铁定发团
                model.IsCertain = Utils.GetFormValue(chk_FITRegistration.UniqueID) == "true";
                //报价包含
                string fITOrTeam = Utils.GetFormValue("hd_FITOrTeam").Trim();
                //线路配图
                string[] imgs = Utils.GetFormValue(this.files.UniqueID + "$hidFileName").Split('|');
                if (imgs != null && imgs.Count() > 1)
                {
                    model.RouteImg  = imgs[0];
                    model.RouteImg1 = imgs[1];
                    model.RouteImg2 = imgs[1];
                }
                //model.RouteImg = Utils.GetFormValue(this.files.UniqueID + "$hidFileName").Length > 0 ? Utils.GetFormValue(this.files.UniqueID + "$hidFileName") : model.RouteImg == null ? string.Empty : model.RouteImg;
                //实例化
                model.ServiceStandard = new MServiceStandard();
                #region 行程
                if (fITOrTeam == "FIT")
                {
                    string strTmp = Utils.GetFormValue(txt_FIT.UniqueID);
                    model.FitQuotation = string.IsNullOrEmpty(strTmp)
                                             ? string.Empty
                                             : strTmp;
                    /*清空标准版原有信息*/
                    //用车
                    model.ServiceStandard.CarContent = string.Empty;
                    //其他包含
                    model.ServiceStandard.IncludeOtherContent = string.Empty;
                    //用餐
                    model.ServiceStandard.DinnerContent = string.Empty;
                    //导游
                    model.ServiceStandard.GuideContent = string.Empty;
                    //住宿
                    model.ServiceStandard.ResideContent = string.Empty;
                    //景点
                    model.ServiceStandard.SightContent = string.Empty;
                    //往返交通
                    model.ServiceStandard.TrafficContent = string.Empty;
                    /***********************************************************/
                }
                else
                {
                    /*清空简易版原有信息*/
                    model.FitQuotation = string.Empty;
                    /************************************************************/
                    //用车
                    model.ServiceStandard.CarContent = Utils.GetFormValue("txt_car");
                    //其他包含
                    model.ServiceStandard.IncludeOtherContent = Utils.GetFormValue("txt_qt");
                    //用餐
                    model.ServiceStandard.DinnerContent = Utils.GetFormValue("txt_yc");
                    //导游
                    model.ServiceStandard.GuideContent = Utils.GetFormValue("txt_dy");
                    //住宿
                    model.ServiceStandard.ResideContent = Utils.GetFormValue("txt_zs");
                    //景点
                    model.ServiceStandard.SightContent = Utils.GetFormValue("txt_jd");
                    //往返交通
                    model.ServiceStandard.TrafficContent = Utils.GetFormValue("txt_fhjt");
                }
                #endregion
                //报价不包含
                model.ServiceStandard.NotContainService = Utils.GetFormValue(txt_PriceExcluding.UniqueID);
                //赠送项目
                model.ServiceStandard.GiftInfo = Utils.GetFormValue(txt_GiftItems.UniqueID);
                //儿童及其他安排
                model.ServiceStandard.ChildrenInfo = Utils.GetFormValue(txt_OtherArr.UniqueID);
                //购物安排
                model.ServiceStandard.ShoppingInfo = Utils.GetFormValue(txt_ShoppingArr.UniqueID);
                //自费项目
                model.ServiceStandard.ExpenseItem = Utils.GetFormValue(txt_ThisConsumption.UniqueID);
                //销售商须知(只有组团社用到)
                model.VendorsNotes = Utils.GetFormValue(txt_Notes.UniqueID);
                //备注
                model.ServiceStandard.Notes = Utils.GetFormValue(txt_Remarks.UniqueID);
                //销售区域
                if (routeSource == RouteSource.专线商添加 || model.RouteSource == RouteSource.专线商添加)
                {
                    model.Citys = GetSalesArea();
                }
                #endregion
                IRoute bll = EyouSoft.BLL.NewTourStructure.BRoute.CreateInstance();
                //行程类型
                string travelType = Utils.GetFormValue("hd_TravelContent").Trim();

                /*
                 * 操作结果变量
                 * >0=保存成功的线路Id,空字符串=保存失败,-2线路名已存在
                 */
                string isSave = "-1";
                //添加
                if (Operating == "AddSave")
                {
                    #region 添加
                    if (travelType == "SAE")
                    {
                        #region 行程简易版
                        model.FastPlan = Utils.EditInputText(Request.Form[txt_AddTourismBriefnessTravel.UniqueID] ?? string.Empty);
                        if ((RouteSource)Utils.GetInt(Utils.GetQueryStringValue("RouteSource"), 1) == RouteSource.专线商添加)
                        {
                            //专线添加
                            isSave = (!bll.IsExits(SiteUserInfo.CompanyID, model.RouteName)) ? bll.AddQuickRoute(model) : "-2";
                        }
                        else
                        {
                            //地接添加
                            isSave = (!bll.IsExits(SiteUserInfo.CompanyID, model.RouteName)) ? bll.AddGroundQuickRoute(model) : "-2";
                        }
                        #endregion
                    }
                    else
                    {
                        #region 行程内容标准
                        model.StandardPlans = GetTravel();
                        if ((RouteSource)Utils.GetInt(Utils.GetQueryStringValue("RouteSource"), 1) == RouteSource.专线商添加)
                        {
                            //专线添加
                            isSave = (!bll.IsExits(SiteUserInfo.CompanyID, model.RouteName)) ? bll.AddStandardRoute(model) : "-2";
                        }
                        else
                        {
                            //地接添加
                            isSave = (!bll.IsExits(SiteUserInfo.CompanyID, model.RouteName)) ? bll.AddGroundStandardRoute(model) : "-2";
                        }
                        #endregion
                    }
                    #endregion
                }
                else
                {
                    #region 修改
                    if (travelType == "SAE")
                    {
                        #region 行程简易版
                        model.ReleaseType = ReleaseType.Quick;
                        //清除原先标准版数据
                        model.StandardPlans = null;
                        model.FastPlan      = Utils.EditInputText(
                            Request.Form[txt_AddTourismBriefnessTravel.UniqueID] != null
                            &&
                            Request.Form[txt_AddTourismBriefnessTravel.UniqueID].ToString().Length > 0 ?
                            Request.Form[txt_AddTourismBriefnessTravel.UniqueID] :
                            string.Empty);
                        #endregion
                    }
                    else
                    {
                        #region 行程标准版
                        model.ReleaseType = ReleaseType.Standard;
                        //清除原先简易版数据
                        model.FastPlan      = string.Empty;
                        model.StandardPlans = GetTravel();
                        #endregion
                    }
                    #endregion
                    isSave = bll.UpdateRoute(model) ? model.RouteId : "-2";
                }
                Response.Clear();
                Response.Write(isSave.ToString());
                Response.End();
            }
            Response.Clear();
            Response.Write("");
            Response.End();
        }