コード例 #1
0
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        protected string PageSave(string doType, string id)
        {
            string msg = string.Empty;

            EyouSoft.BLL.SourceStructure.BSource        Bll        = new EyouSoft.BLL.SourceStructure.BSource();
            EyouSoft.Model.SourceStructure.MSourceHotel modelHotel = new EyouSoft.Model.SourceStructure.MSourceHotel();
            EyouSoft.Model.SourceStructure.MSource      Msource    = new EyouSoft.Model.SourceStructure.MSource();
            modelHotel.SourceModel = new EyouSoft.Model.SourceStructure.MSource();
            //t为false为编辑,true时为新增
            bool t = String.Equals(doType, "update", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(id) ? false : true;

            if (!string.IsNullOrEmpty(id))
            {
                modelHotel = new EyouSoft.BLL.SourceStructure.BSource().GetOneHotelModel(id);
            }
            //酒店图片
            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);
                    }
                }
            }
            modelHotel.AttachList = imglist;
            #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 (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;
                }
            }
            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;
                        }
                    }
                }
            }

            Msource.ContractAttach = visaModel;
            #endregion



            //if (!String.IsNullOrEmpty(newFilePath))
            //{
            //    modelHotel.SourceModel.ContractAttach = new MComAttach() { FilePath = newFilePath, Name = newFileName };
            //}
            //else
            //{
            //    if (String.IsNullOrEmpty(this.Agreement.Value))
            //    {
            //        modelHotel.SourceModel.ContractAttach = new MComAttach() { FilePath = "", Name = "" };
            //    }
            //}
            Msource.ContractPeriodStart = String.IsNullOrEmpty(Utils.GetFormValue(this.txtContractDate_Start.UniqueID)) ? null : (DateTime?)DateTime.Parse(Utils.GetFormValue(this.txtContractDate_Start.UniqueID));
            Msource.ContractPeriodEnd   = String.IsNullOrEmpty(Utils.GetFormValue(this.txtContractDate.UniqueID)) ? null : (DateTime?)DateTime.Parse(Utils.GetFormValue(this.txtContractDate.UniqueID));

            modelHotel.ReceptionTel  = Utils.GetFormValue(txtTel.UniqueID);
            modelHotel.AttachList    = imglist;
            modelHotel.HotelRoomList = GetDataList();
            modelHotel.LinkManList   = UtilsCommons.GetDataList();
            //是否签单
            Msource.IsPermission = false;
            if (radyes.Checked)
            {
                Msource.IsPermission = true;
            }
            Msource.CompanyId = this.SiteUserInfo.CompanyId;

            Msource.IssueTime = DateTime.Now;
            //是否返佣
            Msource.IsCommission = false;
            if (RadioButton1.Checked)
            {
                Msource.IsCommission = true;
            }
            //是否推荐
            Msource.IsRecommend = false;
            if (radRecommendyes.Checked)
            {
                Msource.IsRecommend = true;
            }
            //是否签订合同
            Msource.IsSignContract = false;
            if (Radio_hd_yes.Checked)
            {
                Msource.IsSignContract = true;
                Msource.ContractCode   = Utils.GetFormValue(this.txtContractNum.UniqueID);
            }
            Msource.LastModifierId = this.SiteUserInfo.Name;
            Msource.LastModifyTime = DateTime.Now;
            Msource.Address        = Utils.GetFormValue(this.txtaddress.UniqueID);
            Msource.Desc           = txtHotelDesc.Text;
            Msource.CountryId      = Utils.GetInt(Utils.GetFormValue(this.ddlCountry.UniqueID));
            Msource.ProvinceId     = Utils.GetInt(Utils.GetFormValue(this.ddlProvice.UniqueID));
            Msource.CityId         = Utils.GetInt(Utils.GetFormValue(this.ddlCity.UniqueID));
            Msource.CountyId       = Utils.GetInt(Utils.GetFormValue(this.ddlArea.UniqueID));
            Msource.Name           = Utils.GetFormValue(txtHotelName.UniqueID).Trim();
            Msource.Remark         = Utils.GetFormValue(txtRemarks.UniqueID);
            Msource.OperatorId     = this.SiteUserInfo.UserId;
            modelHotel.Star        = (EyouSoft.Model.EnumType.SourceStructure.HotelStar)Utils.GetInt(Utils.GetFormValue(this.StarValue.UniqueID));
            if (!String.IsNullOrEmpty(id))
            {
                modelHotel.SourceId = id;
            }
            modelHotel.SourceModel = Msource;
            int result = 0;
            if (t)
            {//新增
                result = Bll.AddHotelModel(modelHotel);
                if (result == -1)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"酒店名称已存在!\"}";
                    return(msg);
                }
                if (result == -2)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"该酒店已经存在相同的酒店房型!\"}";
                    return(msg);
                }
                if (result == -3)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"已经存在相同的附件!\"}";
                    return(msg);
                }
            }
            else
            { //编辑
                result = Bll.UpdateHotelModel(modelHotel);
                if (result == -1)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"酒店名称已存在!\"}";
                    return(msg);
                }
                if (result == -2)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"该酒店已经存在相同的酒店房型!\"}";
                    return(msg);
                }
                if (result == -3)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"已经存在相同的附件!\"}";
                    return(msg);
                }
            }
            string type = t ? "新增" : "修改";
            if (result > 0)
            {
                msg = "{\"result\":\"1\",\"msg\":\"" + type + "成功!\"}";
                return(msg);
            }
            else
            {
                msg = "{\"result\":\"0\",\"msg\":\"" + type + "失败!\"}";
                return(msg);
            }
        }