public ActionResult Delete(string id, int pageIndex, string SearchString) { string msg = "删除失败"; try { if (!string.IsNullOrEmpty(id)) { EF.ContractManagement contractManagement = contractDAL.GetContractByWhere(id); if (contractManagement != null) { contractDAL.Delete(contractManagement); } } //记录列表的页码以及查询条件,便于从编辑、详情等页面返回列表页时使用 if (pageIndex > 1) { ViewBag.pageIndex = pageIndex; } if (!string.IsNullOrWhiteSpace(SearchString)) { ViewBag.CurrentFilter = HttpUtility.UrlEncode(SearchString); } msg = "删除成功"; return(Content(msg)); } catch { return(View()); } }
public ActionResult Edit(int id, int reviewed, int pageIndex, string SearchString) { const int pageSize = 8; IEnumerable <EF.OutsourcingCompany> outsourcingcompanys = null; EF.OutsourcingCompany outsourcingcompany = outsourcingcompanyDAL.GetOutsourcingCompany(id); if (reviewed == 3) //解禁标志 { //解禁后置当前状态为通过状态; outsourcingcompany.AuditingStatue = 1; } else { // outsourcingcompany.AuditingStatue = reviewed; } //outsourcingcompany.AuditingStatue = reviewed; outsourcingcompanyDAL.Update(outsourcingcompany); ViewBag.CurrentFilter = SearchString; outsourcingcompanys = outsourcingcompanyDAL.GetOutsourcingCompanyList(string.Empty).AsQueryable(); if (reviewed == 1) { #region 生成新的合同项 EF.ContractManagement contract = contractDAL.GetContractByPartner(outsourcingcompany.CompnayId); //EF.ContractManagement contract = new EF.ContractManagement(); if (contract == null) //如果不存在,则添加新记录 { contract = new EF.ContractManagement(); contract.ID = Guid.NewGuid().ToString(); int k = outsourcingcompany.CompnayId; contract.Code = string.Format("WB-{0}", k.ToString("0000")); contract.ContractName = string.Format("{0}-外包合同", outsourcingcompany.CompnayName); contract.ContractStatus = "已审核"; contract.ContractTypes = "外包合同"; contract.ContractPartner = outsourcingcompany.CompnayName; contract.RegisterId = outsourcingcompany.CompnayId; contract.PartnerType = "外包公司"; contract.CreateTime = DateTime.Now; contract.UpdateTime = DateTime.Now; contractDAL.Insert(contract); } else //如果存在,那么更新时间; { contract.UpdateTime = DateTime.Now; contractDAL.Update(contract); } #endregion } else { //未通过 } var model = outsourcingcompanys.OrderBy(m => m.CompnayName).ToPagedList(pageIndex, pageSize); return(View("Index", model)); }