Ejemplo n.º 1
0
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        protected string PageSave(string doType, string id)
        {
            #region 获取表单值
            string msg = string.Empty;
            //t为false为编辑,true时为新增
            bool t = String.Equals(doType, "update", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(id) ? false : true;
            //国家
            string country = Utils.GetFormValue(this.ddlCountry.UniqueID);
            //省份
            string provice = Utils.GetFormValue(this.ddlProvice.UniqueID);
            //城市
            string city = Utils.GetFormValue(this.ddlCity.UniqueID);
            //县区
            string area = Utils.GetFormValue(this.ddlArea.UniqueID);
            //政策
            string Policy = Utils.GetFormValue(this.txtPolicy.UniqueID);
            //合同开始时间
            string ContractStartDate = Utils.GetFormValue(this.txtContractDate_Start.UniqueID);
            //合同有到期时间
            string ContractDate = Utils.GetFormValue(this.txtContractDate.UniqueID);
            //景点名称
            string scenicName = Utils.GetFormValue(this.txtUnitName.UniqueID);
            //合同号
            string ContractNum = Utils.GetFormValue(this.txtContractNum.UniqueID);

            if (String.IsNullOrEmpty(scenicName))
            {
                msg = UtilsCommons.AjaxReturnJson("0", "单位名称不能为空");
                return(msg);
            }
            #endregion

            //景点图片
            string[] imgUpload    = Utils.GetFormValues(this.UploadControl1.ClientHideID);
            string[] oldimgUpload = Utils.GetFormValues("hideimg");
            #region 景点图片上传
            IList <EyouSoft.Model.ComStructure.MComAttach> imglist = null;
            if (imgUpload.Length > 0)
            {
                imglist = new List <EyouSoft.Model.ComStructure.MComAttach>();
                for (int i = 0; i < imgUpload.Length; i++)
                {
                    if (imgUpload[i].Trim() != "")
                    {
                        if (imgUpload[i].Split('|').Length > 1)
                        {
                            EyouSoft.Model.ComStructure.MComAttach imgModel = new EyouSoft.Model.ComStructure.MComAttach();
                            imgModel.Downloads = 0;
                            imgModel.FilePath  = imgUpload[i].Split('|')[1];
                            imgModel.ItemType  = EyouSoft.Model.EnumType.ComStructure.AttachItemType.供应商;
                            imgModel.Name      = imgUpload[i].Split('|')[0];
                            imgModel.Size      = 0;
                            imglist.Add(imgModel);
                        }
                    }
                }
            }
            if (oldimgUpload.Length > 0)
            {
                if (imglist == null)
                {
                    imglist = new List <EyouSoft.Model.ComStructure.MComAttach>();
                }
                for (int i = 0; i < oldimgUpload.Length; i++)
                {
                    if (oldimgUpload[i].Trim() != "")
                    {
                        EyouSoft.Model.ComStructure.MComAttach imgModel = new EyouSoft.Model.ComStructure.MComAttach();
                        imgModel.FilePath = oldimgUpload[i].Split('|')[1];
                        imgModel.ItemType = EyouSoft.Model.EnumType.ComStructure.AttachItemType.供应商;
                        imgModel.Name     = oldimgUpload[i].Split('|')[0];
                        imgModel.Size     = 0;
                        imglist.Add(imgModel);
                    }
                }
            }
            #endregion

            //合同附件
            //合同附件(新)
            string[] visaUpload    = Utils.GetFormValues(this.UploadControl2.ClientHideID);
            string[] oldVisaUpload = Utils.GetFormValues("hideFileInfo");
            #region 合同附件
            EyouSoft.Model.ComStructure.MComAttach visaModel = new EyouSoft.Model.ComStructure.MComAttach();

            if (visaUpload.Length > 0)
            {
                for (int i = 0; i < visaUpload.Length; i++)
                {
                    if (visaUpload[i].Trim() != "")
                    {
                        if (visaUpload[i].Split('|').Length > 1)
                        {
                            visaModel.Downloads = 0;
                            visaModel.FilePath  = visaUpload[i].Split('|')[1];
                            visaModel.ItemType  = EyouSoft.Model.EnumType.ComStructure.AttachItemType.供应商合同附件;
                            visaModel.Name      = visaUpload[i].Split('|')[0];
                            visaModel.Size      = 0;
                        }
                    }
                }
            }

            if (oldVisaUpload.Length > 0)
            {
                for (int i = 0; i < oldVisaUpload.Length; i++)
                {
                    visaModel.FilePath = oldVisaUpload[i].Split('|')[1];
                    visaModel.ItemType = EyouSoft.Model.EnumType.ComStructure.AttachItemType.供应商合同附件;
                    visaModel.Name     = oldVisaUpload[i].Split('|')[0];
                    visaModel.Size     = 0;
                }
            }
            #endregion

            #region 景区实体赋值
            EyouSoft.Model.SourceStructure.MSourceSpot Model  = new EyouSoft.Model.SourceStructure.MSourceSpot();
            EyouSoft.Model.SourceStructure.MSource     source = new EyouSoft.Model.SourceStructure.MSource();

            if (!string.IsNullOrEmpty(id))
            {
                //Model = new EyouSoft.BLL.SourceStructure.BSource().GetSpotModel(id);

                source.SourceId = id;
            }

            Model.AttachList      = imglist;
            source.ContractAttach = visaModel;
            source.CountryId      = Utils.GetInt(country);
            source.CityId         = Utils.GetInt(city);
            source.ProvinceId     = Utils.GetInt(provice);
            source.CountyId       = Utils.GetInt(area);
            source.UnitPolicy     = Policy;
            source.OperatorId     = this.SiteUserInfo.UserId;
            source.DeptId         = this.SiteUserInfo.DeptId;
            source.IssueTime      = DateTime.Now;
            source.CompanyId      = this.SiteUserInfo.CompanyId;
            //返佣
            source.IsCommission = false;
            if (radyes.Checked)
            {
                source.IsCommission = true;
            }
            //返单
            source.IsBackSingle = false;
            if (radBackSingleyes.Checked)
            {
                source.IsBackSingle = true;
            }
            //签单
            source.IsPermission = false;
            if (RadSign_yes.Checked)
            {
                source.IsPermission = true;
            }
            //推荐
            source.IsRecommend = false;
            if (RadRecommend_yes.Checked)
            {
                source.IsRecommend = true;
            }
            //合同
            source.IsSignContract = false;
            if (Radio_hd_yes.Checked)
            {
                source.IsSignContract = true;
                source.ContractCode   = ContractNum;
            }
            source.Name = scenicName.Trim();
            source.ContractPeriodEnd   = string.IsNullOrEmpty(ContractDate) ? null : (DateTime?)DateTime.Parse(ContractDate);
            source.ContractPeriodStart = string.IsNullOrEmpty(ContractStartDate) ? null : (DateTime?)DateTime.Parse(ContractStartDate);
            source.LastModifierId      = this.SiteUserInfo.Name;
            source.LastModifyTime      = DateTime.Now;
            //Model.Star = (EyouSoft.Model.EnumType.SourceStructure.SpotStar)int.Parse(ddlstar.SelectedValue);
            Model.SourceModel     = source;
            Model.LinkManList     = UtilsCommons.GetDataList();
            Model.PriceSystemList = GetSpotList();
            #endregion

            #region 执行保存(新增,修改)操作,并返回结果
            EyouSoft.BLL.SourceStructure.BSource bllsource = new EyouSoft.BLL.SourceStructure.BSource();
            int result = 0;
            if (t)
            {//新增
                result = bllsource.AddSpotModel(Model);
                if (result == -1)
                {
                    msg = UtilsCommons.AjaxReturnJson("0", "景点名称已存在");
                    return(msg);
                }
                if (result == -2)
                {
                    msg = UtilsCommons.AjaxReturnJson("0", "该附件已存在");
                    return(msg);
                }
            }
            else
            { //编辑
                result = bllsource.UpdateSpotModel(Model);
                if (result == -1)
                {
                    msg = UtilsCommons.AjaxReturnJson("0", "景点名称已存在");
                    return(msg);
                }
                if (result == -2)
                {
                    msg = UtilsCommons.AjaxReturnJson("0", "该附件已存在");
                    return(msg);
                }
            }
            string type = t ? "新增" : "修改";
            if (result > 0)
            {
                msg = UtilsCommons.AjaxReturnJson("1", type + "成功");
                return(msg);
            }
            else
            {
                msg = UtilsCommons.AjaxReturnJson("0", type + "失败");
                return(msg);
            }
            #endregion
        }