Пример #1
0
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        protected string PageSave(string doType, string id)
        {
            string msg = string.Empty;
            //t为false为编辑,true时为新增
            bool t = String.Equals(doType, "update", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(id) ? false : true;
            //餐馆简介
            string Hotleinfo = Utils.GetFormValue(this.txthotleinfo.UniqueID);
            //国家
            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 address = Utils.GetFormValue(this.txtaddress.UniqueID);
            //菜系编号
            string cuisineid = Utils.GetFormValue(this.CuisineSelect1.CuisineSelectIDClient);
            //餐馆名称
            string HotleName = Utils.GetFormValue(this.txtHotleName.UniqueID).Trim();
            //备注
            string remarks = Utils.GetFormValue(this.txtRemarks.UniqueID);
            //餐标最大价格
            string Pmax = Utils.GetFormValue(this.txtPmax.UniqueID);
            //餐标最小价格
            string Pmin = Utils.GetFormValue(this.txtPmin.UniqueID);
            //合同开始时间
            string StartTime = Utils.GetFormValue(this.txtContractDate_Start.UniqueID);
            //合同终止时间
            string EndTime = Utils.GetFormValue(this.txtContractDate.UniqueID);

            if (String.IsNullOrEmpty(HotleName))
            {
                return(EyouSoft.Common.UtilsCommons.AjaxReturnJson("0", "请填写餐馆名称!"));
            }
            if (string.IsNullOrEmpty(cuisineid))
            {
                return(EyouSoft.Common.UtilsCommons.AjaxReturnJson("0", "请选择菜系!"));
            }
            EyouSoft.Model.SourceStructure.MSourceDining mDining = new EyouSoft.Model.SourceStructure.MSourceDining();
            EyouSoft.Model.SourceStructure.MSource       msource = new EyouSoft.Model.SourceStructure.MSource();
            if (!string.IsNullOrEmpty(id))
            {
                mDining = new EyouSoft.BLL.SourceStructure.BSource().GetDiningModel(id);
            }
            IList <EyouSoft.Model.SourceStructure.MSourceDiningCuisine> cuisine = new List <EyouSoft.Model.SourceStructure.MSourceDiningCuisine>();

            for (int i = 0; i < cuisineid.Split(',').Length; i++)
            {
                cuisine.Add(new EyouSoft.Model.SourceStructure.MSourceDiningCuisine()
                {
                    Cuisine = (EyouSoft.Model.EnumType.SourceStructure.SourceCuisine)(Utils.GetInt(cuisineid.Split(',')[i]))
                });
            }

            mDining.DiningCuisineList = cuisine;
            if (!string.IsNullOrEmpty(Pmax + Pmin))
            {
                mDining.DiningStandard = Pmin + "元-" + Pmax + "元";
            }
            else
            {
                mDining.DiningStandard = "";
            }
            mDining.LinkManList = Contact1.GetTravelList;
            if (!String.IsNullOrEmpty(id))
            {
                mDining.SourceId = id;
            }
            msource.CompanyId           = this.SiteUserInfo.CompanyId;
            msource.Address             = address;
            msource.ProvinceId          = Utils.GetInt(provice);
            msource.CityId              = Utils.GetInt(city);
            msource.CountyId            = Utils.GetInt(area);
            msource.CountryId           = Utils.GetInt(country);
            msource.Desc                = Hotleinfo;
            msource.Remark              = remarks;
            msource.LastModifierId      = this.SiteUserInfo.Name;
            msource.LastModifyTime      = DateTime.Now;
            msource.ContractPeriodStart = Utils.GetDateTimeNullable(StartTime);
            msource.ContractPeriodEnd   = Utils.GetDateTimeNullable(EndTime);
            msource.OperatorId          = this.SiteUserInfo.UserId;
            msource.IssueTime           = DateTime.Now;
            //合同附件(新)
            string[] visaUpload    = Utils.GetFormValues(this.UploadControl1.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;
                        }
                    }
                }
            }


            #endregion
            msource.ContractAttach = visaModel;
            msource.IsCommission   = true;
            //是否签单
            msource.IsPermission = false;
            if (RadSign_yes.Checked)
            {
                msource.IsPermission = true;
            }
            //是否返佣
            msource.IsCommission = false;
            if (radyes.Checked)
            {
                msource.IsCommission = true;
            }
            //是否推荐
            msource.IsRecommend = false;
            if (RadRecommend_yes.Checked)
            {
                msource.IsRecommend = true;
            }
            //是否签订合同
            msource.IsSignContract = false;
            if (Radio_hd_yes.Checked)
            {
                msource.IsSignContract = true;
                msource.ContractCode   = Utils.GetFormValue(this.txtContractNum.UniqueID);
            }
            msource.Name        = HotleName;
            mDining.SourceModel = msource;
            mDining.LinkManList = UtilsCommons.GetDataList();

            EyouSoft.BLL.SourceStructure.BSource bllsource = new EyouSoft.BLL.SourceStructure.BSource();
            int result = 0;
            if (t)
            {//新增
                result = bllsource.AddDiningModel(mDining);
                if (result == -1)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"餐馆名称已存在!\"}";
                    return(msg);
                }
                if (result == -2)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"餐馆已存在此菜系!\"}";
                    return(msg);
                }
            }
            else
            { //编辑
                result = bllsource.UpdateDiningModel(mDining);
                if (result == -1)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"餐馆名称已存在!\"}";
                    return(msg);
                }
                if (result == -2)
                {
                    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);
            }
        }