public ActionResult Create(PDCPMS.Modules.Authority.Model.BlockAddModel model) { if (model == null || model.block == null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "操作失败,系统发生了一个错误" }; return RedirectToAction("Add"); } Module domainmodel = new Module(model.block.Name, model.block.AddDate, model.block.Description, model.block.Status); ReadOnlyCollection<BrokenRule> brokenRules = domainmodel.GetBrokenRules(); if (brokenRules.Count != 0) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,模块添加失败" }; TempData["BrokenRules"] = brokenRules; TempData["InvalidModel"] = model; } repository.Add(domainmodel); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("模块({0})添加成功", model.block.Name) }; return RedirectToAction("Index"); }
public ActionResult Create([ModelBinder(typeof(ProducerModelBinder))]Producer model) { if (model == null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "操作失败,系统发生了一个错误" }; return RedirectToAction("Add"); } ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count == 0) { repository.Add(model); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("管材生产厂商({0})添加成功", model.Name) }; } else { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,管材生产厂商添加失败" }; TempData["BrokenRules"] = brokenRules; TempData["InvalidModel"] = model; } return RedirectToAction("Add"); }
public ActionResult Create([ModelBinder(typeof(PipePositionModelBinder))]PipePosition model) { if (model == null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "操作失败,系统发生了一个错误" }; return RedirectToAction("Add"); } ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count == 0) { if (PipePositionPolicy.Exist(model)) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("垛位({0})已存在,不能重复添加", model.ToString()), Type = Application.HintMessageType.Error, DisappearDelay = 30000 }; TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; } else { repository.Add(model); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("垛位({0})添加成功", model.ToString()) }; } } else { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,垛位添加失败" }; TempData["BrokenRules"] = brokenRules; TempData["InvalidModel"] = model; } return RedirectToAction("Add"); }
public ActionResult Create([ModelBinder(typeof(DetectionCompanyModelBinder))]DetectionCompany model) { ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count == 0) { repository.Add(model); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("检测公司({0})添加成功", model.Name) }; } else { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,检测公司添加失败" }; TempData["BrokenRules"] = brokenRules; TempData["InvalidModel"] = model; } return RedirectToAction("Add"); }
public ActionResult Delete(string id) { NewsCategory category = repository.FindBy(id); if (category == null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "指定的类别不存在或已被删除" }; } else { if (NewsCategoryPolicy.CanDelete(category)) { repository.Remove(category); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("资讯类别({0})已被删除", category.Name) }; } else { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "指定的类别正在使用中,不允许被删除" }; } } return RedirectToAction("Index"); }
public ActionResult Delete(int? id) { Function function = this.repository.FindBy(id); if (function == null) { throw new HttpException(404, "无法找到相关的功能!"); } //repository.Remove(function); //unitOfWork.Commit(); //模块功能删除 2011-5-20 by huncherby StringBuilder sb = new StringBuilder(); sb.Append("delete from function where functionid='" + id + "'"); IBusinessCheckNoticeRepository bc = RepositoryFactory.GetRepository<IBusinessCheckNoticeRepository, BusinessCheckNotice>(); bc.Excute(sb.ToString()); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("功能({0})删除成功", function.Name) }; return RedirectToAction("Index", "Block"); }
public ActionResult Update(ActionAddModel model) { if (model == null || model.Function == null) throw new HttpException(404, "系统发生一个错误!"); Function action = model.Function; ReadOnlyCollection<BrokenRule> brokenRules = action.GetBrokenRules(); if (brokenRules.Count == 0) { //功能模块action修改 2011-5-20 by huncherby string moduleid = action.Module.Key.ToString(); string controller = action.Controller; string actionno = action.Action; string name = action.Name; string des = action.Description; int state = (int)action.Status; string key=action.Key.ToString(); StringBuilder sb = new StringBuilder(); sb.Append("update function set name='"+name+"',moduleid='"+moduleid+"',controller='"+controller+"',action='"+actionno+"',Description='"+des+"',status="+state+" where functionid='"+key+"'"); IBusinessCheckNoticeRepository bc = RepositoryFactory.GetRepository<IBusinessCheckNoticeRepository, BusinessCheckNotice>(); bc.Excute(sb.ToString()); //repository[action.Key] = action; //unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("功能({0})修改成功", model.Function.Name) }; } else { TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("人员({0})修改失败,请检查你的输入", model.Function.Name) }; } return RedirectToAction("Edit", new { id = model.Function.Key }); }
public JsonResult UpdateCurrentCheckItems(string code) { PipeType pipeType = null; pipeType = repository.FindBy(code); if (pipeType == null) { return Json(new { success = false, message = "无法找到指定的管材类别" }); } JavaScriptSerializer seralizer = new JavaScriptSerializer(); CheckItemCollection collection = seralizer.Deserialize<CheckItemCollection>(Request.Form["other"]); PDCPMS.DataContracts.Common.PipeCheckItems pci = seralizer.Deserialize<PDCPMS.DataContracts.Common.PipeCheckItems>(Request["normal"]); pipeType.IsCheckThickness = pci.IsCheckThickness; pipeType.ThicknessUnit = pci.ThicknessUnit; pipeType.ThincknessStandard = pci.ThincknessStandard; pipeType.IsCheckAppearance = pci.IsCheckAppearance; pipeType.StraightStandard = pci.StraightStandard; pipeType.IsCheckUnBlock = pci.IsCheckUnBlock; pipeType.UnBlockUnit = pci.UnBlockUnit; pipeType.UnBlockStandard = pci.UnBlockStandard; pipeType.IsCheckCrack = pci.IsCheckCrack; pipeType.IsCheckPressure = pci.IsCheckPressure; pipeType.PressureDetectUnit = pci.PressureDetectUnit; pipeType.PressureDetectStandard = pci.PressureDetectStandard; pipeType.PressureHoldUnit = pci.PressureHoldUnit; pipeType.PressureHoldStandard = pci.PressureHoldStandard; pipeType.IsCheckCloseness = pci.IsCheckCloseness; pipeType.MalePStandard = pci.MalePStandard; pipeType.FemaleAStandard = pci.FemaleAStandard; pipeType.IsNeedMark = pci.IsNeedMark; pipeType.IsCheckBasic = pci.IsCheckBasic; pipeType.OtherCheckItems = collection; repository[pipeType.Key] = pipeType; unitOfWork.Commit(); // Li Zheng 2010.11.25 // 更新该自定义检测项 repository.UpdateOnlyPipeType(code, pci, collection); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("管材型号({0})的检测项更新成功", pipeType.Code + " " + pipeType.ToString()) }; return Json(new { success = true }); }
public ActionResult Update([ModelBinder(typeof(NewsModelBinder))]News model) { ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); #region Attachment if (!string.IsNullOrEmpty(Request.Form["AttachmentPath"])) { IFileShareRepository fsRepository = RepositoryFactory.GetRepository<IFileShareRepository, FileShare>(unitOfWork); IFileShareCategoryRepository fsCategoryRepository = RepositoryFactory.GetRepository<IFileShareCategoryRepository, FileShareCategory>(unitOfWork); if (model.Attachment == null) { FileShare fsNew = new FileShare( Guid.NewGuid().ToString("N"), model.Publisher, DateTime.Now, true); fsNew.Description = "资讯附件"; fsNew.IsPublic = true; fsNew.Name = "资讯 [" + model.Title + "] - 附件"; fsNew.Path = Request.Form["AttachmentPath"]; IList<FileShareCategory> fsCategories = fsCategoryRepository.FindAll(); FileShareCategory newsAttachmentCategory = fsCategories.FirstOrDefault(fsc => fsc.Name == "资讯附件"); if (newsAttachmentCategory == null) { newsAttachmentCategory = new FileShareCategory(Guid.NewGuid().ToString("N"), true); newsAttachmentCategory.Name = "资讯附件"; fsCategoryRepository.Add(newsAttachmentCategory); } fsNew.Category = newsAttachmentCategory; fsRepository.Add(fsNew); model.Attachment = fsNew; } else { if (!model.Attachment.Path.Equals(Request.Form["AttachmentPath"], StringComparison.InvariantCultureIgnoreCase)) { FileShare fs = model.Attachment; fsRepository.Remove(fs); FileShare fsNew = new FileShare(Guid.NewGuid().ToString("N"), model.Publisher, DateTime.Now, true); fsNew.Description = "资讯附件"; fsNew.IsPublic = true; fsNew.Name = model.Title + " - 附件"; fsNew.Path = Request.Form["AttachmentPath"]; fsNew.Category = fs.Category; fsRepository.Add(fsNew); model.Attachment = fsNew; } } } else { if (model.Attachment != null) { IFileShareRepository fsRepository = RepositoryFactory.GetRepository<IFileShareRepository, FileShare>(unitOfWork); fsRepository.Remove(model.Attachment); model.Attachment = null; } } #endregion if (brokenRules.Count == 0) { repository[model.Key] = model; unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("资讯({0})修改成功", model.Title) }; } else { TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("资讯({0})修改失败,请检查你的输入", model.Title) }; } return RedirectToAction("Edit", new { id = model.Key }); }
public ActionResult DeleteSend(string id) { Account user = null; if (PDCPMS.Application.UserSession.OnlineAccount != null) { user = (Account)PDCPMS.Application.UserSession.OnlineAccount; } Message msg = repository.FindBy(id); if (msg == null) { throw new HttpException(404, "指定文件不存在或已被删除"); } //repository.Remove(msg); repository.DeleteSendedMsg(user, msg); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("站内信({0})删除成功", msg.Subject) }; return RedirectToAction("Sended"); }
public ActionResult Delete(string code) { PipeType pipeType = null; pipeType = repository.FindBy(code); if (pipeType == null) { throw new HttpException(404, "无法找到指定的管材类别"); } if (!PipeTypePolicy.CanDelte(pipeType)) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("管材型号({0})正在使用中,不允许被删除", pipeType.Code + " " + pipeType.ToString()), Type = Application.HintMessageType.Error }; } else { repository.Remove(pipeType); unitOfWork.Commit(); } return RedirectToAction("Index"); }
public ActionResult Update(RoleEditModel model) { if (model == null || model.Role == null) throw new ArgumentNullException("the model is null!!!"); ReadOnlyCollection<BrokenRule> brokenRules = model.Role.GetBrokenRules(); if (brokenRules.Count > 0) { TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("角色({0})修改失败,请检查你的输入", model.Role.Name) }; } else { repository[model.Role.Key] = model.Role; unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("人员({0})修改成功", model.Role.Name) }; } return this.RedirectToAction("Edit", new { id = model.Role.Key }); }
public ActionResult Delete(string id) { DetectionCompany dc = repository.FindBy(id); if (dc == null) { throw new HttpException(404, "无法找到指定的钻探公司"); } if (!DetectionCompanyPolicy.CanDelete(dc)) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("检测公司({0})正在使用中,不允许被删除", dc.Name) }; } else { repository.Remove(dc); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("检测公司({0})删除成功", dc.Name) }; } return RedirectToAction("Index"); }
public ActionResult Delete(int? id) { Role role = null; if (id == null || !id.HasValue || (role = this.repository.FindBy(id.Value)) == null) { throw new HttpException(404, "无法找到指定模块"); } if (role.CanDelete()) { this.repository.Remove(role); this.unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("根角色({0})删除成功", role.Name) }; return this.RedirectToAction("Index"); } else { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("根角色({0})不能删除,请检查该角色下是否有所属功能", role.Name) }; return this.RedirectToAction("Edit", new { id = role.Key }); } }
public ActionResult Index(int? id) { RoleIndexModel model = null; if (TempData["HintMessage"] != null) { ViewData["HintMessage"] = TempData["HintMessage"]; } if (id.HasValue) { Role role = this.repository.FindBy(id); if (role == null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "请检查有无该角色!" }; model = new RoleIndexModel(); } else { model = new RoleIndexModel(role); } } else { model = new RoleIndexModel(); } return View(model); }
public ActionResult Create(RoleAddModel model) { if (model == null || model.Role == null) { throw new ArgumentNullException("the model for add is null "); } ReadOnlyCollection<BrokenRule> brokenRules = model.Role.GetBrokenRules(); if (brokenRules.Count > 0) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,检测公司添加失败" }; TempData["BrokenRules"] = brokenRules; TempData["InvalidModel"] = model; } this.repository.Add(model.Role); this.unitOfWork.Commit(); return this.RedirectToAction("Edit", new { id = model.Role.Key }); }
public ActionResult Delete(string id) { FileShare fs = repository.FindBy(id); if (fs == null) { throw new HttpException(404, "指定文件不存在或已被删除"); } if (fs.IsLocked) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("共享文件是咨询附件,被锁定,({0})不允许被删除成功", fs.Name), Type = Application.HintMessageType.Error }; } else { repository.Remove(fs); unitOfWork.Commit(); string fileName = Server.MapPath(fs.Path); System.IO.FileInfo fi = new System.IO.FileInfo(fileName); if (fi.Exists) { fi.Delete(); } TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("共享文件({0})删除成功", fs.Name) }; } return RedirectToAction("Index"); }
public ActionResult Create([ModelBinder(typeof(NewsModelBinder))]News model) { if (model == null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "操作失败,系统发生了一个错误" }; return RedirectToAction("Add"); } #region Attachment if (!string.IsNullOrEmpty(Request.Form["AttachmentPath"])) { IFileShareRepository fsRepository = RepositoryFactory.GetRepository<IFileShareRepository, FileShare>(unitOfWork); IFileShareCategoryRepository fsCategoryRepository = RepositoryFactory.GetRepository<IFileShareCategoryRepository, FileShareCategory>(unitOfWork); FileShare fs = new FileShare( Guid.NewGuid().ToString("N"), model.Publisher, DateTime.Now, true); fs.Description = "资讯附件"; fs.IsPublic = true; fs.Name = "资讯 [" + model.Title + "] - 附件"; fs.Path = Request.Form["AttachmentPath"]; IList<FileShareCategory> fsCategories = fsCategoryRepository.FindAll(); FileShareCategory newsAttachmentCategory = fsCategories.FirstOrDefault(fsc => fsc.Name == "资讯附件"); if (newsAttachmentCategory == null) { newsAttachmentCategory = new FileShareCategory(Guid.NewGuid().ToString("N"), true); newsAttachmentCategory.Name = "资讯附件"; fsCategoryRepository.Add(newsAttachmentCategory); } fs.Category = newsAttachmentCategory; fsRepository.Add(fs); model.Attachment = fs; } #endregion ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count == 0) { repository.Add(model); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("成功发布资讯({0})", model.Title) }; } else { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,发布资讯失败", Type = Application.HintMessageType.Error }; TempData["BrokenRules"] = brokenRules; TempData["InvalidModel"] = model; TempData["AttachmentPath"] = Request.Form["AttachmentPath"]; } return RedirectToAction("Add"); }
public ActionResult Delete(int? id) { Module module = null; if (!id.HasValue || (module = this.repository.FindBy(id.Value)) == null) { throw new HttpException(404, "未能找到相关的模块!"); } if (!module.CanDelete) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("模块({0})不允许被删除", module.Name), Type = Application.HintMessageType.Error }; } else { this.repository.Remove(module); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("模块({0})删除成功", module.Name) }; } return RedirectToAction("Index"); }
public ActionResult Delete(int id) { PipePosition pos = repository.FindBy(id); if (pos == null) { throw new HttpException(404, "无法找到指定人员"); } if (!PipePositionPolicy.CanDelete(pos)) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("垛位({0})不允许被删除", pos.ToString()), Type = Application.HintMessageType.Error }; } else { repository.Remove(pos); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("垛位({0})删除成功", pos.Name) }; } return RedirectToAction("Index"); }
public ActionResult Update([ModelBinder(typeof(ProducerModelBinder))]Producer model) { ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count == 0) { repository[model.Key] = model; unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("管材生产厂商({0})修改成功", model.NickName) }; } else { TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("管材生产厂商({0})修改失败,请检查你的输入", model.NickName) }; } return RedirectToAction("Edit", new { id = model.Key }); }
public ActionResult Update([ModelBinder(typeof(PipePositionModelBinder))]PipePosition model) { ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count == 0) { repository[model.Key] = model; unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("垛位({0})修改成功", model.ToString()) }; } else { TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("垛位({0})修改失败,请检查你的输入", model.ToString()), Type = Application.HintMessageType.Error }; } return RedirectToAction("Edit", new { id = model.Key }); }
public ActionResult Delete(string id) { Producer producer = repository.FindByNotCache(id); if (producer != null) { repository.Remove(producer); unitOfWork.Commit(); } TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("管材生产厂商{0}删除成功", (producer == null) ? "" : "(" + producer.Name + ")") }; return RedirectToAction("Index"); }
public ActionResult Update(Module model) { if (model == null) { throw new HttpException(404, "无法找到指定的模块,请确认该模块是否存在"); } ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count != 0) { TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("模块({0})修改失败,请检查你的输入", model.Name) }; } else { repository[model.Key] = model; unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("模块({0})修改成功", model.Name) }; } return RedirectToAction("Index"); }
public ActionResult Create([ModelBinder(typeof(MessageModelBinder))]Message model) { repository.Add(model); if (model.ReceiveType == MessageReceiveType.Group) { model.ReceiveGroup = RepositoryFactory.GetRepository<IDetectionGroupRepository, DetectionGroup>().FindBy( Request.Form["DG"]); } else if (model.ReceiveType == MessageReceiveType.MultiPerson) { string[] acocuntIdList = Request.Form["ReceiveAccounts"].Split(','); int accountId; IAccountRepository accountRepository = RepositoryFactory.GetRepository<IAccountRepository, Account>(); foreach (string aid in acocuntIdList) { if (int.TryParse(aid, out accountId)) { Account receiver = accountRepository.FindBy(accountId); if (receiver != null) { MessageAccount ma = new MessageAccount(model, receiver); ma.IsRead = false; repository.SaveMessageAccount(ma); model.MessageAccounts.Add(ma); } } } } #region Attachment if (!string.IsNullOrEmpty(Request.Form["AttachmentPath"])) { IFileShareRepository fsRepository = RepositoryFactory.GetRepository<IFileShareRepository, FileShare>(unitOfWork); IFileShareCategoryRepository fsCategoryRepository = RepositoryFactory.GetRepository<IFileShareCategoryRepository, FileShareCategory>(unitOfWork); FileShare fs = new FileShare( Guid.NewGuid().ToString("N"), model.Sender, DateTime.Now, true); fs.Description = "资讯附件"; fs.IsPublic = true; fs.Name = "资讯 [" + model.Subject + "] - 附件"; fs.Path = Request.Form["AttachmentPath"]; IList<FileShareCategory> fsCategories = fsCategoryRepository.FindAll(); FileShareCategory newsAttachmentCategory = fsCategories.FirstOrDefault(fsc => fsc.Name == "站内信附件"); if (newsAttachmentCategory == null) { newsAttachmentCategory = new FileShareCategory(Guid.NewGuid().ToString("N"), true); newsAttachmentCategory.Name = "站内信附件"; fsCategoryRepository.Add(newsAttachmentCategory); } fs.Category = newsAttachmentCategory; fsRepository.Add(fs); model.Attachment = fs; } #endregion ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count == 0) { unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = string.Format("成功发送站内信({0})", model.Subject) }; } else { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "你的输入有误,发送站内信失败" }; TempData["BrokenRules"] = brokenRules; TempData["InvalidModel"] = model; } return RedirectToAction("Add"); }
public ActionResult Delete(string id) { Supplier supplier = repository.FindBy(id); if (supplier == null) { throw new HttpException(404, "无法找到指定的钻探公司"); } if (!SupplierPolicy.CanDelete(supplier)) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("供应商({0})正在使用中,不允许被删除", supplier.Name), Type = Application.HintMessageType.Error }; } else { repository.Remove(supplier); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("供应商({0})删除成功", supplier.Name) }; } return RedirectToAction("Index"); }
public ActionResult Update([ModelBinder(typeof(PipeTypeModelBinder))]PipeType model) { ReadOnlyCollection<BrokenRule> brokenRules = model.GetBrokenRules(); if (brokenRules.Count == 0) { //2011-5-5 by huncherby 新增改变管材型号厂商时,改变管子厂商 StringBuilder sb = new StringBuilder(); sb.Append("select b.producerid from pipetype a,producer b where a.producerid=b.producerid and a.pipetypeid=" + model.Key.ToString()); DataTable dt = repository.ExcuteDs(sb.ToString()); string oldproducer = dt.Rows[0]["producerid"].ToString(); repository[model.Key] = model; unitOfWork.Commit(); if (oldproducer != model.Producer.Key.ToString()) { //改变pipe sb = new StringBuilder(); sb.Append("update pipe set producerid='"+model.Producer.Key.ToString()+"' where pipetypeid="+model.Key.ToString()); repository.Excute(sb.ToString()); //改变delivernotice sb = new StringBuilder(); sb.Append("update delivernotice set producerid='" + model.Producer.Key.ToString() + "' where pipetypeid=" + model.Key.ToString()); repository.Excute(sb.ToString()); //改变pipeincomerecord sb = new StringBuilder(); sb.Append("update pipeincomerecord set producerid='" + model.Producer.Key.ToString() + "' where pipetypeid=" + model.Key.ToString()); repository.Excute(sb.ToString()); } TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("管材型号({0})修改成功", model.Code) }; } else { TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("管材型号({0})修改失败,请检查你的输入", model.Code) }; } return RedirectToAction("Edit", new { code = model.Code }); }
public ActionResult Create(ActionAddModel model) { if (model == null) { TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = "操作失败,系统发生了一个错误" }; return RedirectToAction("Add"); } ReadOnlyCollection<BrokenRule> brokenRules = model.Function.GetBrokenRules(); if (brokenRules.Count == 0) { repository.Add(model.Function); unitOfWork.Commit(); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("功能({0})添加成功", model.Function.Name) }; } else { TempData["InvalidModel"] = model; TempData["BrokenRules"] = brokenRules; TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("人员({0})修改失败,请检查你的输入", model.Function.Name) }; } return RedirectToAction("Index", "Block" /*, new { id = model.Function.Module.Key } */); }
public ActionResult ReLogin(string reason) { if (string.IsNullOrEmpty(reason)) { if (TempData["HintMessage"] != null) { ViewData["HintMessage"] = TempData["HintMessage"]; } } else { ViewData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = !string.IsNullOrEmpty(reason) ? reason : "您已经退出!" }; } return View("Login"); }
public ActionResult Delete(string id) { News news = repository.FindBy(id); if (news == null) { throw new HttpException(404, "指定文件不存在或已被删除"); } repository.Remove(news); if (news.Attachment != null) { StringBuilder sb = new StringBuilder(); sb.Append("delete from fileshare where fileshareid='" + news.Attachment.Key + "'"); INewsRepository sbfile = RepositoryFactory.GetRepository<INewsRepository, News>(); sbfile.Excute(sb.ToString()); TempData["HintMessage"] = new PDCPMS.Application.HintMessage { Content = String.Format("共享文件({0})删除成功", news.Title) }; string fileName = Server.MapPath(news.Attachment.Path); System.IO.FileInfo fi = new System.IO.FileInfo(fileName); if (fi.Exists) { fi.Delete(); } RepositoryFactory.GetRepository<IFileShareRepository, FileShare>(unitOfWork).Remove(news.Attachment); } unitOfWork.Commit(); return RedirectToAction("Index"); }