public ActionResult Create(int TaskID = 1) { if (TaskID != 1) { Tender_GongGao tg = db.Tender_GongGaos.Find(TaskID); if (tg != null) { if (tg.IsShenhe != true) { return(Content("尚未进行供应商投标审核,不能投标~!")); } Tender_GongGao tgonggao = db.Tender_GongGaos.Find(TaskID); if (tgonggao.TenderModel != null && tgonggao.TenderModel.Trim().Equals("三轮报价模式")) { //return Content("您已选择三轮报价模式,不能再选择竞价模式"); if (db.Tender_ModelManage1.FirstOrDefault(m => m.Tid == TaskID) != null) { return(Content("您已选择三轮报价模式并已操作,不能再选择竞价模式")); } } tgonggao.TenderModel = "竞价模式"; db.Entry(tgonggao).State = EntityState.Modified; db.SaveChanges(); int mcount = db.Tender_ModelManage2.Where(m => m.Tid == TaskID).Count(); if (mcount > 0) { ViewBag.ggM = tg; Tender_ModelManage2 mod2 = db.Tender_ModelManage2.Single(m => m.Tid == TaskID); mod2.Tid = TaskID; return(View(mod2)); //return Content("已经投标 请不要重复投标"); } ViewBag.ggM = tg; Tender_ModelManage2 mod1 = new Tender_ModelManage2(); mod1.Tid = TaskID; mod1.PriceUnit = "元/标"; return(View(mod1)); //mod1.tenderGonggao = tg; //ViewBag.Tid = new SelectList(db.Tender_GongGaos, "TaskID", "SN"); //return View(mod1); } else { return(Content("请求页面异常~!")); } } return(Content("如有问题 请联系管理员")); //ViewBag.Tid = new SelectList(db.Tender_GongGaos, "TaskID", "SN"); //return View(); }
public ActionResult EditDelete(Tender_GongGao tender_gonggao) { if (ModelState.IsValid) { Tender_GongGao tgg = db.Tender_GongGaos.Find(tender_gonggao.TaskID); if (tgg != null) { tgg.IsDelete = tender_gonggao.IsDelete; db.Entry(tgg).State = EntityState.Modified; db.SaveChanges(); return(Content("修改成功!")); } //return RedirectToAction("Index"); } return(Content("修改失败!")); //return View(tender_gonggao); }
public ActionResult Edit(BLinkCompany blinkcompany) { if (ModelState.IsValid) { db.Entry(blinkcompany).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(blinkcompany)); }
public ActionResult Edit(BProduct bproduct) { if (ModelState.IsValid) { db.Entry(bproduct).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(bproduct)); }
public ActionResult Edit(BDepartment bdepartment) { if (ModelState.IsValid) { db.Entry(bdepartment).State = EntityState.Modified; db.SaveChanges(); //return RedirectToAction("Index"); } return(View(bdepartment)); }
public ActionResult Edit(Permission permission) { if (ModelState.IsValid) { db.Entry(permission).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(permission)); }
public ActionResult Edit(Tender_CompanyInfo tender_companyinfo) { if (ModelState.IsValid) { db.Entry(tender_companyinfo).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmpID = new SelectList(db.BEmplyees, "EmpID", "NumberEmp", tender_companyinfo.EmpID); return(View(tender_companyinfo)); }
public ActionResult Edit(Bemp_GongGao bemp_gonggao) { if (ModelState.IsValid) { db.Entry(bemp_gonggao).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.UserId = new SelectList(db.BEmplyees, "EmpID", "NumberEmp", bemp_gonggao.UserId); ViewBag.GongGaoId = new SelectList(db.Tender_GongGaos, "TaskID", "SN", bemp_gonggao.GongGaoId); return(View(bemp_gonggao)); }
public ActionResult Edit(Role role, string[] EmpListH = null, string btnEmp = "") { ViewData["emps"] = db.BEmplyees.ToList <BEmplyee>(); try { if (ModelState.IsValid) { if (EmpListH != null && EmpListH.Count() > 0) { int[] intEmps = new int[EmpListH.Count()]; for (int i = 0; i < EmpListH.Count(); i++) { intEmps[i] = int.Parse(EmpListH[i]); } var empts = from es in db.BEmplyees where intEmps.Contains(es.EmpID) select es.NumberEmp; //foreach (BEmplyee bemp in empts) //{ // if (!role.Emplyees.Contains(bemp)) // { // role.Emplyees.Add(bemp); // } //} //role.Emplyees = empts.ToList<BEmplyee>(); Roles.RemoveUsersFromRole(Roles.GetUsersInRole(role.RoleName), role.RoleName); Roles.AddUsersToRole(empts.ToArray <string>(), role.RoleName); //return View(role); } else { return(Content("没取到")); } db.Entry(role).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(role)); } catch (Exception ex) { return(Content(ex.Message)); } }
public ActionResult Edit(Tender_TongZhi tender_tongzhi) { if (ModelState.IsValid) { Tender_TongZhi ttz = db.Tender_TongZhi.Find(tender_tongzhi.TZID); //tender_tongzhi.CreateDateT = ttz.CreateDateT; //tender_tongzhi.CustFile = ttz.CustFile; //tender_tongzhi.CustName = ttz.CustName; ttz.TitleT = tender_tongzhi.TitleT; ttz.ContentT = tender_tongzhi.ContentT; db.Entry(ttz).State = EntityState.Modified; db.SaveChanges(); return(Content("修改成功!")); } return(Content("修改失败!")); }
public ActionResult Edit(BEmplyee emp) { if (ModelState.IsValid) { int mid = emp.EmpID; BEmplyee emp1; try { emp1 = db.BEmplyees.Find(mid); }catch (Exception ex) { return(Content("用户不存在")); } HttpPostedFileBase fCodeAtt = Request.Files["fCodeAtt"]; HttpPostedFileBase fTaxAtt = Request.Files["fTaxAtt"]; HttpPostedFileBase fCertAtt = Request.Files["fCertAtt"]; HttpPostedFileBase fLicenceAtt = Request.Files["fLicenceAtt"]; HttpPostedFileBase fDelegateBook = Request.Files["fDelegateBook"]; //**************** 委托书 ************** HttpPostedFileBase fPromiseAtt = Request.Files["fPromiseAtt"]; HttpPostedFileBase fSecretAtt = Request.Files["fSecretAtt"]; HttpPostedFileBase fPeopleAtt = Request.Files["fPeopleAtt"]; HttpPostedFileBase fOpenAccountAtt = Request.Files["fOpenAccountAtt"]; HttpPostedFileBase fprojectAtt = Request.Files["fprojectAtt"]; //**************** 开户许可证 ************** if (fOpenAccountAtt != null && !String.IsNullOrEmpty(fOpenAccountAtt.FileName)) { emp.OpenAccountAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.OpenAccountAtt.Substring(0, 4) + @"\" + emp.OpenAccountAtt.Substring(4, 4) + @"\"))); fOpenAccountAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.OpenAccountAtt.Substring(0, 4) + @"\" + emp.OpenAccountAtt.Substring(4, 4) + @"\" + emp.OpenAccountAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.OpenAccountAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fOpenAccountAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fOpenAccountAtt.FileName), "DbType.String", null }, { "@Size", fOpenAccountAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } //**************** 类似项目的经营业绩 ************** if (fprojectAtt != null && !String.IsNullOrEmpty(fprojectAtt.FileName)) { emp.projectAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.projectAtt.Substring(0, 4) + @"\" + emp.projectAtt.Substring(4, 4) + @"\"))); fprojectAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.projectAtt.Substring(0, 4) + @"\" + emp.projectAtt.Substring(4, 4) + @"\" + emp.projectAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.projectAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fprojectAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fprojectAtt.FileName), "DbType.String", null }, { "@Size", fprojectAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } //**************** 保密协议 ************** if (fSecretAtt != null && !String.IsNullOrEmpty(fSecretAtt.FileName)) { emp.SecretAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.SecretAtt.Substring(0, 4) + @"\" + emp.SecretAtt.Substring(4, 4) + @"\"))); fSecretAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.SecretAtt.Substring(0, 4) + @"\" + emp.SecretAtt.Substring(4, 4) + @"\" + emp.SecretAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.SecretAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fSecretAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fSecretAtt.FileName), "DbType.String", null }, { "@Size", fSecretAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } //***************************************** if (fPeopleAtt != null && !String.IsNullOrEmpty(fPeopleAtt.FileName)) { emp.PeopleAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.PeopleAtt.Substring(0, 4) + @"\" + emp.PeopleAtt.Substring(4, 4) + @"\"))); fPeopleAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.PeopleAtt.Substring(0, 4) + @"\" + emp.PeopleAtt.Substring(4, 4) + @"\" + emp.PeopleAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.PeopleAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fPeopleAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fPeopleAtt.FileName), "DbType.String", null }, { "@Size", fPeopleAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } if (fPromiseAtt != null && !String.IsNullOrEmpty(fPromiseAtt.FileName)) { emp.PromiseAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.PromiseAtt.Substring(0, 4) + @"\" + emp.PromiseAtt.Substring(4, 4) + @"\"))); fPromiseAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.PromiseAtt.Substring(0, 4) + @"\" + emp.PromiseAtt.Substring(4, 4) + @"\" + emp.PromiseAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.PromiseAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fPromiseAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fPromiseAtt.FileName), "DbType.String", null }, { "@Size", fPromiseAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } if (fCodeAtt != null && !String.IsNullOrEmpty(fCodeAtt.FileName)) { emp.CodeAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.CodeAtt.Substring(0, 4) + @"\" + emp.CodeAtt.Substring(4, 4) + @"\"))); fCodeAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.CodeAtt.Substring(0, 4) + @"\" + emp.CodeAtt.Substring(4, 4) + @"\" + emp.CodeAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.CodeAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fCodeAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fCodeAtt.FileName), "DbType.String", null }, { "@Size", fCodeAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } if (fTaxAtt != null && !String.IsNullOrEmpty(fTaxAtt.FileName)) { emp.TaxAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.TaxAtt.Substring(0, 4) + @"\" + emp.TaxAtt.Substring(4, 4) + @"\"))); fTaxAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.TaxAtt.Substring(0, 4) + @"\" + emp.TaxAtt.Substring(4, 4) + @"\" + emp.TaxAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.TaxAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fTaxAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fTaxAtt.FileName), "DbType.String", null }, { "@Size", fTaxAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } if (fCertAtt != null && !String.IsNullOrEmpty(fCertAtt.FileName)) { emp.CertAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.CertAtt.Substring(0, 4) + @"\" + emp.CertAtt.Substring(4, 4) + @"\"))); fCertAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.CertAtt.Substring(0, 4) + @"\" + emp.CertAtt.Substring(4, 4) + @"\" + emp.CertAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.CertAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fCertAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fCertAtt.FileName), "DbType.String", null }, { "@Size", fCertAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } if (fLicenceAtt != null && !String.IsNullOrEmpty(fLicenceAtt.FileName)) { emp.LicenceAtt = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.LicenceAtt.Substring(0, 4) + @"\" + emp.LicenceAtt.Substring(4, 4) + @"\"))); fLicenceAtt.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.LicenceAtt.Substring(0, 4) + @"\" + emp.LicenceAtt.Substring(4, 4) + @"\" + emp.LicenceAtt.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.LicenceAtt, "DbType.String", null }, { "@Name", Path.GetFileName(fLicenceAtt.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fLicenceAtt.FileName), "DbType.String", null }, { "@Size", fLicenceAtt.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } if (fDelegateBook != null && !String.IsNullOrEmpty(fDelegateBook.FileName)) { emp.DelegateBook = DateTime.Now.ToString("yyyyMMdd") + Guid.NewGuid().ToString("N"); Directory.CreateDirectory(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.DelegateBook.Substring(0, 4) + @"\" + emp.DelegateBook.Substring(4, 4) + @"\"))); fDelegateBook.SaveAs(Path.Combine(System.Web.Configuration.WebConfigurationManager.AppSettings["AttachmentRootPath"], (emp.DelegateBook.Substring(0, 4) + @"\" + emp.DelegateBook.Substring(4, 4) + @"\" + emp.DelegateBook.Substring(8)))); GenericDataAccess.UpdateBySql("Insert into YZAppAttachment(FileID,Name,Ext,Size,OwnerAccount) values(@FileID,@Name,@Ext,@Size,@OwnerAccount)", new string[, ] { { "@FileID", emp.DelegateBook, "DbType.String", null }, { "@Name", Path.GetFileName(fDelegateBook.FileName), "DbType.String", null }, { "@Ext", Path.GetExtension(fDelegateBook.FileName), "DbType.String", null }, { "@Size", fDelegateBook.ContentLength.ToString(), "DbType.Int32", null }, { "@OwnerAccount", "0", "DbType.String", null } }); } emp1.CopyFrom(emp); db.Entry(emp1).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", "Home")); //return Content("修改成功!"); } else { string err = ""; foreach (string k in ModelState.Keys) { if (ModelState[k].Errors.Count > 0) { err += k + "\n "; foreach (ModelError eor in ModelState[k].Errors) { err += ">>" + eor.ErrorMessage; } } } return(Content(err)); } return(Content("修改失败")); //return View(emp); }
public ActionResult Index(int id = 0) { var tender_mcust = db.Tender_ModelCustomer2.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id); isSmall = isSmallByid(id); //第一次加载 生成客户初始数据 if (tender_mcust.Count() <= 0) { List <Bemp_GongGao> list = db.Bemp_GongGaos.Include(b => b.bemplyees).Where(m => m.GongGaoId == id && m.IsPassShen != null && m.IsPassShen == true).ToList(); if (list.Count > 0) { lock (this) { foreach (Bemp_GongGao bemp in list) { Tender_ModelCustomer2 cust = new Tender_ModelCustomer2(); cust.UserName = bemp.bemplyees.NumberEmp; cust.LinkMan = bemp.bemplyees.LinkMan; cust.LinkType = bemp.bemplyees.LinkType; cust.EmpGonggaoID = bemp.BGid; cust.PriceLost = 0; db.Tender_ModelCustomer2.Add(cust); //li.Add(cust); db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; } } } } //找每轮最低价 tender_mcust = db.Tender_ModelCustomer2.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id); ViewBag.PriceD = 0; tender_mcust = db.Tender_ModelCustomer2.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id && mc.PriceLost > 0); if (tender_mcust.Count() > 0) { if (isSmall) { ViewBag.PriceD = tender_mcust.Min(m => m.PriceLost); } else { ViewBag.PriceD = tender_mcust.Max(m => m.PriceLost); } } if (isSmall) { foreach (Tender_ModelCustomer2 custVar in tender_mcust.ToList <Tender_ModelCustomer2>()) { Bemp_GongGao bgong = db.Bemp_GongGaos.Find(custVar.EmpGonggaoID); if (bgong.LostPrice == null || (custVar.PriceLost != 0 && bgong.LostPrice > custVar.PriceLost)) { bgong.LostPrice = custVar.PriceLost; db.Entry(bgong).State = EntityState.Modified; db.SaveChanges(); } } } else { foreach (Tender_ModelCustomer2 custVar in tender_mcust.ToList <Tender_ModelCustomer2>()) { Bemp_GongGao bgong = db.Bemp_GongGaos.Find(custVar.EmpGonggaoID); if (bgong.LostPrice == null || (custVar.PriceLost != 0 && bgong.LostPrice < custVar.PriceLost)) { bgong.LostPrice = custVar.PriceLost; db.Entry(bgong).State = EntityState.Modified; db.SaveChanges(); } } } ViewBag.IsSmall = isSmall; tender_mcust = db.Tender_ModelCustomer2.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id); return(View(tender_mcust.ToList())); }
public ActionResult Index(int id = 0) { isSmall = isSmallByid(id); var tender_mcust = db.Tender_ModelCustomer1.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id); //第一次加载 生成客户初始数据 if (tender_mcust.Count() <= 0) { List <Bemp_GongGao> list = db.Bemp_GongGaos.Include(b => b.bemplyees).Where(m => m.GongGaoId == id && m.IsPassShen != null && m.IsPassShen == true).ToList(); if (list.Count > 0) { //List<Tender_ModelCustomer1> li = new List<Tender_ModelCustomer1>(); lock (this) { foreach (Bemp_GongGao bemp in list) { Tender_ModelCustomer1 cust = new Tender_ModelCustomer1(); cust.UserName = bemp.bemplyees.NumberEmp; cust.LinkMan = bemp.bemplyees.LinkMan; cust.LinkType = bemp.bemplyees.LinkType; cust.EmpGonggaoID = bemp.BGid; cust.PriceOne = 0; cust.PriceTwo = 0; cust.PriceThree = 0; if (db.Tender_ModelCustomer1.Where(m => m.EmpGonggaoID == bemp.BGid).Count() <= 0) { db.Tender_ModelCustomer1.Add(cust); } //li.Add(cust); db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; } } } } //找每轮最低价 //tender_mcust = db.Tender_ModelCustomer1.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id); ViewBag.PriceD1 = ViewBag.PriceD2 = ViewBag.PriceD3 = 0; tender_mcust = db.Tender_ModelCustomer1.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id && mc.PriceOne > 0); if (tender_mcust.Count() > 0) { if (isSmall) { ViewBag.PriceD1 = tender_mcust.Min(m => m.PriceOne); } else { ViewBag.PriceD1 = tender_mcust.Max(m => m.PriceOne); } } tender_mcust = db.Tender_ModelCustomer1.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id && mc.PriceTwo > 0); if (tender_mcust.Count() > 0) { if (isSmall) { ViewBag.PriceD2 = tender_mcust.Min(m => m.PriceTwo); } else { ViewBag.PriceD2 = tender_mcust.Max(m => m.PriceTwo); } } tender_mcust = db.Tender_ModelCustomer1.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id && mc.PriceThree > 0); if (tender_mcust.Count() > 0) { if (isSmall) { ViewBag.PriceD3 = tender_mcust.Min(m => m.PriceThree); } else { ViewBag.PriceD3 = tender_mcust.Max(m => m.PriceThree); } } //重新取数 tender_mcust = db.Tender_ModelCustomer1.Include(t => t.bemp_Gonggao).Where(mc => mc.bemp_Gonggao.GongGaoId == id); if (isSmall) { //循环找最低价 foreach (Tender_ModelCustomer1 custVar in tender_mcust.ToList <Tender_ModelCustomer1>()) { Bemp_GongGao bgong = db.Bemp_GongGaos.Find(custVar.EmpGonggaoID); var v1 = custVar.PriceOne != 0 ? custVar.PriceOne : 9999999999; var v2 = custVar.PriceTwo != 0 ? custVar.PriceTwo : 9999999999; var v3 = custVar.PriceThree != 0 ? custVar.PriceThree : 9999999999; bgong.LostPrice = (v1 < v2 ? v1 : v2) < v3 ? (v1 < v2 ? v1 : v2) : v3; if (bgong.LostPrice != 9999999999) { db.Entry(bgong).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; } else { bgong.LostPrice = 0; } } } else { //循环找最高价 foreach (Tender_ModelCustomer1 custVar in tender_mcust.ToList <Tender_ModelCustomer1>()) { Bemp_GongGao bgong = db.Bemp_GongGaos.Find(custVar.EmpGonggaoID); var v1 = custVar.PriceOne; var v2 = custVar.PriceTwo; var v3 = custVar.PriceThree; bgong.LostPrice = (v1 > v2 ? v1 : v2) > v3 ? (v1 > v2 ? v1 : v2) : v3; if (bgong.LostPrice != 0) { db.Entry(bgong).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; } else { bgong.LostPrice = 0; } } } ViewBag.IsSmall = isSmall; return(View(tender_mcust)); }