public ActionResult DeleteConfirmed(int id) { Tender_ModelCustomer1 tender_modelcustomer1 = db.Tender_ModelCustomer1.Find(id); db.Tender_ModelCustomer1.Remove(tender_modelcustomer1); db.SaveChanges(); return(RedirectToAction("Index")); }
// // GET: /Tender_ModelCustomer1/Delete/5 public ActionResult Delete(int id = 0) { Tender_ModelCustomer1 tender_modelcustomer1 = db.Tender_ModelCustomer1.Find(id); if (tender_modelcustomer1 == null) { return(HttpNotFound()); } return(View(tender_modelcustomer1)); }
public ActionResult Edit(Tender_ModelCustomer1 tender_modelcustomer1) { if (ModelState.IsValid) { db.Entry(tender_modelcustomer1).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmpGonggaoID = new SelectList(db.Bemp_GongGaos, "BGid", "BGid", tender_modelcustomer1.EmpGonggaoID); return(View(tender_modelcustomer1)); }
// // GET: /Tender_ModelCustomer1/Edit/5 public ActionResult Edit(int id = 0) { Tender_ModelCustomer1 tender_modelcustomer1 = db.Tender_ModelCustomer1.Find(id); if (tender_modelcustomer1 == null) { return(HttpNotFound()); } ViewBag.EmpGonggaoID = new SelectList(db.Bemp_GongGaos, "BGid", "BGid", tender_modelcustomer1.EmpGonggaoID); return(View(tender_modelcustomer1)); }
public ActionResult Create(Tender_ModelCustomer1 tender_modelcustomer1, string LunciLab = "") { if (ModelState.IsValid) { int ttid = db.Bemp_GongGaos.Single(n => n.BGid == tender_modelcustomer1.EmpGonggaoID).GongGaoId; //**2014/4/1** isSmall = isSmallByid(ttid); //********** end ********** Tender_ModelManage1 modelM = db.Tender_ModelManage1.Single(m => m.Tid == ttid); Tender_ModelCustomer1 tender_modelcustomer2 = db.Tender_ModelCustomer1.Single(m => m.EmpGonggaoID == tender_modelcustomer1.EmpGonggaoID); switch (LunciLab) { case "": break; case "一": if (TimeSpan.Parse(modelM.BeginTime1) <= System.DateTime.Now.TimeOfDay && System.DateTime.Now.TimeOfDay <= TimeSpan.Parse(modelM.EndTime1)) { if (tender_modelcustomer2.PriceOne > 0) { return(Content("每轮只能报价一次!")); } //Bemp_GongGao bempG1 = db.Bemp_GongGaos.Single(n => n.BGid == tender_modelcustomer1.EmpGonggaoID); tender_modelcustomer2.bemp_Gonggao.PayType = tender_modelcustomer1.bemp_Gonggao.PayType; tender_modelcustomer2.bemp_Gonggao.HandDate = tender_modelcustomer1.bemp_Gonggao.HandDate; tender_modelcustomer2.PriceOne = tender_modelcustomer1.PriceThree; db.Entry(tender_modelcustomer2).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; return(Content("投标完成!")); } break; case "二": if (TimeSpan.Parse(modelM.BeginTime2) <= System.DateTime.Now.TimeOfDay && System.DateTime.Now.TimeOfDay <= TimeSpan.Parse(modelM.EndTime2)) { if (tender_modelcustomer2.PriceTwo > 0) { //ceshi 要删掉 //tender_modelcustomer2.bemp_Gonggao.PayType = tender_modelcustomer1.bemp_Gonggao.PayType; //db.Entry(tender_modelcustomer2).State = EntityState.Modified; //db.Configuration.ValidateOnSaveEnabled = false; //db.SaveChanges(); //db.Configuration.ValidateOnSaveEnabled = true; return(Content("每轮只能报价一次!")); } if (isSmall) { if (tender_modelcustomer2.PriceOne != 0 && tender_modelcustomer1.PriceThree >= tender_modelcustomer2.PriceOne) { return(Content("投标价格必须小于上一轮")); } } else { if (tender_modelcustomer2.PriceOne != 0 && tender_modelcustomer1.PriceThree <= tender_modelcustomer2.PriceOne) { return(Content("投标价格必须大于上一轮")); } } tender_modelcustomer2.PriceTwo = tender_modelcustomer1.PriceThree; tender_modelcustomer2.bemp_Gonggao.PayType = tender_modelcustomer1.bemp_Gonggao.PayType; tender_modelcustomer2.bemp_Gonggao.HandDate = tender_modelcustomer1.bemp_Gonggao.HandDate; db.Entry(tender_modelcustomer2).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; return(Content("投标完成!")); } break; case "三": if (TimeSpan.Parse(modelM.BeginTime3) <= System.DateTime.Now.TimeOfDay && System.DateTime.Now.TimeOfDay <= TimeSpan.Parse(modelM.EndTime3)) { if (tender_modelcustomer2.PriceThree > 0) { return(Content("每轮只能报价一次!")); } if (isSmall) { if ((tender_modelcustomer2.PriceTwo != 0 && tender_modelcustomer1.PriceThree >= tender_modelcustomer2.PriceTwo) || (tender_modelcustomer2.PriceOne != 0 && tender_modelcustomer1.PriceThree >= tender_modelcustomer2.PriceOne)) { return(Content("投标价格必须小于上一轮")); } } else { if ((tender_modelcustomer2.PriceTwo != 0 && tender_modelcustomer1.PriceThree <= tender_modelcustomer2.PriceTwo) || (tender_modelcustomer2.PriceOne != 0 && tender_modelcustomer1.PriceThree <= tender_modelcustomer2.PriceOne)) { return(Content("投标价格必须大于上一轮")); } } tender_modelcustomer2.PriceThree = tender_modelcustomer1.PriceThree; tender_modelcustomer2.bemp_Gonggao.PayType = tender_modelcustomer1.bemp_Gonggao.PayType; tender_modelcustomer2.bemp_Gonggao.HandDate = tender_modelcustomer1.bemp_Gonggao.HandDate; db.Entry(tender_modelcustomer2).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; db.SaveChanges(); db.Configuration.ValidateOnSaveEnabled = true; return(Content("投标完成!")); } else { return(Content("投标未开始")); } //db.Entry(tender_modelcustomer1).State = EntityState.Modified; break; } return(Content("投标未开始~!")); //db.SaveChanges(); } ViewBag.EmpGonggaoID = new SelectList(db.Bemp_GongGaos, "BGid", "BGid", tender_modelcustomer1.EmpGonggaoID); return(View(tender_modelcustomer1)); }
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)); }