コード例 #1
0
        // GET: BooksNeeds
        public ActionResult Index()
        {
            List <Book> bk = new List <Book>();

            bk = db.Books.ToList();
            List <BooksNeed>                bkn            = db.BooksNeeds.ToList();
            List <SchoolsCategory>          sc             = db.SchoolsCategorys.ToList();
            List <BooksCategory>            _booksCategory = db.BooksCategorys.ToList();
            List <BooksStock>               bkstk          = db.BooksStocks.ToList();
            List <ShoolBooksNeedsViewModel> wmlist         = new List <ShoolBooksNeedsViewModel>();

            foreach (var item in bkn)
            {// bu model foreach içinde eklenmeli
                ShoolBooksNeedsViewModel wm = new ShoolBooksNeedsViewModel();
                wm.Id     = item.Id;
                wm.UserId = item.UserId;
                //wm.BookId=
                wm.Name = bk.FirstOrDefault(x => x.Id == item.BookId).Name;
                //wm.Name = item.Name;
                wm.DemandDate = item.DemandDate;
                //wm.BookCode= bk.FirstOrDefault(x => x.Id == item.BookId).Code;
                wm.Class        = bk.FirstOrDefault(x => x.Id == item.BookId).Class;
                wm.BookCategory = bk.FirstOrDefault(x => x.Id == item.BookId).BookType;
                // stoktaki kitap sayısını bulmak için çalışıldı.
                if ((bkstk.FirstOrDefault(x => x.BookId == item.BookId)) == null)
                {
                    wm.BooksStockBookCount = 0;
                }
                else
                {
                    wm.BooksStockBookCount = bkstk.FirstOrDefault(x => x.BookId == item.BookId).BookCount;
                }

                wm.BookCount = item.BookCount;
                //bkn.FirstOrDefault(x => x.Id == item.Id).BookCount;
                /* wm.SchoolsCategory =*/ /*sc.FirstOrDefault(x => x.Id == item.Id).Category;*/
                wm.SchoolsCategory = db.Books.FirstOrDefault(x => x.Id == item.BookId).BookType;
                wmlist.Add(wm);
            }


            //wm.Id = bk[0].Id;
            //wm.Name = bk[0].Name;
            //wm.Class = bk[0].Class;
            ////wm.BookCount = bkn[0].BookCount;
            //wm.Category = sc[0].Category;
            //wm.Id = bk[0].Id;
            //wm.Name = bk[0].Name;
            //wm.Class = bk[0].Class;
            ////wm.BookCount = bkn[0].BookCount;
            //wm.BookCategory = sc[0].Category;
            //wmlist.Add(wm);
            //kişinin kendi eklediği kayıtları görmesi sağlandı
            string managerId = (Session["ManagerId"]).ToString();

            return(View(wmlist.Where(x => x.UserId.ToString() == managerId)));
            // return View(wmlist);
        }
コード例 #2
0
        // GET: BooksDeliveries
        //public ActionResult Index()
        //{
        //    return View(db.BooksDeliverys.ToList());
        //}
        // GET: BooksNeeds
        public ActionResult Index(string text)
        {
            ViewBag.KayıtHata1 = "";
            ViewBag.KayıtHata2 = "";
            ViewBag.KayıtHata3 = "";

            if (TempData["Control"] != null)
            {
                if (TempData["Control"] == "1")
                {
                    ViewBag.KayıtHata1 = " Girmiş olduğunuz kitap sayısı okulun ihtiyacından fazla olamaz!";
                }
                if (TempData["Control"] == "2")
                {
                    ViewBag.KayıtHata2 = " Depoda bu kadar kitap yok!";
                }
                if (TempData["Control"] == "3")
                {
                    ViewBag.KayıtHata3 = "Kaydınız başarı ile gerçekleştirildi. Lütfen tutanak oluşturunuz.";
                }
            }


            ViewBag.selected = text;
            List <Book> bk = new List <Book>();

            bk = db.Books.ToList();
            List <BooksNeed>                bkn            = db.BooksNeeds.ToList();
            List <SchoolsCategory>          sc             = db.SchoolsCategorys.ToList();
            List <BooksCategory>            _booksCategory = db.BooksCategorys.ToList();
            List <BooksStock>               bkstk          = db.BooksStocks.ToList();
            List <ShoolBooksNeedsViewModel> wmlist         = new List <ShoolBooksNeedsViewModel>();
            List <LookUpDto>                LookUpDto      = new List <LookUpDto>();
            var    Bookneed   = db.BooksNeeds.Select(x => x.ShoolName).Distinct().ToList();
            string parameters = Bookneed[0];

            ViewBag.ShoolListViewBag = Bookneed;
            foreach (var item in bkn)
            {
                // bu model foreach içinde eklenmeli
                ShoolBooksNeedsViewModel wm = new ShoolBooksNeedsViewModel();
                wm.Id           = item.Id;
                wm.BookId       = item.BookId;
                wm.UserId       = item.UserId;
                wm.ShoolName    = item.ShoolName;
                wm.Name         = bk.FirstOrDefault(x => x.Id == item.BookId).Name;
                wm.DemandDate   = item.DemandDate;
                wm.Class        = bk.FirstOrDefault(x => x.Id == item.BookId).Class;
                wm.BookCategory = bk.FirstOrDefault(x => x.Id == item.BookId).BookType;
                // stoktaki kitap sayısını bulmak için çalışıldı.
                if ((bkstk.FirstOrDefault(x => x.BookId == item.BookId)) == null)
                {
                    wm.BooksStockBookCount = 0;
                }
                else
                {
                    wm.BooksStockBookCount = bkstk.FirstOrDefault(x => x.BookId == item.BookId).BookCount;
                }

                wm.BookCount       = item.BookCount;
                wm.SchoolsCategory = db.Books.FirstOrDefault(x => x.Id == item.BookId).BookType;
                wmlist.Add(wm);
            }
            if (text != null && text != string.Empty)
            {
                parameters = text;
            }
            var test = wmlist.Where(x => x.ShoolName.Trim() == parameters.Trim());

            //kişinin kendi eklediği kayıtları görmesi sağlandı
            return(View(wmlist.Where(x => x.ShoolName.Trim() == parameters.Trim())));
        }
コード例 #3
0
        public ActionResult Index(string list, string BookIdList, string Schols, string DeliveredName, string Recipedname)
        {
            List <BooksStock>        bkstk = db.BooksStocks.ToList();
            ShoolBooksNeedsViewModel wm    = new ShoolBooksNeedsViewModel();

            string[] CounterCount = BookIdList.Split(',');
            for (int i = 0; i < CounterCount.Count(); i++)
            {
                string item       = BookIdList.Split(',')[i];
                string Count      = list.Split(',')[i];
                var    BookNeeds  = db.BooksNeeds.FirstOrDefault(x => x.BookId.ToString() == item && x.ShoolName == Schols);
                var    BookStocks = db.BooksStocks.FirstOrDefault(x => x.BookId.ToString() == item);
                if (BookNeeds != null)
                {
                    if (Count == "")
                    {
                        Count = "0";
                    }

                    if (Convert.ToInt32(Count) < 1)
                    {
                        Count = "0";
                    }

                    if (BookStocks.BookCount < Convert.ToInt32(Count))
                    {
                        TempData["Control"] = "2";



                        return(RedirectToAction("Index", new RouteValueDictionary(
                                                    new { controller = "BooksDeliveries", action = "Index" })));
                    }



                    ViewBag.KayıtHata = "";
                    if (BookNeeds.BookCount < Convert.ToInt32(Count))
                    {
                        TempData["Control"] = "1";
                        //ViewBag.KayıtHata = " Girmiş olduğunuz kitap sayısı okulun ihtiyacından fazla olamaz!";


                        return(RedirectToAction("Index", new RouteValueDictionary(
                                                    new { controller = "BooksDeliveries", action = "Index" })));
                    }

                    //     ViewBag.KayıtHata = "";
                    //     if ((bkstk.FirstOrDefault(x => x.Id ==item.)) == null)
                    //     {
                    //         TempData["Control"] = "1";

                    //         return RedirectToAction("Index", new RouteValueDictionary(
                    //new { controller = "BooksDeliveries", action = "Index" }));



                    //     }



                    //     if (Count == "")
                    //     {
                    //         Count = "0";
                    //     }



                    //ViewBag.KayıtHata = "";
                    //BooksNeed bookNeedControl = new BooksNeed();
                    ////bookNeedControl = db.BooksNeeds.FirstOrDefault(x => x.BookId == booksNeed.BookId);
                    //bookDeliveriesControl = db.BooksNeeds(x => x. == booksNeed.BookId);
                    //if (bookNeedControl != null)
                    //{
                    //    TempData["Control"] = "1";

                    //    return RedirectToAction("Edit", new RouteValueDictionary(
                    //   new { controller = "BooksNeeds", action = "Edit", Id = bookNeedControl.Id }));



                    //}


                    BookNeeds.BookCount       = BookNeeds.BookCount - Convert.ToInt32(Count);
                    db.Entry(BookNeeds).State = EntityState.Modified;
                    db.SaveChanges();
                }
                //var BookStocks = db.BooksStocks.FirstOrDefault(x => x.BookId.ToString() == item);
                if (BookStocks != null)
                {
                    var delivery = new BooksDelivery();


                    BookStocks.BookCount       = BookStocks.BookCount - Convert.ToInt32(Count);
                    db.Entry(BookStocks).State = EntityState.Modified;
                    db.SaveChanges();

                    delivery.CreateDate  = DateTime.Now;
                    delivery.Year        = DateTime.Now.Year;
                    delivery.UpdateDate  = DateTime.Now;
                    delivery.SchoolsName = Schols;
                    delivery.BookCount   = Convert.ToInt32(Count);
                    delivery.Deliverer   = DeliveredName;
                    //delivery.Deliverer = "Tutanak Düzenlenmedi";
                    delivery.Recipient = Recipedname;
                    //delivery.Recipient = "Tutanak Düzenlenmedi";
                    delivery.BookId          = BookNeeds.BookId;
                    db.Entry(delivery).State = EntityState.Added;
                    db.SaveChanges();
                }
            }

            ViewBag.KayıtHata = "";
            if (true)
            {
                TempData["Control"] = "3";
                //ViewBag.KayıtHata = " Girmiş olduğunuz kitap sayısı okulun ihtiyacından fazla olamaz!";


                return(RedirectToAction("Index", new RouteValueDictionary(
                                            new { controller = "BooksDeliveries", action = "Index" })));
            }


            return(RedirectToAction("Index", new RouteValueDictionary(
                                        new { controller = "BooksDeliveries", action = "Index" })));
        }