Esempio n. 1
0
 public book(string name, char type, string author, uint year)
 {
     this.author = author;
     this.type   = GetTypebook(type);
     this.name   = name;
     this.year   = year;
 }
        public ActionResult DeleteConfirmed(int id)
        {
            bookType bookType = db.bookType.Find(id);

            db.bookType.Remove(bookType);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "bookTypeID,bookTypeName")] bookType bookType)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bookType).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.bookTypeID = new SelectList(db.book, "bookID", "bookName", bookType.bookTypeID);
     return(View(bookType));
 }
        public ActionResult Create([Bind(Include = "bookTypeID,bookTypeName")] bookType bookType)
        {
            if (ModelState.IsValid)
            {
                db.bookType.Add(bookType);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.bookTypeID = new SelectList(db.book, "bookID", "bookName", bookType.bookTypeID);
            return(View(bookType));
        }
        // GET: bookTypes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            bookType bookType = db.bookType.Find(id);

            if (bookType == null)
            {
                return(HttpNotFound());
            }
            return(View(bookType));
        }
        // GET: bookTypes/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            bookType bookType = db.bookType.Find(id);

            if (bookType == null)
            {
                return(HttpNotFound());
            }
            ViewBag.bookTypeID = new SelectList(db.book, "bookID", "bookName", bookType.bookTypeID);
            return(View(bookType));
        }
Esempio n. 7
0
 private IWorkbook creatBookWithType(bookType type, string path)
 {
     try {
         FileStream file;
         IWorkbook  book;
         file = new FileStream(path, FileMode.Open, FileAccess.Read);
         if ((type == bookType.xlsExcel))
         {
             book = new HSSFWorkbook(file);
         }
         else
         {
             book = new XSSFWorkbook(file);
         }
         if (book.GetSheetAt(listSheetIndex) == null)
         {
             throw new ExcelOpenFailedException("Excel不是可读取的学生名单");
         }
         return(book);
     } catch {
         throw new ExcelOpenFailedException("Excel文件无法读取");
     }
 }