public ActionResult FaCompanyMgmt(string id)
        {
            if (SessionUserId == 0)
            {
                return(View("../Error/LoginError"));
            }
            string companyNameDisabled = "false";
            string enable = "true";

            if (!string.IsNullOrEmpty(id))
            {
                FaCompany company = _faDocService.GetCompany(long.Parse(id));
                ViewData["companyId"]   = company.Id;
                ViewData["companyName"] = company.Name;
                ViewData["remark"]      = company.Remark;
                if (!company.Enable)
                {
                    enable = "false";
                }
                companyNameDisabled = "true";
            }
            ViewData["enable"] = enable;
            ViewData["companyNameDisabled"] = companyNameDisabled;
            return(View());
        }
Beispiel #2
0
 public void Save(FaCompany entity)
 {
     entity.LastUpdated = DateTime.Now;
     if (entity.Id == 0)
     {
         entity.CreateTime = DateTime.Now;
         DataContext.FaCompanies.InsertOnSubmit(entity);
     }
     DataContext.SubmitChanges();
 }
        public string SaveCompany(FaCompany company)
        {
            try
            {
                int currentUserId = SessionUserId;
                if (currentUserId == 0)
                {
                    return(PesponseResult(false, "登录已失效,请重新登录在操作."));
                }
                var entity = new FaCompany();
                if (company.Id > 0)
                {
                    entity = _faDocService.GetCompany(company.Id);
                }
                else
                {
                    if (_faDocService.HasCompanyName(company.Name))
                    {
                        return(PesponseResult(false, "该公司名称已存在!"));
                    }
                }
                entity.Name   = company.Name;
                entity.Enable = company.Enable;
                entity.Remark = company.Remark ?? string.Empty;

                _faDocService.SaveCompany(entity);
                if (entity.Id > 0)
                {
                    string saveMsg = string.Format("AdCompany数据保存成功,编号:{0},I操作人:{1},时间:{2}。",
                                                   entity.Id, currentUserId, DateTime.Now);
                    LogHelper.Info(saveMsg);
                    return(PesponseResult("保存成功."));
                }
                return(PesponseResult(false, "保存失败."));
            }
            catch (Exception ex)
            {
                LogHelper.ExceptionLog(SessionUserId, "FaCompany/SaveCompany", ex);
                return(PesponseResult(false, "出现异常,ex.Message=" + ex.Message));
            }
        }
 public void SaveCompany(FaCompany entity)
 {
     _faCompanyRepository.Save(entity);
 }