public static int warn() { BLL.DepotDrugBLL DepotDrugBLL = new BLL.DepotDrugBLL(); BLL.WarningBLL warningBLL = new BLL.WarningBLL(); int warnNum = 0; var wa = warningBLL.GetList(en => DateTime.Now >= en.WarningDays && en.tb_DepotDrug.Num > 0, en => en.tb_DepotDrug); warnNum = wa.Count; //var idlist = wa.Select(en => en.DepotDrugId); //var dep = DepotDrugBLL.GetList(en => !idlist.Contains(en.Id), en => en.tb_DrugInfo); //List<models.tb_Warning> warnList = new List<tb_Warning>(); //foreach(var d in dep) //{ //} //foreach (var w in wa) //{ // idlist.Add(w.DepotDrugId); //} //foreach (var d in dep) //{ // if (!idlist.Exists(x => x == d.Id)) // { // int wd = Convert.ToInt32(Math.Ceiling(d.tb_DrugInfo.Shelf * 0.8)); // tb_Warning Warning = new tb_Warning(); // Warning.DepotDrugId = d.Id; // DateTime ProductionDate = d.ProductionDate; // Warning.WarningDays = ProductionDate.AddDays(wd); // warningBLL.Add(Warning); // } //} //string now = DateTime.Now.ToShortDateString(); //wa = warningBLL.GetList(en => true); //foreach (var w in wa) //{ // if (w.WarningDays.ToShortDateString() == now) // { // warnNum = warnNum + 1; // } //} return(warnNum); }
public List <tb_Warning> selectwa(int pageIndex) { int pageMax = Convert.ToInt32(Math.Ceiling(warningBLL.GetList(en => true).Count() / 20.0)); ViewData["count"] = pageMax; ViewData["privousEnabled"] = ""; ViewData["nextEnabled"] = ""; if (pageIndex < 2) { ViewData["privousEnabled"] = "disabled"; } if (pageIndex > pageMax - 1) { ViewData["nextEnabled"] = "disabled"; } pageIndex = pageIndex - 1; DateTime now = DateTime.Now; var wa = warningBLL.GetPageList(pageIndex, 20, en => en.WarningDays >= now, en => en.WarningDays); return(wa); }