示例#1
0
        public async Task <IActionResult> Create(BooksView book)
        {
            if (ModelState.IsValid)
            {
                string fileName = "";
                if (book.Image != null)
                {
                    fileName = Guid.NewGuid().ToString() + "_" +
                               book.Image.FileName.Substring(book.Image.FileName.LastIndexOf('\\') + 1);

                    string     uploadFolder = Path.Combine(_hostEnvironment.ContentRootPath, "wwwroot", "images");
                    string     filePath     = Path.Combine(uploadFolder, fileName);
                    FileStream uploadFile   = new FileStream(filePath, FileMode.Create);
                    book.Image.CopyTo(uploadFile);
                }
                else
                {
                    fileName = "no_image.png";
                }
                Book newBook = new Book()
                {
                    Title         = book.Title,
                    Author        = book.Author,
                    ISBN          = book.ISBN,
                    PublishedDate = book.PublishedDate,
                    Image         = fileName
                };
                _context.Add(newBook);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details), new { id = newBook.Id }));
            }
            return(View(book));
        }
 public async Task <ActionResult> Create(BooksView newBook)
 {
     try
     {
         var done = _booksService.Edit(_mapper.Map <BooksView, IBooks>(newBook));
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public async Task <ActionResult> Edit(BooksView book)
        {
            try
            {
                await _booksService.Update(_mapper.Map <IBooks>(book));

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
示例#4
0
文件: Form1.cs 项目: infra-hdc/LIBFL
        private void proccessData(string data)
        {
            string FromPort = data;

            FromPort = FromPort.Trim();

            //if (!BarScanner.CheckScanData(FromPort))
            //{
            //    MessageBox.Show("Считанный штрихкод не является штрихкодом книги! Если вы уверены, что штрихкод правильный, попробуйте считать его еще раз");
            //    return;
            //}
            Book bookg = new Book();

            try
            {
                switch (bookbll.ISBJVVV(FromPort))
                {
                case 1:
                    BooksView book = new BooksView();
                    book  = bookbll.GetBookByBar(FromPort);
                    bookg = new Book(book);
                    FillGrid(bookg);
                    break;

                case 2:
                    BooksViewRED bookred = new BooksViewRED();
                    bookred = bookbll.GetBookByBarRED(FromPort);
                    bookg   = new Book(bookred);
                    FillGrid(bookg);
                    break;

                case 3:
                    BooksViewFCC bookFCC = new BooksViewFCC();
                    bookFCC = bookbll.GetBookByBarFCC(FromPort);
                    bookg   = new Book(bookFCC);
                    FillGrid(bookg);
                    break;

                case -1:
                    MessageBox.Show("Книга не найдена в базе!");
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }
            bookg.idm = bl.Count + 1;
            bl.Add(new BookForRep(bookg));
        }
示例#5
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Title,Author,ISBN,PublishedDate,Image")] BooksView book)
        {
            Book oldBook = await _context.Book.FindAsync(id);

            if (id != book.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                string fileName = "";
                if (book.Image != null)
                {
                    fileName = Guid.NewGuid().ToString() + "_" + book.Image.FileName.Substring(book.Image.FileName.LastIndexOf('\\') + 1);

                    string     uploadFolder = Path.Combine(_hostEnvironment.ContentRootPath, "wwwroot", "images");
                    string     filePath     = Path.Combine(uploadFolder, fileName);
                    FileStream uploadFile   = new FileStream(filePath, FileMode.Create);
                    book.Image.CopyTo(uploadFile);
                    //delete old file
                    System.IO.File.Delete(Path.Combine(uploadFolder, oldBook.Image));
                    oldBook.Image = fileName;
                }
                oldBook.Title         = book.Title;
                oldBook.ISBN          = book.ISBN;
                oldBook.PublishedDate = book.PublishedDate;

                try
                {
                    _context.Update(oldBook);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BookExists(book.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Details), new { id = book.Id }));
            }
            return(View(book));
        }
示例#6
0
    void InitTreeView()
    {
        string[] Title = { "Id", "Title", "Author", "Press", "ISBN", "Price" };
        IList <TreeViewColumn> Columns = new List <TreeViewColumn>
        {
            new TreeViewColumn {
                Title = "Id", Sizing = TreeViewColumnSizing.Fixed, MinWidth = 80, Alignment = 0.50F
            },
            new TreeViewColumn {
                Title = "Title", Sizing = TreeViewColumnSizing.Fixed, MinWidth = 200, Alignment = 0.50F
            },
            new TreeViewColumn {
                Title = "Author", Sizing = TreeViewColumnSizing.Fixed, MinWidth = 200, Alignment = 0.50F
            },
            new TreeViewColumn {
                Title = "Press", Sizing = TreeViewColumnSizing.Fixed, MinWidth = 200, Alignment = 0.50F
            },
            new TreeViewColumn {
                Title = "ISBN", Sizing = TreeViewColumnSizing.Fixed, MinWidth = 150, Alignment = 0.50F
            },
            new TreeViewColumn {
                Title = "Price", Sizing = TreeViewColumnSizing.Fixed, MinWidth = 15, Alignment = 0.50F
            }
        };

        for (int i = 0; i < Columns.Count; i++)
        {
            var column        = Columns[i];
            var custom_header = new Gtk.Label(Title[i]);
            custom_header.Show();
            column.Widget = custom_header;
            custom_header.ModifyFont(Pango.FontDescription.FromString("Times Bold Italic 13"));

            var CellRender = new CellRendererText
            {
                Xalign     = 0.50F,
                Background = "White",
                Foreground = "Black",
                Font       = "Lucida Console"
            };
            column.PackStart(CellRender, true);
            column.AddAttribute(CellRender, "text", i);
            BooksView.AppendColumn(column);
        }
        BookList.Clear();
        BooksView.Model = BookList;
    }
示例#7
0
文件: Book.cs 项目: infra-hdc/LIBFL
 public Book(BooksView b)
 {
     this.author   = b.author;
     this.bar      = b.bar;
     this.cdc      = b.cdc;
     this.dpublish = b.dpublish;
     this.id       = b.id;
     this.idm      = b.idm;
     this.illustrs = b.illustrs;
     this.inv      = b.inv;
     this.note     = b.note;
     this.notesp   = b.notesp;
     this.placepub = b.placepub;
     this.pubhouse = b.pubhouse;
     this.size     = b.size;
     this.title    = b.title;
     this.volume   = b.volume;
 }
示例#8
0
        private void BooksButtonOnClick(object sender, EventArgs e)
        {
            BooksView booksView = new BooksView();

            booksView.Show(this);
        }
示例#9
0
        private void button2_Click(object sender, System.EventArgs e)
        {
            var booksView = new BooksView();

            booksView.Show();
        }