예제 #1
0
        /// <summary>
        /// 保存执行方法
        /// </summary>
        private string PageSave(string id, string doType)
        {
            string msg = string.Empty;
            //t为false为编辑,true时为新增
            bool   t            = String.Equals(doType, "update", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(id) ? false : true;
            string AdultPrice   = Utils.GetFormValue(txtAdultPrice.UniqueID);    //成人价格
            string ChildPrice   = Utils.GetFormValue(txtChildPrice.UniqueID);    //儿童价格
            string TotalPrice   = Utils.GetFormValue(txtTotalPrice.UniqueID);    //合计价格
            string Collection   = Utils.GetFormValue(txtCollection.UniqueID);    //集合方式
            string DayCount     = Utils.GetFormValue(txtDayCount.UniqueID);      //天数
            string StartTraffic = Utils.GetFormValue(txtStartTraffic.UniqueID);  //出发交通
            string EndTraffic   = Utils.GetFormValue(txtEndTraffic.UniqueID);    //返程交通
            //txtFile 附件
            string OtherPrice = Utils.GetFormValue(txtOtherPrice.UniqueID);      //其他费用
            string PathDesc   = Utils.GetFormValue(txtPathDesc.UniqueID);        //线路描述
            string PathName   = Utils.GetFormValue(txtPathName.UniqueID).Trim(); //线路名称
            string AreaID     = Utils.GetFormValue(HidRouteAreaID.UniqueID);     //线路区域编号
            string StrRemark  = Utils.GetFormValue(txtPathRemark.UniqueID);      //获取价格备注

            if (string.IsNullOrEmpty(PathName))
            {
                msg = UtilsCommons.AjaxReturnJson("0", "请输入线路名称");
                return(msg);
            }
            EyouSoft.Model.SourceStructure.MRoute ModelRoute = new EyouSoft.Model.SourceStructure.MRoute();
            EyouSoft.BLL.SourceStructure.BSource  bll        = new EyouSoft.BLL.SourceStructure.BSource();
            if (!string.IsNullOrEmpty(id) && doType == "update")
            {
                ModelRoute         = bll.GetRouteModel(id);
                ModelRoute.RouteId = id;
                if (string.IsNullOrEmpty(AreaID))
                {
                    AreaID = ModelRoute.AreaId.ToString();
                }
            }
            if (Utils.GetInt(AreaID) == 0)
            {
                msg = UtilsCommons.AjaxReturnJson("0", "请选择线路区域!");
                return(msg);
            }
            //合同附件
            //合同附件(新)
            string[] hdUpload    = Utils.GetFormValues(this.UploadControl1.ClientHideID);
            string[] oldhdUpload = Utils.GetFormValues("hideFileInfo");
            #region 合同附件
            EyouSoft.Model.ComStructure.MComAttach hdModel = new EyouSoft.Model.ComStructure.MComAttach();
            if (oldhdUpload.Length > 0)
            {
                for (int i = 0; i < oldhdUpload.Length; i++)
                {
                    hdModel.FilePath = oldhdUpload[i].Split('|')[1];
                    hdModel.ItemType = EyouSoft.Model.EnumType.ComStructure.AttachItemType.线路附件;
                    hdModel.Name     = oldhdUpload[i].Split('|')[0];
                    hdModel.Size     = 0;
                }
            }
            if (hdUpload.Length > 0)
            {
                for (int i = 0; i < hdUpload.Length; i++)
                {
                    if (hdUpload[i].Trim() != "")
                    {
                        if (hdUpload[i].Split('|').Length > 1)
                        {
                            hdModel.Downloads = 0;
                            hdModel.FilePath  = hdUpload[i].Split('|')[1];
                            hdModel.ItemType  = EyouSoft.Model.EnumType.ComStructure.AttachItemType.线路附件;
                            hdModel.Name      = hdUpload[i].Split('|')[0];
                            hdModel.Size      = 0;
                        }
                    }
                }
            }


            ModelRoute.Attach = hdModel;
            #endregion


            #region 签证附件
            //签证附件(新)
            string[] visaUpload    = Utils.GetFormValues(this.UploadControl2.ClientHideID);
            string[] oldVisaUpload = Utils.GetFormValues("hideVisaFile");
            IList <EyouSoft.Model.ComStructure.MComAttach> visaList = null;
            if (oldVisaUpload.Length > 0)
            {
                if (visaList == null)
                {
                    visaList = new List <EyouSoft.Model.ComStructure.MComAttach>();
                }
                for (int i = 0; i < oldVisaUpload.Length; i++)
                {
                    EyouSoft.Model.ComStructure.MComAttach visaModel = new EyouSoft.Model.ComStructure.MComAttach();
                    visaModel.FilePath = oldVisaUpload[i].Split('|')[1];
                    visaModel.ItemType = EyouSoft.Model.EnumType.ComStructure.AttachItemType.线路签证资料;
                    visaModel.Name     = oldVisaUpload[i].Split('|')[0];
                    visaList.Add(visaModel);
                }
            }
            if (visaUpload.Length > 0)
            {
                if (visaList == null)
                {
                    visaList = new List <EyouSoft.Model.ComStructure.MComAttach>();
                }
                for (int i = 0; i < visaUpload.Length; i++)
                {
                    if (visaUpload[i].Trim() != "")
                    {
                        if (visaUpload[i].Split('|').Length > 1)
                        {
                            EyouSoft.Model.ComStructure.MComAttach visaModel = new EyouSoft.Model.ComStructure.MComAttach();
                            visaModel.FilePath = visaUpload[i].Split('|')[1];
                            visaModel.ItemType = EyouSoft.Model.EnumType.ComStructure.AttachItemType.线路签证资料;
                            visaModel.Name     = visaUpload[i].Split('|')[0];
                            visaList.Add(visaModel);
                        }
                    }
                }
            }
            ModelRoute.VisaInfoList = visaList;
            #endregion
            //对外报价
            ModelRoute.PlanModelList = UtilsCommons.GetPlanList();//行程安排
            #region 线路服务赋值
            string costCalculation = string.Empty;
            EyouSoft.Model.TourStructure.MTourService tourService = UtilsCommons.GetTourService(out costCalculation);
            ModelRoute.ServicesModel = tourService;
            #endregion
            ModelRoute.AdultPrice       = Utils.GetDecimal(AdultPrice);
            ModelRoute.AreaId           = Utils.GetInt(AreaID);
            ModelRoute.ChildrenPrice    = Utils.GetDecimal(ChildPrice);
            ModelRoute.OtherPrice       = Utils.GetDecimal(OtherPrice);
            ModelRoute.CompanyId        = this.SiteUserInfo.CompanyId;
            ModelRoute.Days             = Utils.GetInt(DayCount);
            ModelRoute.DepartureTraffic = StartTraffic;
            ModelRoute.ReturnTraffic    = EndTraffic;
            ModelRoute.SetMode          = Collection;
            ModelRoute.LineIntro        = PathDesc;
            ModelRoute.RouteName        = PathName;
            ModelRoute.PathRemark       = StrRemark;
            ModelRoute.OperatorId       = this.SiteUserInfo.UserId;
            ModelRoute.DeptId           = this.SiteUserInfo.DeptId;
            ModelRoute.IsShare          = true;
            if (radno.Checked)
            {
                ModelRoute.IsShare = false;
            }
            ModelRoute.IssueTime = DateTime.Now;
            #region 对外报价赋值
            ForeignQuote1.IsFromTourOrRoute = false;


            Dictionary <string, object> Standarlist = UtilsCommons.GetServiceType();
            bool IsTourOrSubentry = (bool)Standarlist["IsTourOrSubentry"];
            ModelRoute.IsTourOrSubentry  = IsTourOrSubentry;
            ModelRoute.StandardModelList = new List <EyouSoft.Model.SourceStructure.MRouteStandard>();
            if (IsTourOrSubentry)
            {
                ModelRoute.Service = Standarlist["Service"].ToString();
            }
            else
            {
                ModelRoute.StandardModelList = (IList <EyouSoft.Model.SourceStructure.MRouteStandard>)Standarlist["Service"];
            }
            #endregion
            ModelRoute.TotalPrice = Utils.GetDecimal(TotalPrice);
            int result = 0;
            if (t)
            {
                //返回值 -1:已经存在相同的线路名称 -2;同一个行程已经存在相同的景点 -3:已经存在相同的附件名称 -4:公司编号未赋值 -5:线路必填信息不完善 0:事务回滚 1:正确
                result = bll.AddRouteModel(ModelRoute);
            }
            else
            {
                result = bll.UpdateRouteModel(ModelRoute);
            }
            msg = GetResult(result, t ? "新增" : "修改");
            return(msg);
        }