public static AuthorDAO GetAuthorDAO() { if (AuthorDAO == null) { AuthorSqlCeDAOImpl authorDAOImpl = new AuthorSqlCeDAOImpl(); authorDAOImpl.dbContext = DBContextProvider.getDBContext(); AuthorDAO = authorDAOImpl; } return AuthorDAO; }
/// <summary> /// Xoá đi 1 tác giả /// </summary> /// <param name="id"></param> /// <returns></returns> public JsonResult Delete(int id) { var result = new AuthorDAO().Delete(id); if (result) { return(Json(new { status = true })); } else { return(Json(new { status = false })); } }
private void getCombobox() { AuthorDAO aDAO = new AuthorDAO(); DataTable dt1 = aDAO.ToDataTable(); DataRow empty1 = dt1.NewRow(); empty1["Mã Tác giả"] = "empty"; empty1["Tên Tác giả"] = "--Chọn--"; empty1["Liên lạc"] = ""; dt1.Rows.InsertAt(empty1, 0); inAuthor.DataSource = dt1; inAuthor.DataTextField = "Tên Tác giả"; inAuthor.DataValueField = "Mã Tác giả"; inAuthor.DataBind(); CategoryDAO cDAO = new CategoryDAO(); DataTable dt2 = cDAO.ToDataTable(); DataRow empty2 = dt2.NewRow(); empty2["Mã Thể loại"] = "empty"; empty2["Tên Thể loại"] = "--Chọn--"; empty2["Mô tả"] = ""; dt2.Rows.InsertAt(empty2, 0); inCategory.DataSource = dt2; inCategory.DataTextField = "Tên Thể loại"; inCategory.DataValueField = "Mã Thể loại"; inCategory.DataBind(); ProducerDAO pDAO = new ProducerDAO(); DataTable dt3 = pDAO.toDataTable(); DataRow empty3 = dt3.NewRow(); empty3["Mã Nhà xuất bản"] = "empty"; empty3["Tên Nhà xuất bản"] = "--Chọn--"; empty3["Liên Hệ"] = ""; empty3["Địa Chỉ"] = ""; dt3.Rows.InsertAt(empty3, 0); inProducer.DataSource = dt3; inProducer.DataTextField = "Tên Nhà xuất bản"; inProducer.DataValueField = "Mã Nhà xuất bản"; inProducer.DataBind(); }
// GET: Manage public ActionResult Index() { account a = (account)Session["user"]; if (a != null) { if (a.Role) { BookDAO db = new BookDAO(); accountDAO adb = new accountDAO(); categoryDAO cdb = new categoryDAO(); commentDAO cd = new commentDAO(); AuthorDAO authorDAO = new AuthorDAO(); List <author> authors = authorDAO.getAll(); List <book> books = db.getAll(1000, 1); List <comment> comments = cd.getAll(); List <account> accounts = adb.getAll(); List <category> categories = cdb.getAll(); List <book_categories> bcats = cdb.getAllss(); dynamic dy = new ExpandoObject(); // dynamic - multiple model dy.books = books; dy.cates = categories; dy.bcats = bcats; dy.comments = comments; dy.accounts = accounts; dy.authors = authors; ViewData["countb"] = db.getAll(1000, 1).Count; ViewData["counta"] = accounts.Count; ViewData["countc"] = comments.Count; return(View(dy)); } else { return(RedirectToAction("Index", "Home")); } } else { return(RedirectToAction("Index", "Login")); } }
//[HttpPost] //public JsonResult LoadData() //{ // IEnumerable<AuthorViewModel> model = //} //public JsonResult LoadData() //{ // setViewbagforAuthor(); // List<Author> model = new AuthorDAO().getListAuthor(); // model = model.OrderBy(x => x.Name).ToList(); // var TotalRow = model.Count(); // return Json(new // { // data = model, // totalRow = TotalRow, // status = true // }, JsonRequestBehavior.AllowGet); //} public JsonResult LoadData() { setViewbagforAuthor(); List <Author> model = new AuthorDAO().getListAuthor(); model = model.OrderBy(x => x.Name).ToList(); var TotalRow = model.Count(); var output = JsonConvert.SerializeObject(model, new JsonSerializerSettings { ReferenceLoopHandling = ReferenceLoopHandling.Ignore }); var jsonresult = Json(new { data = output, totalRow = TotalRow, status = true }, JsonRequestBehavior.AllowGet); jsonresult.MaxJsonLength = int.MaxValue; return(jsonresult); }
static void Main(string[] args) { using (var sqlConnection = new NpgsqlConnection("Host=localhost;Username=postgres;Password=postgres;Database=dotnet")) { sqlConnection.Open(); AuthorDAO authorDAO = new AuthorDAO(sqlConnection); Author myAuthor = new Author(); myAuthor.Name = "Arthur"; authorDAO.Add(myAuthor); var authors = authorDAO.FindByName("Arthur"); foreach (var author in authors) { Console.WriteLine(author.Name); } authorDAO.DeleteAll(); sqlConnection.Close(); } }
protected void btnSave_Click(object sender, EventArgs e) { AuthorDAO dao = new AuthorDAO(); if (mode == "add") { Author author = new Author(); author.AuthorID = inAuthorID.Value; author.AuthorName = inAuthorName.Value; author.AuthorContact = inAuthorContact.Value; dao.AddAuthor(author); } if (mode == "edit") { Author author = new Author(); author.AuthorID = inAuthorID.Value; author.AuthorName = inAuthorName.Value; author.AuthorContact = inAuthorContact.Value; dao.UpdateAuthor(author); } init(); emptyForm(); }
/// <summary> /// Sửa 1 tác giả /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Edit(int id) { var authorDetail = new AuthorDAO().ViewDetail(id); return(View(authorDetail)); }
public LibraryController() { BookDAO = BookDAOFactory.GetBookDAO(); AuthorDAO = AuthorDAOFactory.GetAuthorDAO(); GenreDAO = GenreDAOFactory.GetGenreDAO(); }
public EditBooksController() { BookDAO = BookDAOFactory.GetBookDAO(); AuthorDAO = AuthorDAOFactory.GetAuthorDAO(); GenreDAO = GenreDAOFactory.GetGenreDAO(); }
public ActionResult UpdateAuthor(long id) { var model = new AuthorDAO().AuthorDetails(id); return(View(model)); }
public static List <Authors> GetName(string txt) { return(AuthorDAO.GetName(txt)); }
public void setViewbagforAuthor() { AuthorDAO author = new AuthorDAO(); ViewBag.listAuthor = author.getListAuthor(); }
public static int GetNCount(string txt) { return(AuthorDAO.GetNCount(txt)); }
public static List <Authors> GetPage(int pageCount, int pgIndex) { return(AuthorDAO.GetPage(pageCount, pgIndex)); }
public static int GetCount() { return(AuthorDAO.GetCount()); }
public static void Delete(int id) { AuthorDAO.Delete(id); }
public static bool GetALogin(Authors authors) { return(AuthorDAO.GetALogin(authors)); }