コード例 #1
0
ファイル: GroundEdit.aspx.cs プロジェクト: windygu/XiaZhou
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        private 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;

            //国家
            #region 表单取值
            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 UnitName = Utils.GetFormValue(this.txtUnitName.UniqueID);
            //线路特色
            string Character = Utils.GetFormValue(this.txtCharacter.UniqueID);
            //合同开始时间
            string ContractStartDate = Utils.GetFormValue(this.txtContractDate_Start.UniqueID);
            //合同有到期时间
            string ContractDate = Utils.GetFormValue(this.txtContractDate.UniqueID);
            //合同号
            string ContractNum = Utils.GetFormValue(this.txtContractNum.UniqueID);
            //法人代表
            string LegalName = Utils.GetFormValue(this.txtLegalName.UniqueID);
            //许可证号
            string PermitNum = Utils.GetFormValue(this.txtPermitNum.UniqueID);
            //返佣政策
            string Policy = Utils.GetFormValue(this.txtpolicy.UniqueID);
            //联系电话
            string Tel = Utils.GetFormValue(this.txtTel.UniqueID);
            //合同附件(新)
            string[] visaUpload    = Utils.GetFormValues(this.UploadControl1.ClientHideID);
            string[] oldVisaUpload = Utils.GetFormValues("hideFileInfo");
            #endregion

            EyouSoft.Model.CrmStructure.MCrmLinkman m = new EyouSoft.Model.CrmStructure.MCrmLinkman();
            MComUser mUser = new MComUser();
            IList <EyouSoft.Model.CrmStructure.MCrmLinkman> list = UtilsCommons.GetDataList();
            if (list != null && list.Count > 0)
            {
                mUser.ContactMobile = list[0].MobilePhone;
                mUser.ContactName   = list[0].Name;
                mUser.ContactTel    = list[0].Telephone;
                mUser.QQ            = list[0].QQ;
                m.Post = list[0].Post;
            }
            if (string.IsNullOrEmpty(UnitName))
            {
                msg = "{\"result\":\"0\",\"msg\":\"单位名称不能为空!\"}";
                return(msg);
            }
            EyouSoft.Model.SourceStructure.MSourceTravel mTravel = new EyouSoft.Model.SourceStructure.MSourceTravel();
            if (!string.IsNullOrEmpty(id))
            {
                mTravel = new EyouSoft.BLL.SourceStructure.BSource().GetTravelServiceModel(id);
            }
            EyouSoft.Model.SourceStructure.MSource mModel = new EyouSoft.Model.SourceStructure.MSource();
            mModel.Address      = this.txtaddress.Text;
            mModel.CityId       = Utils.GetInt(Utils.GetFormValue(this.ddlCity.UniqueID));
            mModel.CountryId    = Utils.GetInt(Utils.GetFormValue(this.ddlCountry.UniqueID));
            mModel.CountyId     = Utils.GetInt(Utils.GetFormValue(this.ddlArea.UniqueID));
            mModel.ProvinceId   = Utils.GetInt(Utils.GetFormValue(this.ddlProvice.UniqueID));
            mModel.Name         = Utils.GetFormValue(this.txtUnitName.UniqueID).Trim();
            mModel.CompanyId    = this.SiteUserInfo.CompanyId;
            mModel.OperatorId   = this.SiteUserInfo.UserId;
            mModel.ContractCode = ContractNum;
            mModel.DeptId       = this.SiteUserInfo.DeptId;

            mModel.ContractPeriodStart = String.IsNullOrEmpty(ContractStartDate) ? null : (DateTime?)DateTime.Parse(ContractStartDate);
            mModel.ContractPeriodEnd   = String.IsNullOrEmpty(ContractDate) ? null : (DateTime?)DateTime.Parse(ContractDate);

            //签单
            if (RadSign_no.Checked)
            {
                mModel.IsPermission = false;
            }
            else
            {
                mModel.IsPermission = true;
            }
            //推荐
            if (RadRecommend_no.Checked)
            {
                mModel.IsRecommend = false;
            }
            else
            {
                mModel.IsRecommend = true;
            }
            //返佣
            mModel.IsCommission = true;
            if (radno.Checked)
            {
                mModel.IsCommission = false;
            }
            //合同
            if (Radio_hd_no.Checked)
            {
                mModel.IsSignContract = false;
            }
            else
            {
                mModel.IsSignContract = true;
                mModel.ContractCode   = Utils.GetFormValue(this.txtContractNum.UniqueID);
            }
            mModel.LastModifierId = this.SiteUserInfo.Name;
            mModel.LastModifyTime = DateTime.Now;
            mModel.LicenseKey     = PermitNum;
            mModel.UnitPolicy     = Policy;
            mModel.Desc           = Character;
            mModel.IssueTime      = DateTime.Now;

            if (!String.IsNullOrEmpty(id))
            {
                mModel.SourceId = id;
            }

            #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;
                        }
                    }
                }
            }

            mModel.ContractAttach = visaModel;
            #endregion

            mUser.CompanyId = this.SiteUserInfo.CompanyId;
            //mUser.IsEnable = true;
            mUser.IssueTime = DateTime.Now;
            mUser.UserType  = EyouSoft.Model.EnumType.ComStructure.UserType.供应商;
            MSourceTravelInfo Traveinfo = new MSourceTravelInfo();
            Traveinfo.LegalRepresentative = LegalName;
            Traveinfo.Routes          = Character;
            Traveinfo.Telephone       = Tel;
            mTravel.SourceTravelModel = Traveinfo;
            //mTravel.UserModel = mUser;
            mTravel.SourceModel = mModel;
            mTravel.LinkManList = list;
            //mTravel.SourceTravelModel
            EyouSoft.BLL.SourceStructure.BSource bllsource = new EyouSoft.BLL.SourceStructure.BSource();
            EyouSoft.BLL.ComStructure.BComUser   blluser   = new EyouSoft.BLL.ComStructure.BComUser();

            int result = 0;
            if (t)
            {//新增
                result = bllsource.AddTravelServiceModel(mTravel);
                if (result == -1)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"单位名称已存在!\"}";
                    return(msg);
                }
            }
            else
            { //编辑
                result = bllsource.UpdateTravelServiceModel(mTravel);
                if (result == -1)
                {
                    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);
            }
        }