public ActionResult IndexPartialAddNew(tcpjw3.oa.Models.TicketDiscount item) { var model = db.TicketDiscount; if (ModelState.IsValid) { try { model.Add(item); db.SaveChanges(); } catch (Exception e) { ViewData["EditError"] = e.Message; } } else { ViewData["EditError"] = "Please, correct all errors."; } return(PartialView("_MasterGridViewPartial", model)); }
//[Bind(Include = "ProvinceID,CityID")] public ActionResult IndexPartialUpdate(tcpjw3.oa.Models.TicketDiscount item, FormCollection Form) { //string aa = Form["ProvinceID"].ToString(); string cbPush = Form["dASPxCheckBoxPush"].ToString();//C-选中 I-未选中 string cbData = Form["cbDate"].ToString(); //string aa = Form["comboCs"].ToString(); List <viewUserDetail> agentList = new List <viewUserDetail>(); List <TicketPush> pushList = new List <TicketPush>(); var model = db.TicketDiscount; if (ModelState.IsValid) { try { var modelItem = model.FirstOrDefault(it => it.TicketID == item.TicketID); if (modelItem != null) { this.UpdateModel(modelItem);//修改模型必须在此之后 modelItem.TicketCategory = StaticDictiory.getCategory((int)modelItem.TicketType, modelItem.TicketPrice); modelItem.TermType = StaticDictiory.getTerm((int)modelItem.TicketType, (int)modelItem.TicketCategory, Convert.ToDateTime(Convert.ToDateTime(modelItem.PublishTime).ToString("yyyy-MM-dd 23:59:59"))); modelItem.TicketEndTime = Convert.ToDateTime(Convert.ToDateTime(modelItem.TicketEndTime).ToString("yyyy-MM-dd 23:59:59")); modelItem.AuditTime = DateTime.Now; modelItem.AuditorID = 0; modelItem.AuditorName = "管理员"; #region 审核通过 if (item.AuditState == 2) { #region if (modelItem.TradeState == 128) { string yyTime = string.Format("{0} {1}:00", DateTime.Now.ToString("yyyy-MM-dd"), cbData); modelItem.YykbTime = Convert.ToDateTime(yyTime); } else if (modelItem.TradeState == 1) { modelItem.JjzTime = DateTime.Now; modelItem.YykbTime = DateTime.Now; } switch (modelItem.TradeState) { case 128: #region 推送实体 if (cbPush == "C") { agentList = db.viewUserDetail.ToList(); foreach (viewUserDetail agent in agentList) { TicketPush push = new TicketPush(); push.BankName = modelItem.BankName; push.BankType = modelItem.BankType; push.CityID = modelItem.CityID; push.ProvinceID = modelItem.ProvinceID; push.PushTime = DateTime.Now; push.State = 1;//新推送 push.TermType = modelItem.TermType; push.TicketType = (int)modelItem.TicketType; push.TicketCategory = modelItem.TicketCategory; push.TicketEndTime = (DateTime)modelItem.TicketEndTime; push.TicketID = modelItem.TicketID; push.TicketPrice = modelItem.TicketPrice; push.ToUserID = agent.ID; push.UserID = modelItem.UserID; pushList.Add(push); } } #endregion #region 推送 -- 票源推送, 电票, 预约开标 #endregion break; case 1: #region 给上传汇票的用户发送审核通过提醒 #endregion #region 推送实体 if (cbPush == "C") { agentList = db.viewUserDetail.ToList(); foreach (viewUserDetail agent in agentList) { TicketPush push = new TicketPush(); push.BankName = modelItem.BankName; push.BankType = modelItem.BankType; push.CityID = modelItem.CityID; push.ProvinceID = modelItem.ProvinceID; push.PushTime = DateTime.Now; push.State = 1;//新推送 push.TermType = modelItem.TermType; push.TicketType = (int)modelItem.TicketType; push.TicketCategory = modelItem.TicketCategory; push.TicketEndTime = (DateTime)modelItem.TicketEndTime; push.TicketID = modelItem.TicketID; push.TicketPrice = modelItem.TicketPrice; push.ToUserID = agent.ID; push.UserID = modelItem.UserID; pushList.Add(push); } } #endregion #region 推送 -- 票源审核通知, 电票, 竞价中 #endregion break; } #endregion #region 新增推送 var pushModel = db.TicketPush; foreach (TicketPush push in pushList) { pushModel.Add(push); } #endregion } #endregion else if (item.AuditState == 4) #region 审核不通过 { if (string.IsNullOrEmpty(modelItem.BankName)) { modelItem.BankName = "未填写"; } #region 给发票人发送消息推送 #endregion } #endregion db.SaveChanges(); } } catch (Exception e) { ViewData["EditError"] = e.Message; } var query = (from discount in db.TicketDiscount join pro in db.SysStatic on discount.ProvinceID equals pro.Value.ToString() join city in db.SysStatic on discount.CityID equals city.Value.ToString() where discount.UploadChannel.Equals(2) //orderby discount.PublishTime descending select new { #region MyRegion CityName = city.Text, ProvinceName = pro.Text, discount.TicketID, discount.TicketType, discount.BankType, discount.BankName, discount.TicketCategory, discount.TermType, discount.TicketPrice, discount.TicketStartTime, discount.TicketEndTime, discount.TicketFaceImg, discount.TicketBackImg, discount.ProvinceID, discount.CityID, discount.TradeState, discount.PublishTime, discount.LastEditTime, discount.UserID, discount.UserName, discount.AuditorID, discount.PublishTunes, discount.AuditTime, discount.AuditNote, discount.AuditorName, discount.AuditState, discount.BidPrice, discount.BidId, discount.ToAccount, discount.Hits, discount.UserNote, discount.UploadChannel, discount.JjzTime, #endregion } ).Distinct().OrderByDescending(p => p.PublishTime); return(Content("<script>alert('编辑成功!');window.parent.location.href='/Discount/Index'</script>")); } else { ViewData["EditError"] = "Please, correct all errors."; var query = (from discount in db.TicketDiscount join pro in db.SysStatic on discount.ProvinceID equals pro.Value.ToString() join city in db.SysStatic on discount.CityID equals city.Value.ToString() where discount.UploadChannel.Equals(2) //orderby discount.PublishTime descending select new { #region MyRegion CityName = city.Text, ProvinceName = pro.Text, discount.TicketID, discount.TicketType, discount.BankType, discount.BankName, discount.TicketCategory, discount.TermType, discount.TicketPrice, discount.TicketStartTime, discount.TicketEndTime, discount.TicketFaceImg, discount.TicketBackImg, discount.ProvinceID, discount.CityID, discount.TradeState, discount.PublishTime, discount.LastEditTime, discount.UserID, discount.UserName, discount.AuditorID, discount.PublishTunes, discount.AuditTime, discount.AuditNote, discount.AuditorName, discount.AuditState, discount.BidPrice, discount.BidId, discount.ToAccount, discount.Hits, discount.UserNote, discount.UploadChannel, discount.JjzTime, #endregion } ).Distinct().OrderByDescending(p => p.PublishTime); return(Content("<script>alert('编辑失败!');window.parent.location.href='/Discount/Index'</script>")); } //return RedirectToAction("Index"); //return null; //return PartialView("DiscountTicketInformation", query.ToList()); }