public CopyDetailedForm(String isbn) { InitializeComponent(); _listCopy = LoadCopy(isbn); _isbn = isbn; CatalogueBUS bus = new CatalogueBUS(); _catalogue = bus.GetCatalogueById(_isbn); LoadDataToForm(); }
public static List<string> GenerateBarcode(CatalogueDTO catalogue, int NoC) { List<string> barcodes = new List<string>(); string categoryId = int.Parse(catalogue.Category.CategoryId.Split('.')[0]).ToString("00000"); for (int i = 1; i <= NoC; i++) { barcodes.Add(categoryId + (Options.CountOfCopy + i).ToString("000000")); } return barcodes; }
public CatalogueDTO GetCatalogueById(String isbn) { CatalogueDTO catalogueDto = null; try { SqlDataReader reader = ConnectionManager.GetCommand("SP0101ISBN", new Dictionary<string, SqlDbType>() { { "@Param1", SqlDbType.NVarChar } }, new List<object>() { isbn }).ExecuteReader(); if (reader.Read()) { catalogueDto = new CatalogueDTO(); PublisherDTO publisherDto = new PublisherDTO(); CategoryDTO categoryDto = new CategoryDTO(); catalogueDto.ISBN = reader["ISBN"].ToString(); catalogueDto.Title = reader["Title"].ToString(); // add code for get data publisherDto.PublisherId = int.Parse(reader["PublisherID"].ToString()); catalogueDto.Publisher = publisherDto; catalogueDto.ShortDescription = reader["ShortDescription"].ToString(); // add code for get data categoryDto.CategoryId = reader["CategoryID"].ToString(); catalogueDto.Category = categoryDto; catalogueDto.Language = reader["Language"].ToString(); catalogueDto.Year = int.Parse(reader["Year"].ToString()); catalogueDto.ExpandLimit = int.Parse(reader["ExpandLimit"].ToString()); catalogueDto.ExpandDateLimit = int.Parse(reader["ExpandDateLimit"].ToString()); catalogueDto.NumberOfCopies = int.Parse(reader["NumberOfCopies"].ToString()); catalogueDto.AvailableCopies = int.Parse(reader["AvailableCopies"].ToString()); catalogueDto.Price = float.Parse(reader["Price"].ToString()); catalogueDto.Image = reader["Image"].ToString(); catalogueDto.HitTime = int.Parse(reader["HitTime"].ToString()); catalogueDto.RentalTime = int.Parse(reader["RentalTime"].ToString()); catalogueDto.CreatedDate = (DateTime) reader["CreatedDate"]; catalogueDto.UpdatedDate = (DateTime) reader["UpdatedDate"]; } reader.Close(); } catch (Exception e) { Log.Error("Error at CatalogueDAO - GetCatalogueByID", e); return null; } return catalogueDto; }
public CatalogueDTO GetCatalogueById(String isbn) { CatalogueDTO catalogueDto = new CatalogueDTO(); CatalogueDAO dao = new CatalogueDAO(); catalogueDto = dao.GetCatalogueById(isbn); if (catalogueDto != null) { PublisherBUS publisherBus = new PublisherBUS(); CategoryBUS categoryBus = new CategoryBUS(); AuthorOfBookBUS authorOfBookBus = new AuthorOfBookBUS(); catalogueDto.Publisher = publisherBus.GetPublisherById(catalogueDto.Publisher.PublisherId); catalogueDto.Category = categoryBus.GetCategoryById(catalogueDto.Category.CategoryId); catalogueDto.AuthorList = authorOfBookBus.GetAuthorListByIsbn(catalogueDto.ISBN); } return catalogueDto; }
public CatalogueDTO GetRandomCatalogue() { CatalogueDTO catalogueDto = new CatalogueDTO(); CatalogueDAO dao = new CatalogueDAO(); catalogueDto = dao.GetRandomCatalogue(); //Random không dùng thông tin chi tiết nên không cần phải load //if (catalogueDto != null) //{ // PublisherBUS publisherBus = new PublisherBUS(); // CategoryBUS categoryBus = new CategoryBUS(); // AuthorOfBookBUS authorOfBookBus = new AuthorOfBookBUS(); // catalogueDto.Publisher = publisherBus.GetPublisherById(catalogueDto.Publisher.PublisherId); // catalogueDto.Category = categoryBus.GetCategoryById(catalogueDto.Category.CategoryId); // catalogueDto.AuthorList = authorOfBookBus.GetAuthorListByIsbn(catalogueDto.ISBN); //} return catalogueDto; }
public int DeleteCatalogue(CatalogueDTO catalogue, SqlTransaction trans) { CatalogueDAO dao = new CatalogueDAO(); CopyBUS copyBus = new CopyBUS(); bool isInScopeCreated = false; int rs = 1; if (trans == null) { isInScopeCreated = true; trans = ConnectionManager.Con.BeginTransaction("CAT_DEL_TRANSACT"); } List<CopyDTO> list = copyBus.GetCopyByISBN(catalogue.ISBN); foreach (CopyDTO copyDTO in list) { rs = rs & copyBus.DeleteCopy(copyDTO, trans); if (rs == 0) break; } if (rs == 0) { if (isInScopeCreated) trans.Rollback(); } else { rs = rs & dao.DeleteCatalogue(catalogue, trans); if (isInScopeCreated) if (rs == 0) trans.Rollback(); else trans.Commit(); } return rs; }
public int UpdateCatalogue(CatalogueDTO catalogue, SqlTransaction trans) { AuthorOfBookBUS authorOfBookBus = new AuthorOfBookBUS(); bool isInScopeCreated = false; int rs = 1; if (trans == null) { isInScopeCreated = true; trans = ConnectionManager.Con.BeginTransaction("CAT_UPD_TRANSACT"); } rs = rs & authorOfBookBus.DeleteAuthorOfBook(catalogue.ISBN, trans); if (rs == 0) { if (isInScopeCreated) trans.Rollback(); } else { for (int i = 0; i < catalogue.AuthorList.Count; i++) { rs = rs & authorOfBookBus.InsertAuthorOfBook(catalogue.AuthorList.ElementAt(i), trans); if (rs == 0) break; } if (rs == 0) { if (isInScopeCreated) trans.Rollback(); } else { CatalogueDAO dao = new CatalogueDAO(); rs = rs & dao.UpdateCatalogue(catalogue, trans); if (isInScopeCreated) { if (rs == 0) trans.Rollback(); else trans.Commit(); } } } return rs; }
public void DeleteCatalogue(CatalogueDTO cdto) { CatalogueBUS catalogueBus = new CatalogueBUS(); if (catalogueBus.DeleteCatalogue(cdto, null) == 1) { abgCatalogue.DeleteSelectedRows(); } else { MessageBox.Show("Không thể xóa được đầu sách này khỏi CSDL =.='"); } }
public int DeleteCatalogue(CatalogueDTO catalogue, SqlTransaction trans) { catalogue.NumberOfCopies = -1; catalogue.AvailableCopies = -1; return UpdateCatalogue(catalogue, trans); }
public int UpdateCatalogue(CatalogueDTO catalogue, SqlTransaction trans) { catalogue.UpdatedDate = DateTime.Now; try { ConnectionManager.GetCommand("SP0103", new Dictionary<string, SqlDbType>() { {"@Param1", SqlDbType.NVarChar}, {"@Param2", SqlDbType.NVarChar}, {"@Param3", SqlDbType.Int}, {"@Param4", SqlDbType.NVarChar}, {"@Param5", SqlDbType.NVarChar}, {"@Param6", SqlDbType.NVarChar}, {"@Param7", SqlDbType.Int}, {"@Param8", SqlDbType.Int}, {"@Param9", SqlDbType.Int}, {"@Param10", SqlDbType.Int}, {"@Param11", SqlDbType.Int}, {"@Param12", SqlDbType.Float}, //{"@Param13", SqlDbType.Int}, //{"@Param14", SqlDbType.Int}, {"@Param13", SqlDbType.NVarChar}, {"@Param14", SqlDbType.DateTime}, {"@Param15", SqlDbType.DateTime} }, new List<object>() { catalogue.ISBN, catalogue.Title, catalogue.Publisher.PublisherId, catalogue.ShortDescription, catalogue.Category.CategoryId, catalogue.Language, catalogue.Year, catalogue.ExpandLimit, catalogue.ExpandDateLimit, catalogue.NumberOfCopies, catalogue.AvailableCopies, catalogue.Price, //catalogue.RentalTime, //catalogue.HitTime, catalogue.Image, catalogue.CreatedDate, catalogue.UpdatedDate }, trans).ExecuteNonQuery(); } catch (Exception e) { Log.Error("Error at CatalogueDAO - UpdateCatalogue", e); return 0; } return 1; }
public QuickAddCopyForm(CatalogueDTO catalogueDTO) { InitializeComponent(); _catalogue = catalogueDTO; }