Exemplo n.º 1
0
 //Закрывает все ресурсы
 public static void Close()
 {
     if (!IsActivated)
     {
         return;
     }
     CommonBook.UpdateHistory(false);
     CommonBook.CloseHistory();
     try { DaoDb.Compress(General.ReporterFile, 100000000); }
     catch {}
 }
        private void RemoveBooks(IEnumerable <string> booksToRemove, CommonBook book)
        {
            foreach (var i in booksToRemove)
            {
                int converted = Convert.ToInt32(i);

                Book bbb = entityCollector.GetAllBooksDummy().First(m => m.book_id == converted);

                book.Books.Remove(bbb);
            }
        }
        public FileContentResult GetImage(int common_book_id)
        {
            CommonBook cb = comBookRepo.Entities.FirstOrDefault(a => a.common_book_id == common_book_id);

            if (cb != null)
            {
                return(File(cb.imagedata, cb.imagemimetype));
            }
            else
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        public List <SelectListItem> GetBooksForCommonBook(int commonBookId)
        {
            CommonBook            cb          = comBookRepo.Entities.Select(p => p).Where(p => p.common_book_id == commonBookId).First();
            List <SelectListItem> listOfBooks = new List <SelectListItem>();


            foreach (Book p in cb.Books)
            {
                listOfBooks.Add(new SelectListItem {
                    Text = p.name, Value = p.book_id.ToString()
                });
            }

            return(listOfBooks);
        }
Exemplo n.º 5
0
        public List <SelectListItem> GetBooksExcept(int commonBookId)
        {
            CommonBook common = comBookRepo.Entities.Select(b => b).Where(b => b.common_book_id == commonBookId).First();

            var except = bookRepo.Entities.Except(common.Books);
            List <SelectListItem> listOfBooks = new List <SelectListItem>();


            foreach (Book p in except)
            {
                listOfBooks.Add(new SelectListItem {
                    Text = p.name, Value = p.book_id.ToString()
                });
            }

            return(listOfBooks);
        }
        public ViewResult EditCommonBook(/*[Bind(Prefix="comBook")]*/ int common_book_id)
        {
            CommonBook b = comBookRepo.Entities.First(bb => bb.common_book_id == common_book_id);

            var sss = b.Books.Select(bf => bf.name);

            ViewBag.books      = entityCollector.GetAllBooks(common_book_id);
            ViewBag.publishers = entityCollector.GetAllPublishers(b.phouse_id);

            EditCommonBookViewModel model = new EditCommonBookViewModel
            {
                comBook    = b,
                Books      = entityCollector.GetAllBooks(common_book_id),
                Publishers = entityCollector.GetAllPublishers(b.phouse_id)
            };

            return(View(b));
        }
        public ActionResult AddBooksToCommonBook(string newVals, int comBook)
        {
            CommonBook book = comBookRepo.Entities.First(bb => bb.common_book_id == comBook);

            var newBooks = newVals.Split(',');

            var currentBooks = entityCollector.GetBooksForCommonBook(comBook);

            var booksToAdd = newBooks.Except(currentBooks.Select(a => a.Value));

            var booksToRemove = currentBooks.Select(a => a.Value).Except(newBooks);

            AddNewBooks(booksToAdd, book);

            RemoveBooks(booksToRemove, book);

            comBookRepo.Save(book);

            return(RedirectToAction("Index", "Home"));
        }
        public ActionResult EditCommonBook(CommonBook book, HttpPostedFileBase image = null)
        {
            if (ModelState.IsValid)
            {
                if (image != null)
                {
                    book.imagemimetype = image.ContentType;
                    book.imagedata     = new byte[image.ContentLength];
                    image.InputStream.Read(book.imagedata, 0, image.ContentLength);
                }

                Book bbb = entityCollector.GetAllBooksDummy().First(m => m.book_id == 7);
                book.Books.Add(bbb);
                comBookRepo.Save(book);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                return(View(book));
            }
        }
Exemplo n.º 9
0
 //Удаляет закрываемую книгу из списка
 public static void CloseBook()
 {
     if (!IsActivated)
     {
         return;
     }
     try
     {
         if (SysPage.IsInfoTask())
         {
             var s = ActiveBook.SysPage.GetValue("Report");
             using (CommonBook.StartLog("Закрытие книги", "", s))
                 if (Books.ContainsKey(s) && Books[s].Workbook.FullName == Application.ActiveWorkbook.FullName)
                 {
                     Books[s].CloseBook();
                     Books.Remove(s);
                 }
         }
     }
     catch { }
 }
Exemplo n.º 10
0
 //Установить текущую книгу активной, вызывается при смене книги или при открытии новой
 public static void ChangeActiveBook()
 {
     if (!IsActivated)
     {
         return;
     }
     try
     {
         if (!SysPage.IsInfoTask())
         {
             HideBook();
         }
         else
         {
             var wb = Application.ActiveWorkbook;
             var s  = new SysPage(wb).GetValue("Report");
             using (CommonBook.StartLog("Смена активной книги", "", s))
             {
                 try
                 {
                     if (IsOpening && !ProgrammOpening && !s.IsEmpty())
                     {
                         try //Чтобы не вылазила загадочная ошибка
                         {
                             if (Books.ContainsKey(s) && Books[s].Workbook.FullName != wb.FullName)
                             {
                                 Different.MessageError("Файл отчета с кодом " + s + " уже открыт");
                             }
                         }
                         catch { }
                     }
                     if (s.IsEmpty())
                     {
                         ActiveBook = null;
                     }
                     else if (ActiveBook == null || ActiveBook.Code.ToLower() != s.ToLower())
                     {
                         HideBook();
                         if (Books.ContainsKey(s))
                         {
                             ActiveBook = Books[s];
                             foreach (var f in ActiveBook.Forms.Values)
                             {
                                 f.Show();
                             }
                         }
                         else
                         {
                             ActiveBook = new ReportBook(s, wb);
                             ActiveBook.OpenHistory(General.ReporterDir + @"ReporterHistory\" + s + "History.accdb", General.HistryTemplateFile);
                             Books.Add(s, ActiveBook);
                             ActiveBook.LoadSetup();
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     CommonBook.AddError("Ошибка при открытии отчета", ex);
                     throw;
                 }
             }
         }
     }
     catch (Exception ex)
     {
         ex.MessageError("Ошибка при открытии отчета", "Системная ошибка построителя отчетов");
     }
     IsOpening       = false;
     ProgrammOpening = false;
 }