Пример #1
0
        /// <summary>
        /// 保存按钮点击事件执行方法
        /// </summary>
        protected string PageSave(string doType, string id)
        {
            string msg = string.Empty;

            if (String.IsNullOrEmpty(Utils.GetFormValue(txtteamName.UniqueID)))
            {
                msg = "{\"result\":\"0\",\"msg\":\"车队名称不能为空!\"}";
                return(msg);
            }
            //t为false为编辑,true时为新增
            bool t = String.Equals(doType, "update", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(id) ? false : true;

            EyouSoft.BLL.SourceStructure.BSource Bll = new EyouSoft.BLL.SourceStructure.BSource();
            MSourceMotorcade model = new MSourceMotorcade();

            EyouSoft.Model.SourceStructure.MSource            mModel  = new EyouSoft.Model.SourceStructure.MSource();
            IList <EyouSoft.Model.SourceStructure.MSourceCar> carlist = GetDataList();

            if (!string.IsNullOrEmpty(Utils.GetQueryStringValue("id")))
            {
                model = new EyouSoft.BLL.SourceStructure.BSource().GetMotorcadeModel(Utils.GetQueryStringValue("id"));
            }
            //合同附件(新)
            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

            mModel.ContractAttach                 = visaModel;
            mModel.Name                           = Utils.GetFormValue(txtteamName.UniqueID).Trim();
            mModel.Remark                         = Utils.GetFormValue(txtRemark.UniqueID);
            mModel.Address                        = Utils.GetFormValue(this.address.UniqueID);
            model.SourceModel                     = mModel;
            model.SourceModel.CountryId           = Utils.GetInt(Utils.GetFormValue(this.ddlCountry.UniqueID));
            model.SourceModel.ProvinceId          = Utils.GetInt(Utils.GetFormValue(this.ddlProvice.UniqueID));
            model.SourceModel.CityId              = Utils.GetInt(Utils.GetFormValue(this.ddlCity.UniqueID));
            model.SourceModel.CountyId            = Utils.GetInt(Utils.GetFormValue(this.ddlArea.UniqueID));
            model.SourceModel.LastModifierId      = this.SiteUserInfo.Name;
            model.SourceModel.LastModifyTime      = DateTime.Now;
            model.SourceModel.ContractPeriodStart = EyouSoft.Common.Utils.GetDateTimeNullable(Utils.GetFormValue(txtContractDate_Start.UniqueID));
            model.SourceModel.ContractPeriodEnd   = EyouSoft.Common.Utils.GetDateTimeNullable(Utils.GetFormValue(txtContractDate.UniqueID));
            //获取车辆信息
            model.CarList = carlist;
            //获取联系人信息
            model.LinkManList           = UtilsCommons.GetDataList();
            model.SourceModel.CompanyId = this.SiteUserInfo.CompanyId;
            model.SourceModel.IssueTime = DateTime.Now;
            if (!String.IsNullOrEmpty(id))
            {
                model.SourceModel.SourceId = id;
            }
            //是否返佣
            model.SourceModel.IsCommission = false;
            if (this.RadioButton1.Checked)
            {
                model.SourceModel.IsCommission = true;
            }
            //是否签单
            model.SourceModel.IsPermission = false;
            if (this.radyes.Checked)
            {
                model.SourceModel.IsPermission = true;
            }
            //是否推荐
            model.SourceModel.IsRecommend = false;
            if (radRecommendyes.Checked)
            {
                model.SourceModel.IsRecommend = true;
            }
            //是否签订合同
            model.SourceModel.IsSignContract = false;
            if (Radio_hd_yes.Checked)
            {
                model.SourceModel.IsSignContract = true;
                model.SourceModel.ContractCode   = Utils.GetFormValue(this.txtContractNum.UniqueID);
            }

            model.SourceModel.OperatorId = this.SiteUserInfo.UserId;
            int result = 0;
            if (t)
            {//新增
                result = Bll.AddMotorcadeModel(model);
                if (result == -1)
                {
                    msg = "{\"result\":\"0\",\"msg\":\"车辆名已存在!\"}";
                    return(msg);
                }
            }
            else
            { //编辑
                result = Bll.UpdateMotorcadeModel(model);
                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);
            }
        }