Beispiel #1
0
        public ActionResult AddEnterprise(EnterpriseSocialSecurity model)
        {
            //已存在判断
            bool isExists = _enterpriseService.IsExistsEnterprise(model.EnterpriseName);

            if (isExists)
            {
                ViewBag.Message = "企业名称已存在";
                return(AddEnterprise());
            }

            //ProvinceCode CityCode CountyCode
            string ProvinceName = string.Empty;
            string CityName     = string.Empty;
            string CountyName   = string.Empty;

            #region 将编码变成名称
            string sqlstr = "select * from Region where RegionCode = '{0}'";
            ProvinceName = DbHelper.QuerySingle <Region>(string.Format(sqlstr, model.ProvinceCode)).RegionName;
            CityName     = DbHelper.QuerySingle <Region>(string.Format(sqlstr, model.CityCode)).RegionName;
            CountyName   = DbHelper.QuerySingle <Region>(string.Format(sqlstr, model.CountyCode)).RegionName;
            #endregion

            model.EnterpriseArea = ProvinceName + "|" + CityName + "|" + CountyName;

            //更新其他签约企业  注:满足省份|城市和户口类型  默认的只有一个
            if (model.IsDefault)
            {
                _enterpriseService.UpdateEnterpriseDefault(ProvinceName + "|" + CityName, 0);
            }

            //添加
            bool flag = _enterpriseService.AddEnterprise(model);

            #region 记录日志
            LogService.WriteLogInfo(new Log {
                UserName = HttpContext.User.Identity.Name, Contents = string.Format("新增签约企业:{0}", model.EnterpriseName)
            });
            #endregion

            TempData["Message"] = flag ? "保存成功" : "保存失败";
            return(RedirectToAction("GetEnterpriseList"));
        }